You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2015/03/06 14:54:16 UTC
[2/5] olingo-odata4 git commit: [OLINGO-575] Cleanup ServiceVersion
Enum part 2
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/07c37106/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/HeaderName.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/HeaderName.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/HeaderName.java
index e741d60..646a8e8 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/HeaderName.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/HeaderName.java
@@ -1,28 +1,23 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.api.communication.header;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.olingo.commons.api.ODataRuntimeException;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
/**
* Major OData request/response header names.
@@ -32,17 +27,17 @@ public enum HeaderName {
/**
* The OData protocol uses the Accept request-header field, as specified in [RFC2616].
*/
- accept("Accept", Arrays.asList(ODataServiceVersion.V30, ODataServiceVersion.V40)),
+ accept("Accept"),
/**
* As specified in [RFC2616], the client MAY specify the set of accepted character sets with the Accept-Charset
* header.
*/
- acceptCharset("Accept-Charset", Arrays.asList(ODataServiceVersion.V40)),
+ acceptCharset("Accept-Charset"),
/**
* As specified in [RFC2616], the client MAY specify the set of accepted natural languages with the Accept-Language
* header.
*/
- acceptLanguage("Accept-Language", Arrays.asList(ODataServiceVersion.V40)),
+ acceptLanguage("Accept-Language"),
/**
* The Content-Type header is used as specified in [RFC2616].
* <br/>
@@ -51,7 +46,9 @@ public enum HeaderName {
* <li>application/atom+xml</li>
* <li>application/atom+xml;type=entry</li>
* <li>application/atom+xml;type=feed</li>
- * <li>application/json; odata=verbose</li>
+ * <li>application/json; odata.metadata=full</li>
+ * <li>application/json; odata.metadata=minimal</li>
+ * <li>application/json; odata.metadata=none</li>
* <li>application/json</li>
* <li>application/xml</li>
* <li>text/plain</li>
@@ -60,43 +57,39 @@ public enum HeaderName {
* <li>multipart/mixed</li>
* </ul>
*/
- contentType("Content-Type", Arrays.asList(ODataServiceVersion.V30, ODataServiceVersion.V40)),
- /**
- * This header is a custom HTTP header defined for protocol versioning purposes. This header MAY be present on any
- * request or response message.
- */
- dataServiceVersion("DataServiceVersion", Arrays.asList(ODataServiceVersion.V30)),
+ contentType("Content-Type"),
+
/**
* This header is a custom HTTP header defined for protocol versioning purposes. This header MAY be present on any
* request or response message.
*/
- odataVersion("OData-Version", Arrays.asList(ODataServiceVersion.V40)),
+ odataVersion("OData-Version"),
/**
* A response to a create operation that returns 204 No Content MUST include an OData-EntityId response header. The
* value of the header is the entity-id of the entity that was acted on by the request. The syntax of the
* OData-EntityId preference is specified in [OData-ABNF].
*/
- odataEntityId("OData-EntityId", Arrays.asList(ODataServiceVersion.V40)),
+ odataEntityId("OData-EntityId"),
/**
* An ETag (entity tag) is an HTTP response header returned by an HTTP/1.1 compliant web server used to determine
* change in content of a resource at a given URL. The value of the header is an opaque string representing the state
* of the resource at the time the response was generated.
*/
- etag("ETag", Arrays.asList(ODataServiceVersion.V30, ODataServiceVersion.V40)),
+ etag("ETag"),
/**
* The If-Match request-header field is used with a method to make it conditional. As specified in [RFC2616], "the
* purpose of this feature is to allow efficient updates of cached information with a minimum amount of transaction
* overhead. It is also used, on updating requests, to prevent inadvertent modification of the wrong version of a
* resource".
*/
- ifMatch("If-Match", Arrays.asList(ODataServiceVersion.V30, ODataServiceVersion.V40)),
+ ifMatch("If-Match"),
/**
* The If-None-Match request header is used with a method to make it conditional. As specified in [RFC2616], "The
* purpose of this feature is to allow efficient updates of cached information with a minimum amount of transaction
* overhead. It is also used to prevent a method (for example, PUT) from inadvertently modifying an existing resource
* when the client believes that the resource does not exist."
*/
- ifNoneMatch("If-None-Match", Arrays.asList(ODataServiceVersion.V30, ODataServiceVersion.V40)),
+ ifNoneMatch("If-None-Match"),
/**
* Clients SHOULD specify an OData-MaxVersion request header.
* <br />
@@ -106,17 +99,8 @@ public enum HeaderName {
* If OData-MaxVersion is not specified, then the service SHOULD interpret the request as having an OData-MaxVersion
* equal to the maximum version supported by the service.
*/
- odataMaxVersion("OData-MaxVersion", Arrays.asList(ODataServiceVersion.V40)),
- /**
- * This header is a custom HTTP request only header defined for protocol versioning purposes. This header MAY be
- * present on any request message from client to server.
- */
- maxDataServiceVersion("MaxDataServiceVersion", Arrays.asList(ODataServiceVersion.V30)),
- /**
- * This header is a custom HTTP request only header defined for protocol versioning purposes. This header MAY be
- * present on any request message from client to server.
- */
- minDataServiceVersion("MinDataServiceVersion", Arrays.asList(ODataServiceVersion.V30)),
+ odataMaxVersion("OData-MaxVersion"),
+
/**
* The OData-Isolation header specifies the isolation of the current request from external changes. The only supported
* value for this header is snapshot.
@@ -146,7 +130,7 @@ public enum HeaderName {
* A service MAY specify the support for OData-Isolation:snapshot using an annotation with term
* Capabilities.IsolationSupport, see [OData-VocCap].
*/
- odataIsolation("OData-Isolation", Arrays.asList(ODataServiceVersion.V40)),
+ odataIsolation("OData-Isolation"),
/**
* A Prefer header is included in a request to state the client’s preferred, but not required, server behavior (that
* is, a hint to the server). The Prefer header MAY be included on any request type (within a standalone or batch
@@ -154,33 +138,26 @@ public enum HeaderName {
* value of “return-content” MUST NOT be specified on a DELETE request, a batch request as a whole, or a PUT request
* to update a named stream.
*/
- prefer("Prefer", Arrays.asList(ODataServiceVersion.V30, ODataServiceVersion.V40)),
+ prefer("Prefer"),
/**
* When a Prefer header value is successfully honored by the server, it MAY include a Preference-Applied response
* header that states which preference values were honored by the server.
*/
- preferenceApplied("Preference-Applied", Arrays.asList(ODataServiceVersion.V30, ODataServiceVersion.V40)),
- /**
- * The DataServiceId response header is returned by the server when the response payload for an HTTP PUT, POST, PATCH,
- * or MERGE request is empty. The value of the header is the identifier of the entity that was acted on by the PUT,
- * POST, PATCH, or MERGE request. The identifier, in this case, is the same identifier that would have been returned
- * in the response payload (for example, as the value of the atom:id element for Atom responses)
- */
- dataServiceId("DataServiceId", Arrays.asList(ODataServiceVersion.V30)),
+ preferenceApplied("Preference-Applied"),
+
/**
* Location header is used to specify the URL of an entity modified through a Data Modification request, or the
* request URL to check on the status of an asynchronous operation as described in
* <code>202 Accepted</code>.
*/
- location("Location", Arrays.asList(ODataServiceVersion.V30, ODataServiceVersion.V40)),
+ location("Location"),
/**
* A service must include a
* <code>Retry-After</code> header in a
* <code>202 Accepted</code>.
*/
- retryAfter("Retry-After", Arrays.asList(ODataServiceVersion.V30, ODataServiceVersion.V40)),
- dataServiceUrlConventions("DataServiceUrlConventions", Arrays.asList(ODataServiceVersion.V30)),
- slug("Slug", Arrays.asList(ODataServiceVersion.V30)),
+ retryAfter("Retry-After"),
+
/**
* This header is a custom HTTP request header.
* <br/>
@@ -199,21 +176,15 @@ public enum HeaderName {
* <br/>
* This header is only valid when on POST requests.
*/
- xHttpMethod("X-HTTP-METHOD", Arrays.asList(ODataServiceVersion.V30));
+ xHttpMethod("X-HTTP-METHOD"),
+ //TODO: Delete
+ dataServiceUrlConventions("DataServiceUrlConventions");
+
private final String headerName;
- private final List<ODataServiceVersion> supportedVersions;
-
- private HeaderName(final String headerName, final List<ODataServiceVersion> supportedVersions) {
+ private HeaderName(final String headerName) {
this.headerName = headerName;
- this.supportedVersions = supportedVersions;
- }
-
- final void isSupportedBy(final ODataServiceVersion serviceVersion) {
- if (!supportedVersions.contains(serviceVersion)) {
- throw new ODataRuntimeException("Unsupported header " + this.toString());
- }
}
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/07c37106/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/ODataPreferences.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/ODataPreferences.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/ODataPreferences.java
index 87f8ce7..e3e4a22 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/ODataPreferences.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/ODataPreferences.java
@@ -18,30 +18,19 @@
*/
package org.apache.olingo.client.api.communication.header;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.olingo.commons.api.ODataRuntimeException;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
/**
* Values of the Prefer header.
*/
public class ODataPreferences {
- final ODataServiceVersion serviceVersion;
-
- public ODataPreferences(final ODataServiceVersion serviceVersion) {
- this.serviceVersion = serviceVersion;
- }
-
/**
* <code>Prefer</code> header, return content.
*
* @see HeaderName#prefer
*/
public String returnContent() {
- return PreferenceNames.returnContent.isSupportedBy(serviceVersion).toString();
+ return PreferenceNames.returnContent.toString();
}
/**
@@ -50,14 +39,14 @@ public class ODataPreferences {
* @see HeaderName#prefer
*/
public String returnNoContent() {
- return PreferenceNames.returnNoContent.isSupportedBy(serviceVersion).toString();
+ return PreferenceNames.returnNoContent.toString();
}
/**
* @see HeaderName#dataServiceUrlConventions
*/
public String keyAsSegment() {
- return PreferenceNames.keyAsSegment.isSupportedBy(serviceVersion).toString();
+ return PreferenceNames.keyAsSegment.toString();
}
/**
@@ -78,7 +67,7 @@ public class ODataPreferences {
* @return preference.
*/
public String allowEntityReferences() {
- return PreferenceNames.allowEntityReferences.isSupportedBy(serviceVersion).toString();
+ return PreferenceNames.allowEntityReferences.toString();
}
/**
@@ -141,7 +130,7 @@ public class ODataPreferences {
* @return preference.
*/
public String callback(final String url) {
- return PreferenceNames.callback.isSupportedBy(serviceVersion).toString() + ";url=\"" + url + "\"";
+ return PreferenceNames.callback.toString() + ";url=\"" + url + "\"";
}
/**
@@ -162,7 +151,7 @@ public class ODataPreferences {
* @return preference.
*/
public String continueOnError() {
- return PreferenceNames.continueOnError.isSupportedBy(serviceVersion).toString();
+ return PreferenceNames.continueOnError.toString();
}
/**
@@ -209,7 +198,7 @@ public class ODataPreferences {
* @return preference.
*/
public String includeAnnotations(final String value) {
- return PreferenceNames.includeAnnotations.isSupportedBy(serviceVersion).toString() + "=" + value;
+ return PreferenceNames.includeAnnotations.toString() + "=" + value;
}
/**
@@ -242,7 +231,7 @@ public class ODataPreferences {
* @return preference.
*/
public String maxPageSize(final int size) {
- return PreferenceNames.maxPageSize.isSupportedBy(serviceVersion).toString() + "=" + size;
+ return PreferenceNames.maxPageSize.toString() + "=" + size;
}
/**
@@ -267,7 +256,7 @@ public class ODataPreferences {
* @return preference.
*/
public String trackChanges() {
- return PreferenceNames.trackChanges.isSupportedBy(serviceVersion).toString();
+ return PreferenceNames.trackChanges.toString();
}
/**
@@ -302,7 +291,7 @@ public class ODataPreferences {
* @return preference.
*/
public String respondAsync() {
- return PreferenceNames.respondAsync.isSupportedBy(serviceVersion).toString();
+ return PreferenceNames.respondAsync.toString();
}
/**
@@ -322,7 +311,7 @@ public class ODataPreferences {
* @return preference.
*/
public String wait(final int value) {
- return PreferenceNames.wait.isSupportedBy(serviceVersion).toString() + "=" + value;
+ return PreferenceNames.wait.toString() + "=" + value;
}
/**
@@ -352,7 +341,7 @@ public class ODataPreferences {
* @return preference.
*/
public String returnMinimal() {
- return PreferenceNames.odataReturn.isSupportedBy(serviceVersion).toString() + "=minimal";
+ return PreferenceNames.odataReturn.toString() + "=minimal";
}
/**
@@ -382,39 +371,28 @@ public class ODataPreferences {
* @return preference.
*/
public String returnRepresentation() {
- return PreferenceNames.odataReturn.isSupportedBy(serviceVersion).toString() + "=representation";
+ return PreferenceNames.odataReturn.toString() + "=representation";
}
private static enum PreferenceNames {
- returnContent("return-content", Arrays.asList(ODataServiceVersion.V30, ODataServiceVersion.V40)),
- returnNoContent("return-no-content", Arrays.asList(ODataServiceVersion.V30, ODataServiceVersion.V40)),
- keyAsSegment("KeyAsSegment", Arrays.asList(ODataServiceVersion.V30, ODataServiceVersion.V40)),
- allowEntityReferences("odata.allow-entityreferences", Arrays.asList(ODataServiceVersion.V40)),
- callback("odata.callback", Arrays.asList(ODataServiceVersion.V40)),
- continueOnError("odata.continue-on-error", Arrays.asList(ODataServiceVersion.V40)),
- includeAnnotations("odata.include-annotations", Arrays.asList(ODataServiceVersion.V40)),
- maxPageSize("odata.maxpagesize", Arrays.asList(ODataServiceVersion.V40)),
- trackChanges("odata.track-changes", Arrays.asList(ODataServiceVersion.V40)),
- respondAsync("respond-async", Arrays.asList(ODataServiceVersion.V40)),
- wait("wait", Arrays.asList(ODataServiceVersion.V40)),
- odataReturn("return", Arrays.asList(ODataServiceVersion.V40));
+ returnContent("return-content"),
+ returnNoContent("return-no-content"),
+ keyAsSegment("KeyAsSegment"),
+ allowEntityReferences("odata.allow-entityreferences"),
+ callback("odata.callback"),
+ continueOnError("odata.continue-on-error"),
+ includeAnnotations("odata.include-annotations"),
+ maxPageSize("odata.maxpagesize"),
+ trackChanges("odata.track-changes"),
+ respondAsync("respond-async"),
+ wait("wait"),
+ odataReturn("return");
private final String preferenceName;
- private final List<ODataServiceVersion> supportedVersions;
-
- private PreferenceNames(final String preferenceName, final List<ODataServiceVersion> supportedVersions) {
+ private PreferenceNames(final String preferenceName) {
this.preferenceName = preferenceName;
- this.supportedVersions = supportedVersions;
- }
-
- final PreferenceNames isSupportedBy(final ODataServiceVersion serviceVersion) {
- if (!supportedVersions.contains(serviceVersion)) {
- throw new ODataRuntimeException("Unsupported header " + this.toString());
- }
-
- return this;
}
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/07c37106/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/ODataRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/ODataRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/ODataRequest.java
index 02566f5..b97085f 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/ODataRequest.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/ODataRequest.java
@@ -158,15 +158,6 @@ public interface ODataRequest {
String getContentType();
/**
- * Adds <tt>Slug</tt> OData request header.
- *
- * @param value header value.
- * @return current object
- * @see org.apache.olingo.client.api.communication.header.HeaderName#slug
- */
- ODataRequest setSlug(final String value);
-
- /**
* Adds <tt>X-HTTP-METHOD</tt> OData request header.
*
* @param value header value.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/07c37106/lib/client-core/src/main/java/org/apache/olingo/client/core/EdmEnabledODataClientImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/EdmEnabledODataClientImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/EdmEnabledODataClientImpl.java
index b254473..3416dba 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/EdmEnabledODataClientImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/EdmEnabledODataClientImpl.java
@@ -73,7 +73,7 @@ public class EdmEnabledODataClientImpl extends ODataClientImpl implements EdmEna
@Override
public URIBuilder newURIBuilder() {
- return new URIBuilderImpl(getServiceVersion(), configuration, serviceRoot);
+ return new URIBuilderImpl(configuration, serviceRoot);
}
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/07c37106/lib/client-core/src/main/java/org/apache/olingo/client/core/ODataClientImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/ODataClientImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/ODataClientImpl.java
index bd9282f..e16b0d7 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/ODataClientImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/ODataClientImpl.java
@@ -57,7 +57,7 @@ import org.apache.olingo.commons.core.serialization.JsonSerializer;
public class ODataClientImpl implements ODataClient {
- private final FilterFactory filterFactory = new FilterFactoryImpl(getServiceVersion());
+ private final FilterFactory filterFactory = new FilterFactoryImpl();
private final SearchFactory searchFactory = new SearchFactoryImpl();
@@ -65,7 +65,7 @@ public class ODataClientImpl implements ODataClient {
private final ODataBinder binder = new ODataBinderImpl(this);
- private final ODataObjectFactory objectFactory = new ODataObjectFactoryImpl(getServiceVersion());
+ private final ODataObjectFactory objectFactory = new ODataObjectFactoryImpl();
private final AsyncRequestFactory asyncReqFact = new AsyncRequestFactoryImpl(this);
@@ -88,7 +88,7 @@ public class ODataClientImpl implements ODataClient {
@Override
public ODataPreferences newPreferences() {
- return new ODataPreferences(getServiceVersion());
+ return new ODataPreferences();
}
@Override
@@ -111,7 +111,7 @@ public class ODataClientImpl implements ODataClient {
@Override
public URIBuilder newURIBuilder(final String serviceRoot) {
- return new URIBuilderImpl(getServiceVersion(), getConfiguration(), serviceRoot);
+ return new URIBuilderImpl(getConfiguration(), serviceRoot);
}
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/07c37106/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataBasicRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataBasicRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataBasicRequest.java
index bbd5215..c5c313c 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataBasicRequest.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataBasicRequest.java
@@ -57,7 +57,7 @@ public abstract class AbstractODataBasicRequest<T extends ODataResponse>
@Override
public void setFormat(final ODataFormat format) {
if (format != null) {
- final String formatString = format.getContentType(odataClient.getServiceVersion()).toContentTypeString();
+ final String formatString = format.getContentType().toContentTypeString();
setAccept(formatString);
setContentType(formatString);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/07c37106/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java
index 0b250b0..d10960a 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java
@@ -165,12 +165,6 @@ public abstract class AbstractODataRequest extends AbstractRequest implements OD
}
@Override
- public ODataRequest setSlug(final String value) {
- odataHeaders.setHeader(HeaderName.slug, value);
- return this;
- }
-
- @Override
public ODataRequest addCustomHeader(final String name, final String value) {
odataHeaders.setHeader(name, value);
return this;
@@ -186,7 +180,7 @@ public abstract class AbstractODataRequest extends AbstractRequest implements OD
public String getAccept() {
final String acceptHead = odataHeaders.getHeader(HeaderName.accept);
return StringUtils.isBlank(acceptHead)
- ? getDefaultFormat().getContentType(odataClient.getServiceVersion()).toContentTypeString()
+ ? getDefaultFormat().getContentType().toContentTypeString()
: acceptHead;
}
@@ -209,7 +203,7 @@ public abstract class AbstractODataRequest extends AbstractRequest implements OD
public String getContentType() {
final String contentTypeHead = odataHeaders.getHeader(HeaderName.contentType);
return StringUtils.isBlank(contentTypeHead)
- ? getDefaultFormat().getContentType(odataClient.getServiceVersion()).toContentTypeString()
+ ? getDefaultFormat().getContentType().toContentTypeString()
: contentTypeHead;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/07c37106/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AsyncBatchRequestWrapperImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AsyncBatchRequestWrapperImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AsyncBatchRequestWrapperImpl.java
index 71174a4..d64ea3f 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AsyncBatchRequestWrapperImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AsyncBatchRequestWrapperImpl.java
@@ -32,7 +32,6 @@ import org.apache.olingo.client.api.communication.request.batch.ODataBatchReques
import org.apache.olingo.client.api.communication.request.batch.ODataChangeset;
import org.apache.olingo.client.api.communication.response.AsyncResponseWrapper;
import org.apache.olingo.client.api.communication.response.ODataBatchResponse;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
public class AsyncBatchRequestWrapperImpl extends AsyncRequestWrapperImpl<ODataBatchResponse>
implements AsyncBatchRequestWrapper {
@@ -107,7 +106,7 @@ public class AsyncBatchRequestWrapperImpl extends AsyncRequestWrapperImpl<ODataB
headers = res.getHeader(HeaderName.preferenceApplied.toString());
if (headers != null && !headers.isEmpty()) {
for (String header : headers) {
- if (header.equalsIgnoreCase(new ODataPreferences(ODataServiceVersion.V40).respondAsync())) {
+ if (header.equalsIgnoreCase(new ODataPreferences().respondAsync())) {
preferenceApplied = true;
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/07c37106/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AsyncRequestWrapperImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AsyncRequestWrapperImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AsyncRequestWrapperImpl.java
index f02d9e4..dd8456f 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AsyncRequestWrapperImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AsyncRequestWrapperImpl.java
@@ -41,7 +41,6 @@ import org.apache.olingo.client.api.communication.response.AsyncResponseWrapper;
import org.apache.olingo.client.api.communication.response.ODataDeleteResponse;
import org.apache.olingo.client.api.communication.response.ODataResponse;
import org.apache.olingo.client.api.http.HttpClientException;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.commons.api.http.HttpMethod;
public class AsyncRequestWrapperImpl<R extends ODataResponse> extends AbstractRequest
@@ -76,7 +75,7 @@ public class AsyncRequestWrapperImpl<R extends ODataResponse> extends AbstractRe
this.odataRequest.setAccept(this.odataRequest.getAccept());
this.odataRequest.setContentType(this.odataRequest.getContentType());
- extendHeader(HeaderName.prefer.toString(), new ODataPreferences(ODataServiceVersion.V40).respondAsync());
+ extendHeader(HeaderName.prefer.toString(), new ODataPreferences().respondAsync());
this.odataClient = odataClient;
final HttpMethod method = odataRequest.getMethod();
@@ -95,14 +94,14 @@ public class AsyncRequestWrapperImpl<R extends ODataResponse> extends AbstractRe
@Override
public final AsyncRequestWrapper<R> wait(final int waitInSeconds) {
- extendHeader(HeaderName.prefer.toString(), new ODataPreferences(ODataServiceVersion.V40).wait(waitInSeconds));
+ extendHeader(HeaderName.prefer.toString(), new ODataPreferences().wait(waitInSeconds));
return this;
}
@Override
public final AsyncRequestWrapper<R> callback(URI url) {
extendHeader(HeaderName.prefer.toString(),
- new ODataPreferences(ODataServiceVersion.V40).callback(url.toASCIIString()));
+ new ODataPreferences().callback(url.toASCIIString()));
return this;
}
@@ -272,7 +271,7 @@ public class AsyncRequestWrapperImpl<R extends ODataResponse> extends AbstractRe
headers = res.getHeaders(HeaderName.preferenceApplied.toString());
if (ArrayUtils.isNotEmpty(headers)) {
for (Header header : headers) {
- if (header.getValue().equalsIgnoreCase(new ODataPreferences(ODataServiceVersion.V40).respondAsync())) {
+ if (header.getValue().equalsIgnoreCase(new ODataPreferences().respondAsync())) {
preferenceApplied = true;
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/07c37106/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataBatchRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataBatchRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataBatchRequestImpl.java
index dc967ca..09a7691 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataBatchRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataBatchRequestImpl.java
@@ -68,7 +68,7 @@ public class ODataBatchRequestImpl
@Override
protected HttpResponse doExecute() {
if (odataClient.getConfiguration().isContinueOnError()) {
- addCustomHeader(HeaderName.prefer, new ODataPreferences(odataClient.getServiceVersion()).continueOnError());
+ addCustomHeader(HeaderName.prefer, new ODataPreferences().continueOnError());
}
return super.doExecute();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/07c37106/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
index cebf12d..6bf3282 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
@@ -1,18 +1,18 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@@ -52,8 +52,8 @@ import org.apache.olingo.commons.api.serialization.ODataSerializerException;
* This class implements an OData invoke operation request.
*/
public abstract class AbstractODataInvokeRequest<T extends ODataInvokeResult>
- extends AbstractODataBasicRequest<ODataInvokeResponse<T>>
- implements ODataInvokeRequest<T>, ODataBatchableRequest {
+ extends AbstractODataBasicRequest<ODataInvokeResponse<T>>
+ implements ODataInvokeRequest<T>, ODataBatchableRequest {
private final Class<T> reference;
@@ -71,10 +71,10 @@ public abstract class AbstractODataInvokeRequest<T extends ODataInvokeResult>
* @param uri URI that identifies the operation.
*/
public AbstractODataInvokeRequest(
- final ODataClient odataClient,
- final Class<T> reference,
- final HttpMethod method,
- final URI uri) {
+ final ODataClient odataClient,
+ final Class<T> reference,
+ final HttpMethod method,
+ final URI uri) {
super(odataClient, method, uri);
@@ -97,8 +97,7 @@ public abstract class AbstractODataInvokeRequest<T extends ODataInvokeResult>
private String getActualFormat(final ODataFormat format) {
return ((ODataProperty.class.isAssignableFrom(reference) && format == ODataFormat.ATOM)
- ? ODataFormat.XML : format)
- .getContentType(odataClient.getServiceVersion()).toContentTypeString();
+ ? ODataFormat.XML : format).getContentType().toContentTypeString();
}
@Override
@@ -120,18 +119,18 @@ public abstract class AbstractODataInvokeRequest<T extends ODataInvokeResult>
if (param.getValue().isPrimitive()) {
property = odataClient.getObjectFactory().
- newPrimitiveProperty(param.getKey(), param.getValue().asPrimitive());
+ newPrimitiveProperty(param.getKey(), param.getValue().asPrimitive());
} else if (param.getValue().isComplex()) {
property = odataClient.getObjectFactory().
- newComplexProperty(param.getKey(), param.getValue().asComplex());
+ newComplexProperty(param.getKey(), param.getValue().asComplex());
} else if (param.getValue().isCollection()) {
property = odataClient.getObjectFactory().
- newCollectionProperty(param.getKey(), param.getValue().asCollection());
+ newCollectionProperty(param.getKey(), param.getValue().asCollection());
} else if (param.getValue() instanceof org.apache.olingo.commons.api.domain.ODataValue
- && ((org.apache.olingo.commons.api.domain.ODataValue) param.getValue()).isEnum()) {
+ && ((org.apache.olingo.commons.api.domain.ODataValue) param.getValue()).isEnum()) {
property = ((ODataClient) odataClient).getObjectFactory().
- newEnumProperty(param.getKey(),
+ newEnumProperty(param.getKey(),
((org.apache.olingo.commons.api.domain.ODataValue) param.getValue()).asEnum());
}
@@ -160,7 +159,7 @@ public abstract class AbstractODataInvokeRequest<T extends ODataInvokeResult>
if (!this.parameters.isEmpty()) {
if (this.method == HttpMethod.GET) {
((HttpRequestBase) this.request).setURI(
- URIUtils.buildFunctionInvokeURI(this.uri, parameters, odataClient.getServiceVersion()));
+ URIUtils.buildFunctionInvokeURI(this.uri, parameters));
} else if (this.method == HttpMethod.POST) {
((HttpPost) request).setEntity(URIUtils.buildInputStreamEntity(odataClient, input));
@@ -183,7 +182,7 @@ public abstract class AbstractODataInvokeRequest<T extends ODataInvokeResult>
private T invokeResult = null;
private ODataInvokeResponseImpl(final ODataClient odataClient, final HttpClient httpClient,
- final HttpResponse res) {
+ final HttpResponse res) {
super(odataClient, httpClient, res);
}
@@ -202,13 +201,13 @@ public abstract class AbstractODataInvokeRequest<T extends ODataInvokeResult>
final InputStream responseStream = this.payload == null ? res.getEntity().getContent() : this.payload;
if (ODataEntitySet.class.isAssignableFrom(reference)) {
invokeResult = reference.cast(odataClient.getReader().readEntitySet(responseStream,
- ODataFormat.fromString(getContentType())));
+ ODataFormat.fromString(getContentType())));
} else if (ODataEntity.class.isAssignableFrom(reference)) {
invokeResult = reference.cast(odataClient.getReader().readEntity(responseStream,
- ODataFormat.fromString(getContentType())));
+ ODataFormat.fromString(getContentType())));
} else if (ODataProperty.class.isAssignableFrom(reference)) {
invokeResult = reference.cast(odataClient.getReader().readProperty(responseStream,
- ODataFormat.fromString(getContentType())));
+ ODataFormat.fromString(getContentType())));
}
}
} catch (IOException e) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/07c37106/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataMediaRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataMediaRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataMediaRequestImpl.java
index bcffc59..7c7c34c 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataMediaRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataMediaRequestImpl.java
@@ -25,7 +25,6 @@ import java.net.URI;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.olingo.client.api.ODataClient;
-import org.apache.olingo.client.api.communication.header.HeaderName;
import org.apache.olingo.client.api.communication.request.retrieve.ODataMediaRequest;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.api.http.HttpClientException;
@@ -47,10 +46,6 @@ public class ODataMediaRequestImpl extends AbstractODataRetrieveRequest<InputStr
setAccept(ODataFormat.APPLICATION_OCTET_STREAM.toString());
setContentType(ODataFormat.APPLICATION_OCTET_STREAM.toString());
-
- this.odataHeaders.removeHeader(HeaderName.minDataServiceVersion);
- this.odataHeaders.removeHeader(HeaderName.maxDataServiceVersion);
- this.odataHeaders.removeHeader(HeaderName.dataServiceVersion);
}
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/07c37106/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedEntityRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedEntityRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedEntityRequest.java
index 0242674..c257803 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedEntityRequest.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedEntityRequest.java
@@ -1,18 +1,18 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@@ -34,8 +34,8 @@ import org.apache.olingo.commons.api.http.HttpMethod;
* @param <T> OData request payload type corresponding to the request implementation.
*/
public abstract class AbstractODataStreamedEntityRequest<V extends ODataResponse, T extends ODataPayloadManager<V>>
- extends AbstractODataStreamedRequest<V, T>
- implements ODataStreamedEntityRequest<V, T> {
+ extends AbstractODataStreamedRequest<V, T>
+ implements ODataStreamedEntityRequest<V, T> {
private ODataFormat format;
@@ -47,10 +47,10 @@ public abstract class AbstractODataStreamedEntityRequest<V extends ODataResponse
* @param uri request URI.
*/
public AbstractODataStreamedEntityRequest(final ODataClient odataClient, final HttpMethod method,
- final URI uri) {
+ final URI uri) {
super(odataClient, method, uri);
- setAccept(getFormat().getContentType(odataClient.getServiceVersion()).toContentTypeString());
+ setAccept(getFormat().getContentType().toContentTypeString());
}
@Override
@@ -61,6 +61,6 @@ public abstract class AbstractODataStreamedEntityRequest<V extends ODataResponse
@Override
public final void setFormat(final ODataFormat format) {
this.format = format;
- setAccept(format.getContentType(odataClient.getServiceVersion()).toContentTypeString());
+ setAccept(format.getContentType().toContentTypeString());
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/07c37106/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AbstractEdmDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AbstractEdmDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AbstractEdmDeserializer.java
index 0391517..d45d749 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AbstractEdmDeserializer.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AbstractEdmDeserializer.java
@@ -21,7 +21,6 @@ package org.apache.olingo.client.core.edm.xml;
import java.io.IOException;
import org.apache.olingo.client.core.edm.xml.annotation.ConstantAnnotationExpressionImpl;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
@@ -31,7 +30,7 @@ import com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser;
public abstract class AbstractEdmDeserializer<T> extends JsonDeserializer<T> {
- protected ODataServiceVersion version;
+ //protected ODataServiceVersion version;
protected boolean isAnnotationConstExprConstruct(final JsonParser jp) throws IOException {
return ConstantAnnotationExpressionImpl.Type.fromString(jp.getCurrentName()) != null;
@@ -63,7 +62,7 @@ public abstract class AbstractEdmDeserializer<T> extends JsonDeserializer<T> {
public T deserialize(final JsonParser jp, final DeserializationContext ctxt)
throws IOException, JsonProcessingException {
- version = (ODataServiceVersion) ctxt.findInjectableValue(ODataServiceVersion.class.getName(), null, null);
+ //version = (ODataServiceVersion) ctxt.findInjectableValue(ODataServiceVersion.class.getName(), null, null);
return doDeserialize(jp, ctxt);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/07c37106/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ClientODataDeserializerImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ClientODataDeserializerImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ClientODataDeserializerImpl.java
index f0d2ba1..4dd1658 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ClientODataDeserializerImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ClientODataDeserializerImpl.java
@@ -37,7 +37,6 @@ import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.domain.ODataError;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.serialization.ODataDeserializer;
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
@@ -91,9 +90,7 @@ public class ClientODataDeserializerImpl implements ClientODataDeserializer {
final XmlMapper xmlMapper = new XmlMapper(
new XmlFactory(new InputFactoryImpl(), new OutputFactoryImpl()), new JacksonXmlModule());
- xmlMapper.setInjectableValues(new InjectableValues.Std().
- addValue(ODataServiceVersion.class, ODataServiceVersion.V40).
- addValue(Boolean.class, Boolean.FALSE));
+ xmlMapper.setInjectableValues(new InjectableValues.Std().addValue(Boolean.class, Boolean.FALSE));
xmlMapper.addHandler(new DeserializationProblemHandler() {
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/07c37106/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterArgFactoryImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterArgFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterArgFactoryImpl.java
index 9eca1ba..02e9c63 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterArgFactoryImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterArgFactoryImpl.java
@@ -1,18 +1,18 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@@ -21,17 +21,9 @@ package org.apache.olingo.client.core.uri;
import org.apache.olingo.client.api.uri.FilterArg;
import org.apache.olingo.client.api.uri.FilterArgFactory;
import org.apache.olingo.client.api.uri.URIFilter;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
public class FilterArgFactoryImpl implements FilterArgFactory {
- private final ODataServiceVersion version;
-
- public FilterArgFactoryImpl(final ODataServiceVersion version) {
- this.version = version;
- }
-
-
@Override
public FilterArg _null() {
return new FilterConst("null");
@@ -44,7 +36,7 @@ public class FilterArgFactoryImpl implements FilterArgFactory {
@Override
public FilterArg literal(final Object value) {
- return new FilterLiteral(version, value);
+ return new FilterLiteral(value);
}
@Override
@@ -181,7 +173,7 @@ public class FilterArgFactoryImpl implements FilterArgFactory {
public FilterArg isof(final FilterArg expression, final FilterArg type) {
return new FilterFunction("isof", expression, type);
}
-
+
@Override
public FilterArg contains(final FilterArg first, final FilterArg second) {
return new FilterFunction("contains", first, second);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/07c37106/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterFactoryImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterFactoryImpl.java
index 8ba09b8..92f0c22 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterFactoryImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterFactoryImpl.java
@@ -23,16 +23,9 @@ import org.apache.olingo.client.api.uri.FilterArgFactory;
import org.apache.olingo.client.api.uri.FilterFactory;
import org.apache.olingo.client.api.uri.URIFilter;
import org.apache.olingo.commons.api.edm.EdmEnumType;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
public class FilterFactoryImpl implements FilterFactory {
- private final ODataServiceVersion version;
-
- public FilterFactoryImpl(ODataServiceVersion version) {
- this.version = version;
- }
-
@Override
public URIFilter match(final FilterArg arg) {
return new MatchFilter(arg);
@@ -115,7 +108,7 @@ public class FilterFactoryImpl implements FilterFactory {
@Override
public FilterArgFactory getArgFactory() {
- return new FilterArgFactoryImpl(version);
+ return new FilterArgFactoryImpl();
}
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/07c37106/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterLiteral.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterLiteral.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterLiteral.java
index ad03934..4842a96 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterLiteral.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterLiteral.java
@@ -19,7 +19,6 @@
package org.apache.olingo.client.core.uri;
import org.apache.olingo.client.api.uri.FilterArg;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
/**
* Filter value literals; obtain instances via <tt>FilterArgFactory</tt>.
@@ -28,17 +27,15 @@ import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
*/
public class FilterLiteral implements FilterArg {
- private final ODataServiceVersion version;
private final Object value;
- FilterLiteral(final ODataServiceVersion version, final Object value) {
- this.version = version;
+ FilterLiteral(final Object value) {
this.value = value;
}
@Override
public String build() {
- return URIUtils.escape(version, value);
+ return URIUtils.escape(value);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/07c37106/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIBuilderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIBuilderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIBuilderImpl.java
index 78bf87b..5e8273d 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIBuilderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIBuilderImpl.java
@@ -1,18 +1,18 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@@ -39,7 +39,6 @@ import org.apache.olingo.client.api.uri.URIFilter;
import org.apache.olingo.client.api.uri.URISearch;
import org.apache.olingo.commons.api.Constants;
import org.apache.olingo.commons.api.edm.EdmEnumType;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.commons.core.Encoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -52,14 +51,12 @@ public class URIBuilderImpl implements URIBuilder {
* @param serviceRoot absolute URL (schema, host and port included) representing the location of the root of the data
* service.
*/
- public URIBuilderImpl(
- final ODataServiceVersion version, final Configuration configuration, final String serviceRoot) {
- this.version = version;
+ public URIBuilderImpl(final Configuration configuration, final String serviceRoot) {
this.configuration = configuration;
segments.add(new Segment(SegmentType.SERVICEROOT, serviceRoot));
}
-
+
protected static class Segment {
private final SegmentType type;
@@ -85,8 +82,6 @@ public class URIBuilderImpl implements URIBuilder {
*/
protected static final Logger LOG = LoggerFactory.getLogger(URIBuilderImpl.class);
- private final ODataServiceVersion version;
-
private final Configuration configuration;
protected final List<Segment> segments = new ArrayList<Segment>();
@@ -136,7 +131,7 @@ public class URIBuilderImpl implements URIBuilder {
@Override
public URIBuilder appendKeySegment(final Object val) {
- final String segValue = URIUtils.escape(version, val);
+ final String segValue = URIUtils.escape(val);
segments.add(configuration.isKeyAsSegment()
? new Segment(SegmentType.KEY_AS_SEGMENT, segValue)
@@ -343,7 +338,7 @@ public class URIBuilderImpl implements URIBuilder {
final StringBuilder keyBuilder = new StringBuilder().append('(');
for (Map.Entry<String, Object> entry : segmentValues.entrySet()) {
keyBuilder.append(entry.getKey()).append('=').append(
- escape ? URIUtils.escape(version, entry.getValue()) : entry.getValue());
+ escape ? URIUtils.escape(entry.getValue()) : entry.getValue());
keyBuilder.append(',');
}
keyBuilder.deleteCharAt(keyBuilder.length() - 1).append(')');
@@ -359,7 +354,7 @@ public class URIBuilderImpl implements URIBuilder {
@Override
public URIBuilder appendKeySegment(final Map<String, Pair<EdmEnumType, String>> enumValues,
- final Map<String, Object> segmentValues) {
+ final Map<String, Object> segmentValues) {
final Map<String, Object> values = new LinkedHashMap<String, Object>();
for (Map.Entry<String, Pair<EdmEnumType, String>> entry : enumValues.entrySet()) {
@@ -403,7 +398,7 @@ public class URIBuilderImpl implements URIBuilder {
@Override
public URIBuilder appendCrossjoinSegment(final String... segmentValues) {
final StringBuilder segValue = new StringBuilder(SegmentType.CROSS_JOIN.getValue()).
- append('(').append(StringUtils.join(segmentValues, ",")).append(')');
+ append('(').append(StringUtils.join(segmentValues, ",")).append(')');
segments.add(new Segment(SegmentType.CROSS_JOIN, segValue.toString()));
return this;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/07c37106/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java
index b70ff8f..12e5573 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java
@@ -53,7 +53,6 @@ import org.apache.olingo.commons.api.Constants;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.commons.api.edm.geo.Geospatial;
import org.apache.olingo.commons.core.edm.primitivetype.EdmBinary;
import org.apache.olingo.commons.core.edm.primitivetype.EdmDateTimeOffset;
@@ -145,18 +144,18 @@ public final class URIUtils {
}
// TODO: Delete prefix method since these are not relevant in V4
- private static String prefix(final ODataServiceVersion version, final EdmPrimitiveTypeKind typeKind) {
+ private static String prefix(final EdmPrimitiveTypeKind typeKind) {
String result = StringUtils.EMPTY;
return result;
}
//TODO: Delete suffix method since these are not relevant in V4
- private static String suffix(final ODataServiceVersion version, final EdmPrimitiveTypeKind typeKind) {
+ private static String suffix(final EdmPrimitiveTypeKind typeKind) {
String result = StringUtils.EMPTY;
return result;
}
- private static String timestamp(final ODataServiceVersion version, final Timestamp timestamp)
+ private static String timestamp(final Timestamp timestamp)
throws UnsupportedEncodingException, EdmPrimitiveTypeException {
return URLEncoder.encode(EdmDateTimeOffset.getInstance().
@@ -164,7 +163,7 @@ public final class URIUtils {
Constants.UTF8);
}
- private static String calendar(final ODataServiceVersion version, final Calendar calendar)
+ private static String calendar(final Calendar calendar)
throws UnsupportedEncodingException, EdmPrimitiveTypeException {
return URLEncoder.encode(EdmDateTimeOffset.getInstance().
@@ -172,7 +171,7 @@ public final class URIUtils {
Constants.UTF8);
}
- private static String duration(final ODataServiceVersion version, final Duration duration)
+ private static String duration(final Duration duration)
throws UnsupportedEncodingException, EdmPrimitiveTypeException {
return EdmDuration.getInstance().toUriLiteral(URLEncoder.encode(EdmDuration.getInstance().
@@ -197,21 +196,21 @@ public final class URIUtils {
* @param obj primitive value
* @return URI representation
*/
- public static String escape(final ODataServiceVersion version, final Object obj) {
- return escape(version, obj, true);
+ public static String escape(final Object obj) {
+ return escape(obj, true);
}
- private static String escape(final ODataServiceVersion version, final Object obj, final boolean singleQuoteEscape) {
+ private static String escape(final Object obj, final boolean singleQuoteEscape) {
String value;
try {
if (obj == null) {
value = Constants.ATTR_NULL;
- } else if (version.compareTo(ODataServiceVersion.V40) >= 0 && obj instanceof Collection) {
+ } else if (obj instanceof Collection) {
final StringBuffer buffer = new StringBuffer("[");
for (@SuppressWarnings("unchecked")
final Iterator<Object> itor = ((Collection<Object>) obj).iterator(); itor.hasNext();) {
- buffer.append(escape(version, itor.next(), false));
+ buffer.append(escape(itor.next(), false));
if (itor.hasNext()) {
buffer.append(',');
}
@@ -219,7 +218,7 @@ public final class URIUtils {
buffer.append(']');
value = buffer.toString();
- } else if (version.compareTo(ODataServiceVersion.V40) >= 0 && obj instanceof Map) {
+ } else if (obj instanceof Map) {
final StringBuffer buffer = new StringBuffer("{");
for (@SuppressWarnings("unchecked")
final Iterator<Map.Entry<String, Object>> itor =
@@ -227,7 +226,7 @@ public final class URIUtils {
final Map.Entry<String, Object> entry = itor.next();
buffer.append("\"").append(entry.getKey()).append("\"");
- buffer.append(':').append(escape(version, entry.getValue(), false));
+ buffer.append(':').append(escape(entry.getValue(), false));
if (itor.hasNext()) {
buffer.append(',');
@@ -243,33 +242,33 @@ public final class URIUtils {
: (obj instanceof Boolean)
? BooleanUtils.toStringTrueFalse((Boolean) obj)
: (obj instanceof UUID)
- ? prefix(version, EdmPrimitiveTypeKind.Guid)
+ ? prefix(EdmPrimitiveTypeKind.Guid)
+ obj.toString()
- + suffix(version, EdmPrimitiveTypeKind.Guid)
+ + suffix(EdmPrimitiveTypeKind.Guid)
: (obj instanceof byte[])
? EdmBinary.getInstance().toUriLiteral(Hex.encodeHexString((byte[]) obj))
: (obj instanceof Timestamp)
- ? timestamp(version, (Timestamp) obj)
+ ? timestamp((Timestamp) obj)
: (obj instanceof Calendar)
- ? calendar(version, (Calendar) obj)
+ ? calendar((Calendar) obj)
: (obj instanceof Duration)
- ? duration(version, (Duration) obj)
+ ? duration((Duration) obj)
: (obj instanceof BigDecimal)
? EdmDecimal.getInstance().valueToString(obj, null, null,
Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null)
- + suffix(version, EdmPrimitiveTypeKind.Decimal)
+ + suffix(EdmPrimitiveTypeKind.Decimal)
: (obj instanceof Double)
? EdmDouble.getInstance().valueToString(obj, null, null,
Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null)
- + suffix(version, EdmPrimitiveTypeKind.Double)
+ + suffix(EdmPrimitiveTypeKind.Double)
: (obj instanceof Float)
? EdmSingle.getInstance().valueToString(obj, null, null,
Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null)
- + suffix(version, EdmPrimitiveTypeKind.Single)
+ + suffix(EdmPrimitiveTypeKind.Single)
: (obj instanceof Long)
? EdmInt64.getInstance().valueToString(obj, null, null,
Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null)
- + suffix(version, EdmPrimitiveTypeKind.Int64)
+ + suffix(EdmPrimitiveTypeKind.Int64)
: (obj instanceof Geospatial)
? URLEncoder.encode(EdmPrimitiveTypeFactory.getInstance(
((Geospatial) obj).getEdmPrimitiveTypeKind()).
@@ -347,61 +346,43 @@ public final class URIUtils {
return res;
}
- public static URI buildFunctionInvokeURI(
- final URI uri, final Map<String, ODataValue> parameters, final ODataServiceVersion serviceVersion) {
-
- if (serviceVersion.compareTo(ODataServiceVersion.V40) >= 0) {
- final String rawQuery = uri.getRawQuery();
- String baseURI = StringUtils.substringBefore(uri.toASCIIString(), "?" + rawQuery);
- if (baseURI.endsWith("()")) {
- baseURI = baseURI.substring(0, baseURI.length() - 2);
- }
-
- final StringBuilder inlineParams = new StringBuilder();
- for (Map.Entry<String, ODataValue> param : parameters.entrySet()) {
- inlineParams.append(param.getKey()).append("=");
-
- Object value = null;
- if (param.getValue().isPrimitive()) {
- value = param.getValue().asPrimitive().toValue();
- } else if (param.getValue().isComplex()) {
- value = param.getValue().asComplex().asJavaMap();
- } else if (param.getValue().isCollection()) {
- value = param.getValue().asCollection().asJavaCollection();
- } else if (param.getValue() instanceof org.apache.olingo.commons.api.domain.ODataValue
- && ((org.apache.olingo.commons.api.domain.ODataValue) param.getValue()).isEnum()) {
-
- value = ((org.apache.olingo.commons.api.domain.ODataValue) param.getValue()).asEnum().toString();
- }
-
- inlineParams.append(URIUtils.escape(serviceVersion, value)).append(',');
- }
+ public static URI buildFunctionInvokeURI(final URI uri, final Map<String, ODataValue> parameters) {
+ final String rawQuery = uri.getRawQuery();
+ String baseURI = StringUtils.substringBefore(uri.toASCIIString(), "?" + rawQuery);
+ if (baseURI.endsWith("()")) {
+ baseURI = baseURI.substring(0, baseURI.length() - 2);
+ }
- if (inlineParams.length() > 0) {
- inlineParams.deleteCharAt(inlineParams.length() - 1);
+ final StringBuilder inlineParams = new StringBuilder();
+ for (Map.Entry<String, ODataValue> param : parameters.entrySet()) {
+ inlineParams.append(param.getKey()).append("=");
+
+ Object value = null;
+ if (param.getValue().isPrimitive()) {
+ value = param.getValue().asPrimitive().toValue();
+ } else if (param.getValue().isComplex()) {
+ value = param.getValue().asComplex().asJavaMap();
+ } else if (param.getValue().isCollection()) {
+ value = param.getValue().asCollection().asJavaCollection();
+ } else if (param.getValue() instanceof org.apache.olingo.commons.api.domain.ODataValue
+ && ((org.apache.olingo.commons.api.domain.ODataValue) param.getValue()).isEnum()) {
+
+ value = ((org.apache.olingo.commons.api.domain.ODataValue) param.getValue()).asEnum().toString();
}
- try {
- return URI.create(baseURI + "(" + URLEncoder.encode(inlineParams.toString(), Constants.UTF8) + ")"
- + (StringUtils.isNotBlank(rawQuery) ? "?" + rawQuery : StringUtils.EMPTY));
- } catch (UnsupportedEncodingException e) {
- throw new IllegalArgumentException("While adding GET parameters", e);
- }
- } else {
- final URIBuilder uriBuilder = new URIBuilder(uri);
- for (Map.Entry<String, ODataValue> param : parameters.entrySet()) {
- if (!param.getValue().isPrimitive()) {
- throw new IllegalArgumentException("Only primitive values can be passed via GET");
- }
+ inlineParams.append(URIUtils.escape(value)).append(',');
+ }
- uriBuilder.addParameter(param.getKey(), URIUtils.escape(serviceVersion, param.getValue()));
- }
+ if (inlineParams.length() > 0) {
+ inlineParams.deleteCharAt(inlineParams.length() - 1);
+ }
- try {
- return uriBuilder.build();
- } catch (URISyntaxException e) {
- throw new IllegalArgumentException("While adding GET parameters", e);
- }
+ try {
+ return URI.create(baseURI + "(" + URLEncoder.encode(inlineParams.toString(), Constants.UTF8) + ")"
+ + (StringUtils.isNotBlank(rawQuery) ? "?" + rawQuery : StringUtils.EMPTY));
+ } catch (UnsupportedEncodingException e) {
+ throw new IllegalArgumentException("While adding GET parameters", e);
}
+
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/07c37106/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/URIEscapeTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/URIEscapeTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/URIEscapeTest.java
index 09116bd..f10e236 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/URIEscapeTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/URIEscapeTest.java
@@ -18,15 +18,7 @@
*/
package org.apache.olingo.client.core.uri;
-import org.apache.olingo.client.core.edm.EdmEnumTypeImpl;
-import org.apache.olingo.client.core.edm.xml.EnumTypeImpl;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.edm.EdmEnumType;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.api.edm.geo.Geospatial;
-import org.apache.olingo.commons.api.edm.geo.Point;
-import org.junit.Test;
+import static org.junit.Assert.assertEquals;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
@@ -35,18 +27,25 @@ import java.util.Calendar;
import java.util.Collections;
import java.util.TimeZone;
-import static org.junit.Assert.assertEquals;
+import org.apache.olingo.client.core.edm.EdmEnumTypeImpl;
+import org.apache.olingo.client.core.edm.xml.EnumTypeImpl;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.edm.EdmEnumType;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.geo.Geospatial;
+import org.apache.olingo.commons.api.edm.geo.Point;
+import org.junit.Test;
public class URIEscapeTest {
@Test
public void _null() {
- assertEquals("null", URIUtils.escape(ODataServiceVersion.V40, null));
+ assertEquals("null", URIUtils.escape( null));
}
@Test
public void _boolean() {
- assertEquals("true", URIUtils.escape(ODataServiceVersion.V40, Boolean.TRUE));
+ assertEquals("true", URIUtils.escape( Boolean.TRUE));
}
@Test
@@ -54,7 +53,7 @@ public class URIEscapeTest {
final EdmEnumType pattern =
new EdmEnumTypeImpl(null, new FullQualifiedName("Sales", "Pattern"), new EnumTypeImpl());
- assertEquals("Sales.Pattern'Yellow'", URIUtils.escape(ODataServiceVersion.V40, pattern.toUriLiteral("Yellow")));
+ assertEquals("Sales.Pattern'Yellow'", URIUtils.escape( pattern.toUriLiteral("Yellow")));
}
@Test
@@ -64,7 +63,7 @@ public class URIEscapeTest {
calendar.set(2014, 6, 11, 12, 30, 04);
assertEquals(URLEncoder.encode("2014-07-11T12:30:04+01:00", Constants.UTF8),
- URIUtils.escape(ODataServiceVersion.V40, calendar));
+ URIUtils.escape( calendar));
}
@Test
@@ -74,18 +73,18 @@ public class URIEscapeTest {
point.setY(64.1);
assertEquals(URLEncoder.encode("geography'SRID=4326;Point(142.1 64.1)'", Constants.UTF8),
- URIUtils.escape(ODataServiceVersion.V40, point));
+ URIUtils.escape( point));
}
@Test
public void collection() {
assertEquals("[\"red\",\"green\"]",
- URIUtils.escape(ODataServiceVersion.V40, Arrays.asList(new String[] { "red", "green" })));
+ URIUtils.escape( Arrays.asList(new String[] { "red", "green" })));
}
@Test
public void complex() {
assertEquals("{\"Name\":\"Value\"}",
- URIUtils.escape(ODataServiceVersion.V40, Collections.singletonMap("Name", "Value")));
+ URIUtils.escape( Collections.singletonMap("Name", "Value")));
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/07c37106/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataFormat.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataFormat.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataFormat.java
index 897e2da..6a4b494 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataFormat.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataFormat.java
@@ -18,10 +18,6 @@
*/
package org.apache.olingo.commons.api.format;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-
-import java.util.HashMap;
-import java.util.Map;
/**
* Available formats to be used in various contexts.
@@ -29,11 +25,11 @@ import java.util.Map;
public enum ODataFormat {
/** JSON format with no metadata. */
- JSON_NO_METADATA,
+ JSON_NO_METADATA(ContentType.create(ContentType.APPLICATION_JSON, "odata.metadata=none")),
/** JSON format with minimal metadata (default). */
- JSON,
+ JSON(ContentType.create(ContentType.APPLICATION_JSON, "odata.metadata=minimal")),
/** JSON format with full metadata. */
- JSON_FULL_METADATA,
+ JSON_FULL_METADATA(ContentType.create(ContentType.APPLICATION_JSON, "odata.metadata=full")),
/** XML format. */
XML(ContentType.APPLICATION_XML),
@@ -53,53 +49,19 @@ public enum ODataFormat {
TEXT_XML(ContentType.TEXT_XML),
TEXT_HTML(ContentType.TEXT_HTML);
- private static final String JSON_METADATA_PARAMETER_V3 = "odata";
- private static final String JSON_METADATA_PARAMETER_V4 = "odata.metadata";
-
- private static final Map<ODataServiceVersion, Map<ODataFormat, ContentType>> FORMAT_PER_VERSION = new
- HashMap<ODataServiceVersion, Map<ODataFormat, ContentType>>();
-
- static {
- final Map<ODataFormat, ContentType> v3 = new HashMap<ODataFormat, ContentType>();
- v3.put(ODataFormat.JSON_NO_METADATA, ContentType.create(
- ContentType.APPLICATION_JSON, JSON_METADATA_PARAMETER_V3 + "=nometadata"));
- v3.put(ODataFormat.JSON, ContentType.create(
- ContentType.APPLICATION_JSON, JSON_METADATA_PARAMETER_V3 + "=minimalmetadata"));
- v3.put(ODataFormat.JSON_FULL_METADATA, ContentType.create(
- ContentType.APPLICATION_JSON, JSON_METADATA_PARAMETER_V3 + "=fullmetadata"));
- FORMAT_PER_VERSION.put(ODataServiceVersion.V30, v3);
-
- final Map<ODataFormat, ContentType> v4 = new HashMap<ODataFormat, ContentType>();
- v4.put(ODataFormat.JSON_NO_METADATA, ContentType.create(
- ContentType.APPLICATION_JSON, JSON_METADATA_PARAMETER_V4 + "=none"));
- v4.put(ODataFormat.JSON, ContentType.create(
- ContentType.APPLICATION_JSON, JSON_METADATA_PARAMETER_V4 + "=minimal"));
- v4.put(ODataFormat.JSON_FULL_METADATA, ContentType.create(
- ContentType.APPLICATION_JSON, JSON_METADATA_PARAMETER_V4 + "=full"));
- FORMAT_PER_VERSION.put(ODataServiceVersion.V40, v4);
- }
-
private final ContentType contentType;
ODataFormat(final ContentType contentType) {
this.contentType = contentType;
}
- ODataFormat() {
- contentType = null;
- }
-
/**
* Gets format as {@link ContentType}.
* @param version OData service version.
* @return format as ContentType.
*/
- public ContentType getContentType(final ODataServiceVersion version) {
- if (version.ordinal() < ODataServiceVersion.V30.ordinal()) {
- throw new IllegalArgumentException("Unsupported version " + version);
- }
-
- return contentType == null ? FORMAT_PER_VERSION.get(version).get(this) : contentType;
+ public ContentType getContentType() {
+ return contentType;
}
@Override
@@ -128,24 +90,14 @@ public enum ODataFormat {
} else if (contentType.isCompatible(ContentType.APPLICATION_XML)) {
return XML;
} else if (contentType.isCompatible(ContentType.APPLICATION_JSON)) {
- String jsonVariant = contentType.getParameters().get(JSON_METADATA_PARAMETER_V3);
- if (jsonVariant != null) {
- for (ODataFormat candidate : FORMAT_PER_VERSION.get(ODataServiceVersion.V30).keySet()) {
- if (FORMAT_PER_VERSION.get(ODataServiceVersion.V30).get(candidate).getParameters()
- .get(JSON_METADATA_PARAMETER_V3)
- .equals(jsonVariant)) {
- return candidate;
- }
- }
- }
- jsonVariant = contentType.getParameters().get(JSON_METADATA_PARAMETER_V4);
+ String jsonVariant = contentType.getParameters().get("odata.metadata");
if (jsonVariant != null) {
- for (ODataFormat candidate : FORMAT_PER_VERSION.get(ODataServiceVersion.V40).keySet()) {
- if (FORMAT_PER_VERSION.get(ODataServiceVersion.V40).get(candidate).getParameters()
- .get(JSON_METADATA_PARAMETER_V4)
- .equals(jsonVariant)) {
- return candidate;
- }
+ if("none".equals(jsonVariant)){
+ return JSON_NO_METADATA;
+ }else if("minimal".equals(jsonVariant)){
+ return ODataFormat.JSON;
+ }else if("full".equals(jsonVariant)){
+ return ODataFormat.JSON_FULL_METADATA;
}
}
return JSON;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/07c37106/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataObjectFactoryImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataObjectFactoryImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataObjectFactoryImpl.java
index b8bb9e6..5162555 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataObjectFactoryImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataObjectFactoryImpl.java
@@ -36,16 +36,9 @@ import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ODataSingleton;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
public class ODataObjectFactoryImpl implements ODataObjectFactory {
- protected final ODataServiceVersion version;
-
- public ODataObjectFactoryImpl(final ODataServiceVersion version) {
- this.version = version;
- }
-
@Override
public ODataInlineEntitySet newDeepInsertEntitySet(final String name, final ODataEntitySet entitySet) {
return new ODataInlineEntitySet(null, ODataLinkType.ENTITY_SET_NAVIGATION, name, entitySet);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/07c37106/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java
index f0e3d2d..1e279fc 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java
@@ -21,7 +21,6 @@ package org.apache.olingo.server.core;
import java.util.Arrays;
import java.util.List;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.commons.api.format.AcceptType;
import org.apache.olingo.commons.api.format.ContentType;
import org.apache.olingo.commons.api.format.ODataFormat;
@@ -49,8 +48,8 @@ public class ContentNegotiator {
return Arrays.asList(ContentType.MULTIPART_MIXED);
default:
return Arrays.asList(
- ODataFormat.JSON.getContentType(ODataServiceVersion.V40),
- ODataFormat.JSON_NO_METADATA.getContentType(ODataServiceVersion.V40));
+ ODataFormat.JSON.getContentType(),
+ ODataFormat.JSON_NO_METADATA.getContentType());
}
}
@@ -85,7 +84,7 @@ public class ContentNegotiator {
try {
result = getAcceptedType(
AcceptType.fromContentType(format == null ?
- ContentType.create(formatOption.getFormat()) : format.getContentType(ODataServiceVersion.V40)),
+ ContentType.create(formatOption.getFormat()) : format.getContentType()),
supportedContentTypes);
} catch (final IllegalArgumentException e) {}
if (result == null) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/07c37106/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
index c8928b5..282b482 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
@@ -223,7 +223,7 @@ public class ODataHandler {
uriInfo == null ? null : uriInfo.getFormatOption(), request, customContentTypeSupport,
RepresentationType.ERROR);
} catch (final ContentNegotiatorException e) {
- requestedContentType = ODataFormat.JSON.getContentType(ODataServiceVersion.V40);
+ requestedContentType = ODataFormat.JSON.getContentType();
}
exceptionProcessor.processError(request, response, serverError, requestedContentType);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/07c37106/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java
index 1551461..9e43e71 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java
@@ -20,7 +20,6 @@ package org.apache.olingo.server.core;
import java.util.List;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.server.api.OData;
import org.apache.olingo.server.api.ODataHttpHandler;
@@ -75,7 +74,7 @@ public class ODataImpl extends OData {
@Override
public ServiceMetadata createServiceMetadata(EdmProvider edmProvider, List<EdmxReference> references) {
- return new ServiceMetadataImpl(ODataServiceVersion.V40, edmProvider, references);
+ return new ServiceMetadataImpl(edmProvider, references);
}
@Override
@@ -89,7 +88,7 @@ public class ODataImpl extends OData {
}
@Override
- public ODataDeserializer createDeserializer(ODataFormat format) throws DeserializerException{
+ public ODataDeserializer createDeserializer(ODataFormat format) throws DeserializerException {
ODataDeserializer serializer;
switch (format) {
case JSON:
@@ -98,7 +97,7 @@ public class ODataImpl extends OData {
serializer = new ODataJsonDeserializer();
break;
case XML:
- //We do not support xml deserialization right now so this mus lead to an error
+ // We do not support xml deserialization right now so this mus lead to an error
default:
throw new DeserializerException("Unsupported format: " + format,
SerializerException.MessageKeys.UNSUPPORTED_FORMAT, format.toString());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/07c37106/lib/server-core/src/main/java/org/apache/olingo/server/core/ServiceMetadataImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ServiceMetadataImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ServiceMetadataImpl.java
index 5008092..06743d5 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ServiceMetadataImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ServiceMetadataImpl.java
@@ -34,12 +34,10 @@ import java.util.List;
public class ServiceMetadataImpl implements ServiceMetadata {
private final EdmProviderImpl edm;
- private final ODataServiceVersion version;
private final List<EdmxReference> references = new ArrayList<EdmxReference>();
- public ServiceMetadataImpl(ODataServiceVersion version, EdmProvider edmProvider, List<EdmxReference> references) {
+ public ServiceMetadataImpl(EdmProvider edmProvider, List<EdmxReference> references) {
this.edm = new EdmProviderImpl(edmProvider);
- this.version = version;
this.references.addAll(references);
}
@@ -50,7 +48,7 @@ public class ServiceMetadataImpl implements ServiceMetadata {
@Override
public ODataServiceVersion getDataServiceVersion() {
- return version;
+ return ODataServiceVersion.V40;
}
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/07c37106/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java
index 972432d..979d39b 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java
@@ -30,7 +30,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.commons.api.format.ContentType;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.http.HttpContentType;
@@ -146,7 +145,7 @@ public class ContentNegotiatorTest {
@Test
public void checkSupport() throws Exception {
- ContentNegotiator.checkSupport(ODataFormat.JSON.getContentType(ODataServiceVersion.V40), null,
+ ContentNegotiator.checkSupport(ODataFormat.JSON.getContentType(), null,
RepresentationType.ENTITY);
ContentNegotiator.checkSupport(ContentType.TEXT_PLAIN, null, RepresentationType.VALUE);
try {