You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2015/07/08 10:14:55 UTC
[01/12] olingo-odata4 git commit: [OLINGO-712] HeaderName is
redundant (there is HttpHeader)
Repository: olingo-odata4
Updated Branches:
refs/heads/OLINGO-708_AsyncSupportTec 2080f23bf -> 1476b034b
[OLINGO-712] HeaderName is redundant (there is HttpHeader)
Signed-off-by: Christian Amend <ch...@sap.com>
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/d54b0711
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/d54b0711
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/d54b0711
Branch: refs/heads/OLINGO-708_AsyncSupportTec
Commit: d54b071198b95c04e4386cd41da082ce3fd2be7a
Parents: a3fbf39
Author: Klaus Straubinger <kl...@sap.com>
Authored: Tue Jun 23 13:09:23 2015 +0200
Committer: Christian Amend <ch...@sap.com>
Committed: Tue Jun 23 13:16:11 2015 +0200
----------------------------------------------------------------------
.../fit/tecsvc/client/ActionImportITCase.java | 4 +-
.../olingo/fit/tecsvc/client/BasicITCase.java | 7 +-
.../tecsvc/client/PrimitiveComplexITCase.java | 3 +-
.../tecsvc/client/SystemQueryOptionITCase.java | 4 +-
.../olingo/fit/v4/AuthBatchTestITCase.java | 4 +-
.../apache/olingo/fit/v4/BatchTestITCase.java | 4 +-
.../olingo/fit/v4/ConformanceTestITCase.java | 17 +-
.../olingo/fit/v4/MediaEntityTestITCase.java | 4 +-
.../api/communication/header/HeaderName.java | 194 -------------------
.../api/communication/header/ODataHeaders.java | 21 --
.../communication/header/ODataPreferences.java | 28 +--
.../api/communication/request/ODataRequest.java | 33 ++--
.../communication/response/ODataResponse.java | 9 -
.../olingo/client/core/ODataClientImpl.java | 10 +-
.../communication/header/ODataHeadersImpl.java | 17 --
.../request/AbstractODataRequest.java | 54 +++---
.../request/AsyncBatchRequestWrapperImpl.java | 8 +-
.../request/AsyncRequestWrapperImpl.java | 29 +--
.../request/batch/ODataBatchRequestImpl.java | 3 +-
.../request/batch/ODataBatchUtilities.java | 10 +-
.../request/batch/ODataChangesetImpl.java | 4 +-
.../retrieve/EdmMetadataRequestImpl.java | 6 -
.../response/AbstractODataResponse.java | 60 +-----
.../batch/ODataBatchResponseManager.java | 12 +-
24 files changed, 107 insertions(+), 438 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d54b0711/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
index f29fbe3..291ae40 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
@@ -33,7 +33,6 @@ import java.util.TimeZone;
import org.apache.olingo.client.api.ODataClient;
import org.apache.olingo.client.api.communication.ODataClientErrorException;
-import org.apache.olingo.client.api.communication.header.HeaderName;
import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest;
import org.apache.olingo.client.api.communication.response.ODataInvokeResponse;
import org.apache.olingo.client.api.domain.ClientCollectionValue;
@@ -45,6 +44,7 @@ import org.apache.olingo.client.api.domain.ClientValue;
import org.apache.olingo.client.core.ODataClientFactory;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.http.HttpHeader;
import org.apache.olingo.commons.api.http.HttpStatusCode;
import org.apache.olingo.fit.AbstractBaseTestITCase;
import org.apache.olingo.fit.tecsvc.TecSvcConst;
@@ -80,7 +80,7 @@ public class ActionImportITCase extends AbstractBaseTestITCase {
request.setPrefer(getClient().newPreferences().returnMinimal());
final ODataInvokeResponse<ClientProperty> response = request.execute();
assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
- assertEquals("return=minimal", response.getHeader(HeaderName.preferenceApplied).iterator().next());
+ assertEquals("return=minimal", response.getHeader(HttpHeader.PREFERENCE_APPLIED).iterator().next());
}
@Test
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d54b0711/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
index 6406241..8e44289 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
@@ -37,7 +37,6 @@ import java.util.List;
import org.apache.olingo.client.api.EdmEnabledODataClient;
import org.apache.olingo.client.api.ODataClient;
import org.apache.olingo.client.api.communication.ODataClientErrorException;
-import org.apache.olingo.client.api.communication.header.HeaderName;
import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest;
import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
@@ -415,7 +414,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
final ODataEntityCreateResponse<ClientEntity> response = request.execute();
assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
- assertEquals("return=minimal", response.getHeader(HeaderName.preferenceApplied).iterator().next());
+ assertEquals("return=minimal", response.getHeader(HttpHeader.PREFERENCE_APPLIED).iterator().next());
assertEquals(SERVICE_URI + "/ESTwoPrim(1)", response.getHeader(HttpHeader.LOCATION).iterator().next());
}
@@ -696,7 +695,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
final ODataEntityUpdateResponse<ClientEntity> response = request.execute();
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
- assertEquals("return=representation", response.getHeader(HeaderName.preferenceApplied).iterator().next());
+ assertEquals("return=representation", response.getHeader(HttpHeader.PREFERENCE_APPLIED).iterator().next());
assertTrue(response.getBody().getProperty("PropertyString").hasNullValue());
assertEquals(34, response.getBody().getProperty("PropertyDecimal").getPrimitiveValue().toValue());
}
@@ -843,7 +842,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
request.setPrefer(getClient().newPreferences().returnMinimal());
final ODataEntityUpdateResponse<ClientEntity> response = request.execute();
assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
- assertEquals("return=minimal", response.getHeader(HeaderName.preferenceApplied).iterator().next());
+ assertEquals("return=minimal", response.getHeader(HttpHeader.PREFERENCE_APPLIED).iterator().next());
final String cookie = response.getHeader(HttpHeader.SET_COOKIE).iterator().next();
final ODataEntityRequest<ClientEntity> entityRequest = client.getRetrieveRequestFactory()
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d54b0711/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/PrimitiveComplexITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/PrimitiveComplexITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/PrimitiveComplexITCase.java
index 02d7708..f6f68cc 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/PrimitiveComplexITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/PrimitiveComplexITCase.java
@@ -33,7 +33,6 @@ import java.util.Iterator;
import org.apache.commons.io.IOUtils;
import org.apache.olingo.client.api.ODataClient;
import org.apache.olingo.client.api.communication.ODataClientErrorException;
-import org.apache.olingo.client.api.communication.header.HeaderName;
import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest;
import org.apache.olingo.client.api.communication.request.cud.ODataPropertyUpdateRequest;
import org.apache.olingo.client.api.communication.request.cud.ODataValueUpdateRequest;
@@ -380,7 +379,7 @@ public class PrimitiveComplexITCase extends AbstractBaseTestITCase {
final ODataValueUpdateResponse response = request.execute();
assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
- assertEquals("return=minimal", response.getHeader(HeaderName.preferenceApplied).iterator().next());
+ assertEquals("return=minimal", response.getHeader(HttpHeader.PREFERENCE_APPLIED).iterator().next());
}
@Test
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d54b0711/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/SystemQueryOptionITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/SystemQueryOptionITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/SystemQueryOptionITCase.java
index 13ca917..7fa83be 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/SystemQueryOptionITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/SystemQueryOptionITCase.java
@@ -25,13 +25,13 @@ import java.net.URI;
import org.apache.olingo.client.api.ODataClient;
import org.apache.olingo.client.api.communication.ODataClientErrorException;
-import org.apache.olingo.client.api.communication.header.HeaderName;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.api.domain.ClientEntity;
import org.apache.olingo.client.api.domain.ClientEntitySet;
import org.apache.olingo.client.core.ODataClientFactory;
import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.http.HttpHeader;
import org.apache.olingo.commons.api.http.HttpStatusCode;
import org.apache.olingo.fit.AbstractBaseTestITCase;
import org.apache.olingo.fit.tecsvc.TecSvcConst;
@@ -268,7 +268,7 @@ public class SystemQueryOptionITCase extends AbstractBaseTestITCase {
request.setPrefer(getClient().newPreferences().maxPageSize(7));
final ODataRetrieveResponse<ClientEntitySet> response = request.execute();
- assertEquals("odata.maxpagesize=7", response.getHeader(HeaderName.preferenceApplied).iterator().next());
+ assertEquals("odata.maxpagesize=7", response.getHeader(HttpHeader.PREFERENCE_APPLIED).iterator().next());
assertEquals(SERVICE_URI + '/' + ES_SERVER_SIDE_PAGING + "?%24skiptoken=1%2A" + 7,
response.getBody().getNext().toASCIIString());
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d54b0711/fit/src/test/java/org/apache/olingo/fit/v4/AuthBatchTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/AuthBatchTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/AuthBatchTestITCase.java
index 47d50c0..f6964b3 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/AuthBatchTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/AuthBatchTestITCase.java
@@ -23,7 +23,6 @@ import static org.junit.Assert.assertEquals;
import java.net.URI;
import org.apache.olingo.client.api.ODataClient;
-import org.apache.olingo.client.api.communication.header.HeaderName;
import org.apache.olingo.client.api.communication.request.batch.BatchManager;
import org.apache.olingo.client.api.communication.request.batch.ODataBatchRequest;
import org.apache.olingo.client.api.communication.request.batch.ODataChangeset;
@@ -40,6 +39,7 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.format.ContentType;
import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.http.HttpHeader;
import org.junit.Test;
public class AuthBatchTestITCase extends AbstractTestITCase {
@@ -71,7 +71,7 @@ public class AuthBatchTestITCase extends AbstractTestITCase {
final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(baseURL);
request.setAccept(ACCEPT.toContentTypeString());
request.addCustomHeader("User-Agent", "Apache Olingo OData Client");
- request.addCustomHeader(HeaderName.acceptCharset, "UTF-8");
+ request.addCustomHeader(HttpHeader.ACCEPT_CHARSET, "UTF-8");
final BatchManager streamManager = request.payloadManager();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d54b0711/fit/src/test/java/org/apache/olingo/fit/v4/BatchTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/BatchTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/BatchTestITCase.java
index 50a6260..26c38f9 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/BatchTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/BatchTestITCase.java
@@ -35,7 +35,6 @@ import java.util.concurrent.TimeUnit;
import org.apache.http.HttpResponse;
import org.apache.olingo.client.api.ODataBatchConstants;
-import org.apache.olingo.client.api.communication.header.HeaderName;
import org.apache.olingo.client.api.communication.request.AsyncBatchRequestWrapper;
import org.apache.olingo.client.api.communication.request.ODataPayloadManager;
import org.apache.olingo.client.api.communication.request.batch.BatchManager;
@@ -68,6 +67,7 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.format.ContentType;
import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.http.HttpHeader;
import org.junit.Test;
public class BatchTestITCase extends AbstractTestITCase {
@@ -570,7 +570,7 @@ public class BatchTestITCase extends AbstractTestITCase {
assertEquals(202, res.getStatusCode());
assertEquals("Accepted", res.getStatusMessage());
- final Collection<String> newMonitorLocation = res.getHeader(HeaderName.location);
+ final Collection<String> newMonitorLocation = res.getHeader(HttpHeader.LOCATION);
if (newMonitorLocation != null && !newMonitorLocation.isEmpty()) {
responseWrapper.forceNextMonitorCheck(URI.create(newMonitorLocation.iterator().next()));
// .... now you can start again with isDone() and getODataResponse().
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d54b0711/fit/src/test/java/org/apache/olingo/fit/v4/ConformanceTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/ConformanceTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/ConformanceTestITCase.java
index 472928f..9579239 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/ConformanceTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/ConformanceTestITCase.java
@@ -28,7 +28,6 @@ import java.net.URI;
import java.util.Calendar;
import java.util.TimeZone;
-import org.apache.olingo.client.api.communication.header.HeaderName;
import org.apache.olingo.client.api.communication.request.AsyncRequestWrapper;
import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest;
import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
@@ -55,6 +54,7 @@ import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.http.HttpHeader;
import org.junit.Test;
/**
@@ -75,8 +75,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
final ODataEntityRequest<ClientEntity> req =
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- assertEquals("4.0", req.getHeader("OData-MaxVersion"));
- assertEquals("4.0", req.getHeader(HeaderName.odataMaxVersion.toString()));
+ assertEquals("4.0", req.getHeader(HttpHeader.ODATA_MAX_VERSION));
assertNotNull(req.execute().getBody());
}
@@ -121,16 +120,12 @@ public class ConformanceTestITCase extends AbstractTestITCase {
req.setFormat(ODataFormat.JSON_FULL_METADATA);
// check for OData-Version
- assertEquals("4.0", req.getHeader("OData-Version"));
- assertEquals("4.0", req.getHeader(HeaderName.odataVersion.toString()));
+ assertEquals("4.0", req.getHeader(HttpHeader.ODATA_VERSION));
// check for Content-Type
assertEquals(
ODataFormat.JSON_FULL_METADATA.getContentType().toContentTypeString(),
- req.getHeader("Content-Type"));
- assertEquals(
- ODataFormat.JSON_FULL_METADATA.getContentType().toContentTypeString(),
- req.getHeader(HeaderName.contentType.toString()));
+ req.getHeader(HttpHeader.CONTENT_TYPE));
assertEquals(
ODataFormat.JSON_FULL_METADATA.getContentType().toContentTypeString(),
req.getContentType());
@@ -158,8 +153,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
final ODataEntityRequest<ClientEntity> req =
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- assertEquals("4.0", req.getHeader("OData-MaxVersion"));
- assertEquals("4.0", req.getHeader(HeaderName.odataMaxVersion.toString()));
+ assertEquals("4.0", req.getHeader(HttpHeader.ODATA_MAX_VERSION));
final ODataRetrieveResponse<ClientEntity> res = req.execute();
final ClientEntity entity = res.getBody();
@@ -411,7 +405,6 @@ public class ConformanceTestITCase extends AbstractTestITCase {
req.setFormat(ODataFormat.JSON);
assertEquals("application/json;odata.metadata=minimal", req.getHeader("Accept"));
- assertEquals("application/json;odata.metadata=minimal", req.getHeader(HeaderName.accept.toString()));
assertEquals("application/json;odata.metadata=minimal", req.getAccept());
final ODataRetrieveResponse<ClientEntity> res = req.execute();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d54b0711/fit/src/test/java/org/apache/olingo/fit/v4/MediaEntityTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/MediaEntityTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/MediaEntityTestITCase.java
index a39e71b..cdc3c12 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/MediaEntityTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/MediaEntityTestITCase.java
@@ -32,7 +32,6 @@ import java.util.UUID;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.olingo.client.api.ODataClient;
-import org.apache.olingo.client.api.communication.header.HeaderName;
import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
import org.apache.olingo.client.api.communication.request.cud.UpdateType;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
@@ -53,6 +52,7 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.http.HttpHeader;
import org.junit.Test;
public class MediaEntityTestITCase extends AbstractTestITCase {
@@ -108,7 +108,7 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
final ODataMediaEntityCreateResponse<ClientEntity> createRes = streamManager.getResponse();
assertEquals(201, createRes.getStatusCode());
- final Collection<String> location = createRes.getHeader(HeaderName.location);
+ final Collection<String> location = createRes.getHeader(HttpHeader.LOCATION);
assertNotNull(location);
final URI createdLocation = URI.create(location.iterator().next());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d54b0711/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
deleted file mode 100644
index 646a8e8..0000000
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/HeaderName.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * 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
- *
- * 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
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.client.api.communication.header;
-
-
-/**
- * Major OData request/response header names.
- */
-public enum HeaderName {
-
- /**
- * The OData protocol uses the Accept request-header field, as specified in [RFC2616].
- */
- accept("Accept"),
- /**
- * As specified in [RFC2616], the client MAY specify the set of accepted character sets with the Accept-Charset
- * header.
- */
- 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"),
- /**
- * The Content-Type header is used as specified in [RFC2616].
- * <br/>
- * OData request/response supports the following types:
- * <ul>
- * <li>application/atom+xml</li>
- * <li>application/atom+xml;type=entry</li>
- * <li>application/atom+xml;type=feed</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>
- * <li>text/xml</li>
- * <li>octet/stream</li>
- * <li>multipart/mixed</li>
- * </ul>
- */
- 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"),
- /**
- * 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"),
- /**
- * 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"),
- /**
- * 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"),
- /**
- * 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"),
- /**
- * Clients SHOULD specify an OData-MaxVersion request header.
- * <br />
- * If specified the service MUST generate a response with an OData-Version less than or equal to the specified
- * OData-MaxVersion.
- * <br />
- * 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"),
-
- /**
- * The OData-Isolation header specifies the isolation of the current request from external changes. The only supported
- * value for this header is snapshot.
- * <br />
- * If the service doesn’t support OData-Isolation:snapshot and this header was specified on the request, the service
- * MUST NOT process the request and MUST respond with 412 Precondition Failed.
- * <br />
- * Snapshot isolation guarantees that all data returned for a request, including multiple requests within a batch or
- * results retrieved across multiple pages, will be consistent as of a single point in time. Only data modifications
- * made within the request (for example, by a data modification request within the same batch) are visible. The effect
- * is as if the request generates a "snapshot" of the committed data as it existed at the start of the request.
- * <br />
- * The OData-Isolation header may be specified on a single or batch request. If it is specified on a batch then the
- * value is applied to all statements within the batch.
- * <br />
- * Next links returned within a snapshot return results within the same snapshot as the initial request; the client is
- * not required to repeat the header on each individual page request.
- * <br />
- * The OData-Isolation header has no effect on links other than the next link. Navigation links, read links, and edit
- * links return the current version of the data.
- * <br />
- * A service returns 410 Gone or 404 Not Found if a consumer tries to follow a next link referring to a snapshot that
- * is no longer available.
- * <br />
- * The syntax of the OData-Isolation header is specified in [OData-ABNF].
- * <br />
- * A service MAY specify the support for OData-Isolation:snapshot using an annotation with term
- * Capabilities.IsolationSupport, see [OData-VocCap].
- */
- 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
- * request), and a server MAY honor the header for HTTP POST, PUT, PATCH, and MERGE requests. A Prefer header with a
- * 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"),
- /**
- * 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"),
-
- /**
- * 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"),
- /**
- * A service must include a
- * <code>Retry-After</code> header in a
- * <code>202 Accepted</code>.
- */
- retryAfter("Retry-After"),
-
- /**
- * This header is a custom HTTP request header.
- * <br/>
- * It is possible to instruct network intermediaries (proxies, firewalls, and so on) inspecting traffic at the
- * application protocol layer (for example, HTTP) to block requests that contain certain HTTP verbs. In practice, GET
- * and POST verbs are rarely blocked (traditional web pages rely heavily on these HTTP methods), while, for a variety
- * of reasons (such as security vulnerabilities in prior protocols), other HTTP methods (PUT, DELETE, and so on) are
- * at times blocked by intermediaries. Additionally, some existing HTTP libraries do not allow creation of requests
- * using verbs other than GET or POST. Therefore, an alternative way of specifying request types which use verbs other
- * than GET and POST is needed to ensure that this document works well in a wide range of environments.
- * <br/>
- * To address this need, the X-HTTP-Method header can be added to a POST request that signals that the server MUST
- * process the request not as a POST, but as if the HTTP verb specified as the value of the header was used as the
- * method on the HTTP request's request line, as specified in [RFC2616] section 5.1. This technique is often referred
- * to as "verb tunneling".
- * <br/>
- * This header is only valid when on POST requests.
- */
- xHttpMethod("X-HTTP-METHOD"),
-
- //TODO: Delete
- dataServiceUrlConventions("DataServiceUrlConventions");
-
- private final String headerName;
-
- private HeaderName(final String headerName) {
- this.headerName = headerName;
- }
-
- @Override
- public String toString() {
- return headerName;
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d54b0711/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/ODataHeaders.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/ODataHeaders.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/ODataHeaders.java
index 484d9a6..fb515d2 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/ODataHeaders.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/ODataHeaders.java
@@ -36,16 +36,6 @@ public interface ODataHeaders {
* @param name name of the header to be retrieved.
* @return header value.
*/
- String getHeader(final HeaderName name);
-
- /**
- * Gets the value of the header identified by the given name.
- * <br/>
- * Please note that header name is case-insensitive.
- *
- * @param name name of the header to be retrieved.
- * @return header value.
- */
String getHeader(final String name);
/**
@@ -67,15 +57,6 @@ public interface ODataHeaders {
ODataHeaders setHeader(String name, String value);
/**
- * Add the specified header.
- *
- * @param name header key.
- * @param value header value.
- * @return the current updated header instance.
- */
- ODataHeaders setHeader(HeaderName name, String value);
-
- /**
* Removes the header identified by the given name.
* <br/>
* Please note that header name is case-insensitive.
@@ -83,8 +64,6 @@ public interface ODataHeaders {
* @param name name of the header to be retrieved.
* @return header name (if found).
*/
- String removeHeader(HeaderName name);
-
String removeHeader(String name);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d54b0711/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 1a659de..be8f4fa 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
@@ -28,7 +28,7 @@ public class ODataPreferences {
/**
* <code>Prefer</code> header, return content.
*
- * @see HeaderName#prefer
+ * @see org.apache.olingo.commons.api.http.HttpHeader#PREFER
*/
public String returnContent() {
return PreferenceNames.returnContent.toString();
@@ -37,14 +37,16 @@ public class ODataPreferences {
/**
* <code>Prefer</code> header, return no content.
*
- * @see HeaderName#prefer
+ * @see org.apache.olingo.commons.api.http.HttpHeader#PREFER
*/
public String returnNoContent() {
return PreferenceNames.returnNoContent.toString();
}
/**
- * @see HeaderName#dataServiceUrlConventions
+ * Gets the value of the non-standard preference that the URL should follow the convention
+ * that keys are formatted as separate segments.
+ * @see org.apache.olingo.commons.api.http.HttpHeader#PREFER
*/
public String keyAsSegment() {
return PreferenceNames.keyAsSegment.toString();
@@ -64,7 +66,7 @@ public class ODataPreferences {
* <br/><br/>
* Supported by OData version 4.0 only.
*
- * @see HeaderName#prefer
+ * @see org.apache.olingo.commons.api.http.HttpHeader#PREFER
* @return preference.
*/
public String allowEntityReferences() {
@@ -127,7 +129,7 @@ public class ODataPreferences {
* <br/><br/>
* Supported by OData version 4.0 only.
*
- * @see HeaderName#prefer
+ * @see org.apache.olingo.commons.api.http.HttpHeader#PREFER
* @return preference.
*/
public String callback(final String url) {
@@ -148,7 +150,7 @@ public class ODataPreferences {
* <br/><br/>
* Supported by OData version 4.0 only.
*
- * @see HeaderName#prefer
+ * @see org.apache.olingo.commons.api.http.HttpHeader#PREFER
* @return preference.
*/
public String continueOnError() {
@@ -195,7 +197,7 @@ public class ODataPreferences {
* <br/><br/>
* Supported by OData version 4.0 only.
*
- * @see HeaderName#prefer
+ * @see org.apache.olingo.commons.api.http.HttpHeader#PREFER
* @return preference.
*/
public String includeAnnotations(final String value) {
@@ -228,7 +230,7 @@ public class ODataPreferences {
* <br/><br/>
* Supported by OData version 4.0 only.
*
- * @see HeaderName#prefer
+ * @see org.apache.olingo.commons.api.http.HttpHeader#PREFER
* @return preference.
*/
public String maxPageSize(final int size) {
@@ -253,7 +255,7 @@ public class ODataPreferences {
* <br/><br/>
* Supported by OData version 4.0 only.
*
- * @see HeaderName#prefer
+ * @see org.apache.olingo.commons.api.http.HttpHeader#PREFER
* @return preference.
*/
public String trackChanges() {
@@ -288,7 +290,7 @@ public class ODataPreferences {
* <br/><br/>
* Supported by OData version 4.0 only.
*
- * @see HeaderName#prefer
+ * @see org.apache.olingo.commons.api.http.HttpHeader#PREFER
* @return preference.
*/
public String respondAsync() {
@@ -308,7 +310,7 @@ public class ODataPreferences {
* <br/><br/>
* Supported by OData version 4.0 only.
*
- * @see HeaderName#prefer
+ * @see org.apache.olingo.commons.api.http.HttpHeader#PREFER
* @return preference.
*/
public String wait(final int value) {
@@ -338,7 +340,7 @@ public class ODataPreferences {
* <br/><br/>
* Supported by OData version 4.0 only.
*
- * @see HeaderName#prefer
+ * @see org.apache.olingo.commons.api.http.HttpHeader#PREFER
* @return preference.
*/
public String returnMinimal() {
@@ -368,7 +370,7 @@ public class ODataPreferences {
* <br/><br/>
* Supported by OData version 4.0 only.
*
- * @see HeaderName#prefer
+ * @see org.apache.olingo.commons.api.http.HttpHeader#PREFER
* @return preference.
*/
public String returnRepresentation() {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d54b0711/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 55831b7..ffc70b7 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
@@ -22,7 +22,6 @@ import java.io.InputStream;
import java.net.URI;
import java.util.Collection;
-import org.apache.olingo.client.api.communication.header.HeaderName;
import org.apache.olingo.commons.api.http.HttpMethod;
/**
@@ -75,7 +74,7 @@ public interface ODataRequest {
*
* @param value header value.
* @return current object
- * @see org.apache.olingo.client.api.communication.header.HeaderName#accept
+ * @see org.apache.olingo.commons.api.http.HttpHeader#ACCEPT
*/
ODataRequest setAccept(final String value);
@@ -83,7 +82,7 @@ public interface ODataRequest {
* Gets <tt>Accept</tt> OData request header.
*
* @return header value.
- * @see org.apache.olingo.client.api.communication.header.HeaderName#accept
+ * @see org.apache.olingo.commons.api.http.HttpHeader#ACCEPT
*/
String getAccept();
@@ -92,7 +91,7 @@ public interface ODataRequest {
*
* @param value header value.
* @return current object
- * @see org.apache.olingo.client.api.communication.header.HeaderName#ifMatch
+ * @see org.apache.olingo.commons.api.http.HttpHeader#IF_MATCH
*/
ODataRequest setIfMatch(final String value);
@@ -100,7 +99,7 @@ public interface ODataRequest {
* Gets <tt>If-Match</tt> OData request header.
*
* @return header value.
- * @see org.apache.olingo.client.api.communication.header.HeaderName#ifMatch
+ * @see org.apache.olingo.commons.api.http.HttpHeader#IF_MATCH
*/
String getIfMatch();
@@ -109,7 +108,7 @@ public interface ODataRequest {
*
* @param value header value.
* @return current object
- * @see org.apache.olingo.client.api.communication.header.HeaderName#ifNoneMatch
+ * @see org.apache.olingo.commons.api.http.HttpHeader#IF_NONE_MATCH
*/
ODataRequest setIfNoneMatch(final String value);
@@ -117,7 +116,7 @@ public interface ODataRequest {
* Gets <tt>If-None-Match</tt> OData request header.
*
* @return header value.
- * @see org.apache.olingo.client.api.communication.header.HeaderName#ifNoneMatch
+ * @see org.apache.olingo.commons.api.http.HttpHeader#IF_NONE_MATCH
*/
String getIfNoneMatch();
@@ -126,7 +125,7 @@ public interface ODataRequest {
*
* @param value header value.
* @return current object
- * @see org.apache.olingo.client.api.communication.header.HeaderName#prefer
+ * @see org.apache.olingo.commons.api.http.HttpHeader#PREFER
*/
ODataRequest setPrefer(final String value);
@@ -134,7 +133,7 @@ public interface ODataRequest {
* Gets <tt>Prefer</tt> OData request header.
*
* @return header value.
- * @see org.apache.olingo.client.api.communication.header.HeaderName#prefer
+ * @see org.apache.olingo.commons.api.http.HttpHeader#PREFER
*/
String getPrefer();
@@ -143,7 +142,7 @@ public interface ODataRequest {
*
* @param value header value.
* @return current object
- * @see org.apache.olingo.client.api.communication.header.HeaderName#contentType
+ * @see org.apache.olingo.commons.api.http.HttpHeader#CONTENT_TYPE
*/
ODataRequest setContentType(final String value);
@@ -151,7 +150,7 @@ public interface ODataRequest {
* Gets <tt>contentType</tt> OData request header.
*
* @return header value.
- * @see org.apache.olingo.client.api.communication.header.HeaderName#contentType
+ * @see org.apache.olingo.commons.api.http.HttpHeader#CONTENT_TYPE
*/
String getContentType();
@@ -160,7 +159,7 @@ public interface ODataRequest {
*
* @param value header value.
* @return current object
- * @see org.apache.olingo.client.api.communication.header.HeaderName#xHttpMethod
+ * @see org.apache.olingo.commons.api.http.HttpHeader#X_HTTP_METHOD
*/
ODataRequest setXHTTPMethod(final String value);
@@ -174,16 +173,6 @@ public interface ODataRequest {
ODataRequest addCustomHeader(final String name, final String value);
/**
- * Adds a custom OData request header. The method fails in case of the header name is not supported by the current
- * working version.
- *
- * @param name header name.
- * @param value header value.
- * @return current object
- */
- ODataRequest addCustomHeader(final HeaderName name, final String value);
-
- /**
* Gets byte array representation of the full request header.
*
* @return full request header.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d54b0711/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataResponse.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataResponse.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataResponse.java
index f2e0765..2bbee88 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataResponse.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataResponse.java
@@ -23,7 +23,6 @@ import java.util.Collection;
import java.util.Map;
import org.apache.http.HttpResponse;
-import org.apache.olingo.client.api.communication.header.HeaderName;
import org.apache.olingo.client.api.communication.request.batch.ODataBatchLineIterator;
/**
@@ -47,14 +46,6 @@ public interface ODataResponse {
Collection<String> getHeader(final String name);
/**
- * Gets header value of the given header.
- *
- * @param name header to be retrieved.
- * @return response header value.
- */
- Collection<String> getHeader(final HeaderName name);
-
- /**
* Gets 'ETag' header value.
*
* @return ETag header value, if provided
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d54b0711/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 c490dae..4ee8924 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
@@ -20,7 +20,6 @@ package org.apache.olingo.client.core;
import org.apache.olingo.client.api.Configuration;
import org.apache.olingo.client.api.ODataClient;
-import org.apache.olingo.client.api.communication.header.HeaderName;
import org.apache.olingo.client.api.communication.header.ODataHeaders;
import org.apache.olingo.client.api.communication.header.ODataPreferences;
import org.apache.olingo.client.api.communication.request.AsyncRequestFactory;
@@ -28,6 +27,7 @@ import org.apache.olingo.client.api.communication.request.batch.BatchRequestFact
import org.apache.olingo.client.api.communication.request.cud.CUDRequestFactory;
import org.apache.olingo.client.api.communication.request.invoke.InvokeRequestFactory;
import org.apache.olingo.client.api.communication.request.retrieve.RetrieveRequestFactory;
+import org.apache.olingo.client.api.domain.ClientObjectFactory;
import org.apache.olingo.client.api.serialization.ClientODataDeserializer;
import org.apache.olingo.client.api.serialization.ODataBinder;
import org.apache.olingo.client.api.serialization.ODataReader;
@@ -42,6 +42,7 @@ import org.apache.olingo.client.core.communication.request.batch.BatchRequestFac
import org.apache.olingo.client.core.communication.request.cud.CUDRequestFactoryImpl;
import org.apache.olingo.client.core.communication.request.invoke.InvokeRequestFactoryImpl;
import org.apache.olingo.client.core.communication.request.retrieve.RetrieveRequestFactoryImpl;
+import org.apache.olingo.client.core.domain.ClientObjectFactoryImpl;
import org.apache.olingo.client.core.serialization.AtomSerializer;
import org.apache.olingo.client.core.serialization.ClientODataDeserializerImpl;
import org.apache.olingo.client.core.serialization.JsonSerializer;
@@ -50,10 +51,9 @@ import org.apache.olingo.client.core.serialization.ODataReaderImpl;
import org.apache.olingo.client.core.serialization.ODataWriterImpl;
import org.apache.olingo.client.core.uri.FilterFactoryImpl;
import org.apache.olingo.client.core.uri.URIBuilderImpl;
-import org.apache.olingo.client.api.domain.ClientObjectFactory;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.client.core.domain.ClientObjectFactoryImpl;
+import org.apache.olingo.commons.api.http.HttpHeader;
public class ODataClientImpl implements ODataClient {
@@ -104,8 +104,8 @@ public class ODataClientImpl implements ODataClient {
@Override
public ODataHeaders newVersionHeaders() {
final ODataHeadersImpl odataHeaders = new ODataHeadersImpl();
- odataHeaders.setHeader(HeaderName.odataMaxVersion, ODataServiceVersion.V40.toString());
- odataHeaders.setHeader(HeaderName.odataVersion, ODataServiceVersion.V40.toString());
+ odataHeaders.setHeader(HttpHeader.ODATA_MAX_VERSION, ODataServiceVersion.V40.toString());
+ odataHeaders.setHeader(HttpHeader.ODATA_VERSION, ODataServiceVersion.V40.toString());
return odataHeaders;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d54b0711/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/header/ODataHeadersImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/header/ODataHeadersImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/header/ODataHeadersImpl.java
index 5a30624..9f79fbb 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/header/ODataHeadersImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/header/ODataHeadersImpl.java
@@ -22,7 +22,6 @@ import java.util.Collection;
import java.util.Map;
import java.util.TreeMap;
-import org.apache.olingo.client.api.communication.header.HeaderName;
import org.apache.olingo.client.api.communication.header.ODataHeaders;
public class ODataHeadersImpl implements ODataHeaders {
@@ -39,27 +38,11 @@ public class ODataHeadersImpl implements ODataHeaders {
}
@Override
- public ODataHeaders setHeader(final HeaderName name, final String value) {
- headers.put(name.toString(), value);
- return this;
- }
-
- @Override
- public String getHeader(final HeaderName name) {
- return headers.get(name.toString());
- }
-
- @Override
public String getHeader(final String name) {
return headers.get(name);
}
@Override
- public String removeHeader(final HeaderName name) {
- return headers.remove(name.toString());
- }
-
- @Override
public String removeHeader(final String name) {
return headers.remove(name);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d54b0711/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 bdfd118..bf198de 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
@@ -34,7 +34,6 @@ import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.client.DecompressingHttpClient;
import org.apache.olingo.client.api.ODataClient;
-import org.apache.olingo.client.api.communication.header.HeaderName;
import org.apache.olingo.client.api.communication.header.ODataHeaders;
import org.apache.olingo.client.api.communication.request.ODataRequest;
import org.apache.olingo.client.api.communication.request.ODataStreamer;
@@ -42,6 +41,7 @@ import org.apache.olingo.client.api.communication.response.ODataResponse;
import org.apache.olingo.client.api.http.HttpClientException;
import org.apache.olingo.commons.api.ODataRuntimeException;
import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.http.HttpHeader;
import org.apache.olingo.commons.api.http.HttpMethod;
/**
@@ -128,37 +128,37 @@ public abstract class AbstractODataRequest extends AbstractRequest implements OD
@Override
public ODataRequest setAccept(final String value) {
- odataHeaders.setHeader(HeaderName.accept, value);
+ odataHeaders.setHeader(HttpHeader.ACCEPT, value);
return this;
}
@Override
public ODataRequest setIfMatch(final String value) {
- odataHeaders.setHeader(HeaderName.ifMatch, value);
+ odataHeaders.setHeader(HttpHeader.IF_MATCH, value);
return this;
}
@Override
public ODataRequest setIfNoneMatch(final String value) {
- odataHeaders.setHeader(HeaderName.ifNoneMatch, value);
+ odataHeaders.setHeader(HttpHeader.IF_NONE_MATCH, value);
return this;
}
@Override
public ODataRequest setPrefer(final String value) {
- odataHeaders.setHeader(HeaderName.prefer, value);
+ odataHeaders.setHeader(HttpHeader.PREFER, value);
return this;
}
@Override
public ODataRequest setXHTTPMethod(final String value) {
- odataHeaders.setHeader(HeaderName.xHttpMethod, value);
+ odataHeaders.setHeader(HttpHeader.X_HTTP_METHOD, value);
return this;
}
@Override
public ODataRequest setContentType(final String value) {
- odataHeaders.setHeader(HeaderName.contentType, value);
+ odataHeaders.setHeader(HttpHeader.CONTENT_TYPE, value);
return this;
}
@@ -169,40 +169,34 @@ public abstract class AbstractODataRequest extends AbstractRequest implements OD
}
@Override
- public ODataRequest addCustomHeader(final HeaderName name, final String value) {
- odataHeaders.setHeader(name, value);
- return this;
- }
-
- @Override
public String getAccept() {
- final String acceptHead = odataHeaders.getHeader(HeaderName.accept);
- return StringUtils.isBlank(acceptHead)
- ? getDefaultFormat().getContentType().toContentTypeString()
- : acceptHead;
+ final String acceptHead = odataHeaders.getHeader(HttpHeader.ACCEPT);
+ return StringUtils.isBlank(acceptHead) ?
+ getDefaultFormat().getContentType().toContentTypeString() :
+ acceptHead;
}
@Override
public String getIfMatch() {
- return odataHeaders.getHeader(HeaderName.ifMatch);
+ return odataHeaders.getHeader(HttpHeader.IF_MATCH);
}
@Override
public String getIfNoneMatch() {
- return odataHeaders.getHeader(HeaderName.ifNoneMatch);
+ return odataHeaders.getHeader(HttpHeader.IF_NONE_MATCH);
}
@Override
public String getPrefer() {
- return odataHeaders.getHeader(HeaderName.prefer);
+ return odataHeaders.getHeader(HttpHeader.PREFER);
}
@Override
public String getContentType() {
- final String contentTypeHead = odataHeaders.getHeader(HeaderName.contentType);
- return StringUtils.isBlank(contentTypeHead)
- ? getDefaultFormat().getContentType().toContentTypeString()
- : contentTypeHead;
+ final String contentTypeHead = odataHeaders.getHeader(HttpHeader.CONTENT_TYPE);
+ return StringUtils.isBlank(contentTypeHead) ?
+ getDefaultFormat().getContentType().toContentTypeString() :
+ contentTypeHead;
}
@Override
@@ -231,10 +225,10 @@ public abstract class AbstractODataRequest extends AbstractRequest implements OD
baos.write(ODataStreamer.CRLF);
// Set Content-Type and Accept headers with default values, if not yet set
- if (StringUtils.isBlank(odataHeaders.getHeader(HeaderName.contentType))) {
+ if (StringUtils.isBlank(odataHeaders.getHeader(HttpHeader.CONTENT_TYPE))) {
setContentType(getContentType());
}
- if (StringUtils.isBlank(odataHeaders.getHeader(HeaderName.accept))) {
+ if (StringUtils.isBlank(odataHeaders.getHeader(HttpHeader.ACCEPT))) {
setAccept(getAccept());
}
@@ -277,18 +271,16 @@ public abstract class AbstractODataRequest extends AbstractRequest implements OD
checkRequest(odataClient, request);
// Set Content-Type and Accept headers with default values, if not yet set
- if (StringUtils.isBlank(odataHeaders.getHeader(HeaderName.contentType))) {
+ if (StringUtils.isBlank(odataHeaders.getHeader(HttpHeader.CONTENT_TYPE))) {
setContentType(getContentType());
}
- if (StringUtils.isBlank(odataHeaders.getHeader(HeaderName.accept))) {
+ if (StringUtils.isBlank(odataHeaders.getHeader(HttpHeader.ACCEPT))) {
setAccept(getAccept());
}
// Add header for KeyAsSegment management
if (odataClient.getConfiguration().isKeyAsSegment()) {
- addCustomHeader(
- HeaderName.dataServiceUrlConventions.toString(),
- odataClient.newPreferences().keyAsSegment());
+ addCustomHeader("DataServiceUrlConventions", odataClient.newPreferences().keyAsSegment());
}
// Add all available headers
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d54b0711/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 d64ea3f..d4821b5 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
@@ -23,7 +23,6 @@ import java.util.Collection;
import org.apache.commons.io.IOUtils;
import org.apache.olingo.client.api.ODataClient;
-import org.apache.olingo.client.api.communication.header.HeaderName;
import org.apache.olingo.client.api.communication.header.ODataPreferences;
import org.apache.olingo.client.api.communication.request.AsyncBatchRequestWrapper;
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
@@ -32,6 +31,7 @@ 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.http.HttpHeader;
public class AsyncBatchRequestWrapperImpl extends AsyncRequestWrapperImpl<ODataBatchResponse>
implements AsyncBatchRequestWrapper {
@@ -91,19 +91,19 @@ public class AsyncBatchRequestWrapperImpl extends AsyncRequestWrapperImpl<ODataB
}
private void retrieveMonitorDetails(final ODataBatchResponse res) {
- Collection<String> headers = res.getHeader(HeaderName.location.toString());
+ Collection<String> headers = res.getHeader(HttpHeader.LOCATION);
if (headers == null || headers.isEmpty()) {
throw new AsyncRequestException("Invalid async request response. Monitor URL not found");
} else {
this.location = URI.create(headers.iterator().next());
}
- headers = res.getHeader(HeaderName.retryAfter.toString());
+ headers = res.getHeader(HttpHeader.RETRY_AFTER);
if (headers != null && !headers.isEmpty()) {
this.retryAfter = Integer.parseInt(headers.iterator().next());
}
- headers = res.getHeader(HeaderName.preferenceApplied.toString());
+ headers = res.getHeader(HttpHeader.PREFERENCE_APPLIED);
if (headers != null && !headers.isEmpty()) {
for (String header : headers) {
if (header.equalsIgnoreCase(new ODataPreferences().respondAsync())) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d54b0711/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 dd8456f..5c8d1e9 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
@@ -32,7 +32,6 @@ import org.apache.http.impl.client.DecompressingHttpClient;
import org.apache.http.util.EntityUtils;
import org.apache.olingo.client.api.ODataClient;
import org.apache.olingo.client.api.communication.ODataClientErrorException;
-import org.apache.olingo.client.api.communication.header.HeaderName;
import org.apache.olingo.client.api.communication.header.ODataPreferences;
import org.apache.olingo.client.api.communication.request.AsyncRequestWrapper;
import org.apache.olingo.client.api.communication.request.ODataRequest;
@@ -41,7 +40,9 @@ 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.http.HttpHeader;
import org.apache.olingo.commons.api.http.HttpMethod;
+import org.apache.olingo.commons.api.http.HttpStatusCode;
public class AsyncRequestWrapperImpl<R extends ODataResponse> extends AbstractRequest
implements AsyncRequestWrapper<R> {
@@ -75,7 +76,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().respondAsync());
+ extendHeader(HttpHeader.PREFER, new ODataPreferences().respondAsync());
this.odataClient = odataClient;
final HttpMethod method = odataRequest.getMethod();
@@ -94,14 +95,13 @@ public class AsyncRequestWrapperImpl<R extends ODataResponse> extends AbstractRe
@Override
public final AsyncRequestWrapper<R> wait(final int waitInSeconds) {
- extendHeader(HeaderName.prefer.toString(), new ODataPreferences().wait(waitInSeconds));
+ extendHeader(HttpHeader.PREFER, new ODataPreferences().wait(waitInSeconds));
return this;
}
@Override
public final AsyncRequestWrapper<R> callback(URI url) {
- extendHeader(HeaderName.prefer.toString(),
- new ODataPreferences().callback(url.toASCIIString()));
+ extendHeader(HttpHeader.PREFER, new ODataPreferences().callback(url.toASCIIString()));
return this;
}
@@ -184,9 +184,9 @@ public class AsyncRequestWrapperImpl<R extends ODataResponse> extends AbstractRe
for (int i = 0; response == null && i < MAX_RETRY; i++) {
res = checkMonitor(location);
- if (res.getStatusLine().getStatusCode() == 202) {
+ if (res.getStatusLine().getStatusCode() == HttpStatusCode.ACCEPTED.getStatusCode()) {
- final Header[] headers = res.getHeaders(HeaderName.retryAfter.toString());
+ final Header[] headers = res.getHeaders(HttpHeader.RETRY_AFTER);
if (ArrayUtils.isNotEmpty(headers)) {
this.retryAfter = Integer.parseInt(headers[0].getValue());
}
@@ -211,27 +211,18 @@ public class AsyncRequestWrapperImpl<R extends ODataResponse> extends AbstractRe
return response;
}
- /**
- * {@inheritDoc}
- */
@Override
public ODataDeleteResponse delete() {
final ODataDeleteRequest deleteRequest = odataClient.getCUDRequestFactory().getDeleteRequest(location);
return deleteRequest.execute();
}
- /**
- * {@inheritDoc}
- */
@Override
public AsyncResponseWrapper<ODataDeleteResponse> asyncDelete() {
return odataClient.getAsyncRequestFactory().<ODataDeleteResponse>getAsyncRequestWrapper(
odataClient.getCUDRequestFactory().getDeleteRequest(location)).execute();
}
- /**
- * {@inheritDoc}
- */
@Override
public AsyncResponseWrapper<R> forceNextMonitorCheck(final URI uri) {
this.location = uri;
@@ -255,7 +246,7 @@ public class AsyncRequestWrapperImpl<R extends ODataResponse> extends AbstractRe
}
private void retrieveMonitorDetails(final HttpResponse res) {
- Header[] headers = res.getHeaders(HeaderName.location.toString());
+ Header[] headers = res.getHeaders(HttpHeader.LOCATION);
if (ArrayUtils.isNotEmpty(headers)) {
this.location = URI.create(headers[0].getValue());
} else {
@@ -263,12 +254,12 @@ public class AsyncRequestWrapperImpl<R extends ODataResponse> extends AbstractRe
"Invalid async request response. Monitor URL '" + headers[0].getValue() + "'");
}
- headers = res.getHeaders(HeaderName.retryAfter.toString());
+ headers = res.getHeaders(HttpHeader.RETRY_AFTER);
if (ArrayUtils.isNotEmpty(headers)) {
this.retryAfter = Integer.parseInt(headers[0].getValue());
}
- headers = res.getHeaders(HeaderName.preferenceApplied.toString());
+ headers = res.getHeaders(HttpHeader.PREFERENCE_APPLIED);
if (ArrayUtils.isNotEmpty(headers)) {
for (Header header : headers) {
if (header.getValue().equalsIgnoreCase(new ODataPreferences().respondAsync())) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d54b0711/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 8893c5e..3b9e621 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
@@ -26,7 +26,6 @@ import java.util.concurrent.TimeUnit;
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.header.ODataPreferences;
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
import org.apache.olingo.client.api.communication.request.batch.BatchManager;
@@ -68,7 +67,7 @@ public class ODataBatchRequestImpl
@Override
protected HttpResponse doExecute() {
if (odataClient.getConfiguration().isContinueOnError()) {
- addCustomHeader(HeaderName.prefer, new ODataPreferences().continueOnError());
+ setPrefer(new ODataPreferences().continueOnError());
}
return super.doExecute();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d54b0711/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataBatchUtilities.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataBatchUtilities.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataBatchUtilities.java
index f746849..bca612f 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataBatchUtilities.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataBatchUtilities.java
@@ -34,11 +34,11 @@ import org.apache.commons.io.IOUtils;
import org.apache.commons.io.LineIterator;
import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.client.api.ODataBatchConstants;
-import org.apache.olingo.client.api.communication.header.HeaderName;
import org.apache.olingo.client.api.communication.request.ODataStreamer;
import org.apache.olingo.client.api.communication.request.batch.ODataBatchLineIterator;
import org.apache.olingo.commons.api.Constants;
import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.commons.api.http.HttpHeader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -48,12 +48,11 @@ import org.slf4j.LoggerFactory;
public class ODataBatchUtilities {
public static enum BatchItemType {
-
NONE,
CHANGESET,
RETRIEVE
-
}
+
/**
* Logger.
*/
@@ -300,8 +299,9 @@ public class ODataBatchUtilities {
final BatchItemType nextItemType;
- final String contentType = headers.containsKey(HeaderName.contentType.toString())
- ? headers.get(HeaderName.contentType.toString()).toString() : StringUtils.EMPTY;
+ final String contentType = headers.containsKey(HttpHeader.CONTENT_TYPE) ?
+ headers.get(HttpHeader.CONTENT_TYPE).toString() :
+ StringUtils.EMPTY;
if (contentType.contains(ContentType.MULTIPART_MIXED.toContentTypeString())) {
nextItemType = BatchItemType.CHANGESET;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d54b0711/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataChangesetImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataChangesetImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataChangesetImpl.java
index ce6155a..51a55ab 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataChangesetImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataChangesetImpl.java
@@ -20,12 +20,12 @@ package org.apache.olingo.client.core.communication.request.batch;
import java.util.UUID;
-import org.apache.olingo.client.api.communication.header.HeaderName;
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
import org.apache.olingo.client.api.communication.request.batch.ODataBatchRequest;
import org.apache.olingo.client.api.communication.request.batch.ODataChangeset;
import org.apache.olingo.client.core.communication.request.AbstractODataRequest;
import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.commons.api.http.HttpHeader;
import org.apache.olingo.commons.api.http.HttpMethod;
/**
@@ -99,7 +99,7 @@ public class ODataChangesetImpl extends AbstractODataBatchRequestItem
}
if (!hasStreamedSomething) {
- stream((HeaderName.contentType.toString() + ": "
+ stream((HttpHeader.CONTENT_TYPE + ": "
+ ContentType.MULTIPART_MIXED + ";boundary=" + boundary).getBytes());
newLine();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d54b0711/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/EdmMetadataRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/EdmMetadataRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/EdmMetadataRequestImpl.java
index ee5e2e7..e3eef12 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/EdmMetadataRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/EdmMetadataRequestImpl.java
@@ -23,7 +23,6 @@ import java.util.Collection;
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.EdmMetadataRequest;
import org.apache.olingo.client.api.communication.request.retrieve.XMLMetadataRequest;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
@@ -112,11 +111,6 @@ class EdmMetadataRequestImpl extends AbstractMetadataRequestImpl<Edm> implements
return xmlMetadataResponse.getHeader(name);
}
- @Override
- public Collection<String> getHeader(final HeaderName name) {
- return xmlMetadataResponse.getHeader(name);
- }
-
public XMLMetadata getXMLMetadata() {
if (metadata == null) {
try {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d54b0711/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/AbstractODataResponse.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/AbstractODataResponse.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/AbstractODataResponse.java
index 210ae7c..d3ca7e4 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/AbstractODataResponse.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/AbstractODataResponse.java
@@ -35,7 +35,6 @@ import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
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.ODataStreamer;
import org.apache.olingo.client.api.communication.request.batch.ODataBatchLineIterator;
import org.apache.olingo.client.api.communication.response.ODataResponse;
@@ -45,6 +44,7 @@ import org.apache.olingo.client.core.communication.request.batch.ODataBatchLineI
import org.apache.olingo.client.core.communication.request.batch.ODataBatchUtilities;
import org.apache.olingo.commons.api.Constants;
import org.apache.olingo.commons.api.ODataRuntimeException;
+import org.apache.olingo.commons.api.http.HttpHeader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -112,76 +112,46 @@ public abstract class AbstractODataResponse implements ODataResponse {
}
}
- /**
- * {@inheritDoc}
- */
@Override
public Collection<String> getHeaderNames() {
return headers.keySet();
}
- /**
- * {@inheritDoc}
- */
@Override
public Collection<String> getHeader(final String name) {
return headers.get(name);
}
- /**
- * {@inheritDoc}
- */
- @Override
- public Collection<String> getHeader(final HeaderName name) {
- return headers.get(name.toString());
- }
-
- /**
- * {@inheritDoc}
- */
@Override
public String getETag() {
- final Collection<String> etag = getHeader(HeaderName.etag);
- return etag == null || etag.isEmpty()
- ? null
- : etag.iterator().next();
+ final Collection<String> etag = getHeader(HttpHeader.ETAG);
+ return etag == null || etag.isEmpty() ? null : etag.iterator().next();
}
- /**
- * {@inheritDoc}
- */
@Override
public String getContentType() {
- final Collection<String> contentTypes = getHeader(HeaderName.contentType);
- return contentTypes == null || contentTypes.isEmpty()
- ? null
- : contentTypes.iterator().next();
+ final Collection<String> contentTypes = getHeader(HttpHeader.CONTENT_TYPE);
+ return contentTypes == null || contentTypes.isEmpty() ? null : contentTypes.iterator().next();
}
- /**
- * {@inheritDoc}
- */
@Override
public int getStatusCode() {
return statusCode;
}
- /**
- * {@inheritDoc}
- */
@Override
public String getStatusMessage() {
return statusMessage;
}
- /**
- * {@inheritDoc}
- */
@Override
public final ODataResponse initFromHttpResponse(final HttpResponse res) {
try {
this.payload = res.getEntity() == null ? null : res.getEntity().getContent();
- } catch (Exception e) {
+ } catch (final IllegalStateException e) {
+ LOG.error("Error retrieving payload", e);
+ throw new ODataRuntimeException(e);
+ } catch (final IOException e) {
LOG.error("Error retrieving payload", e);
throw new ODataRuntimeException(e);
}
@@ -205,9 +175,6 @@ public abstract class AbstractODataResponse implements ODataResponse {
return this;
}
- /**
- * {@inheritDoc}
- */
@Override
public ODataResponse initFromBatch(
final Map.Entry<Integer, String> responseLine,
@@ -229,9 +196,6 @@ public abstract class AbstractODataResponse implements ODataResponse {
return this;
}
- /**
- * {@inheritDoc}
- */
@Override
public ODataResponse initFromEnclosedPart(final InputStream part) {
try {
@@ -275,9 +239,6 @@ public abstract class AbstractODataResponse implements ODataResponse {
}
}
- /**
- * {@inheritDoc }
- */
@Override
public void close() {
odataClient.getConfiguration().getHttpClientFactory().close(httpClient);
@@ -287,9 +248,6 @@ public abstract class AbstractODataResponse implements ODataResponse {
}
}
- /**
- * {@inheritDoc}
- */
@Override
public InputStream getRawResponse() {
if (HttpStatus.SC_NO_CONTENT == getStatusCode()) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d54b0711/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/batch/ODataBatchResponseManager.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/batch/ODataBatchResponseManager.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/batch/ODataBatchResponseManager.java
index f7fbef0..8404076 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/batch/ODataBatchResponseManager.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/batch/ODataBatchResponseManager.java
@@ -26,7 +26,6 @@ import java.util.Map;
import java.util.NoSuchElementException;
import org.apache.commons.io.IOUtils;
-import org.apache.olingo.client.api.communication.header.HeaderName;
import org.apache.olingo.client.api.communication.request.batch.ODataBatchLineIterator;
import org.apache.olingo.client.api.communication.request.batch.ODataBatchResponseItem;
import org.apache.olingo.client.api.communication.response.ODataBatchResponse;
@@ -34,6 +33,7 @@ import org.apache.olingo.client.core.communication.request.batch.ODataBatchLineI
import org.apache.olingo.client.core.communication.request.batch.ODataBatchUtilities;
import org.apache.olingo.client.core.communication.request.batch.ODataChangesetResponseItem;
import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.http.HttpHeader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -96,7 +96,7 @@ public class ODataBatchResponseManager implements Iterator<ODataBatchResponseIte
// search for boundary
batchBoundary = ODataBatchUtilities.getBoundaryFromHeader(
- res.getHeader(HeaderName.contentType));
+ res.getHeader(HttpHeader.CONTENT_TYPE));
LOG.debug("Retrieved batch response bondary '{}'", batchBoundary);
} catch (IOException e) {
LOG.error("Error parsing batch response", e);
@@ -104,17 +104,11 @@ public class ODataBatchResponseManager implements Iterator<ODataBatchResponseIte
}
}
- /**
- * {@inheritDoc }
- */
@Override
public boolean hasNext() {
return (current == null || continueOnError || !current.isBreaking()) && expectedItemsIterator.hasNext();
}
- /**
- * {@inheritDoc }
- */
@Override
public ODataBatchResponseItem next() {
if (current != null) {
@@ -138,7 +132,7 @@ public class ODataBatchResponseManager implements Iterator<ODataBatchResponseIte
current.initFromBatch(
batchLineIterator,
- ODataBatchUtilities.getBoundaryFromHeader(nextItemHeaders.get(HeaderName.contentType.toString())));
+ ODataBatchUtilities.getBoundaryFromHeader(nextItemHeaders.get(HttpHeader.CONTENT_TYPE)));
break;
case RETRIEVE:
[04/12] olingo-odata4 git commit: [OLINGO-704] Small fix TecSvc
Posted by mi...@apache.org.
[OLINGO-704] Small fix TecSvc
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/b3dcaa25
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/b3dcaa25
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/b3dcaa25
Branch: refs/heads/OLINGO-708_AsyncSupportTec
Commit: b3dcaa25b3d485b886f06913e4adc1635e3cd2bf
Parents: b511174
Author: Christian Holzer <c....@sap.com>
Authored: Mon Jun 29 23:54:45 2015 +0200
Committer: Christian Holzer <c....@sap.com>
Committed: Mon Jun 29 23:54:45 2015 +0200
----------------------------------------------------------------------
.../tecsvc/client/EntityReferencesITCase.java | 46 ++++++++++++++++++++
.../processor/TechnicalEntityProcessor.java | 13 +++++-
.../tecsvc/processor/TechnicalProcessor.java | 5 ++-
3 files changed, 61 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b3dcaa25/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/EntityReferencesITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/EntityReferencesITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/EntityReferencesITCase.java
index 3e3377e..7b24bb5 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/EntityReferencesITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/EntityReferencesITCase.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
import java.net.URI;
+import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -37,7 +38,9 @@ import org.apache.olingo.client.api.communication.response.ODataReferenceAddingR
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.api.domain.ClientEntity;
import org.apache.olingo.client.api.domain.ClientEntitySet;
+import org.apache.olingo.client.api.domain.ClientObjectFactory;
import org.apache.olingo.client.api.uri.QueryOption;
+import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.client.core.ODataClientFactory;
import org.apache.olingo.commons.api.format.ContentType;
import org.apache.olingo.commons.api.http.HttpHeader;
@@ -984,6 +987,49 @@ public class EntityReferencesITCase extends AbstractBaseTestITCase {
assertNull(responseGetESTwoKeyNav.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE));
}
+ @Test
+ public void testCreateMissingNavigationProperty() throws Exception {
+ final ODataClient client = getClient();
+ final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendRefSegment().build();
+ final URI ref = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(1).build();
+
+ try {
+ client.getCUDRequestFactory().getReferenceAddingRequest(new URI(SERVICE_URI), uri, ref).execute();
+ } catch (ODataClientErrorException e) {
+ assertEquals(HttpStatusCode.BAD_REQUEST.getStatusCode(), e.getStatusLine().getStatusCode());
+ }
+ }
+
+ @Test
+ public void testUpdateMissingNavigationProperty() throws Exception {
+ final ODataClient client = getClient();
+ final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)
+ .appendKeySegment(1)
+ .appendRefSegment()
+ .build();
+ final URI ref = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(1).build();
+
+ try {
+ client.getCUDRequestFactory().getReferenceSingleChangeRequest(new URI(SERVICE_URI), uri, ref).execute();
+ } catch (ODataClientErrorException e) {
+ assertEquals(HttpStatusCode.BAD_REQUEST.getStatusCode(), e.getStatusLine().getStatusCode());
+ }
+ }
+
+ @Test
+ public void testDeleteMissingNavigationProperty() {
+ final ODataClient client = getClient();
+ final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)
+ .appendRefSegment()
+ .build();
+
+ try {
+ client.getCUDRequestFactory().getDeleteRequest(uri);
+ } catch (ODataClientErrorException e) {
+ assertEquals(HttpStatusCode.BAD_REQUEST.getStatusCode(), e.getStatusLine().getStatusCode());
+ }
+ }
+
private void sendRequest(final URI uri, final int count, final String... expected) {
final ODataClient client = getClient();
final ODataRetrieveResponse<ClientEntitySet> response = client.getRetrieveRequestFactory()
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b3dcaa25/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
index 2904e18..2045704 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
@@ -318,6 +318,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
final Entity entity = readEntity(uriInfo, true);
final UriResourceNavigation navigationProperty = getLastNavigation(uriInfo);
+ ensureNavigationPropertyNotNull(navigationProperty);
dataProvider.createReference(entity, navigationProperty.getProperty(), references.getEntityReferences().get(0),
request.getRawBaseUri());
@@ -338,6 +339,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
final Entity entity = readEntity(uriInfo, true);
final UriResourceNavigation navigationProperty = getLastNavigation(uriInfo);
+ ensureNavigationPropertyNotNull(navigationProperty);
dataProvider.createReference(entity, navigationProperty.getProperty(), references.getEntityReferences().get(0),
request.getRawBaseUri());
@@ -350,7 +352,8 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
final UriResourceNavigation lastNavigation = getLastNavigation(uriInfo);
final IdOption idOption = uriInfo.getIdOption();
-
+
+ ensureNavigationPropertyNotNull(lastNavigation);
if (lastNavigation.isCollection() && idOption == null) {
throw new ODataApplicationException("Id system query option must be provided",
HttpStatusCode.BAD_REQUEST.getStatusCode(),
@@ -537,4 +540,12 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
.suffix(isSingleEntity && entitySet != null ? Suffix.ENTITY : null);
return builder.build();
}
+
+ private void ensureNavigationPropertyNotNull(final UriResourceNavigation navigationProperty)
+ throws ODataApplicationException {
+ if(navigationProperty == null) {
+ throw new ODataApplicationException("Missing navigation segment", HttpStatusCode.BAD_REQUEST.getStatusCode(),
+ Locale.ROOT);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b3dcaa25/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java
index 55c0761..e0dd7dd 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java
@@ -213,8 +213,9 @@ public abstract class TechnicalProcessor implements Processor {
&& resourcePaths.get(navigationCount) instanceof UriResourceNavigation) {
navigationCount++;
}
-
- return (UriResourceNavigation) resourcePaths.get(--navigationCount);
+
+ final UriResource lastSegment = resourcePaths.get(--navigationCount);
+ return (lastSegment instanceof UriResourceNavigation) ? (UriResourceNavigation) lastSegment : null;
}
private void blockTypeFilters(final UriResource uriResource) throws ODataApplicationException {
[05/12] olingo-odata4 git commit: [OLINGO-718] ETag removed from json
reference payload
Posted by mi...@apache.org.
[OLINGO-718] ETag removed from json reference payload
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/aeb258b5
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/aeb258b5
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/aeb258b5
Branch: refs/heads/OLINGO-708_AsyncSupportTec
Commit: aeb258b5abbd3b871c375d8d850decd3db4c8ddf
Parents: b3dcaa2
Author: Christian Holzer <c....@sap.com>
Authored: Tue Jun 30 08:55:20 2015 +0200
Committer: Christian Holzer <c....@sap.com>
Committed: Tue Jun 30 08:55:20 2015 +0200
----------------------------------------------------------------------
.../olingo/server/core/serializer/json/ODataJsonSerializer.java | 2 --
.../server/core/serializer/json/ODataJsonSerializerTest.java | 4 ----
2 files changed, 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/aeb258b5/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
index e9d4858..a3b7805 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
@@ -656,7 +656,6 @@ public class ODataJsonSerializer implements ODataSerializer {
json.writeStartObject();
writeContextURL(contextURL, json);
- writeMetadataETag(metadata, json);
json.writeStringField(Constants.JSON_ID, uriHelper.buildCanonicalURL(edmEntitySet, entity));
json.writeEndObject();
@@ -681,7 +680,6 @@ public class ODataJsonSerializer implements ODataSerializer {
json.writeStartObject();
writeContextURL(contextURL, json);
- writeMetadataETag(metadata, json);
if (options != null && options.getCount() != null && options.getCount().getValue()) {
writeCount(entityCollection, json);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/aeb258b5/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
index 0b398f4..3856339 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
@@ -793,7 +793,6 @@ public class ODataJsonSerializerTest {
final String resultString = IOUtils.toString(serializerResult.getContent());
Assert.assertEquals("{\"@odata.context\":\"$metadata#$ref\","
- + "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\","
+ "\"@odata.id\":\"ESAllPrim(32767)\"}",
resultString);
}
@@ -822,7 +821,6 @@ public class ODataJsonSerializerTest {
final String resultString = IOUtils.toString(serializerResult.getContent());
Assert.assertEquals("{\"@odata.context\":\"$metadata#Collection($ref)\","
- + "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\","
+ "\"value\":[{\"@odata.id\":\"ESAllPrim(32767)\"},"
+ "{\"@odata.id\":\"ESAllPrim(-32768)\"},"
+ "{\"@odata.id\":\"ESAllPrim(0)\"}]}",
@@ -843,7 +841,6 @@ public class ODataJsonSerializerTest {
final String resultString = IOUtils.toString(serializerResult.getContent());
Assert.assertEquals("{\"@odata.context\":\"$metadata#Collection($ref)\","
- + "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\","
+ "\"value\":[]}", resultString);
}
@@ -1046,7 +1043,6 @@ public class ODataJsonSerializerTest {
Assert.assertThat(resultString, CoreMatchers.startsWith("{"
+ "\"@odata.context\":\"$metadata#Collection($ref)\","
- + "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\","
+ "\"@odata.count\":\"3\",\"value\":["));
Assert.assertThat(resultString, CoreMatchers.endsWith("],"
+ "\"@odata.nextLink\":\"/next\"}"));
[12/12] olingo-odata4 git commit: [OLINGO-708] Merge branch 'master'
into OLINGO-708_AsyncSupportTec
Posted by mi...@apache.org.
[OLINGO-708] Merge branch 'master' into OLINGO-708_AsyncSupportTec
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/1476b034
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/1476b034
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/1476b034
Branch: refs/heads/OLINGO-708_AsyncSupportTec
Commit: 1476b034b5501121fc097de7b79090c6755326a3
Parents: 2080f23 3a103d5
Author: mibo <mi...@apache.org>
Authored: Wed Jul 8 10:03:43 2015 +0200
Committer: mibo <mi...@apache.org>
Committed: Wed Jul 8 10:14:15 2015 +0200
----------------------------------------------------------------------
ext/karaf/karaf-fit/pom.xml | 2 +-
.../osgi/itests/OlingoOSGiTestSupport.java | 2 +-
.../fit/tecsvc/client/ActionImportITCase.java | 70 +-
.../fit/tecsvc/client/AsyncSupportITCase.java | 156 +++-
.../BasicHttpExceptionHandlingITCase.java | 4 +-
.../olingo/fit/tecsvc/client/BasicITCase.java | 21 +-
.../fit/tecsvc/client/BatchClientITCase.java | 96 +-
.../tecsvc/client/EdmEnabledClientITCase.java | 63 --
.../tecsvc/client/EntityReferencesITCase.java | 43 +
.../fit/tecsvc/client/ExpandSelectITCase.java | 12 +
.../fit/tecsvc/client/FunctionImportITCase.java | 76 ++
.../tecsvc/client/PrimitiveComplexITCase.java | 3 +-
.../tecsvc/client/SystemQueryOptionITCase.java | 4 +-
.../fit/tecsvc/http/BasicBatchITCase.java | 15 +-
.../olingo/fit/tecsvc/http/BasicHttpITCase.java | 89 +-
.../fit/tecsvc/http/EntityReferenceITCase.java | 54 +-
.../olingo/fit/tecsvc/http/PingITCase.java | 12 +-
.../olingo/fit/v4/AuthBatchTestITCase.java | 4 +-
.../apache/olingo/fit/v4/BatchTestITCase.java | 20 +-
.../olingo/fit/v4/ConformanceTestITCase.java | 15 +-
.../olingo/fit/v4/EntityRetrieveTestITCase.java | 3 +-
.../olingo/fit/v4/MediaEntityTestITCase.java | 4 +-
.../api/communication/header/HeaderName.java | 194 ----
.../api/communication/header/ODataHeaders.java | 21 -
.../communication/header/ODataPreferences.java | 28 +-
.../api/communication/request/ODataRequest.java | 33 +-
.../communication/response/ODataResponse.java | 9 -
.../api/domain/ClientEntitySetIterator.java | 14 +-
.../client/api/domain/ClientPrimitiveValue.java | 2 +
.../olingo/client/core/ODataClientImpl.java | 18 +-
.../communication/header/ODataHeadersImpl.java | 17 -
.../request/AbstractODataRequest.java | 54 +-
.../request/AsyncBatchRequestWrapperImpl.java | 8 +-
.../request/AsyncRequestWrapperImpl.java | 29 +-
.../request/batch/ODataBatchRequestImpl.java | 3 +-
.../request/batch/ODataBatchUtilities.java | 10 +-
.../request/batch/ODataChangesetImpl.java | 4 +-
.../invoke/AbstractODataInvokeRequest.java | 7 +-
.../retrieve/EdmMetadataRequestImpl.java | 6 -
.../response/AbstractODataResponse.java | 60 +-
.../batch/ODataBatchResponseManager.java | 12 +-
.../core/domain/ClientPrimitiveValueImpl.java | 5 +
.../ClientODataDeserializerImpl.java | 11 +-
.../apache/olingo/client/core/AbstractTest.java | 5 +-
.../olingo/client/core/v4/EntityTest.java | 3 +-
.../olingo/commons/api/format/AcceptType.java | 26 +-
.../olingo/commons/api/format/ContentType.java | 85 +-
.../olingo/commons/api/format/TypeUtil.java | 36 +-
.../olingo/commons/api/http/HttpHeader.java | 20 +-
.../commons/api/format/ContentTypeTest.java | 1 -
.../olingo/server/core/uri/antlr/UriLexer.g4 | 16 +-
.../olingo/server/core/uri/antlr/UriParser.g4 | 2 +-
.../json/ODataJsonDeserializer.java | 3 +-
.../serializer/json/ODataJsonSerializer.java | 5 +-
.../core/uri/parser/UriParseTreeVisitor.java | 3 +-
.../tecsvc/async/TechnicalAsyncService.java | 13 +-
.../olingo/server/tecsvc/data/ActionData.java | 59 +-
.../olingo/server/tecsvc/data/DataCreator.java | 903 +++++++++++--------
.../olingo/server/tecsvc/data/DataProvider.java | 22 +-
.../olingo/server/tecsvc/data/FunctionData.java | 82 +-
.../processor/TechnicalActionProcessor.java | 9 +-
.../processor/TechnicalEntityProcessor.java | 39 +-
.../tecsvc/processor/TechnicalProcessor.java | 9 +-
.../tecsvc/provider/ContainerProvider.java | 12 +-
.../tecsvc/provider/FunctionProvider.java | 20 +-
.../server/tecsvc/provider/SchemaProvider.java | 4 +-
.../server/tecsvc/data/DataProviderTest.java | 6 +-
.../olingo/server/core/ODataHandlerTest.java | 4 +-
...ataJsonDeserializerActionParametersTest.java | 18 +-
.../json/ODataJsonSerializerTest.java | 13 +-
.../core/uri/antlr/TestFullResourcePath.java | 26 +-
.../olingo/server/core/uri/antlr/TestLexer.java | 35 +-
.../core/uri/antlr/TestUriParserImpl.java | 6 +-
pom.xml | 10 +-
samples/client/pom.xml | 2 +-
75 files changed, 1507 insertions(+), 1303 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1476b034/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AsyncSupportITCase.java
----------------------------------------------------------------------
diff --cc fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AsyncSupportITCase.java
index db7dc5c,0000000..fb0cfd1
mode 100644,000000..100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AsyncSupportITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AsyncSupportITCase.java
@@@ -1,97 -1,0 +1,245 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * 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
+ *
+ * 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
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.fit.tecsvc.client;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
++import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
++import static org.junit.Assert.fail;
+
+import java.net.URI;
++import java.util.List;
+import java.util.concurrent.TimeUnit;
+
++import junit.framework.Assert;
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.communication.request.ODataRequest;
++import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
+import org.apache.olingo.client.api.communication.response.AsyncResponseWrapper;
++import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
+import org.apache.olingo.client.api.communication.response.ODataResponse;
+import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
+import org.apache.olingo.client.api.domain.ClientEntity;
++import org.apache.olingo.client.api.domain.ClientEntitySet;
++import org.apache.olingo.client.api.domain.ClientObjectFactory;
++import org.apache.olingo.client.api.domain.ClientProperty;
++import org.apache.olingo.client.api.domain.ClientValue;
+import org.apache.olingo.client.core.ODataClientFactory;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.ResWrap;
++import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.format.ContentType;
++import org.apache.olingo.commons.api.http.HttpHeader;
++import org.apache.olingo.commons.api.http.HttpStatusCode;
+import org.apache.olingo.fit.AbstractBaseTestITCase;
+import org.apache.olingo.fit.tecsvc.TecSvcConst;
+import org.apache.olingo.server.tecsvc.async.TechnicalAsyncService;
+import org.junit.Test;
+
+public final class AsyncSupportITCase extends AbstractBaseTestITCase {
+ private static final String ES_ALL_PRIM = "ESAllPrim";
+ private static final String SERVICE_URI = TecSvcConst.BASE_URI;
++ public static final int SLEEP_TIMEOUT_IN_MS = 100;
+
+ @Test
- public void testSimple() throws Exception {
++ public void testReadEntity() throws Exception {
+ ODataClient client = getClient();
+ URI uri = client.newURIBuilder(SERVICE_URI)
+ .appendEntitySetSegment(ES_ALL_PRIM)
+ .appendKeySegment(32767).build();
+
+ //
+ final ODataRetrieveResponse<ClientEntity> response = getClient().getRetrieveRequestFactory()
+ .getEntityRequest(uri).execute();
+ assertEquals(32767, response.getBody().getProperty("PropertyInt16").getPrimitiveValue().toValue());
+ assertEquals(200, response.getStatusCode());
+
+ // first async request
++
+ ODataRequest re1 = getClient().getRetrieveRequestFactory()
+ .getEntityRequest(uri)
- .addCustomHeader("Prefer", "respond-async, " + TechnicalAsyncService.TEC_ASYNC_SLEEP + "=1");
++ .addCustomHeader(HttpHeader.PREFER, "respond-async; " + TechnicalAsyncService.TEC_ASYNC_SLEEP + "=1");
+ AsyncResponseWrapper<ODataResponse> first = client.getAsyncRequestFactory().getAsyncRequestWrapper(re1).execute();
+
+ assertTrue(first.isPreferenceApplied());
+
+ // second async request
+ ODataRequest re2 = getClient().getRetrieveRequestFactory()
+ .getEntityRequest(uri)
- .addCustomHeader("Prefer", "respond-async, " + TechnicalAsyncService.TEC_ASYNC_SLEEP + "=1");
++ .addCustomHeader(HttpHeader.PREFER, "respond-async; " + TechnicalAsyncService.TEC_ASYNC_SLEEP + "=1");
+ AsyncResponseWrapper<ODataResponse> second = client.getAsyncRequestFactory().getAsyncRequestWrapper(re2).execute();
+ assertTrue(second.isPreferenceApplied());
+
+ // get result of first async request
+ assertFalse(first.isDone());
+
- TimeUnit.SECONDS.sleep(2);
++ waitTillDone(first, 2);
+ assertTrue(first.isDone());
+
+ assertNotNull(first.getODataResponse());
+ ODataResponse firstResponse = first.getODataResponse();
+ assertEquals(200, firstResponse.getStatusCode());
+ ResWrap<Entity> entity = getClient().getDeserializer(ContentType.APPLICATION_JSON)
+ .toEntity(firstResponse.getRawResponse());
+ assertEquals(32767, entity.getPayload().getProperty("PropertyInt16").asPrimitive());
+ assertEquals("First Resource - positive values", entity.getPayload().getProperty("PropertyString").asPrimitive());
+ }
+
++ @Test
++ public void testReadEntitySet() throws Exception {
++ ODataClient client = getClient();
++ URI uri = client.newURIBuilder(SERVICE_URI)
++ .appendEntitySetSegment(ES_ALL_PRIM)
++ .build();
++
++ //
++ final ODataRetrieveResponse<ClientEntitySet> response = getClient().getRetrieveRequestFactory()
++ .getEntitySetRequest(uri).execute();
++ assertEquals(200, response.getStatusCode());
++ ClientEntitySet responseBody = response.getBody();
++ assertEquals(3, responseBody.getEntities().size());
++ checkEntityAvailableWith(responseBody, "PropertyInt16", 32767);
++
++ // first async request
++ ODataRequest re1 = getClient().getRetrieveRequestFactory()
++ .getEntitySetRequest(uri)
++ .addCustomHeader(HttpHeader.PREFER, "respond-async; " + TechnicalAsyncService.TEC_ASYNC_SLEEP + "=1");
++ AsyncResponseWrapper<ODataResponse> first = client.getAsyncRequestFactory().getAsyncRequestWrapper(re1).execute();
++
++ assertTrue(first.isPreferenceApplied());
++
++ // second async request
++ ODataRequest re2 = getClient().getRetrieveRequestFactory()
++ .getEntitySetRequest(uri)
++ .addCustomHeader(HttpHeader.PREFER, "respond-async; " + TechnicalAsyncService.TEC_ASYNC_SLEEP + "=1");
++ AsyncResponseWrapper<ODataResponse> second = client.getAsyncRequestFactory().getAsyncRequestWrapper(re2).execute();
++ assertTrue(second.isPreferenceApplied());
++
++ // get result of first async request
++ assertFalse(first.isDone());
++
++ waitTillDone(first, 2);
++ assertTrue(first.isDone());
++
++ assertNotNull(first.getODataResponse());
++ ODataResponse firstResponse = first.getODataResponse();
++ assertEquals(200, firstResponse.getStatusCode());
++ ResWrap<Entity> entity = getClient().getDeserializer(ContentType.APPLICATION_JSON)
++ .toEntity(firstResponse.getRawResponse());
++ assertEquals(32767, entity.getPayload().getProperty("PropertyInt16").asPrimitive());
++ assertEquals("First Resource - positive values", entity.getPayload().getProperty("PropertyString").asPrimitive());
++ }
++
++ private void checkEntityAvailableWith(ClientEntitySet entitySet, String property, Object value) {
++ List<ClientEntity> entities = entitySet.getEntities();
++ for (ClientEntity entity : entities) {
++ ClientProperty ep = entity.getProperty("PropertyInt16");
++ if(ep != null) {
++ assertEquals(value, ep.getPrimitiveValue().toValue());
++ return;
++ }
++ }
++ fail("Entity with property '" + property +
++ "' and value '" + value + "' not found in entitySet '" + entitySet + "'");
++ }
++
++ private static final String NAV_PROPERTY_ET_TWO_PRIM_ONE = "NavPropertyETTwoPrimOne";
++
++ @Test
++ public void testCreateEntity() throws Exception {
++ ODataClient client = getClient();
++ URI uri = client.newURIBuilder(SERVICE_URI)
++ .appendEntitySetSegment(ES_ALL_PRIM).build();
++
++ //
++ final ClientObjectFactory factory = client.getObjectFactory();
++ ClientEntity newEntity = factory.newEntity(new FullQualifiedName("olingo.odata.test1", "ETAllPrim"));
++ newEntity.getProperties().add(factory.newPrimitiveProperty("PropertyInt64",
++ factory.newPrimitiveValueBuilder().buildInt32(42)));
++ newEntity.addLink(factory.newEntityNavigationLink(NAV_PROPERTY_ET_TWO_PRIM_ONE,
++ client.newURIBuilder(SERVICE_URI)
++ .appendEntitySetSegment("ESTwoPrim")
++ .appendKeySegment(32766)
++ .build()));
++
++ final ODataEntityCreateRequest<ClientEntity> createRequest =
++ client.getCUDRequestFactory().getEntityCreateRequest(uri, newEntity);
++ assertNotNull(createRequest);
++ final ODataEntityCreateResponse<ClientEntity> createResponse = createRequest.execute();
++
++ assertEquals(HttpStatusCode.CREATED.getStatusCode(), createResponse.getStatusCode());
++ assertEquals(SERVICE_URI + "/ESAllPrim(1)", createResponse.getHeader(HttpHeader.LOCATION).iterator().next());
++ final ClientEntity createdEntity = createResponse.getBody();
++ assertNotNull(createdEntity);
++ final ClientProperty property1 = createdEntity.getProperty("PropertyInt64");
++ assertNotNull(property1);
++ assertEquals(42, property1.getPrimitiveValue().toValue());
++ final ClientProperty property2 = createdEntity.getProperty("PropertyDecimal");
++ assertNotNull(property2);
++ assertNull(property2.getPrimitiveValue()); //
++
++
++// // first async request
++// ODataRequest re1 = getClient().getRetrieveRequestFactory()
++// .getEntityRequest(uri)
++// .addCustomHeader(HttpHeader.PREFER, "respond-async; " + TechnicalAsyncService.TEC_ASYNC_SLEEP + "=1");
++// AsyncResponseWrapper<ODataResponse> first = client.getAsyncRequestFactory().getAsyncRequestWrapper(re1).execute();
++//
++// assertTrue(first.isPreferenceApplied());
++//
++// // second async request
++// ODataRequest re2 = getClient().getRetrieveRequestFactory()
++// .getEntityRequest(uri)
++// .addCustomHeader(HttpHeader.PREFER, "respond-async; " + TechnicalAsyncService.TEC_ASYNC_SLEEP + "=1");
++// AsyncResponseWrapper<ODataResponse> second = client.getAsyncRequestFactory().getAsyncRequestWrapper(re2).execute();
++// assertTrue(second.isPreferenceApplied());
++//
++// // get result of first async request
++// assertFalse(first.isDone());
++//
++// waitTillDone(first, 2);
++// assertTrue(first.isDone());
++//
++// assertNotNull(first.getODataResponse());
++// ODataResponse firstResponse = first.getODataResponse();
++// assertEquals(200, firstResponse.getStatusCode());
++// ResWrap<Entity> entity = getClient().getDeserializer(ContentType.APPLICATION_JSON)
++// .toEntity(firstResponse.getRawResponse());
++// assertEquals(32767, entity.getPayload().getProperty("PropertyInt16").asPrimitive());
++// assertEquals("First Resource - positive values", entity.getPayload().getProperty("PropertyString").asPrimitive());
++ }
++
++
++ private void waitTillDone(AsyncResponseWrapper async, int maxWaitInSeconds) throws InterruptedException {
++ int waitCounter = maxWaitInSeconds * 1000;
++ while(!async.isDone() && waitCounter > 0) {
++ TimeUnit.MILLISECONDS.sleep(SLEEP_TIMEOUT_IN_MS);
++ waitCounter -= SLEEP_TIMEOUT_IN_MS;
++ }
++ }
++
+ @Override
+ protected ODataClient getClient() {
+ ODataClient odata = ODataClientFactory.getClient();
+ odata.getConfiguration().setDefaultPubFormat(ContentType.JSON);
+ return odata;
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1476b034/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/async/TechnicalAsyncService.java
----------------------------------------------------------------------
diff --cc lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/async/TechnicalAsyncService.java
index 2b752f0,0000000..6a1cede
mode 100644,000000..100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/async/TechnicalAsyncService.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/async/TechnicalAsyncService.java
@@@ -1,250 -1,0 +1,259 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * 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
+ *
+ * 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
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.server.tecsvc.async;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.olingo.commons.api.ODataRuntimeException;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.commons.api.http.HttpHeader;
+import org.apache.olingo.commons.api.http.HttpStatusCode;
+import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.ODataApplicationException;
+import org.apache.olingo.server.api.ODataLibraryException;
+import org.apache.olingo.server.api.ODataRequest;
+import org.apache.olingo.server.api.ODataResponse;
+import org.apache.olingo.server.api.processor.Processor;
+import org.apache.olingo.server.api.serializer.SerializerException;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class TechnicalAsyncService {
+
+ public static final String TEC_ASYNC_SLEEP = "tec.sleep";
+
+ private static final Map<String, AsyncRunner> LOCATION_2_ASYNC_RUNNER =
+ Collections.synchronizedMap(new HashMap<String, AsyncRunner>());
+ private static final ExecutorService ASYNC_REQUEST_EXECUTOR = Executors.newFixedThreadPool(10);
+ private static final AtomicInteger ID_GENERATOR = new AtomicInteger();
+ public static final String STATUS_MONITOR_TOKEN = "status";
+
+
-
-
+ public <T extends Processor> AsyncProcessor<T> register(T processor, Class<T> processorInterface) {
+ return new AsyncProcessor<T>(processor, processorInterface, this);
+ }
+
++ public static void updateHeader(ODataResponse response, HttpStatusCode status, String location) {
++ response.setStatusCode(status.getStatusCode());
++ response.setHeader(HttpHeader.LOCATION, location);
++ response.setHeader(HttpHeader.PREFERENCE_APPLIED, "respond-async");
++
++ }
++
++ public static void acceptedResponse(ODataResponse response, String location) {
++ updateHeader(response, HttpStatusCode.ACCEPTED, location);
++ }
++
+
+ private static final class AsyncProcessorHolder {
+ private static final TechnicalAsyncService INSTANCE = new TechnicalAsyncService();
+ }
+
+ public static TechnicalAsyncService getInstance() {
+ return AsyncProcessorHolder.INSTANCE;
+ }
+
+ public void shutdownThreadPool() {
+ ASYNC_REQUEST_EXECUTOR.shutdown();
+ }
+
+ public boolean isStatusMonitorResource(HttpServletRequest request) {
+ return request.getRequestURL() != null && request.getRequestURL().toString().contains(STATUS_MONITOR_TOKEN);
+ }
+
+ String processAsynchronous(AsyncProcessor dispatchedProcessor)
+ throws ODataApplicationException, ODataLibraryException {
+ // use executor thread pool
+ String location = createNewAsyncLocation(dispatchedProcessor.getRequest());
+ dispatchedProcessor.setLocation(location);
+ AsyncRunner run = new AsyncRunner(dispatchedProcessor);
+ LOCATION_2_ASYNC_RUNNER.put(location, run);
+ ASYNC_REQUEST_EXECUTOR.execute(run);
+ //
+ return location;
+ }
+
+ public void handle(HttpServletRequest request, HttpServletResponse response) throws SerializerException, IOException {
+ String location = getAsyncLocation(request);
+ AsyncRunner runner = LOCATION_2_ASYNC_RUNNER.get(location);
+
+ if(runner == null) {
+ response.setStatus(HttpStatusCode.NOT_FOUND.getStatusCode());
+ } else {
+ if(runner.isFinished()) {
+ ODataResponse wrapResult = runner.getDispatched().getProcessResponse();
+ wrapToAsyncHttpResponse(wrapResult, response);
+ LOCATION_2_ASYNC_RUNNER.remove(location);
+ } else {
+ response.setStatus(HttpStatusCode.ACCEPTED.getStatusCode());
+ response.setHeader(HttpHeader.LOCATION, location);
+ String content = "In progress for async location = " + location;
+ writeToResponse(response, content);
+ }
+ }
+ }
+
+ private static void writeToResponse(HttpServletResponse response, InputStream input) throws IOException {
+ copy(input, response.getOutputStream());
+ }
+
+ private void writeToResponse(HttpServletResponse response, String content) {
+ writeToResponse(response, content.getBytes());
+ }
+
+ private static void writeToResponse(HttpServletResponse response, byte[] content) {
+ OutputStream output = null;
+ try {
+ output = response.getOutputStream();
+ output.write(content);
+ } catch (IOException e) {
+ throw new ODataRuntimeException(e);
+ } finally {
+ closeStream(output);
+ }
+ }
+
+ static void wrapToAsyncHttpResponse(final ODataResponse odResponse, final HttpServletResponse response)
+ throws SerializerException, IOException {
+ OData odata = OData.newInstance();
+ InputStream odResponseStream = odata.createFixedFormatSerializer().asyncResponse(odResponse);
+
+ response.setHeader(HttpHeader.CONTENT_TYPE, ContentType.APPLICATION_HTTP.toContentTypeString());
+ response.setHeader(HttpHeader.CONTENT_ENCODING, "binary");
+ response.setStatus(HttpStatusCode.OK.getStatusCode());
+
+ writeToResponse(response, odResponseStream);
+ }
+
+ static void writeHttpResponse(final ODataResponse odResponse, final HttpServletResponse response) throws IOException {
+ response.setStatus(odResponse.getStatusCode());
+
+ for (Map.Entry<String, String> entry : odResponse.getHeaders().entrySet()) {
+ response.setHeader(entry.getKey(), entry.getValue());
+ }
+
+ copy(odResponse.getContent(), response.getOutputStream());
+ }
+
+ static void copy(final InputStream input, final OutputStream output) {
+ if(output == null || input == null) {
+ return;
+ }
+
+ try {
+ byte[] buffer = new byte[1024];
+ int n;
+ while (-1 != (n = input.read(buffer))) {
+ output.write(buffer, 0, n);
+ }
+ } catch (IOException e) {
+ throw new ODataRuntimeException(e);
+ } finally {
+ closeStream(output);
+ closeStream(input);
+ }
+ }
+
+
+ private static void closeStream(final Closeable closeable) {
+ if (closeable != null) {
+ try {
+ closeable.close();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+
+ private String createNewAsyncLocation(ODataRequest request) {
+ int pos = request.getRawBaseUri().lastIndexOf("/") + 1;
+ return request.getRawBaseUri().substring(0, pos) + STATUS_MONITOR_TOKEN + "/" + ID_GENERATOR.incrementAndGet();
+ }
+
+ private String getAsyncLocation(HttpServletRequest request) {
+ return request.getRequestURL().toString();
+ }
+
+ private static class AsyncRunner implements Runnable {
+ private final AsyncProcessor dispatched;
+ private int defaultSleepTimeInSeconds = 0;
+ private Exception exception;
+ boolean finished = false;
+
+ public AsyncRunner(AsyncProcessor wrap) {
+ this(wrap, 0);
+ }
+
+ public AsyncRunner(AsyncProcessor wrap, int defaultSleepTimeInSeconds) {
+ this.dispatched = wrap;
+ if(defaultSleepTimeInSeconds > 0) {
+ this.defaultSleepTimeInSeconds = defaultSleepTimeInSeconds;
+ }
+ }
+
+ @Override
+ public void run() {
+ try {
+ int sleep = getSleepTime(dispatched);
+ TimeUnit.SECONDS.sleep(sleep);
+ dispatched.process();
+ } catch (Exception e) {
+ exception = e;
+ }
+ finished = true;
+ }
+
+ private int getSleepTime(AsyncProcessor wrap) {
+ String preferHeader = wrap.getPreferHeader();
+ Matcher matcher = Pattern.compile("(" + TEC_ASYNC_SLEEP +
+ "=)(\\d*)").matcher(preferHeader);
+ if (matcher.find()) {
+ String waitTimeAsString = matcher.group(2);
+ return Integer.parseInt(waitTimeAsString);
+ }
+ return defaultSleepTimeInSeconds;
+ }
+
+ public Exception getException() {
+ return exception;
+ }
+
+ public boolean isFinished() {
+ return finished;
+ }
+
+ public AsyncProcessor getDispatched() {
+ return dispatched;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1476b034/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
----------------------------------------------------------------------
diff --cc lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
index 60d7538,2045704..fc37b40
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
@@@ -357,8 -339,9 +360,9 @@@ public class TechnicalEntityProcessor e
final Entity entity = readEntity(uriInfo, true);
final UriResourceNavigation navigationProperty = getLastNavigation(uriInfo);
+ ensureNavigationPropertyNotNull(navigationProperty);
dataProvider.createReference(entity, navigationProperty.getProperty(), references.getEntityReferences().get(0),
- request.getRawBaseUri());
+ request.getRawBaseUri());
response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
}
@@@ -398,23 -382,6 +403,20 @@@
private void readEntity(final ODataRequest request, final ODataResponse response, final UriInfo uriInfo,
final ContentType requestedFormat, final boolean isReference)
throws ODataApplicationException, ODataLibraryException {
+ //
+ if(odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).hasRespondAsync()) {
+ TechnicalAsyncService asyncService = TechnicalAsyncService.getInstance();
+ TechnicalEntityProcessor processor = new TechnicalEntityProcessor(dataProvider, serviceMetadata);
+ processor.init(odata, serviceMetadata);
+ AsyncProcessor<EntityProcessor> asyncProcessor = asyncService.register(processor, EntityProcessor.class);
+ asyncProcessor.prepareFor().readEntity(request, response, uriInfo, requestedFormat);
+ String location = asyncProcessor.processAsync();
- //
- response.setStatusCode(HttpStatusCode.ACCEPTED.getStatusCode());
- response.setHeader(HttpHeader.LOCATION, location);
- response.setHeader(HttpHeader.PREFERENCE_APPLIED, "respond-async");
++ TechnicalAsyncService.acceptedResponse(response, location);
+ //
+ return;
+ }
+ //
+
final EdmEntitySet edmEntitySet = getEdmEntitySet(uriInfo);
final EdmEntityType edmEntityType = edmEntitySet == null ?
(EdmEntityType) ((UriResourcePartTyped) uriInfo.getUriResourceParts()
@@@ -453,6 -420,6 +455,21 @@@
private void readEntityCollection(final ODataRequest request, final ODataResponse response,
final UriInfo uriInfo, final ContentType requestedContentType, final boolean isReference)
throws ODataApplicationException, ODataLibraryException {
++ //
++ if(odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).hasRespondAsync()) {
++ TechnicalAsyncService asyncService = TechnicalAsyncService.getInstance();
++ TechnicalEntityProcessor processor = new TechnicalEntityProcessor(dataProvider, serviceMetadata);
++ processor.init(odata, serviceMetadata);
++ AsyncProcessor<EntityCollectionProcessor> asyncProcessor =
++ asyncService.register(processor, EntityCollectionProcessor.class);
++ asyncProcessor.prepareFor().readEntityCollection(request, response, uriInfo, requestedContentType);
++ String location = asyncProcessor.processAsync();
++ TechnicalAsyncService.acceptedResponse(response, location);
++ //
++ return;
++ }
++ //
++
final EdmEntitySet edmEntitySet = getEdmEntitySet(uriInfo.asUriInfoResource());
final EdmEntityType edmEntityType = edmEntitySet == null ?
(EdmEntityType) ((UriResourcePartTyped) uriInfo.getUriResourceParts()
[10/12] olingo-odata4 git commit: [OLINGO-659] Added data to TecSvc,
Bugfix URI Parser, Bugfix JsonDeserializer
Posted by mi...@apache.org.
[OLINGO-659] Added data to TecSvc, Bugfix URI Parser, Bugfix JsonDeserializer
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/f1a40746
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/f1a40746
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/f1a40746
Branch: refs/heads/OLINGO-708_AsyncSupportTec
Commit: f1a40746de5502f2b05c464031ae02c0e1ab26fa
Parents: d18cbcc
Author: Christian Holzer <c....@sap.com>
Authored: Tue Jul 7 17:14:58 2015 +0200
Committer: Christian Holzer <c....@sap.com>
Committed: Tue Jul 7 17:15:54 2015 +0200
----------------------------------------------------------------------
.../fit/tecsvc/client/ActionImportITCase.java | 47 +++++++++++-
.../fit/tecsvc/client/FunctionImportITCase.java | 76 ++++++++++++++++++++
.../client/api/domain/ClientPrimitiveValue.java | 2 +
.../core/domain/ClientPrimitiveValueImpl.java | 5 ++
.../olingo/server/core/uri/antlr/UriLexer.g4 | 6 +-
.../json/ODataJsonDeserializer.java | 3 +-
.../core/uri/parser/UriParseTreeVisitor.java | 3 +-
.../olingo/server/tecsvc/data/ActionData.java | 25 +++++--
.../olingo/server/tecsvc/data/DataCreator.java | 26 ++++++-
.../olingo/server/tecsvc/data/FunctionData.java | 76 ++++++++++++++++++++
.../tecsvc/provider/ContainerProvider.java | 12 ++--
.../tecsvc/provider/FunctionProvider.java | 20 +++---
.../server/tecsvc/provider/SchemaProvider.java | 4 +-
.../server/tecsvc/data/DataProviderTest.java | 2 +-
...ataJsonDeserializerActionParametersTest.java | 18 ++++-
.../json/ODataJsonSerializerTest.java | 6 +-
.../core/uri/antlr/TestFullResourcePath.java | 26 ++++---
.../core/uri/antlr/TestUriParserImpl.java | 6 +-
18 files changed, 313 insertions(+), 50 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f1a40746/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
index 00d55ad..1aada74 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
@@ -39,6 +39,7 @@ import org.apache.olingo.client.api.domain.ClientCollectionValue;
import org.apache.olingo.client.api.domain.ClientComplexValue;
import org.apache.olingo.client.api.domain.ClientEntity;
import org.apache.olingo.client.api.domain.ClientEntitySet;
+import org.apache.olingo.client.api.domain.ClientObjectFactory;
import org.apache.olingo.client.api.domain.ClientProperty;
import org.apache.olingo.client.api.domain.ClientValue;
import org.apache.olingo.client.core.ODataClientFactory;
@@ -113,9 +114,9 @@ public class ActionImportITCase extends AbstractBaseTestITCase {
ClientCollectionValue<ClientValue> valueArray = response.getBody().getCollectionValue();
assertEquals(3, valueArray.size());
Iterator<ClientValue> iterator = valueArray.iterator();
- assertEquals("PT1S", iterator.next().asPrimitive().toValue());
- assertEquals("PT2S", iterator.next().asPrimitive().toValue());
- assertEquals("PT3S", iterator.next().asPrimitive().toValue());
+ assertEquals("UARTCollStringTwoParam duration value: PT1S", iterator.next().asPrimitive().toValue());
+ assertEquals("UARTCollStringTwoParam duration value: PT2S", iterator.next().asPrimitive().toValue());
+ assertEquals("UARTCollStringTwoParam duration value: PT3S", iterator.next().asPrimitive().toValue());
}
@Test
@@ -324,7 +325,47 @@ public class ActionImportITCase extends AbstractBaseTestITCase {
assertEquals(location, response.getHeader(HttpHeader.LOCATION).iterator().next());
assertEquals(location, response.getHeader(HttpHeader.ODATA_ENTITY_ID).iterator().next());
}
+
+ @Test
+ public void airtCollStringTwoParanNotNull() {
+ final URI actionURI = getClient().newURIBuilder(TecSvcConst.BASE_URI)
+ .appendActionCallSegment("AIRTCollStringTwoParam").build();
+ final Map<String, ClientValue> parameters = new HashMap<String, ClientValue>();
+ final ClientObjectFactory of = getClient().getObjectFactory();
+ parameters.put("ParameterInt16", of.newPrimitiveValueBuilder().buildInt16((short) 2));
+ parameters.put("ParameterDuration", of.newPrimitiveValueBuilder().buildDuration(BigDecimal.valueOf(1)));
+ final ODataInvokeResponse<ClientProperty> response = getClient()
+ .getInvokeRequestFactory().getActionInvokeRequest(actionURI, ClientProperty.class, parameters).execute();
+
+ assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
+ ClientCollectionValue<ClientValue> collectionValue = response.getBody().getCollectionValue().asCollection();
+ assertEquals(2, collectionValue.size());
+ final Iterator<ClientValue> iter = collectionValue.iterator();
+
+ assertEquals("UARTCollStringTwoParam duration value: PT1S", iter.next().asPrimitive().toValue());
+ assertEquals("UARTCollStringTwoParam duration value: PT2S", iter.next().asPrimitive().toValue());
+ }
+
+ @Test
+ public void airtCollStringTwoParanNull() {
+ final URI actionURI = getClient().newURIBuilder(TecSvcConst.BASE_URI)
+ .appendActionCallSegment("AIRTCollStringTwoParam").build();
+ final Map<String, ClientValue> parameters = new HashMap<String, ClientValue>();
+ final ClientObjectFactory of = getClient().getObjectFactory();
+ parameters.put("ParameterInt16", of.newPrimitiveValueBuilder().buildInt16((short) 2));
+ parameters.put("ParameterDuration", of.newPrimitiveValueBuilder().buildDuration(null));
+ final ODataInvokeResponse<ClientProperty> response = getClient()
+ .getInvokeRequestFactory().getActionInvokeRequest(actionURI, ClientProperty.class, parameters).execute();
+
+ assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
+ ClientCollectionValue<ClientValue> collectionValue = response.getBody().getCollectionValue().asCollection();
+ assertEquals(2, collectionValue.size());
+ final Iterator<ClientValue> iter = collectionValue.iterator();
+ assertEquals("UARTCollStringTwoParam int16 value: 2", iter.next().asPrimitive().toValue());
+ assertEquals("UARTCollStringTwoParam duration value: null", iter.next().asPrimitive().toValue());
+ }
+
@Override
protected ODataClient getClient() {
ODataClient odata = ODataClientFactory.getClient();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f1a40746/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/FunctionImportITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/FunctionImportITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/FunctionImportITCase.java
index f2ea75e..eb45765 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/FunctionImportITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/FunctionImportITCase.java
@@ -22,17 +22,22 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.Collections;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.apache.olingo.client.api.ODataClient;
import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataRawRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataValueRequest;
import org.apache.olingo.client.api.communication.response.ODataInvokeResponse;
import org.apache.olingo.client.api.communication.response.ODataRawResponse;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
+import org.apache.olingo.client.api.domain.ClientCollectionValue;
+import org.apache.olingo.client.api.domain.ClientComplexValue;
import org.apache.olingo.client.api.domain.ClientEntity;
import org.apache.olingo.client.api.domain.ClientEntitySet;
import org.apache.olingo.client.api.domain.ClientPrimitiveValue;
@@ -220,6 +225,77 @@ public class FunctionImportITCase extends AbstractBaseTestITCase {
assertEquals("UFCRTCTTwoPrim string value", response.getBody().toValue());
}
+ @Test
+ public void testFICRTStringTwoParamNotNull() {
+ final Map<String, Object> keys = new HashMap<String, Object>();
+ keys.put("ParameterInt16", 3);
+ keys.put("ParameterString", "ab");
+
+ ODataPropertyRequest<ClientProperty> request = getClient().getRetrieveRequestFactory()
+ .getPropertyRequest(getClient().newURIBuilder(TecSvcConst.BASE_URI)
+ .appendPropertySegment("FICRTStringTwoParam").appendKeySegment(keys).build());
+ final ODataRetrieveResponse<ClientProperty> response = request.execute();
+ assertEquals("\"ab\",\"ab\",\"ab\"", response.getBody().getPrimitiveValue().toValue());
+ }
+
+ @Test
+ public void testFICRTStringTwoParamNull() {
+ final Map<String, Object> keys = new HashMap<String, Object>();
+ keys.put("ParameterInt16", 1);
+
+ ODataPropertyRequest<ClientProperty> request = getClient().getRetrieveRequestFactory()
+ .getPropertyRequest(getClient().newURIBuilder(TecSvcConst.BASE_URI)
+ .appendPropertySegment("FICRTStringTwoParam").appendKeySegment(keys).build());
+ final ODataRetrieveResponse<ClientProperty> response = request.execute();
+ assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
+ }
+
+ @Test
+ public void testFICRTCollCTTwoPrimTwoParamNotNull() {
+ final Map<String, Object> keys = new HashMap<String, Object>();
+ keys.put("ParameterInt16", 2);
+ keys.put("ParameterString", "TestString");
+
+ ODataPropertyRequest<ClientProperty> request = getClient().getRetrieveRequestFactory()
+ .getPropertyRequest(getClient().newURIBuilder(TecSvcConst.BASE_URI)
+ .appendEntitySetSegment("FICRTCollCTTwoPrimTwoParam").appendKeySegment(keys).build());
+ final ODataRetrieveResponse<ClientProperty> response = request.execute();
+ final ClientCollectionValue<ClientValue> collection = response.getBody().getCollectionValue().asCollection();
+ final Iterator<ClientValue> iter = collection.iterator();
+
+ ClientComplexValue complexValue = iter.next().asComplex();
+ assertEquals(1, complexValue.get("PropertyInt16").getPrimitiveValue().toValue());
+ assertEquals("UFCRTCollCTTwoPrimTwoParam string value: TestString", complexValue.get("PropertyString")
+ .getPrimitiveValue().toValue());
+ complexValue = iter.next().asComplex();
+ assertEquals(2, complexValue.get("PropertyInt16").getPrimitiveValue().toValue());
+ assertEquals("UFCRTCollCTTwoPrimTwoParam string value: TestString", complexValue.get("PropertyString")
+ .getPrimitiveValue().toValue());
+ }
+
+ @Test
+ public void testFICRTCollCTTwoPrimTwoParamNull() {
+ final Map<String, Object> keys = new HashMap<String, Object>();
+ keys.put("ParameterInt16", 2);
+ keys.put("ParameterString", null);
+
+ ODataPropertyRequest<ClientProperty> request = getClient().getRetrieveRequestFactory()
+ .getPropertyRequest(getClient().newURIBuilder(TecSvcConst.BASE_URI)
+ .appendEntitySetSegment("FICRTCollCTTwoPrimTwoParam").appendKeySegment(keys).build());
+ final ODataRetrieveResponse<ClientProperty> response = request.execute();
+ final ClientCollectionValue<ClientValue> collection = response.getBody().getCollectionValue().asCollection();
+ final Iterator<ClientValue> iter = collection.iterator();
+
+ ClientComplexValue complexValue = iter.next().asComplex();
+ assertEquals(1, complexValue.get("PropertyInt16").getPrimitiveValue().toValue());
+ assertEquals("UFCRTCollCTTwoPrimTwoParam int16 value: 2", complexValue.get("PropertyString")
+ .getPrimitiveValue().toValue());
+ complexValue = iter.next().asComplex();
+ assertEquals(2, complexValue.get("PropertyInt16").getPrimitiveValue().toValue());
+ assertEquals("UFCRTCollCTTwoPrimTwoParamstring value: null", complexValue.get("PropertyString")
+ .getPrimitiveValue().toValue());
+ }
+
@Override
protected ODataClient getClient() {
ODataClient odata = ODataClientFactory.getClient();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f1a40746/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ClientPrimitiveValue.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ClientPrimitiveValue.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ClientPrimitiveValue.java
index 445af84..cd3339c 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ClientPrimitiveValue.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ClientPrimitiveValue.java
@@ -57,6 +57,8 @@ public interface ClientPrimitiveValue extends ClientValue {
ClientPrimitiveValue buildBinary(byte[] value);
ClientPrimitiveValue buildDecimal(BigDecimal value);
+
+ ClientPrimitiveValue buildDuration(BigDecimal value);
}
EdmPrimitiveTypeKind getTypeKind();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f1a40746/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientPrimitiveValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientPrimitiveValueImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientPrimitiveValueImpl.java
index e6f7fa6..1c18c02 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientPrimitiveValueImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientPrimitiveValueImpl.java
@@ -139,6 +139,11 @@ public class ClientPrimitiveValueImpl extends AbstractClientValue implements Cli
return setType(EdmPrimitiveTypeKind.Decimal).setValue(value).build();
}
+ @Override
+ public ClientPrimitiveValue buildDuration(BigDecimal value) {
+ return setType(EdmPrimitiveTypeKind.Duration).setValue(value).build();
+ }
+
}
/**
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f1a40746/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriLexer.g4
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriLexer.g4 b/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriLexer.g4
index a74fd2f..f2ec378 100644
--- a/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriLexer.g4
+++ b/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriLexer.g4
@@ -112,10 +112,10 @@ REF : '$ref';
COUNT : '$count';
//inlined query parameters ( e.g. $skip)
-TOP_I : '$top' -> type(TOP);
-SKIP_QO_I : '$skip' -> type(SKIP_QO);
+TOP_I : '$top' -> type(TOP);
+SKIP_QO_I : '$skip' -> type(SKIP_QO);
FILTER_I : '$filter' -> type(FILTER);
-ORDERBY_I : '$orderby' -> type(ORDERBY);
+ORDERBY_I : '$orderby'-> type(ORDERBY);
SELECT_I : '$select' -> type(SELECT);
EXPAND_I : '$expand' -> type(EXPAND);
LEVELS_I : '$levels' -> type(LEVELS);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f1a40746/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
index 71e5030..84beb61 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
@@ -274,6 +274,8 @@ public class ODataJsonDeserializer implements ODataDeserializer {
DeserializerException.MessageKeys.INVALID_NULL_PARAMETER, paramName);
}
parameter.setValue(ValueType.PRIMITIVE, null);
+ parameters.put(paramName, parameter);
+ node.remove(paramName);
} else {
Property consumePropertyNode =
consumePropertyNode(edmParameter.getName(), edmParameter.getType(), edmParameter.isCollection(),
@@ -859,7 +861,6 @@ public class ODataJsonDeserializer implements ODataDeserializer {
throw new DeserializerException("Value must be an array", DeserializerException.MessageKeys.UNKNOWN_CONTENT);
}
tree.remove(Constants.VALUE);
- // if this is value there can be only one property
return DeserializerResultImpl.with().entityReferences(parsedValues).build();
}
if (tree.get(key) != null) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f1a40746/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java
index 803b0ad..16aa42e 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java
@@ -1636,7 +1636,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
uriParameter.setName(ctx.vODI.getText());
if (ctx.vCOM != null) {
- uriParameter.setText(ctx.vCOM.getText());
+ final String text = ctx.vCOM.getText();
+ uriParameter.setText("null".equals(text) ? null : text);
uriParameter.setExpression((ExpressionImpl) ctx.vCOM.accept(this));
} else {
uriParameter.setAlias("@" + ctx.vALI.getText());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f1a40746/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/ActionData.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/ActionData.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/ActionData.java
index 81a723a..6d7a41f 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/ActionData.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/ActionData.java
@@ -20,6 +20,7 @@ package org.apache.olingo.server.tecsvc.data;
import java.math.BigDecimal;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
@@ -52,9 +53,18 @@ public class ActionData {
if ("UARTCollStringTwoParam".equals(name)) {
Parameter paramInt16 = parameters.get("ParameterInt16");
Parameter paramDuration = parameters.get("ParameterDuration");
- if (paramInt16 == null || paramDuration == null) {
- throw new DataProviderException("Missing parameters for action: UARTCollStringTwoParam",
- HttpStatusCode.BAD_REQUEST);
+ if ((paramInt16 == null || paramInt16.isNull()) || (paramDuration == null || paramDuration.isNull())) {
+ try {
+ String param16String = valueAsString(paramInt16, EdmPrimitiveTypeKind.Int16);
+ String paramDurationString = valueAsString(paramDuration, EdmPrimitiveTypeKind.Duration);
+
+ return new Property(null, name, ValueType.COLLECTION_PRIMITIVE, Arrays.asList(new String[] {
+ name + " int16 value: " + param16String,
+ name + " duration value: " + paramDurationString
+ }));
+ } catch(EdmPrimitiveTypeException e) {
+ throw new DataProviderException("EdmPrimitiveTypeException", e);
+ }
}
short loopCount = (Short) paramInt16.asPrimitive();
BigDecimal duration = (BigDecimal) paramDuration.asPrimitive();
@@ -64,7 +74,7 @@ public class ActionData {
for (int i = 0; i < loopCount; i++) {
try {
String value = primDuration.valueToString(duration, false, null, null, null, null);
- collectionValues.add(value);
+ collectionValues.add(name + " duration value: " + value);
} catch (EdmPrimitiveTypeException e) {
throw new DataProviderException("EdmPrimitiveTypeException", e);
}
@@ -75,6 +85,13 @@ public class ActionData {
throw new DataProviderException("Action " + name + " is not yet implemented.");
}
+ private static <T> String valueAsString(final Parameter parameter, final EdmPrimitiveTypeKind kind)
+ throws EdmPrimitiveTypeException {
+ return parameter == null ? "null"
+ : OData.newInstance().createPrimitiveTypeInstance(kind)
+ .valueToString(parameter.asPrimitive(), null, null, null, null, null);
+ }
+
protected static Property complexAction(final String name, final Map<String, Parameter> parameters)
throws DataProviderException {
if ("UARTCTTwoPrimParam".equals(name)) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f1a40746/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
index 341a7b1..759516c 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
@@ -698,7 +698,7 @@ public class DataCreator {
createPrimitive("PropertyByte", (short) 255),
createPrimitive("PropertyDate", getDateTime(2014, 12, 5, 0, 0, 0)),
createPrimitive("PropertyDateTimeOffset", getTimestamp(2014, 12, 5, 8, 17, 45, 123456700)),
- createPrimitive("PropertyDecimal", 17.98),
+ createPrimitive("PropertyDecimal", BigDecimal.valueOf(17.98)),
createPrimitive("PropertySingle", 1.79000000E+20),
createPrimitive("PropertyDouble", -1.7900000000000000E+02),
createPrimitive("PropertyDuration", BigDecimal.valueOf(6)),
@@ -710,7 +710,29 @@ public class DataCreator {
createPrimitive("PropertyTimeOfDay", getTime(13, 27, 45))));
entity.setETag("W/\"0\"");
entityCollection.getEntities().add(entity);
-
+
+ entity = new Entity()
+ .addProperty(createPrimitive("PropertyInt16", (short) -32768))
+ .addProperty(createComplex("PropertyComp",
+ createPrimitive("PropertyString", null),
+ createPrimitive("PropertyBinary", null),
+ createPrimitive("PropertyBoolean", null),
+ createPrimitive("PropertyByte", null),
+ createPrimitive("PropertyDate", null),
+ createPrimitive("PropertyDateTimeOffset", null),
+ createPrimitive("PropertyDecimal", null),
+ createPrimitive("PropertySingle", null),
+ createPrimitive("PropertyDouble", null),
+ createPrimitive("PropertyDuration", null),
+ createPrimitive("PropertyGuid", null),
+ createPrimitive("PropertyInt16", null),
+ createPrimitive("PropertyInt32", null),
+ createPrimitive("PropertyInt64", null),
+ createPrimitive("PropertySByte", null),
+ createPrimitive("PropertyTimeOfDay", null)));
+ entity.setETag("W/\"-32768\"");
+ entityCollection.getEntities().add(entity);
+
return entityCollection;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f1a40746/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/FunctionData.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/FunctionData.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/FunctionData.java
index 238dd8b..65099dc 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/FunctionData.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/FunctionData.java
@@ -18,13 +18,17 @@
*/
package org.apache.olingo.server.tecsvc.data;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import org.apache.olingo.commons.api.data.ComplexValue;
import org.apache.olingo.commons.api.data.Entity;
import org.apache.olingo.commons.api.data.EntityCollection;
import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ValueType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.server.api.OData;
@@ -108,6 +112,78 @@ public class FunctionData {
DataCreator.createPrimitive("PropertyString", "Test456")),
Arrays.asList(DataCreator.createPrimitive("PropertyInt16", 18),
DataCreator.createPrimitive("PropertyString", "Test678")));
+ } else if(name.equals("UFCRTStringTwoParam")) {
+ final String parameterStringRaw = getParameterText("ParameterString", parameters);
+ final String parameterInt16Raw = getParameterText("ParameterInt16", parameters);
+
+ // ParameterString is not provided
+ if(parameterStringRaw == null) {
+ return new Property(null, "value", ValueType.PRIMITIVE, null);
+ } else {
+ try {
+ EdmPrimitiveType edmInt16 = OData.newInstance().createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Int16);
+ EdmPrimitiveType edmString = OData.newInstance().createPrimitiveTypeInstance(EdmPrimitiveTypeKind.String);
+ Short parameterInt16 = edmInt16.valueOfString(parameterInt16Raw, null, null, null, null, null, Short.class);
+ String parameterString = edmString.fromUriLiteral(parameterStringRaw);
+ final StringBuilder builder = new StringBuilder();
+
+ // if parameterInt16 <= 0 return an empty string
+ for(short i = parameterInt16; i > 0; i--) {
+ if(builder.length() != 0) {
+ builder.append(',');
+ }
+ builder.append('"');
+ builder.append(parameterString);
+ builder.append('"');
+ }
+ return new Property(null, "value", ValueType.PRIMITIVE, builder.toString());
+ } catch (EdmPrimitiveTypeException e) {
+ throw new DataProviderException("Invalid function parameter.");
+ }
+ }
+ } else if(name.equals("UFCRTCollCTTwoPrimTwoParam")) {
+ String parameterStringRaw = getParameterText("ParameterString", parameters);
+ String parameteInt16Raw = getParameterText("ParameterInt16", parameters);
+ EdmPrimitiveType edmInt16 = OData.newInstance().createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Int16);
+ EdmPrimitiveType edmString = OData.newInstance().createPrimitiveTypeInstance(EdmPrimitiveTypeKind.String);
+ try {
+ Short parameterInt16 = edmInt16.valueOfString(parameteInt16Raw, null, null, null, null, null, Short.class);
+
+ if (parameterStringRaw == null) {
+ ComplexValue complexValue1 = new ComplexValue();
+ ComplexValue complexValue2 = new ComplexValue();
+
+ complexValue1.getValue().add(new Property(null, "PropertyInt16", ValueType.PRIMITIVE, 1));
+ complexValue1.getValue().add(new Property(null, "PropertyString", ValueType.PRIMITIVE,
+ name + " int16 value: " + parameterInt16));
+
+ complexValue2.getValue().add(new Property(null, "PropertyInt16", ValueType.PRIMITIVE, 2));
+ complexValue2.getValue().add(new Property(null, "PropertyString", ValueType.PRIMITIVE,
+ name + "string value: null"));
+
+
+ return new Property(null, "value", ValueType.COLLECTION_COMPLEX, Arrays.asList(new ComplexValue[] {
+ complexValue1, complexValue2
+ }));
+ } else {
+ String parameterString = edmString.fromUriLiteral(parameterStringRaw);
+ List<ComplexValue> complexValues = new ArrayList<ComplexValue>();
+ short counter = 1;
+
+ for(short i = parameterInt16; 0 < i; i--) {
+ ComplexValue complexValue = new ComplexValue();
+ complexValue.getValue().add(new Property(null, "PropertyInt16", ValueType.PRIMITIVE, counter++));
+ complexValue.getValue().add(new Property(null, "PropertyString", ValueType.PRIMITIVE,
+ name + " string value: " + parameterString));
+ complexValues.add(complexValue);
+ }
+
+ return new Property(null, "value", ValueType.COLLECTION_COMPLEX, complexValues);
+ }
+ } catch (EdmPrimitiveTypeException e) {
+ throw new DataProviderException("Invalid function parameter");
+ }
+
} else {
throw new DataProviderException("Function " + name + " is not yet implemented.");
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f1a40746/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ContainerProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ContainerProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ContainerProvider.java
index 1f5bd03..3a17775 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ContainerProvider.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ContainerProvider.java
@@ -142,12 +142,12 @@ public class ContainerProvider {
functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCollCTTwoPrim"));
functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTESMedia"));
functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCollESMedia"));
- functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCTTwoPrimParam"));
+ functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCTTwoPrimTwoParam"));
functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCTTwoPrim"));
functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCollString"));
functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTString"));
functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCollESTwoKeyNavParam"));
- functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCollCTTwoPrimParam"));
+ functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCollCTTwoPrimTwoParam"));
functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FINRTCollCTNavFiveProp"));
functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCollESKeyNavContParam"));
@@ -598,10 +598,10 @@ public class ContainerProvider {
.setEntitySet(entityContainer.getFullQualifiedNameAsString() + "/ESMedia")
.setIncludeInServiceDocument(true);
- } else if (name.equals("FICRTCTTwoPrimParam")) {
+ } else if (name.equals("FICRTCTTwoPrimTwoParam")) {
return new CsdlFunctionImport()
.setName(name)
- .setFunction(FunctionProvider.nameUFCRTCTTwoPrimParam)
+ .setFunction(FunctionProvider.nameUFCRTCTTwoPrimTwoParam)
.setIncludeInServiceDocument(true);
} else if (name.equals("FICRTCTTwoPrim")) {
@@ -629,10 +629,10 @@ public class ContainerProvider {
.setEntitySet(entityContainer.getFullQualifiedNameAsString() + "/ESTwoKeyNav")
.setIncludeInServiceDocument(true);
- } else if (name.equals("FICRTCollCTTwoPrimParam")) {
+ } else if (name.equals("FICRTCollCTTwoPrimTwoParam")) {
return new CsdlFunctionImport()
.setName(name)
- .setFunction(FunctionProvider.nameUFCRTCollCTTwoPrimParam)
+ .setFunction(FunctionProvider.nameUFCRTCollCTTwoPrimTwoParam)
.setIncludeInServiceDocument(true);
} else if (name.equals("FINRTCollCTNavFiveProp")) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f1a40746/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/FunctionProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/FunctionProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/FunctionProvider.java
index 63dfec1..1694d13 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/FunctionProvider.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/FunctionProvider.java
@@ -125,8 +125,8 @@ public class FunctionProvider {
// Unbound Functions
public static final FullQualifiedName nameUFCRTCollCTTwoPrim =
new FullQualifiedName(SchemaProvider.NAMESPACE, "UFCRTCollCTTwoPrim");
- public static final FullQualifiedName nameUFCRTCollCTTwoPrimParam =
- new FullQualifiedName(SchemaProvider.NAMESPACE, "UFCRTCollCTTwoPrimParam");
+ public static final FullQualifiedName nameUFCRTCollCTTwoPrimTwoParam =
+ new FullQualifiedName(SchemaProvider.NAMESPACE, "UFCRTCollCTTwoPrimTwoParam");
public static final FullQualifiedName nameUFCRTCollString = new FullQualifiedName(SchemaProvider.NAMESPACE,
"UFCRTCollString");
public static final FullQualifiedName nameUFCRTCollStringTwoParam =
@@ -135,8 +135,8 @@ public class FunctionProvider {
new FullQualifiedName(SchemaProvider.NAMESPACE, "UFCRTCTAllPrimTwoParam");
public static final FullQualifiedName nameUFCRTCTTwoPrim = new FullQualifiedName(SchemaProvider.NAMESPACE,
"UFCRTCTTwoPrim");
- public static final FullQualifiedName nameUFCRTCTTwoPrimParam =
- new FullQualifiedName(SchemaProvider.NAMESPACE, "UFCRTCTTwoPrimParam");
+ public static final FullQualifiedName nameUFCRTCTTwoPrimTwoParam =
+ new FullQualifiedName(SchemaProvider.NAMESPACE, "UFCRTCTTwoPrimTwoParam");
public static final FullQualifiedName nameUFCRTESMixPrimCollCompTwoParam =
new FullQualifiedName(SchemaProvider.NAMESPACE, "UFCRTESMixPrimCollCompTwoParam");
public static final FullQualifiedName nameUFCRTCollETTwoKeyNavParam =
@@ -243,7 +243,7 @@ public class FunctionProvider {
.setNullable(false)))
.setComposable(true)
.setReturnType(
- new CsdlReturnType().setType(PropertyProvider.nameString).setNullable(false)),
+ new CsdlReturnType().setType(PropertyProvider.nameString).setNullable(true)),
new CsdlFunction()
.setName("UFCRTStringTwoParam")
.setParameters(Arrays.asList(
@@ -256,7 +256,7 @@ public class FunctionProvider {
.setType(PropertyProvider.nameInt16)
.setNullable(false)))
.setComposable(true)
- .setReturnType(new CsdlReturnType().setType(PropertyProvider.nameString).setNullable(false))
+ .setReturnType(new CsdlReturnType().setType(PropertyProvider.nameString).setNullable(true))
);
@@ -360,10 +360,10 @@ public class FunctionProvider {
.setNullable(false)
.setCollection(true))
);
- } else if (functionName.equals(nameUFCRTCTTwoPrimParam)) {
+ } else if (functionName.equals(nameUFCRTCTTwoPrimTwoParam)) {
return Arrays.asList(
new CsdlFunction()
- .setName("UFCRTCTTwoPrimParam")
+ .setName("UFCRTCTTwoPrimTwoParam")
.setParameters(
Arrays.asList(
new CsdlParameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16).setNullable(
@@ -374,10 +374,10 @@ public class FunctionProvider {
.setReturnType(
new CsdlReturnType().setType(ComplexTypeProvider.nameCTTwoPrim).setNullable(false))
);
- } else if (functionName.equals(nameUFCRTCollCTTwoPrimParam)) {
+ } else if (functionName.equals(nameUFCRTCollCTTwoPrimTwoParam)) {
return Arrays.asList(
new CsdlFunction()
- .setName("UFCRTCollCTTwoPrimParam")
+ .setName("UFCRTCollCTTwoPrimTwoParam")
.setParameters(
Arrays.asList(
new CsdlParameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16).setNullable(
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f1a40746/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/SchemaProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/SchemaProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/SchemaProvider.java
index c8d299d..7891556 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/SchemaProvider.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/SchemaProvider.java
@@ -146,8 +146,8 @@ public class SchemaProvider {
functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTCollStringTwoParam));
functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTCollString));
functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTCTAllPrimTwoParam));
- functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTCTTwoPrimParam));
- functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTCollCTTwoPrimParam));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTCTTwoPrimTwoParam));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTCollCTTwoPrimTwoParam));
functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTCTTwoPrim));
functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTCollCTTwoPrim));
functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTETMedia));
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f1a40746/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/DataProviderTest.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/DataProviderTest.java b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/DataProviderTest.java
index 4300ade..1d29a8e 100644
--- a/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/DataProviderTest.java
+++ b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/DataProviderTest.java
@@ -122,7 +122,7 @@ public class DataProviderTest {
public void esCompAllPrim() throws Exception {
EntityCollection outSet = new DataProvider().readAll(esCompAllPrim);
- Assert.assertEquals(3, outSet.getEntities().size());
+ Assert.assertEquals(4, outSet.getEntities().size());
Assert.assertEquals(2, outSet.getEntities().get(0).getProperties().size());
Property complex = outSet.getEntities().get(0).getProperties().get(1);
Assert.assertTrue(complex.isComplex());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f1a40746/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerActionParametersTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerActionParametersTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerActionParametersTest.java
index b3568f5..3ed9f89 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerActionParametersTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerActionParametersTest.java
@@ -79,7 +79,21 @@ public class ODataJsonDeserializerActionParametersTest extends AbstractODataDese
assertNotNull(parameter);
assertEquals(BigDecimal.valueOf(3669753), parameter.getValue());
}
-
+
+ @Test
+ public void testParameterWithNullLiteral() throws Exception {
+ final Map<String, Parameter> parameters = deserialize("{\"ParameterInt16\":1,\"ParameterDuration\":null}",
+ "UARTCollStringTwoParam");
+ assertNotNull(parameters);
+ assertEquals(2, parameters.size());
+ Parameter parameter = parameters.get("ParameterInt16");
+ assertNotNull(parameter);
+ assertEquals((short) 1, parameter.getValue());
+ parameter = parameters.get("ParameterDuration");
+ assertNotNull(parameter);
+ assertEquals(null, parameter.getValue());
+ }
+
@Test(expected = DeserializerException.class)
public void bindingParameter() throws Exception {
deserialize("{\"ParameterETAllPrim\":{\"PropertyInt16\":42}}", "BAETAllPrimRT", "ETAllPrim");
@@ -109,7 +123,7 @@ public class ODataJsonDeserializerActionParametersTest extends AbstractODataDese
public void wrongType() throws Exception {
deserialize("{\"ParameterInt16\":\"42\"}", "UARTParam");
}
-
+
private Map<String, Parameter> deserialize(final String input, final String actionName) throws DeserializerException {
return OData.newInstance().createDeserializer(CONTENT_TYPE_JSON)
.actionParameters(new ByteArrayInputStream(input.getBytes()),
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f1a40746/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
index 0877df6..ca070a9 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
@@ -179,9 +179,9 @@ public class ODataJsonSerializerTest {
Assert.assertThat(resultString, CoreMatchers.startsWith("{"
+ "\"@odata.context\":\"$metadata#ESCompAllPrim\","
+ "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\","
- + "\"@odata.count\":3,\"value\":["
+ + "\"@odata.count\":4,\"value\":["
+ "{\"@odata.etag\":\"W/\\\"32767\\\"\","));
- Assert.assertThat(resultString, CoreMatchers.endsWith("\"}}],"
+ Assert.assertThat(resultString, CoreMatchers.endsWith("}}],"
+ "\"@odata.nextLink\":\"/next\"}"));
int count = 0;
@@ -189,7 +189,7 @@ public class ODataJsonSerializerTest {
while ((index = resultString.indexOf("PropertyInt16\":", ++index)) > 0) {
count++;
}
- Assert.assertEquals(6, count);
+ Assert.assertEquals(8, count);
}
@Test
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f1a40746/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
index db58288..d1ffaab 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
@@ -1705,6 +1705,14 @@ public class TestFullResourcePath {
.isKeyPredicate(1, "PropertyString", "'3'")
.n()
.isFunction("BFCETBaseTwoKeyNavRTETTwoKeyNav");
+
+ testUri.run("FICRTCollCTTwoPrimTwoParam(ParameterInt16=1,ParameterString=null)")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isFunctionImport("FICRTCollCTTwoPrimTwoParam")
+ .isFunction("UFCRTCollCTTwoPrimTwoParam")
+ .isParameter(0, "ParameterInt16", "1")
+ .isParameter(1, "ParameterString", null);
}
@Test
@@ -1817,11 +1825,11 @@ public class TestFullResourcePath {
@Test
public void runFunctionImpError() {
- testUri.runEx("FICRTCollCTTwoPrimParam")
+ testUri.runEx("FICRTCollCTTwoPrimTwoParam")
.isExSyntax(UriParserSyntaxException.MessageKeys.SYNTAX);
- testUri.runEx("FICRTCollCTTwoPrimParam()")
+ testUri.runEx("FICRTCollCTTwoPrimTwoParam()")
.isExSemantic(UriParserSemanticException.MessageKeys.FUNCTION_NOT_FOUND);
- testUri.runEx("FICRTCollCTTwoPrimParam(invalidParam=2)")
+ testUri.runEx("FICRTCollCTTwoPrimTwoParam(invalidParam=2)")
.isExSemantic(UriParserSemanticException.MessageKeys.FUNCTION_NOT_FOUND);
}
@@ -4606,11 +4614,11 @@ public class TestFullResourcePath {
.goParameter(0).isLiteral("'Walldorf'")
.root().left().goParameter(1).isLiteral("'Wall'");
- testFilter.runOnETAllPrim("olingo.odata.test1.UFCRTCTTwoPrimParam(ParameterInt16=null,ParameterString=null)")
+ testFilter.runOnETAllPrim("olingo.odata.test1.UFCRTCTTwoPrimTwoParam(ParameterInt16=null,ParameterString=null)")
.goPath()
- .isFunction("UFCRTCTTwoPrimParam")
- .isParameter(0, "ParameterInt16", "null")
- .isParameter(1, "ParameterString", "null");
+ .isFunction("UFCRTCTTwoPrimTwoParam")
+ .isParameter(0, "ParameterInt16", null)
+ .isParameter(1, "ParameterString", null);
testFilter.runOnETAllPrim("PropertyBoolean eq true")
.is("<<PropertyBoolean> eq <true>>")
@@ -5180,12 +5188,12 @@ public class TestFullResourcePath {
.isExSemantic(UriParserSemanticException.MessageKeys.INCOMPATIBLE_TYPE_FILTER);
// type filter for complex double on entry
- testUri.runEx("FICRTCTTwoPrimParam(ParameterInt16=1,ParameterString='2')"
+ testUri.runEx("FICRTCTTwoPrimTwoParam(ParameterInt16=1,ParameterString='2')"
+ "/olingo.odata.test1.CTBase/olingo.odata.test1.CTBase")
.isExSemantic(UriParserSemanticException.MessageKeys.TYPE_FILTER_NOT_CHAINABLE);
// type filter for complex double on collection
- testUri.runEx("FICRTCollCTTwoPrimParam(ParameterInt16=1,ParameterString='2')"
+ testUri.runEx("FICRTCollCTTwoPrimTwoParam(ParameterInt16=1,ParameterString='2')"
+ "/olingo.odata.test1.CTBase/olingo.odata.test1.CTBase")
.isExSemantic(UriParserSemanticException.MessageKeys.TYPE_FILTER_NOT_CHAINABLE);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f1a40746/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
index 0d333f3..9f79a84 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
@@ -1018,7 +1018,7 @@ public class TestUriParserImpl {
@Test(expected = UriValidationException.class)
public void testMemberStartingWithCastFailOnValidation2() throws Exception {
- testUri.run("FICRTCTTwoPrimParam(ParameterInt16=1,ParameterString='2')",
+ testUri.run("FICRTCTTwoPrimTwoParam(ParameterInt16=1,ParameterString='2')",
"$filter=olingo.odata.test1.CTBase/AdditionalPropString")
.goFilter().root().isMember()
.isMemberStartType(ComplexTypeProvider.nameCTBase).goPath()
@@ -1043,7 +1043,7 @@ public class TestUriParserImpl {
.at(0).isType(PropertyProvider.nameDate);
// on Complex collection
- testUri.run("FICRTCollCTTwoPrimParam(ParameterInt16=1,ParameterString='2')",
+ testUri.run("FICRTCollCTTwoPrimTwoParam(ParameterInt16=1,ParameterString='2')",
"$filter=olingo.odata.test1.CTBase/AdditionalPropString")
.goFilter().root().isMember()
.isMemberStartType(ComplexTypeProvider.nameCTBase).goPath()
@@ -1057,7 +1057,7 @@ public class TestUriParserImpl {
@Test
public void testComplexTypeCastFollowingAsCollection() throws Exception {
- testUri.run("FICRTCollCTTwoPrimParam(ParameterInt16=1,ParameterString='2')/olingo.odata.test1.CTBase");
+ testUri.run("FICRTCollCTTwoPrimTwoParam(ParameterInt16=1,ParameterString='2')/olingo.odata.test1.CTBase");
}
@Test
[06/12] olingo-odata4 git commit: [OLINGO-714] Java types in the
DataProvider (TecSvc) changed
Posted by mi...@apache.org.
[OLINGO-714] Java types in the DataProvider (TecSvc) changed
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/de64c318
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/de64c318
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/de64c318
Branch: refs/heads/OLINGO-708_AsyncSupportTec
Commit: de64c3189b201b1604fcc7749b7f83b6a96095b9
Parents: aeb258b
Author: Christian Holzer <c....@sap.com>
Authored: Tue Jun 30 16:07:12 2015 +0200
Committer: Christian Holzer <c....@sap.com>
Committed: Tue Jun 30 16:07:12 2015 +0200
----------------------------------------------------------------------
.../fit/tecsvc/client/BatchClientITCase.java | 4 +-
.../tecsvc/client/EntityReferencesITCase.java | 3 -
.../olingo/server/tecsvc/data/ActionData.java | 34 +-
.../olingo/server/tecsvc/data/DataCreator.java | 879 +++++++++++--------
.../olingo/server/tecsvc/data/DataProvider.java | 22 +-
.../olingo/server/tecsvc/data/FunctionData.java | 6 +-
.../server/tecsvc/data/DataProviderTest.java | 4 +-
.../json/ODataJsonSerializerTest.java | 3 +-
8 files changed, 542 insertions(+), 413 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/de64c318/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java
index 3ab94da..c108d7b 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java
@@ -348,9 +348,9 @@ public class BatchClientITCase extends AbstractTestITCase {
assertNotNull(oDataResponse);
assertEquals(HttpStatusCode.OK.getStatusCode(), oDataResponse.getStatusCode());
assertEquals(1, oDataResponse.getHeader(HttpHeader.ODATA_VERSION).size());
- assertEquals("4.0", oDataResponse.getHeader(HttpHeader.ODATA_VERSION).toArray()[0]);
+ assertEquals("4.0", oDataResponse.getHeader(HttpHeader.ODATA_VERSION).iterator().next());
assertEquals(1, oDataResponse.getHeader(HttpHeader.CONTENT_LENGTH).size());
- assertEquals("513", oDataResponse.getHeader(HttpHeader.CONTENT_LENGTH).toArray()[0]);
+ assertEquals("517", oDataResponse.getHeader(HttpHeader.CONTENT_LENGTH).iterator().next());
assertEquals(ContentType.JSON.toContentTypeString(), oDataResponse.getContentType());
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/de64c318/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/EntityReferencesITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/EntityReferencesITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/EntityReferencesITCase.java
index 7b24bb5..7285920 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/EntityReferencesITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/EntityReferencesITCase.java
@@ -24,7 +24,6 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
import java.net.URI;
-import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -38,9 +37,7 @@ import org.apache.olingo.client.api.communication.response.ODataReferenceAddingR
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.api.domain.ClientEntity;
import org.apache.olingo.client.api.domain.ClientEntitySet;
-import org.apache.olingo.client.api.domain.ClientObjectFactory;
import org.apache.olingo.client.api.uri.QueryOption;
-import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.client.core.ODataClientFactory;
import org.apache.olingo.commons.api.format.ContentType;
import org.apache.olingo.commons.api.http.HttpHeader;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/de64c318/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/ActionData.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/ActionData.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/ActionData.java
index 4dd118e..81a723a 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/ActionData.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/ActionData.java
@@ -235,17 +235,19 @@ public class ActionData {
return new Entity()
.addProperty(DataCreator.createPrimitive("PropertyInt16", number))
.addProperty(DataCreator.createPrimitive("PropertyString", "UARTCollETKeyNavParam int16 value: " + number))
- .addProperty(
- DataCreator.createComplex("PropertyCompNav", DataCreator.createPrimitive("PropertyInt16", 0)))
- .addProperty(createKeyNavAllPrimComplexValue("PropertyCompAllPrim")).addProperty(
- DataCreator.createComplex("PropertyCompTwoPrim", DataCreator.createPrimitive("PropertyInt16", 0),
- DataCreator.createPrimitive("PropertyString", ""))).addProperty(
- DataCreator.createPrimitiveCollection("CollPropertyString"))
- .addProperty(DataCreator.createPrimitiveCollection("CollPropertyInt16")).addProperty(
- DataCreator.createComplexCollection("CollPropertyComp"))
- .addProperty(
- DataCreator.createComplex("PropertyCompCompNav", DataCreator.createPrimitive("PropertyString", ""),
- DataCreator.createComplex("PropertyCompNav", DataCreator.createPrimitive("PropertyInt16", 0))));
+ .addProperty(DataCreator.createComplex("PropertyCompNav",
+ DataCreator.createPrimitive("PropertyInt16", (short) 0)))
+ .addProperty(createKeyNavAllPrimComplexValue("PropertyCompAllPrim"))
+ .addProperty(DataCreator.createComplex("PropertyCompTwoPrim",
+ DataCreator.createPrimitive("PropertyInt16", (short) 0),
+ DataCreator.createPrimitive("PropertyString", ""))).addProperty(
+ DataCreator.createPrimitiveCollection("CollPropertyString"))
+ .addProperty(DataCreator.createPrimitiveCollection("CollPropertyInt16"))
+ .addProperty(DataCreator.createComplexCollection("CollPropertyComp"))
+ .addProperty(DataCreator.createComplex("PropertyCompCompNav",
+ DataCreator.createPrimitive("PropertyString", ""),
+ DataCreator.createComplex("PropertyCompNav",
+ DataCreator.createPrimitive("PropertyInt16", (short) 0))));
}
protected static Property createKeyNavAllPrimComplexValue(final String name) {
@@ -253,13 +255,13 @@ public class ActionData {
DataCreator.createPrimitive("PropertyString", ""),
DataCreator.createPrimitive("PropertyBinary", new byte[] {}),
DataCreator.createPrimitive("PropertyBoolean", false),
- DataCreator.createPrimitive("PropertyByte", 0),
+ DataCreator.createPrimitive("PropertyByte", (short) 0),
DataCreator.createPrimitive("PropertyDate", null),
DataCreator.createPrimitive("PropertyDateTimeOffset", null),
- DataCreator.createPrimitive("PropertyDecimal", 0),
- DataCreator.createPrimitive("PropertySingle", 0),
- DataCreator.createPrimitive("PropertyDouble", 0),
- DataCreator.createPrimitive("PropertyDuration", 0),
+ DataCreator.createPrimitive("PropertyDecimal", BigDecimal.valueOf(0)),
+ DataCreator.createPrimitive("PropertySingle", (float) 0),
+ DataCreator.createPrimitive("PropertyDouble", 0D),
+ DataCreator.createPrimitive("PropertyDuration", BigDecimal.valueOf(0)),
DataCreator.createPrimitive("PropertyGuid", null),
DataCreator.createPrimitive("PropertyInt16", null),
DataCreator.createPrimitive("PropertyInt32", null),
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/de64c318/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
index 6a2f658..341a7b1 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
@@ -18,6 +18,7 @@
*/
package org.apache.olingo.server.tecsvc.data;
+import java.math.BigDecimal;
import java.nio.charset.Charset;
import java.sql.Timestamp;
import java.util.ArrayList;
@@ -72,106 +73,59 @@ public class DataCreator {
linkESTwoKeyNav(data);
}
- @SuppressWarnings("unchecked")
private EntityCollection createESCompMixPrimCollComp() {
final EntityCollection entityCollection = new EntityCollection();
- entityCollection.getEntities().add(new Entity()
- .addProperty(createPrimitive("PropertyInt16", 1))
+ entityCollection.getEntities().add(createETCompMixPrimCollComp((short) 1));
+ entityCollection.getEntities().add(createETCompMixPrimCollComp((short) 2));
+ entityCollection.getEntities().add(createETCompMixPrimCollComp((short) 3));
+
+ return entityCollection;
+ }
+
+ @SuppressWarnings("unchecked")
+ private Entity createETCompMixPrimCollComp(Short propertyInt16) {
+ return new Entity()
+ .addProperty(createPrimitive("PropertyInt16",(short) 1))
.addProperty(createComplex("PropertyMixedPrimCollComp",
- createPrimitive("PropertyInt16", 1),
+ createPrimitive("PropertyInt16",(short) 1),
createPrimitiveCollection("CollPropertyString",
- "Employee1@company.example",
- "Employee2@company.example",
- "Employee3@company.example"
- ),
- createComplex("PropertyComp",
- createPrimitive("PropertyInt16", 333),
- createPrimitive("PropertyString", "TEST123")
- ),
- createComplexCollection("CollPropertyComp",
- Arrays.asList(new Property[] {
- createPrimitive("PropertyInt16", 222),
- createPrimitive("PropertyString", "TEST9876")
- }),
- Arrays.asList(new Property[] {
- createPrimitive("PropertyInt16", 333),
- createPrimitive("PropertyString", "TEST123")
- })
- )
- ))
- );
-
- entityCollection.getEntities().add(new Entity()
- .addProperty(createPrimitive("PropertyInt16", 2))
- .addProperty(createComplex("PropertyMixedPrimCollComp",
- createPrimitive("PropertyInt16", 1),
- createPrimitiveCollection("CollPropertyString",
- "Employee1@company.example",
- "Employee2@company.example",
- "Employee3@company.example"
- ),
- createComplex("PropertyComp",
- createPrimitive("PropertyInt16", 333),
- createPrimitive("PropertyString", "TEST123")
- ),
- createComplexCollection("CollPropertyComp",
- Arrays.asList(new Property[] {
- createPrimitive("PropertyInt16", 222),
- createPrimitive("PropertyString", "TEST9876")
- }),
- Arrays.asList(new Property[] {
- createPrimitive("PropertyInt16", 333),
- createPrimitive("PropertyString", "TEST123")
- })
- )
- ))
- );
-
- entityCollection.getEntities().add(new Entity()
- .addProperty(createPrimitive("PropertyInt16", 3))
- .addProperty(createComplex("PropertyMixedPrimCollComp",
- createPrimitive("PropertyInt16", 1),
- createPrimitiveCollection("CollPropertyString",
"Employee1@company.example",
"Employee2@company.example",
"Employee3@company.example"
- ),
- createComplex("PropertyComp",
- createPrimitive("PropertyInt16", 333),
+ ),
+ createComplex("PropertyComp",
+ createPrimitive("PropertyInt16",(short) 333),
createPrimitive("PropertyString", "TEST123")
- ),
- createComplexCollection("CollPropertyComp",
- Arrays.asList(new Property[] {
- createPrimitive("PropertyInt16", 222),
+ ),
+ createComplexCollection("CollPropertyComp",
+ Arrays.asList(new Property[] {
+ createPrimitive("PropertyInt16",(short) 222),
createPrimitive("PropertyString", "TEST9876")
}),
Arrays.asList(new Property[] {
- createPrimitive("PropertyInt16", 333),
+ createPrimitive("PropertyInt16",(short) 333),
createPrimitive("PropertyString", "TEST123")
})
- )
- ))
- );
-
- return entityCollection;
+ )
+ ));
}
-
+
private EntityCollection createESBase() {
final EntityCollection entityCollection = new EntityCollection();
entityCollection.getEntities().add(new Entity()
- .addProperty(createPrimitive("PropertyInt16", 111))
+ .addProperty(createPrimitive("PropertyInt16",(short) 111))
.addProperty(createPrimitive("PropertyString", "TEST A"))
.addProperty(createPrimitive("AdditionalPropertyString_5", "TEST A 0815")));
entityCollection.getEntities().add(new Entity()
- .addProperty(createPrimitive("PropertyInt16", 222))
+ .addProperty(createPrimitive("PropertyInt16",(short) 222))
.addProperty(createPrimitive("PropertyString", "TEST B"))
.addProperty(createPrimitive("AdditionalPropertyString_5", "TEST C 0815")));
entityCollection.getEntities().add(new Entity()
- .addProperty(createPrimitive("PropertyInt16", 333))
+ .addProperty(createPrimitive("PropertyInt16",(short) 333))
.addProperty(createPrimitive("PropertyString", "TEST C"))
.addProperty(createPrimitive("AdditionalPropertyString_5", "TEST E 0815")));
@@ -183,14 +137,14 @@ public class DataCreator {
final EntityCollection entityCollection = new EntityCollection();
entityCollection.getEntities().add(new Entity()
- .addProperty(createPrimitive("PropertyInt16", 1))
+ .addProperty(createPrimitive("PropertyInt16",(short) 1))
.addProperty(createComplex("PropertyComp",
- createPrimitive("PropertyInt16", 11),
+ createPrimitive("PropertyInt16",(short) 11),
createPrimitive("PropertyString", "Num11")
))
.addProperty(createComplex("PropertyCompComp",
createComplex("PropertyComp",
- createPrimitive("PropertyInt16", 111),
+ createPrimitive("PropertyInt16",(short) 111),
createPrimitive("PropertyString", "Num111")
)
))
@@ -202,23 +156,61 @@ public class DataCreator {
private EntityCollection createESCompCollAllPrim() {
final EntityCollection entityCollection = new EntityCollection();
- entityCollection.getEntities().add(new Entity()
- .addProperty(createPrimitive("PropertyInt16", 5678))
+
+ entityCollection.getEntities().add(createETCompCollAllPrim((short) 5678));
+ entityCollection.getEntities().add(createETCompCollAllPrim((short) 12326));
+
+ return entityCollection;
+ }
+
+ private Entity createETCompCollAllPrim(short propertyInt16) {
+ return new Entity()
+ .addProperty(createPrimitive("PropertyInt16", propertyInt16))
.addProperty(createComplex("PropertyComp",
createPrimitiveCollection("CollPropertyString",
"Employee1@company.example",
"Employee2@company.example",
"Employee3@company.example"),
- createPrimitiveCollection("CollPropertyBoolean", true, false, true),
- createPrimitiveCollection("CollPropertyByte", 50, 200, 249),
- createPrimitiveCollection("CollPropertySByte", -120, 120, 126),
- createPrimitiveCollection("CollPropertyInt16", 1000, 2000, 30112),
- createPrimitiveCollection("CollPropertyInt32", 23232323, 11223355, 10000001),
- createPrimitiveCollection("CollPropertyInt64", 929292929292L, 333333333333L, 444444444444L),
- createPrimitiveCollection("CollPropertySingle", 1790, 26600, 3210),
- createPrimitiveCollection("CollPropertyDouble", -17900, -27800000, 3210),
- createPrimitiveCollection("CollPropertyDecimal", 12, -2, 1234),
- createPrimitiveCollection("CollPropertyByte", 50, 200, 249),
+ createPrimitiveCollection("CollPropertyBoolean",
+ true,
+ false,
+ true),
+ createPrimitiveCollection("CollPropertyByte",
+ (short) 50,
+ (short) 200,
+ (short) 249),
+ createPrimitiveCollection("CollPropertySByte",
+ (byte) -120,
+ (byte) 120,
+ (byte) 126),
+ createPrimitiveCollection("CollPropertyInt16",
+ (short) 1000,
+ (short) 2000,
+ (short) 30112),
+ createPrimitiveCollection("CollPropertyInt32",
+ 23232323,
+ 11223355,
+ 10000001),
+ createPrimitiveCollection("CollPropertyInt64",
+ 929292929292L,
+ 333333333333L,
+ 444444444444L),
+ createPrimitiveCollection("CollPropertySingle",
+ (float) 1790,
+ (float) 26600,
+ (float) 3210),
+ createPrimitiveCollection("CollPropertyDouble",
+ -17900D,
+ -27800000D,
+ 3210D),
+ createPrimitiveCollection("CollPropertyDecimal",
+ BigDecimal.valueOf(12),
+ BigDecimal.valueOf(-2),
+ BigDecimal.valueOf(1234)),
+ createPrimitiveCollection("CollPropertyByte",
+ (short) 50,
+ (short) 200,
+ (short) 249),
createPrimitiveCollection("CollPropertyBinary",
new byte[] { -85, -51, -17 },
new byte[] { 1, 35, 69 },
@@ -249,94 +241,45 @@ public class DataCreator {
getTime(23, 59, 59),
getTime(1, 12, 33)
)
- ))
- );
-
- entityCollection.getEntities().add(new Entity()
- .addProperty(createPrimitive("PropertyInt16", 12326))
- .addProperty(createComplex("PropertyComp",
- createPrimitiveCollection("CollPropertyString",
- "Employee1@company.example",
- "Employee2@company.example",
- "Employee3@company.example"),
- createPrimitiveCollection("CollPropertyBoolean", true, false, true),
- createPrimitiveCollection("CollPropertyByte", 50, 200, 249),
- createPrimitiveCollection("CollPropertySByte", -120, 120, 126),
- createPrimitiveCollection("CollPropertyInt16", 1000, 2000, 30112),
- createPrimitiveCollection("CollPropertyInt32", 23232323, 11223355, 10000001),
- createPrimitiveCollection("CollPropertyInt64", 929292929292L, 333333333333L, 444444444444L),
- createPrimitiveCollection("CollPropertySingle", 1790, 26600, 3210),
- createPrimitiveCollection("CollPropertyDouble", -17900, -27800000, 3210),
- createPrimitiveCollection("CollPropertyDecimal", 12, -2, 1234),
- createPrimitiveCollection("CollPropertyByte", 50, 200, 249),
- createPrimitiveCollection("CollPropertyBinary",
- new byte[] { -85, -51, -17 },
- new byte[] { 1, 35, 69 },
- new byte[] { 84, 103, -119 }
- ),
- createPrimitiveCollection("CollPropertyDate",
- getDateTime(1958, 12, 3, 0, 0, 0),
- getDateTime(1999, 8, 5, 0, 0, 0),
- getDateTime(2013, 6, 25, 0, 0, 0)
- ),
- createPrimitiveCollection("CollPropertyDateTimeOffset",
- getDateTime(2015, 8, 12, 3, 8, 34),
- getDateTime(1970, 3, 28, 12, 11, 10),
- getDateTime(1948, 2, 17, 9, 9, 9)
- ),
- createPrimitiveCollection("CollPropertyDuration",
- getDurration(0, 0, 0, 13),
- getDurration(0, 5, 28, 20),
- getDurration(0, 1, 0, 0)
- ),
- createPrimitiveCollection("CollPropertyGuid",
- UUID.fromString("ffffff67-89ab-cdef-0123-456789aaaaaa"),
- UUID.fromString("eeeeee67-89ab-cdef-0123-456789bbbbbb"),
- UUID.fromString("cccccc67-89ab-cdef-0123-456789cccccc")
- ),
- createPrimitiveCollection("CollPropertyTimeOfDay",
- getTime(4, 14, 13),
- getTime(23, 59, 59),
- getTime(1, 12, 33)
- )
- ))
- );
-
- return entityCollection;
+ ));
}
-
+
private EntityCollection createESBaseTwoKeyNav() {
final EntityCollection entityCollection = new EntityCollection();
- entityCollection.getEntities().add(createESTwoKeyNavEntity(1, "1")
- .addProperty(createPrimitive("PropertyDate", getDateTime(2013, 12, 12, 0, 0, 0))));
+ entityCollection.getEntities().add(
+ createESTwoKeyNavEntity((short) 1, "1")
+ .addProperty(createPrimitive("PropertyDate", getDateTime(2013, 12, 12, 0, 0, 0))));
- entityCollection.getEntities().add(createESTwoKeyNavEntity(1, "2")
- .addProperty(createPrimitive("PropertyDate", getDateTime(2013, 12, 12, 0, 0, 0))));
+ entityCollection.getEntities().add(
+ createESTwoKeyNavEntity((short) 1, "2")
+ .addProperty(createPrimitive("PropertyDate", getDateTime(2013, 12, 12, 0, 0, 0))));
- entityCollection.getEntities().add(createESTwoKeyNavEntity(2, "1")
- .addProperty(createPrimitive("PropertyDate", getDateTime(2013, 12, 12, 0, 0, 0))));
+ entityCollection.getEntities().add(
+ createESTwoKeyNavEntity((short) 2, "1")
+ .addProperty(createPrimitive("PropertyDate", getDateTime(2013, 12, 12, 0, 0, 0))));
- entityCollection.getEntities().add(createESTwoKeyNavEntity(3, "1")
- .addProperty(createPrimitive("PropertyDate", getDateTime(2013, 12, 12, 0, 0, 0))));
+ entityCollection.getEntities().add(
+ createESTwoKeyNavEntity((short) 3, "1")
+ .addProperty(createPrimitive("PropertyDate", getDateTime(2013, 12, 12, 0, 0, 0))));
return entityCollection;
}
private EntityCollection createESTwoBase() {
final EntityCollection entityCollection = new EntityCollection();
entityCollection.getEntities().add(new Entity()
- .addProperty(createPrimitive("PropertyInt16", 111))
+ .addProperty(createPrimitive("PropertyInt16",(short) 111))
.addProperty(createPrimitive("PropertyString", "TEST A"))
.addProperty(createPrimitive("AdditionalPropertyString_5", "TEST A 0815"))
.addProperty(createPrimitive("AdditionalPropertyString_6", "TEST B 0815")));
entityCollection.getEntities().add(new Entity()
- .addProperty(createPrimitive("PropertyInt16", 222))
+ .addProperty(createPrimitive("PropertyInt16",(short) 222))
.addProperty(createPrimitive("PropertyString", "TEST B"))
.addProperty(createPrimitive("AdditionalPropertyString_5", "TEST C 0815"))
.addProperty(createPrimitive("AdditionalPropertyString_6", "TEST D 0815")));
entityCollection.getEntities().add(new Entity()
- .addProperty(createPrimitive("PropertyInt16", 333))
+ .addProperty(createPrimitive("PropertyInt16",(short) 333))
.addProperty(createPrimitive("PropertyString", "TEST C"))
.addProperty(createPrimitive("AdditionalPropertyString_5", "TEST E 0815"))
.addProperty(createPrimitive("AdditionalPropertyString_6", "TEST F 0815")));
@@ -348,7 +291,7 @@ public class DataCreator {
final EntityCollection entityCollection = new EntityCollection();
entityCollection.getEntities().add(
new Entity()
- .addProperty(createPrimitive("PropertyKey", 1))
+ .addProperty(createPrimitive("PropertyKey",(short) 1))
.addProperty(createPrimitive("PropertyInt16", null))
.addProperty(createPrimitive("PropertyString", null))
.addProperty(createPrimitive("PropertyBoolean", null))
@@ -369,15 +312,42 @@ public class DataCreator {
"spiderman@comic.com",
null,
"spidergirl@comic.com"))
- .addProperty(createPrimitiveCollection("CollPropertyBoolean", true, null, false))
- .addProperty(createPrimitiveCollection("CollPropertyByte", 50, null, 249))
- .addProperty(createPrimitiveCollection("CollPropertySByte", -120, null, 126))
- .addProperty(createPrimitiveCollection("CollPropertyInt16", 1000, null, 30112))
- .addProperty(createPrimitiveCollection("CollPropertyInt32", 23232323, null, 10000001))
- .addProperty(createPrimitiveCollection("CollPropertyInt64", 929292929292L, null, 444444444444L))
- .addProperty(createPrimitiveCollection("CollPropertySingle", 1790, null, 3210))
- .addProperty(createPrimitiveCollection("CollPropertyDouble", -17900, null, 3210))
- .addProperty(createPrimitiveCollection("CollPropertyDecimal", 12, null, 1234))
+ .addProperty(createPrimitiveCollection("CollPropertyBoolean",
+ true,
+ null,
+ false))
+ .addProperty(createPrimitiveCollection("CollPropertyByte",
+ (short) 50,
+ null,
+ (short) 249))
+ .addProperty(createPrimitiveCollection("CollPropertySByte",
+ (byte) -120,
+ null,
+ (byte) 126))
+ .addProperty(createPrimitiveCollection("CollPropertyInt16",
+ (short) 1000,
+ null,
+ (short) 30112))
+ .addProperty(createPrimitiveCollection("CollPropertyInt32",
+ 23232323,
+ null,
+ 10000001))
+ .addProperty(createPrimitiveCollection("CollPropertyInt64",
+ 929292929292L,
+ null,
+ 444444444444L))
+ .addProperty(createPrimitiveCollection("CollPropertySingle",
+ (float) 1790,
+ null,
+ (float) 3210))
+ .addProperty(createPrimitiveCollection("CollPropertyDouble",
+ -17900D,
+ null,
+ 3210D))
+ .addProperty(createPrimitiveCollection("CollPropertyDecimal",
+ BigDecimal.valueOf(12),
+ null,
+ BigDecimal.valueOf(1234)))
.addProperty(createPrimitiveCollection("CollPropertyBinary",
new byte[] { -85, -51, -17 },
null,
@@ -421,16 +391,18 @@ public class DataCreator {
}
private Entity createETTwoKeyTwoPrimEntity(final short propertyInt16, final String propertyString) {
- return new Entity().addProperty(createPrimitive("PropertyInt16", propertyInt16))
+ return new Entity()
+ .addProperty(createPrimitive("PropertyInt16", propertyInt16))
.addProperty(createPrimitive("PropertyString", propertyString));
}
private EntityCollection createESServerSidePaging() {
EntityCollection entityCollection = new EntityCollection();
- for (int i = 1; i <= 503; i++) {
- entityCollection.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", i))
- .addProperty(createPrimitive("PropertyString", "Number:" + i)));
+ for (short i = 1; i <= 503; i++) {
+ entityCollection.getEntities().add(new Entity()
+ .addProperty(createPrimitive("PropertyInt16", i))
+ .addProperty(createPrimitive("PropertyString", "Number:" + i)));
}
return entityCollection;
@@ -439,79 +411,109 @@ public class DataCreator {
private EntityCollection createESKeyNav() {
final EntityCollection entityCollection = new EntityCollection();
- entityCollection.getEntities().add(createETKeyNavEntity(1, "I am String Property 1"));
- entityCollection.getEntities().add(createETKeyNavEntity(2, "I am String Property 2"));
- entityCollection.getEntities().add(createETKeyNavEntity(3, "I am String Property 3"));
+ entityCollection.getEntities().add(createETKeyNavEntity((short) 1, "I am String Property 1"));
+ entityCollection.getEntities().add(createETKeyNavEntity((short) 2, "I am String Property 2"));
+ entityCollection.getEntities().add(createETKeyNavEntity((short) 3, "I am String Property 3"));
return entityCollection;
}
@SuppressWarnings("unchecked")
- private Entity createETKeyNavEntity(final int propertyInt16, final String propertyString) {
- return new Entity().addProperty(createPrimitive("PropertyInt16", propertyInt16))
+ private Entity createETKeyNavEntity(final short propertyInt16, final String propertyString) {
+ return new Entity()
+ .addProperty(createPrimitive("PropertyInt16", propertyInt16))
.addProperty(createPrimitive("PropertyString", propertyString))
- .addProperty(createComplex("PropertyCompNav", createPrimitive("PropertyInt16", 1)))
- .addProperty(createKeyNavAllPrimComplexValue("PropertyCompAllPrim")).addProperty(
- createComplex("PropertyCompTwoPrim", createPrimitive("PropertyInt16", 16),
- createPrimitive("PropertyString", "Test123"))).addProperty(
- createPrimitiveCollection("CollPropertyString", "Employee1@company.example", "Employee2@company.example",
- "Employee3@company.example"))
- .addProperty(createPrimitiveCollection("CollPropertyInt16", 1000, 2000, 30112)).addProperty(
- createComplexCollection("CollPropertyComp",
- Arrays.asList(createPrimitive("PropertyInt16", 1), createKeyNavAllPrimComplexValue("PropertyComp")),
- Arrays.asList(createPrimitive("PropertyInt16", 2), createKeyNavAllPrimComplexValue("PropertyComp")),
- Arrays.asList(createPrimitive("PropertyInt16", 3), createKeyNavAllPrimComplexValue("PropertyComp"))))
- .addProperty(createComplex("PropertyCompCompNav", createPrimitive("PropertyString", "1"),
- createComplex("PropertyCompNav", createPrimitive("PropertyInt16", 1))));
+ .addProperty(createComplex("PropertyCompNav",
+ createPrimitive("PropertyInt16", 1)))
+ .addProperty(createKeyNavAllPrimComplexValue("PropertyCompAllPrim"))
+ .addProperty(createComplex("PropertyCompTwoPrim",
+ createPrimitive("PropertyInt16",(short) 16),
+ createPrimitive("PropertyString", "Test123")))
+ .addProperty(createPrimitiveCollection("CollPropertyString",
+ "Employee1@company.example",
+ "Employee2@company.example",
+ "Employee3@company.example"))
+ .addProperty(createPrimitiveCollection("CollPropertyInt16",
+ (short) 1000,
+ (short) 2000,
+ (short) 30112))
+ .addProperty(createComplexCollection("CollPropertyComp",
+ Arrays.asList(
+ createPrimitive("PropertyInt16",(short) 1),
+ createKeyNavAllPrimComplexValue("PropertyComp")),
+ Arrays.asList(
+ createPrimitive("PropertyInt16",(short) 2),
+ createKeyNavAllPrimComplexValue("PropertyComp")),
+ Arrays.asList(
+ createPrimitive("PropertyInt16",(short) 3),
+ createKeyNavAllPrimComplexValue("PropertyComp"))))
+ .addProperty(createComplex("PropertyCompCompNav",
+ createPrimitive("PropertyString", "1"),
+ createComplex("PropertyCompNav",
+ createPrimitive("PropertyInt16",(short) 1))));
}
private EntityCollection createESTwoKeyNav() {
final EntityCollection entityCollection = new EntityCollection();
- entityCollection.getEntities().add(createESTwoKeyNavEntity(1, "1"));
- entityCollection.getEntities().add(createESTwoKeyNavEntity(1, "2"));
- entityCollection.getEntities().add(createESTwoKeyNavEntity(2, "1"));
- entityCollection.getEntities().add(createESTwoKeyNavEntity(3, "1"));
+ entityCollection.getEntities().add(createESTwoKeyNavEntity((short) 1, "1"));
+ entityCollection.getEntities().add(createESTwoKeyNavEntity((short) 1, "2"));
+ entityCollection.getEntities().add(createESTwoKeyNavEntity((short) 2, "1"));
+ entityCollection.getEntities().add(createESTwoKeyNavEntity((short) 3, "1"));
return entityCollection;
}
@SuppressWarnings("unchecked")
- private Entity createESTwoKeyNavEntity(final int propertyInt16, final String propertyString) {
+ private Entity createESTwoKeyNavEntity(final short propertyInt16, final String propertyString) {
return new Entity()
.addProperty(createPrimitive("PropertyInt16", propertyInt16))
.addProperty(createPrimitive("PropertyString", propertyString))
- .addProperty(
- createComplex("PropertyComp", createPrimitive("PropertyInt16", 11),
- createComplex("PropertyComp", createPrimitive("PropertyString", "StringValue"),
- createPrimitive("PropertyBinary", new byte[] { 1, 35, 69, 103, -119, -85, -51, -17 }),
- createPrimitive("PropertyBoolean", true), createPrimitive("PropertyByte", 255),
- createPrimitive("PropertyDate", getDateTime(2012, 12, 3, 7, 16, 23)),
- createPrimitive("PropertyDecimal", 34), createPrimitive("PropertySingle", 179000000000000000000D),
- createPrimitive("PropertyDouble", -179000000000000000000D), createPrimitive("PropertyDuration", 6),
- createPrimitive("PropertyGuid", UUID.fromString("01234567-89ab-cdef-0123-456789abcdef")),
- createPrimitive("PropertyInt16", Short.MAX_VALUE),
- createPrimitive("PropertyInt32", Integer.MAX_VALUE),
- createPrimitive("PropertyInt64", Long.MAX_VALUE), createPrimitive("PropertySByte", Byte.MAX_VALUE),
- createPrimitive("PropertyTimeOfDay", getTime(21, 5, 59)))))
- .addProperty(
- createComplex("PropertyCompNav", createPrimitive("PropertyInt16", 1),
- createKeyNavAllPrimComplexValue("PropertyComp")))
+ .addProperty(createComplex("PropertyComp",
+ createPrimitive("PropertyInt16", 11),
+ createComplex("PropertyComp",
+ createPrimitive("PropertyString", "StringValue"),
+ createPrimitive("PropertyBinary", new byte[] { 1, 35, 69, 103, -119, -85, -51, -17 }),
+ createPrimitive("PropertyBoolean", true),
+ createPrimitive("PropertyByte", (short) 255),
+ createPrimitive("PropertyDate", getDateTime(2012, 12, 3, 7, 16, 23)),
+ createPrimitive("PropertyDecimal", BigDecimal.valueOf(34)),
+ createPrimitive("PropertySingle", (float) 179000000000000000000D),
+ createPrimitive("PropertyDouble", -179000000000000000000D),
+ createPrimitive("PropertyDuration", BigDecimal.valueOf(6)),
+ createPrimitive("PropertyGuid", UUID.fromString("01234567-89ab-cdef-0123-456789abcdef")),
+ createPrimitive("PropertyInt16", Short.MAX_VALUE),
+ createPrimitive("PropertyInt32", Integer.MAX_VALUE),
+ createPrimitive("PropertyInt64", Long.MAX_VALUE),
+ createPrimitive("PropertySByte", Byte.MAX_VALUE),
+ createPrimitive("PropertyTimeOfDay", getTime(21, 5, 59)))))
+ .addProperty(createComplex("PropertyCompNav",
+ createPrimitive("PropertyInt16", (short) 1),
+ createKeyNavAllPrimComplexValue("PropertyComp")))
.addProperty(createComplexCollection("CollPropertyComp"))
- .addProperty(createComplexCollection("CollPropertyCompNav", Arrays.asList(createPrimitive("PropertyInt16", 1))))
- .addProperty(createPrimitiveCollection("CollPropertyString", 1, 2)).addProperty(
- createComplex("PropertyCompTwoPrim", createPrimitive("PropertyInt16", 11),
- createPrimitive("PropertyString", "11")));
+ .addProperty(createComplexCollection("CollPropertyCompNav",
+ Arrays.asList(
+ createPrimitive("PropertyInt16", (short) 1))))
+ .addProperty(createPrimitiveCollection("CollPropertyString",
+ "1",
+ "2"))
+ .addProperty(createComplex("PropertyCompTwoPrim",
+ createPrimitive("PropertyInt16", (short) 11),
+ createPrimitive("PropertyString", "11")));
}
protected Property createKeyNavAllPrimComplexValue(final String name) {
- return createComplex(name, createPrimitive("PropertyString", "First Resource - positive values"),
+ return createComplex(name,
+ createPrimitive("PropertyString", "First Resource - positive values"),
createPrimitive("PropertyBinary", new byte[] { 1, 35, 69, 103, -119, -85, -51, -17 }),
- createPrimitive("PropertyBoolean", true), createPrimitive("PropertyByte", 255),
+ createPrimitive("PropertyBoolean", true),
+ createPrimitive("PropertyByte", (short) 255),
createPrimitive("PropertyDate", getDateTime(2012, 12, 3, 7, 16, 23)),
createPrimitive("PropertyDateTimeOffset", getTimestamp(2012, 12, 3, 7, 16, 23, 0)),
- createPrimitive("PropertyDecimal", 34), createPrimitive("PropertySingle", 179000000000000000000D),
- createPrimitive("PropertyDouble", -179000000000000000000D), createPrimitive("PropertyDuration", 6),
+ createPrimitive("PropertyDecimal", 34),
+ createPrimitive("PropertySingle", (float) 179000000000000000000D),
+ createPrimitive("PropertyDouble", -179000000000000000000D),
+ createPrimitive("PropertyDuration", BigDecimal.valueOf(6)),
createPrimitive("PropertyGuid", UUID.fromString("01234567-89ab-cdef-0123-456789abcdef")),
createPrimitive("PropertyInt16", Short.MAX_VALUE), createPrimitive("PropertyInt32", Integer.MAX_VALUE),
createPrimitive("PropertyInt64", Long.MAX_VALUE), createPrimitive("PropertySByte", Byte.MAX_VALUE),
@@ -522,23 +524,33 @@ public class DataCreator {
private EntityCollection createESCompCollComp() {
final EntityCollection entityCollection = new EntityCollection();
- entityCollection.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
- .addProperty(createComplex("PropertyComp", createComplexCollection("CollPropertyComp", Arrays
- .asList(createPrimitive("PropertyInt16", 555),
- createPrimitive("PropertyString", "1 Test Complex in Complex Property")), Arrays
- .asList(createPrimitive("PropertyInt16", 666),
- createPrimitive("PropertyString", "2 Test Complex in Complex Property")), Arrays
- .asList(createPrimitive("PropertyInt16", 777),
- createPrimitive("PropertyString", "3 Test Complex in Complex Property"))))));
-
- entityCollection.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", 12345)).addProperty(
- createComplex("PropertyComp", createComplexCollection("CollPropertyComp", Arrays
- .asList(createPrimitive("PropertyInt16", 888),
- createPrimitive("PropertyString", "11 Test Complex in Complex Property")), Arrays
- .asList(createPrimitive("PropertyInt16", 999),
- createPrimitive("PropertyString", "12 Test Complex in Complex Property")), Arrays
- .asList(createPrimitive("PropertyInt16", 0),
- createPrimitive("PropertyString", "13 Test Complex in Complex Property"))))));
+ entityCollection.getEntities().add(new Entity()
+ .addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
+ .addProperty(createComplex("PropertyComp",
+ createComplexCollection("CollPropertyComp",
+ Arrays.asList(
+ createPrimitive("PropertyInt16",(short) 555),
+ createPrimitive("PropertyString", "1 Test Complex in Complex Property")),
+ Arrays.asList(
+ createPrimitive("PropertyInt16",(short) 666),
+ createPrimitive("PropertyString", "2 Test Complex in Complex Property")),
+ Arrays.asList(
+ createPrimitive("PropertyInt16",(short) 777),
+ createPrimitive("PropertyString", "3 Test Complex in Complex Property"))))));
+
+ entityCollection.getEntities().add(new Entity()
+ .addProperty(createPrimitive("PropertyInt16", 12345))
+ .addProperty(createComplex("PropertyComp",
+ createComplexCollection("CollPropertyComp",
+ Arrays.asList(
+ createPrimitive("PropertyInt16",(short) 888),
+ createPrimitive("PropertyString", "11 Test Complex in Complex Property")),
+ Arrays.asList(
+ createPrimitive("PropertyInt16",(short) 999),
+ createPrimitive("PropertyString", "12 Test Complex in Complex Property")),
+ Arrays.asList(
+ createPrimitive("PropertyInt16",(short) 0),
+ createPrimitive("PropertyString", "13 Test Complex in Complex Property"))))));
return entityCollection;
}
@@ -546,17 +558,21 @@ public class DataCreator {
private EntityCollection createESTwoPrim() {
EntityCollection entityCollection = new EntityCollection();
- entityCollection.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", 32766))
- .addProperty(createPrimitive("PropertyString", "Test String1")));
+ entityCollection.getEntities().add(new Entity()
+ .addProperty(createPrimitive("PropertyInt16", (short) 32766))
+ .addProperty(createPrimitive("PropertyString", "Test String1")));
- entityCollection.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", -365))
- .addProperty(createPrimitive("PropertyString", "Test String2")));
+ entityCollection.getEntities().add(new Entity()
+ .addProperty(createPrimitive("PropertyInt16", (short) -365))
+ .addProperty(createPrimitive("PropertyString", "Test String2")));
- entityCollection.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", -32766))
- .addProperty(createPrimitive("PropertyString", null)));
+ entityCollection.getEntities().add(new Entity()
+ .addProperty(createPrimitive("PropertyInt16", (short) -32766))
+ .addProperty(createPrimitive("PropertyString", null)));
- entityCollection.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
- .addProperty(createPrimitive("PropertyString", "Test String4")));
+ entityCollection.getEntities().add(new Entity()
+ .addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
+ .addProperty(createPrimitive("PropertyString", "Test String4")));
return entityCollection;
}
@@ -564,47 +580,59 @@ public class DataCreator {
private EntityCollection createESAllPrim() {
EntityCollection entityCollection = new EntityCollection();
- entityCollection.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
- .addProperty(createPrimitive("PropertyString", "First Resource - positive values"))
- .addProperty(createPrimitive("PropertyBoolean", true)).addProperty(createPrimitive("PropertyByte", 255))
- .addProperty(createPrimitive("PropertySByte", Byte.MAX_VALUE))
- .addProperty(createPrimitive("PropertyInt32", Integer.MAX_VALUE))
- .addProperty(createPrimitive("PropertyInt64", Long.MAX_VALUE))
- .addProperty(createPrimitive("PropertySingle", 1.79000000E+20))
- .addProperty(createPrimitive("PropertyDouble", -1.7900000000000000E+19))
- .addProperty(createPrimitive("PropertyDecimal", 34)).addProperty(createPrimitive("PropertyBinary",
- new byte[] { 0x01, 0x23, 0x45, 0x67, (byte) 0x89, (byte) 0xAB, (byte) 0xCD, (byte) 0xEF }))
- .addProperty(createPrimitive("PropertyDate", getDateTime(2012, 12, 3, 0, 0, 0)))
- .addProperty(createPrimitive("PropertyDateTimeOffset", getDateTime(2012, 12, 3, 7, 16, 23)))
- .addProperty(createPrimitive("PropertyDuration", 6)).addProperty(createPrimitive("PropertyGuid", GUID))
- .addProperty(createPrimitive("PropertyTimeOfDay", getTime(3, 26, 5))));
+ entityCollection.getEntities().add(new Entity()
+ .addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
+ .addProperty(createPrimitive("PropertyString", "First Resource - positive values"))
+ .addProperty(createPrimitive("PropertyBoolean", true))
+ .addProperty(createPrimitive("PropertyByte", (short) 255))
+ .addProperty(createPrimitive("PropertySByte", Byte.MAX_VALUE))
+ .addProperty(createPrimitive("PropertyInt32", Integer.MAX_VALUE))
+ .addProperty(createPrimitive("PropertyInt64", Long.MAX_VALUE))
+ .addProperty(createPrimitive("PropertySingle", (float) 1.79000000E+20))
+ .addProperty(createPrimitive("PropertyDouble", -1.7900000000000000E+19))
+ .addProperty(createPrimitive("PropertyDecimal", BigDecimal.valueOf(34)))
+ .addProperty(createPrimitive("PropertyBinary",
+ new byte[] { 0x01, 0x23, 0x45, 0x67, (byte) 0x89, (byte) 0xAB, (byte) 0xCD, (byte) 0xEF }))
+ .addProperty(createPrimitive("PropertyDate", getDateTime(2012, 12, 3, 0, 0, 0)))
+ .addProperty(createPrimitive("PropertyDateTimeOffset", getDateTime(2012, 12, 3, 7, 16, 23)))
+ .addProperty(createPrimitive("PropertyDuration", BigDecimal.valueOf(6)))
+ .addProperty(createPrimitive("PropertyGuid", GUID))
+ .addProperty(createPrimitive("PropertyTimeOfDay", getTime(3, 26, 5))));
- entityCollection.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", Short.MIN_VALUE))
+ entityCollection.getEntities().add(new Entity()
+ .addProperty(createPrimitive("PropertyInt16", Short.MIN_VALUE))
.addProperty(createPrimitive("PropertyString", "Second Resource - negative values"))
- .addProperty(createPrimitive("PropertyBoolean", false)).addProperty(createPrimitive("PropertyByte", 0))
+ .addProperty(createPrimitive("PropertyBoolean", false))
+ .addProperty(createPrimitive("PropertyByte", (short) 0))
.addProperty(createPrimitive("PropertySByte", Byte.MIN_VALUE))
.addProperty(createPrimitive("PropertyInt32", Integer.MIN_VALUE))
.addProperty(createPrimitive("PropertyInt64", Long.MIN_VALUE))
- .addProperty(createPrimitive("PropertySingle", -1.79000000E+08))
+ .addProperty(createPrimitive("PropertySingle", (float) -1.79000000E+08))
.addProperty(createPrimitive("PropertyDouble", -1.7900000000000000E+05))
- .addProperty(createPrimitive("PropertyDecimal", -34)).addProperty(createPrimitive("PropertyBinary",
+ .addProperty(createPrimitive("PropertyDecimal", BigDecimal.valueOf(-34)))
+ .addProperty(createPrimitive("PropertyBinary",
new byte[] { 0x01, 0x23, 0x45, 0x67, (byte) 0x89, (byte) 0xAB, (byte) 0xCD, (byte) 0xEF }))
.addProperty(createPrimitive("PropertyDate", getDateTime(2015, 11, 5, 0, 0, 0)))
.addProperty(createPrimitive("PropertyDateTimeOffset", getDateTime(2005, 12, 3, 7, 17, 8)))
- .addProperty(createPrimitive("PropertyDuration", 9))
+ .addProperty(createPrimitive("PropertyDuration", BigDecimal.valueOf(9)))
.addProperty(createPrimitive("PropertyGuid", UUID.fromString("76543201-23ab-cdef-0123-456789dddfff")))
.addProperty(createPrimitive("PropertyTimeOfDay", getTime(23, 49, 14))));
- entityCollection.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", (short) 0))
- .addProperty(createPrimitive("PropertyString", "")).addProperty(createPrimitive("PropertyBoolean", false))
- .addProperty(createPrimitive("PropertyByte", 0)).addProperty(createPrimitive("PropertySByte", 0))
- .addProperty(createPrimitive("PropertyInt32", 0)).addProperty(createPrimitive("PropertyInt64", 0))
- .addProperty(createPrimitive("PropertySingle", 0)).addProperty(createPrimitive("PropertyDouble", 0))
- .addProperty(createPrimitive("PropertyDecimal", 0))
+ entityCollection.getEntities().add(new Entity()
+ .addProperty(createPrimitive("PropertyInt16", (short) 0))
+ .addProperty(createPrimitive("PropertyString", ""))
+ .addProperty(createPrimitive("PropertyBoolean", false))
+ .addProperty(createPrimitive("PropertyByte", (short) 0))
+ .addProperty(createPrimitive("PropertySByte", 0))
+ .addProperty(createPrimitive("PropertyInt32", 0))
+ .addProperty(createPrimitive("PropertyInt64", 0L))
+ .addProperty(createPrimitive("PropertySingle", (float) 0))
+ .addProperty(createPrimitive("PropertyDouble", 0D))
+ .addProperty(createPrimitive("PropertyDecimal", BigDecimal.valueOf(0)))
.addProperty(createPrimitive("PropertyBinary", new byte[] {}))
.addProperty(createPrimitive("PropertyDate", getDateTime(1970, 1, 1, 0, 0, 0)))
.addProperty(createPrimitive("PropertyDateTimeOffset", getDateTime(2005, 12, 3, 0, 0, 0)))
- .addProperty(createPrimitive("PropertyDuration", 0))
+ .addProperty(createPrimitive("PropertyDuration", BigDecimal.valueOf(0)))
.addProperty(createPrimitive("PropertyGuid", UUID.fromString("76543201-23ab-cdef-0123-456789cccddd")))
.addProperty(createPrimitive("PropertyTimeOfDay", getTime(0, 1, 1))));
@@ -614,52 +642,72 @@ public class DataCreator {
private EntityCollection createESCompAllPrim() {
EntityCollection entityCollection = new EntityCollection();
- Entity entity = new Entity();
- entity.addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE));
- entity.addProperty(createComplex("PropertyComp", createPrimitive("PropertyString", "First Resource - first"),
- createPrimitive("PropertyBinary",
- new byte[] { 0x01, 0x23, 0x45, 0x67, (byte) 0x89, (byte) 0xAB, (byte) 0xCD, (byte) 0xEF }),
- createPrimitive("PropertyBoolean", true), createPrimitive("PropertyByte", 255),
- createPrimitive("PropertyDate", getDateTime(2012, 10, 3, 0, 0, 0)),
- createPrimitive("PropertyDateTimeOffset", getTimestamp(2012, 10, 3, 7, 16, 23, 123456700)),
- createPrimitive("PropertyDecimal", 34.27), createPrimitive("PropertySingle", 1.79000000E+20),
- createPrimitive("PropertyDouble", -1.7900000000000000E+19), createPrimitive("PropertyDuration", 6),
- createPrimitive("PropertyGuid", GUID), createPrimitive("PropertyInt16", Short.MAX_VALUE),
- createPrimitive("PropertyInt32", Integer.MAX_VALUE), createPrimitive("PropertyInt64", Long.MAX_VALUE),
- createPrimitive("PropertySByte", Byte.MAX_VALUE), createPrimitive("PropertyTimeOfDay", getTime(1, 0, 1))));
+ Entity entity = new Entity()
+ .addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
+ .addProperty(createComplex("PropertyComp",
+ createPrimitive("PropertyString", "First Resource - first"),
+ createPrimitive("PropertyBinary",
+ new byte[] { 0x01, 0x23, 0x45, 0x67, (byte) 0x89, (byte) 0xAB, (byte) 0xCD, (byte) 0xEF }),
+ createPrimitive("PropertyBoolean", true),
+ createPrimitive("PropertyByte", (short) 255),
+ createPrimitive("PropertyDate", getDateTime(2012, 10, 3, 0, 0, 0)),
+ createPrimitive("PropertyDateTimeOffset", getTimestamp(2012, 10, 3, 7, 16, 23, 123456700)),
+ createPrimitive("PropertyDecimal", BigDecimal.valueOf(34.27)),
+ createPrimitive("PropertySingle", (float) 1.79000000E+20),
+ createPrimitive("PropertyDouble", -1.7900000000000000E+19),
+ createPrimitive("PropertyDuration", BigDecimal.valueOf(6)),
+ createPrimitive("PropertyGuid", GUID),
+ createPrimitive("PropertyInt16", Short.MAX_VALUE),
+ createPrimitive("PropertyInt32", Integer.MAX_VALUE),
+ createPrimitive("PropertyInt64", Long.MAX_VALUE),
+ createPrimitive("PropertySByte", Byte.MAX_VALUE),
+ createPrimitive("PropertyTimeOfDay", getTime(1, 0, 1))));
entity.setETag("W/\"" + Short.MAX_VALUE + '\"');
entityCollection.getEntities().add(entity);
- entity = new Entity();
- entity.addProperty(createPrimitive("PropertyInt16", 7));
- entity.addProperty(createComplex("PropertyComp", createPrimitive("PropertyString", "Second Resource - second"),
+ entity = new Entity()
+ .addProperty(createPrimitive("PropertyInt16",(short) 7))
+ .addProperty(createComplex("PropertyComp",
+ createPrimitive("PropertyString", "Second Resource - second"),
createPrimitive("PropertyBinary",
new byte[] { 0x01, 0x23, 0x45, 0x67, (byte) 0x89, (byte) 0xAB, (byte) 0xCD, (byte) 0xEF }),
- createPrimitive("PropertyBoolean", true), createPrimitive("PropertyByte", 255),
+ createPrimitive("PropertyBoolean", true),
+ createPrimitive("PropertyByte", (short) 255),
createPrimitive("PropertyDate", getDateTime(2013, 11, 4, 0, 0, 0)),
createPrimitive("PropertyDateTimeOffset", getDateTime(2013, 11, 4, 7, 16, 23)),
- createPrimitive("PropertyDecimal", 34.27), createPrimitive("PropertySingle", 1.79000000E+20),
- createPrimitive("PropertyDouble", -1.7900000000000000E+02), createPrimitive("PropertyDuration", 6),
- createPrimitive("PropertyGuid", GUID), createPrimitive("PropertyInt16", 25),
- createPrimitive("PropertyInt32", Integer.MAX_VALUE), createPrimitive("PropertyInt64", Long.MAX_VALUE),
+ createPrimitive("PropertyDecimal", BigDecimal.valueOf(34.27)),
+ createPrimitive("PropertySingle", (float) 1.79000000E+20),
+ createPrimitive("PropertyDouble", -1.7900000000000000E+02),
+ createPrimitive("PropertyDuration", BigDecimal.valueOf(6)),
+ createPrimitive("PropertyGuid", GUID),
+ createPrimitive("PropertyInt16", (short) 25),
+ createPrimitive("PropertyInt32", Integer.MAX_VALUE),
+ createPrimitive("PropertyInt64", Long.MAX_VALUE),
createPrimitive("PropertySByte", Byte.MAX_VALUE),
createPrimitive("PropertyTimeOfDay", getTimestamp(1, 1, 1, 7, 45, 12, 765432100))));
entity.setETag("W/\"7\"");
entityCollection.getEntities().add(entity);
- entity = new Entity();
- entity.addProperty(createPrimitive("PropertyInt16", 0));
- entity.addProperty(createComplex("PropertyComp", createPrimitive("PropertyString", "Third Resource - third"),
+ entity = new Entity()
+ .addProperty(createPrimitive("PropertyInt16", (short) 0))
+ .addProperty(createComplex("PropertyComp",
+ createPrimitive("PropertyString", "Third Resource - third"),
createPrimitive("PropertyBinary",
new byte[] { 0x01, 0x23, 0x45, 0x67, (byte) 0x89, (byte) 0xAB, (byte) 0xCD, (byte) 0xEF }),
- createPrimitive("PropertyBoolean", true), createPrimitive("PropertyByte", 255),
+ createPrimitive("PropertyBoolean", true),
+ createPrimitive("PropertyByte", (short) 255),
createPrimitive("PropertyDate", getDateTime(2014, 12, 5, 0, 0, 0)),
createPrimitive("PropertyDateTimeOffset", getTimestamp(2014, 12, 5, 8, 17, 45, 123456700)),
- createPrimitive("PropertyDecimal", 17.98), createPrimitive("PropertySingle", 1.79000000E+20),
- createPrimitive("PropertyDouble", -1.7900000000000000E+02), createPrimitive("PropertyDuration", 6),
- createPrimitive("PropertyGuid", GUID), createPrimitive("PropertyInt16", -25),
- createPrimitive("PropertyInt32", Integer.MAX_VALUE), createPrimitive("PropertyInt64", Long.MAX_VALUE),
- createPrimitive("PropertySByte", Byte.MAX_VALUE), createPrimitive("PropertyTimeOfDay", getTime(13, 27, 45))));
+ createPrimitive("PropertyDecimal", 17.98),
+ createPrimitive("PropertySingle", 1.79000000E+20),
+ createPrimitive("PropertyDouble", -1.7900000000000000E+02),
+ createPrimitive("PropertyDuration", BigDecimal.valueOf(6)),
+ createPrimitive("PropertyGuid", GUID),
+ createPrimitive("PropertyInt16", (short) -25),
+ createPrimitive("PropertyInt32", Integer.MAX_VALUE),
+ createPrimitive("PropertyInt64", Long.MAX_VALUE),
+ createPrimitive("PropertySByte", Byte.MAX_VALUE),
+ createPrimitive("PropertyTimeOfDay", getTime(13, 27, 45))));
entity.setETag("W/\"0\"");
entityCollection.getEntities().add(entity);
@@ -669,101 +717,166 @@ public class DataCreator {
private EntityCollection createESCollAllPrim() {
EntityCollection entityCollection = new EntityCollection();
- entityCollection.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", 1)).addProperty(
- createPrimitiveCollection("CollPropertyString", "Employee1@company.example", "Employee2@company.example",
- "Employee3@company.example"))
- .addProperty(createPrimitiveCollection("CollPropertyBoolean", true, false, true))
- .addProperty(createPrimitiveCollection("CollPropertyByte", 50, 200, 249))
- .addProperty(createPrimitiveCollection("CollPropertySByte", -120, 120, 126))
- .addProperty(createPrimitiveCollection("CollPropertyInt16", 1000, 2000, 30112))
- .addProperty(createPrimitiveCollection("CollPropertyInt32", 23232323, 11223355, 10000001))
- .addProperty(createPrimitiveCollection("CollPropertyInt64", 929292929292L, 333333333333L, 444444444444L))
- .addProperty(createPrimitiveCollection("CollPropertySingle", 1.79000000E+03, 2.66000000E+04, 3.21000000E+03))
- .addProperty(createPrimitiveCollection("CollPropertyDouble", -1.7900000000000000E+04, -2.7800000000000000E+07,
- 3.2100000000000000E+03)).addProperty(createPrimitiveCollection("CollPropertyDecimal", 12, -2, 1234))
- .addProperty(
- createPrimitiveCollection("CollPropertyBinary", new byte[] { (byte) 0xAB, (byte) 0xCD, (byte) 0xEF }, new
- byte[] { 0x01, 0x23, 0x45 },
- new byte[] { 0x54, 0x67, (byte) 0x89 })).addProperty(
- createPrimitiveCollection("CollPropertyDate", getDateTime(1958, 12, 3, 0, 0, 0),
- getDateTime(1999, 8, 5, 0, 0, 0), getDateTime(2013, 6, 25, 0, 0, 0))).addProperty(
- createPrimitiveCollection("CollPropertyDateTimeOffset", getDateTime(2015, 8, 12, 3, 8, 34),
- getDateTime(1970, 3, 28, 12, 11, 10), getDateTime(1948, 2, 17, 9, 9, 9)))
- .addProperty(createPrimitiveCollection("CollPropertyDuration", 13, 19680, 3600)).addProperty(
- createPrimitiveCollection("CollPropertyGuid", UUID.fromString("ffffff67-89ab-cdef-0123-456789aaaaaa"),
- UUID.fromString("eeeeee67-89ab-cdef-0123-456789bbbbbb"),
- UUID.fromString("cccccc67-89ab-cdef-0123-456789cccccc"))).addProperty(
- createPrimitiveCollection("CollPropertyTimeOfDay", getTime(4, 14, 13), getTime(23, 59, 59),
- getTime(1, 12, 33))));
-
- Entity entity = new Entity();
- entity.getProperties().addAll(entityCollection.getEntities().get(0).getProperties());
- entity.getProperties().set(0, createPrimitive("PropertyInt16", 2));
- entityCollection.getEntities().add(entity);
-
- entity = new Entity();
- entity.getProperties().addAll(entityCollection.getEntities().get(0).getProperties());
- entity.getProperties().set(0, createPrimitive("PropertyInt16", 3));
- entityCollection.getEntities().add(entity);
+ entityCollection.getEntities().add(createETCollAllPrim((short) 1));
+ entityCollection.getEntities().add(createETCollAllPrim((short) 2));
+ entityCollection.getEntities().add(createETCollAllPrim((short) 3));
return entityCollection;
}
-
+
+ private Entity createETCollAllPrim(Short propertyInt16) {
+ return new Entity()
+ .addProperty(createPrimitive("PropertyInt16", propertyInt16))
+ .addProperty(createPrimitiveCollection("CollPropertyString",
+ "Employee1@company.example",
+ "Employee2@company.example",
+ "Employee3@company.example"))
+ .addProperty(createPrimitiveCollection("CollPropertyBoolean",
+ true,
+ false,
+ true))
+ .addProperty(createPrimitiveCollection("CollPropertyByte",
+ (short) 50,
+ (short) 200,
+ (short) 249))
+ .addProperty(createPrimitiveCollection("CollPropertySByte",
+ -120,
+ 120,
+ 126))
+ .addProperty(createPrimitiveCollection("CollPropertyInt16",
+ (short) 1000,
+ (short) 2000,
+ (short) 30112))
+ .addProperty(createPrimitiveCollection("CollPropertyInt32",
+ 23232323,
+ 11223355,
+ 10000001))
+ .addProperty(createPrimitiveCollection("CollPropertyInt64",
+ 929292929292L,
+ 333333333333L,
+ 444444444444L))
+ .addProperty(createPrimitiveCollection("CollPropertySingle",
+ 1.79000000E+03,
+ 2.66000000E+04,
+ 3.21000000E+03))
+ .addProperty(createPrimitiveCollection("CollPropertyDouble",
+ -1.7900000000000000E+04,
+ -2.7800000000000000E+07,
+ 3.2100000000000000E+03))
+ .addProperty(createPrimitiveCollection("CollPropertyDecimal",
+ BigDecimal.valueOf(12),
+ BigDecimal.valueOf(-2),
+ BigDecimal.valueOf(1234)))
+ .addProperty(createPrimitiveCollection("CollPropertyBinary",
+ new byte[] { (byte) 0xAB, (byte) 0xCD, (byte) 0xEF },
+ new byte[] { 0x01, 0x23, 0x45 },
+ new byte[] { 0x54, 0x67, (byte) 0x89 }))
+ .addProperty(createPrimitiveCollection("CollPropertyDate",
+ getDateTime(1958, 12, 3, 0, 0, 0),
+ getDateTime(1999, 8, 5, 0, 0, 0),
+ getDateTime(2013, 6, 25, 0, 0, 0)))
+ .addProperty(createPrimitiveCollection("CollPropertyDateTimeOffset",
+ getDateTime(2015, 8, 12, 3, 8, 34),
+ getDateTime(1970, 3, 28, 12, 11, 10),
+ getDateTime(1948, 2, 17, 9, 9, 9)))
+ .addProperty(createPrimitiveCollection("CollPropertyDuration",
+ BigDecimal.valueOf(13),
+ BigDecimal.valueOf(19680),
+ BigDecimal.valueOf(3600)))
+ .addProperty(createPrimitiveCollection("CollPropertyGuid",
+ UUID.fromString("ffffff67-89ab-cdef-0123-456789aaaaaa"),
+ UUID.fromString("eeeeee67-89ab-cdef-0123-456789bbbbbb"),
+ UUID.fromString("cccccc67-89ab-cdef-0123-456789cccccc")))
+ .addProperty(createPrimitiveCollection("CollPropertyTimeOfDay",
+ getTime(4, 14, 13),
+ getTime(23, 59, 59),
+ getTime(1, 12, 33)));
+ }
+
private EntityCollection createESMixPrimCollComp() {
- @SuppressWarnings("unchecked")
- final Property complexCollection = createComplexCollection("CollPropertyComp",
- Arrays.asList(createPrimitive("PropertyInt16", 123), createPrimitive("PropertyString", "TEST 1")),
- Arrays.asList(createPrimitive("PropertyInt16", 456), createPrimitive("PropertyString", "TEST 2")),
- Arrays.asList(createPrimitive("PropertyInt16", 789), createPrimitive("PropertyString", "TEST 3")));
-
EntityCollection entityCollection = new EntityCollection();
- entityCollection.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
- .addProperty(
- createPrimitiveCollection("CollPropertyString", "Employee1@company.example", "Employee2@company.example",
- "Employee3@company.example")).addProperty(
- createComplex("PropertyComp", createPrimitive("PropertyInt16", 111),
- createPrimitive("PropertyString", "TEST A"))).addProperty(complexCollection));
-
- entityCollection.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", 7)).addProperty(
- createPrimitiveCollection("CollPropertyString", "Employee1@company.example", "Employee2@company.example",
- "Employee3@company.example")).addProperty(
- createComplex("PropertyComp", createPrimitive("PropertyInt16", 222),
- createPrimitive("PropertyString", "TEST B"))).addProperty(complexCollection));
-
- entityCollection.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", 0)).addProperty(
- createPrimitiveCollection("CollPropertyString", "Employee1@company.example", "Employee2@company.example",
- "Employee3@company.example")).addProperty(
- createComplex("PropertyComp", createPrimitive("PropertyInt16", 333),
- createPrimitive("PropertyString", "TEST C"))).addProperty(complexCollection));
+ entityCollection.getEntities().add(new Entity()
+ .addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
+ .addProperty(createPrimitiveCollection("CollPropertyString",
+ "Employee1@company.example",
+ "Employee2@company.example",
+ "Employee3@company.example"))
+ .addProperty(createComplex("PropertyComp",
+ createPrimitive("PropertyInt16", (short) 111),
+ createPrimitive("PropertyString", "TEST A")))
+ .addProperty(createColPropertyComp()));
+
+ entityCollection.getEntities().add(new Entity()
+ .addProperty(createPrimitive("PropertyInt16", (short) 7))
+ .addProperty(createPrimitiveCollection("CollPropertyString",
+ "Employee1@company.example",
+ "Employee2@company.example",
+ "Employee3@company.example"))
+ .addProperty(createComplex("PropertyComp",
+ createPrimitive("PropertyInt16", (short) 222),
+ createPrimitive("PropertyString", "TEST B")))
+ .addProperty(createColPropertyComp()));
+
+ entityCollection.getEntities().add(new Entity()
+ .addProperty(createPrimitive("PropertyInt16", 0))
+ .addProperty(createPrimitiveCollection("CollPropertyString",
+ "Employee1@company.example",
+ "Employee2@company.example",
+ "Employee3@company.example"))
+ .addProperty(createComplex("PropertyComp",
+ createPrimitive("PropertyInt16", (short) 333),
+ createPrimitive("PropertyString", "TEST C")))
+ .addProperty(createColPropertyComp()));
return entityCollection;
}
-
- private EntityCollection createESAllKey() {
+
+ @SuppressWarnings("unchecked")
+ private Property createColPropertyComp() {
+ return createComplexCollection("CollPropertyComp",
+ Arrays.asList(
+ createPrimitive("PropertyInt16", (short) 123),
+ createPrimitive("PropertyString", "TEST 1")),
+ Arrays.asList(
+ createPrimitive("PropertyInt16", (short) 456),
+ createPrimitive("PropertyString", "TEST 2")),
+ Arrays.asList(
+ createPrimitive("PropertyInt16", (short) 789),
+ createPrimitive("PropertyString", "TEST 3")));
+ }
+
+ private EntityCollection createESAllKey() {
EntityCollection entityCollection = new EntityCollection();
- entityCollection.getEntities().add(new Entity().addProperty(createPrimitive("PropertyString", "First"))
- .addProperty(createPrimitive("PropertyBoolean", true)).addProperty(createPrimitive("PropertyByte", 255))
+ entityCollection.getEntities().add(new Entity()
+ .addProperty(createPrimitive("PropertyString", "First"))
+ .addProperty(createPrimitive("PropertyBoolean", true))
+ .addProperty(createPrimitive("PropertyByte", (short) 255))
.addProperty(createPrimitive("PropertySByte", Byte.MAX_VALUE))
.addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
.addProperty(createPrimitive("PropertyInt32", Integer.MAX_VALUE))
.addProperty(createPrimitive("PropertyInt64", Long.MAX_VALUE))
- .addProperty(createPrimitive("PropertyDecimal", 34))
+ .addProperty(createPrimitive("PropertyDecimal", BigDecimal.valueOf(34)))
.addProperty(createPrimitive("PropertyDate", getDateTime(2012, 12, 3, 0, 0, 0)))
.addProperty(createPrimitive("PropertyDateTimeOffset", getDateTime(2012, 12, 3, 7, 16, 23)))
- .addProperty(createPrimitive("PropertyDuration", 6)).addProperty(createPrimitive("PropertyGuid", GUID))
+ .addProperty(createPrimitive("PropertyDuration", BigDecimal.valueOf(6)))
+ .addProperty(createPrimitive("PropertyGuid", GUID))
.addProperty(createPrimitive("PropertyTimeOfDay", getTime(2, 48, 21))));
- entityCollection.getEntities().add(new Entity().addProperty(createPrimitive("PropertyString", "Second"))
- .addProperty(createPrimitive("PropertyBoolean", true)).addProperty(createPrimitive("PropertyByte", 254))
- .addProperty(createPrimitive("PropertySByte", 124)).addProperty(createPrimitive("PropertyInt16", 32764))
+ entityCollection.getEntities().add(new Entity()
+ .addProperty(createPrimitive("PropertyString", "Second"))
+ .addProperty(createPrimitive("PropertyBoolean", true))
+ .addProperty(createPrimitive("PropertyByte", (short) 254))
+ .addProperty(createPrimitive("PropertySByte", (byte) 124))
+ .addProperty(createPrimitive("PropertyInt16", (short) 32764))
.addProperty(createPrimitive("PropertyInt32", 2147483644))
.addProperty(createPrimitive("PropertyInt64", 9223372036854775804L))
- .addProperty(createPrimitive("PropertyDecimal", 34))
+ .addProperty(createPrimitive("PropertyDecimal", BigDecimal.valueOf(34)))
.addProperty(createPrimitive("PropertyDate", getDateTime(2012, 12, 3, 0, 0, 0)))
.addProperty(createPrimitive("PropertyDateTimeOffset", getDateTime(2012, 12, 3, 7, 16, 23)))
- .addProperty(createPrimitive("PropertyDuration", 6)).addProperty(createPrimitive("PropertyGuid", GUID))
+ .addProperty(createPrimitive("PropertyDuration", BigDecimal.valueOf(6)))
+ .addProperty(createPrimitive("PropertyGuid", GUID))
.addProperty(createPrimitive("PropertyTimeOfDay", getTime(2, 48, 21))));
return entityCollection;
@@ -773,16 +886,18 @@ public class DataCreator {
EntityCollection entityCollection = new EntityCollection();
Entity entity = new Entity();
- entity.addProperty(createPrimitive("PropertyInt16", 1));
+ entity.addProperty(createPrimitive("PropertyInt16", (short) 1));
entity.addProperty(createComplex("PropertyComp",
- createComplex("PropertyComp", createPrimitive("PropertyInt16", 123),
+ createComplex("PropertyComp",
+ createPrimitive("PropertyInt16", (short) 123),
createPrimitive("PropertyString", "String 1"))));
entityCollection.getEntities().add(entity);
entity = new Entity();
- entity.addProperty(createPrimitive("PropertyInt16", 2));
+ entity.addProperty(createPrimitive("PropertyInt16", (short) 2));
entity.addProperty(createComplex("PropertyComp",
- createComplex("PropertyComp", createPrimitive("PropertyInt16", 987),
+ createComplex("PropertyComp",
+ createPrimitive("PropertyInt16", (short) 987),
createPrimitive("PropertyString", "String 2"))));
entityCollection.getEntities().add(entity);
@@ -792,26 +907,30 @@ public class DataCreator {
private EntityCollection createESMedia() {
EntityCollection entityCollection = new EntityCollection();
- Entity entity = new Entity().addProperty(createPrimitive("PropertyInt16", 1))
- .addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("darkturquoise")));
+ Entity entity = new Entity()
+ .addProperty(createPrimitive("PropertyInt16", (short) 1))
+ .addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("darkturquoise")));
entity.setMediaContentType("image/svg+xml");
entity.setMediaETag("W/\"1\"");
entityCollection.getEntities().add(entity);
- entity = new Entity().addProperty(createPrimitive("PropertyInt16", 2))
- .addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("royalblue")));
+ entity = new Entity()
+ .addProperty(createPrimitive("PropertyInt16", (short) 2))
+ .addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("royalblue")));
entity.setMediaContentType("image/svg+xml");
entity.setMediaETag("W/\"2\"");
entityCollection.getEntities().add(entity);
- entity = new Entity().addProperty(createPrimitive("PropertyInt16", 3))
- .addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("crimson")));
+ entity = new Entity()
+ .addProperty(createPrimitive("PropertyInt16", (short) 3))
+ .addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("crimson")));
entity.setMediaContentType("image/svg+xml");
entity.setMediaETag("W/\"3\"");
entityCollection.getEntities().add(entity);
- entity = new Entity().addProperty(createPrimitive("PropertyInt16", 4))
- .addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("black")));
+ entity = new Entity()
+ .addProperty(createPrimitive("PropertyInt16", (short) 4))
+ .addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("black")));
entity.setMediaContentType("image/svg+xml");
entity.setMediaETag("W/\"4\"");
entityCollection.getEntities().add(entity);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/de64c318/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
index fe06a1c..79313e6 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
@@ -173,15 +173,25 @@ public class DataProvider {
for (final String keyName : entityType.getKeyPredicateNames()) {
final FullQualifiedName typeName = entityType.getProperty(keyName).getType().getFullQualifiedName();
Object newValue = null;
-
- if (EdmPrimitiveTypeKind.Int16.getFullQualifiedName().equals(typeName)
- || EdmPrimitiveTypeKind.Int32.getFullQualifiedName().equals(typeName)
- || EdmPrimitiveTypeKind.Int64.getFullQualifiedName().equals(typeName)) {
+
+ if (EdmPrimitiveTypeKind.Int16.getFullQualifiedName().equals(typeName)) {
+ newValue = Short.valueOf((short) 1);
+
+ while(!isFree(newValue, keyName, entities)) {
+ newValue = (short) (((Short) newValue) + 1);
+ }
+ } else if (EdmPrimitiveTypeKind.Int32.getFullQualifiedName().equals(typeName)) {
+ newValue = Integer.valueOf((short) 1);
+
+ while(!isFree(newValue, keyName, entities)) {
+ newValue = ((Integer) newValue) + 1;
+ }
+ } else if(EdmPrimitiveTypeKind.Int64.getFullQualifiedName().equals(typeName)) {
// Integer keys
- newValue = Integer.valueOf(1);
+ newValue = Long.valueOf(1);
while (!isFree(newValue, keyName, entities)) {
- newValue = ((Integer) newValue) + 1;
+ newValue = (long) (((Long) newValue) + 1L);
}
} else if (EdmPrimitiveTypeKind.String.getFullQualifiedName().equals(typeName)) {
// String keys
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/de64c318/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/FunctionData.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/FunctionData.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/FunctionData.java
index 517c7df..238dd8b 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/FunctionData.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/FunctionData.java
@@ -75,14 +75,14 @@ public class FunctionData {
protected static Property primitiveComplexFunction(final String name, final List<UriParameter> parameters,
final Map<String, EntityCollection> data) throws DataProviderException {
if (name.equals("UFNRTInt16")) {
- return DataCreator.createPrimitive(name, 12345);
+ return DataCreator.createPrimitive(name, (short) 12345);
} else if (name.equals("UFCRTString")) {
return DataCreator.createPrimitive(name, "UFCRTString string value");
} else if (name.equals("UFCRTCollString")) {
return data.get("ESCollAllPrim").getEntities().get(0).getProperty("CollPropertyString");
} else if (name.equals("UFCRTCTTwoPrim")) {
return DataCreator.createComplex(name,
- DataCreator.createPrimitive("PropertyInt16", 16),
+ DataCreator.createPrimitive("PropertyInt16", (short) 16),
DataCreator.createPrimitive("PropertyString", "UFCRTCTTwoPrim string value"));
} else if (name.equals("UFCRTCTTwoPrimParam")) {
try {
@@ -102,7 +102,7 @@ public class FunctionData {
}
} else if (name.equals("UFCRTCollCTTwoPrim")) {
return DataCreator.createComplexCollection(name,
- Arrays.asList(DataCreator.createPrimitive("PropertyInt16", 16),
+ Arrays.asList(DataCreator.createPrimitive("PropertyInt16", (short) 16),
DataCreator.createPrimitive("PropertyString", "Test123")),
Arrays.asList(DataCreator.createPrimitive("PropertyInt16", 17),
DataCreator.createPrimitive("PropertyString", "Test456")),
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/de64c318/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/DataProviderTest.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/DataProviderTest.java b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/DataProviderTest.java
index f3bfc4f..4300ade 100644
--- a/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/DataProviderTest.java
+++ b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/DataProviderTest.java
@@ -148,7 +148,7 @@ public class DataProviderTest {
Assert.assertEquals(2, linkedComplexValue.getValue().size());
Property lcProp = linkedComplexValue.getValue().get(0);
Assert.assertFalse(lcProp.isCollection());
- Assert.assertEquals(123, lcProp.getValue());
+ Assert.assertEquals((short) 123, lcProp.getValue());
//
Assert.assertEquals(4, outSet.getEntities().get(1).getProperties().size());
Assert.assertEquals(4, outSet.getEntities().get(2).getProperties().size());
@@ -162,7 +162,7 @@ public class DataProviderTest {
dataProvider.delete(esMedia, entity);
Assert.assertEquals(3, dataProvider.readAll(esMedia).getEntities().size());
entity = dataProvider.create(esMedia);
- Assert.assertEquals(3, entity.getProperty("PropertyInt16").getValue());
+ Assert.assertEquals((short) 3, entity.getProperty("PropertyInt16").getValue());
dataProvider.setMedia(entity, new byte[] { 1, 2, 3, 4 }, "x/y");
Assert.assertArrayEquals(new byte[] { 1, 2, 3, 4 }, dataProvider.readMedia(entity));
Assert.assertEquals("x/y", entity.getMediaContentType());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/de64c318/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
index 3856339..0877df6 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
@@ -384,7 +384,8 @@ public class ODataJsonSerializerTest {
+ "\"CollPropertyBoolean\":[true,null,false],\"CollPropertyByte\":[50,null,249],"
+ "\"CollPropertySByte\":[-120,null,126],\"CollPropertyInt16\":[1000,null,30112],"
+ "\"CollPropertyInt32\":[23232323,null,10000001],\"CollPropertyInt64\":[929292929292,null,444444444444],"
- + "\"CollPropertySingle\":[1790,null,3210],\"CollPropertyDouble\":[-17900,null,3210],\"CollPropertyDecimal\":"
+ + "\"CollPropertySingle\":[1790.0,null,3210.0],\"CollPropertyDouble\":[-17900.0,null,3210.0],"
+ + "\"CollPropertyDecimal\":"
+ "[12,null,1234],\"CollPropertyBinary\":[\"q83v\",null,\"VGeJ\"],\"CollPropertyDate\":"
+ "[\"1958-12-03\",null,\"2013-06-25\"],\"CollPropertyDateTimeOffset\":[\"2015-08-12T03:08:34Z\",null,"
+ "\"1948-02-17T09:09:09Z\"],\"CollPropertyDuration\":[\"PT13S\",null,\"PT1H0S\"],\"CollPropertyGuid\":"
[03/12] olingo-odata4 git commit: [OLINGO-712] Merge branch 'master'
into olingo712
Posted by mi...@apache.org.
[OLINGO-712] Merge branch 'master' into olingo712
Conflicts:
fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
fit/src/test/java/org/apache/olingo/fit/tecsvc/client/SystemQueryOptionITCase.java
fit/src/test/java/org/apache/olingo/fit/v4/AuthBatchTestITCase.java
fit/src/test/java/org/apache/olingo/fit/v4/BatchTestITCase.java
fit/src/test/java/org/apache/olingo/fit/v4/ConformanceTestITCase.java
fit/src/test/java/org/apache/olingo/fit/v4/MediaEntityTestITCase.java
lib/client-core/src/main/java/org/apache/olingo/client/core/ODataClientImpl.java
lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/b5111747
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/b5111747
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/b5111747
Branch: refs/heads/OLINGO-708_AsyncSupportTec
Commit: b51117477bcee797fdc6d3b989f7cf7f37bfc8c2
Parents: d54b071 abf5bf7
Author: Christian Amend <ch...@sap.com>
Authored: Mon Jun 29 13:48:14 2015 +0200
Committer: Christian Amend <ch...@sap.com>
Committed: Mon Jun 29 13:48:14 2015 +0200
----------------------------------------------------------------------
.../olingo/ext/proxy/AbstractService.java | 4 +-
.../EntityContainerInvocationHandler.java | 1 +
.../proxy/commons/EntityInvocationHandler.java | 6 +-
.../commons/EntitySetInvocationHandler.java | 6 +-
ext/karaf/karaf-features/pom.xml | 81 ++++
.../src/main/resources/features.xml | 59 +++
ext/karaf/karaf-fit/pom.xml | 152 ++++++++
.../apache/olingo/osgi/itests/BundlesTest.java | 55 +++
.../osgi/itests/OlingoOSGiTestSupport.java | 134 +++++++
.../osgi/itests/server/CarServiceTest.java | 105 ++++++
ext/karaf/pom.xml | 41 ++
.../olingo/ext/pojogen/AbstractPOJOGenMojo.java | 4 +-
ext/pom.xml | 9 +
.../org/apache/olingo/fit/AbstractServices.java | 2 +-
.../olingo/fit/utils/AbstractUtilities.java | 3 +-
.../org/apache/olingo/fit/utils/FSManager.java | 3 +-
.../olingo/fit/AbstractBaseTestITCase.java | 11 +-
.../fit/tecsvc/client/ActionImportITCase.java | 23 +-
.../BasicHttpExceptionHandlingITCase.java | 4 +-
.../olingo/fit/tecsvc/client/BasicITCase.java | 376 ++++++++++++++++++-
.../fit/tecsvc/client/BatchClientITCase.java | 119 +++---
.../olingo/fit/tecsvc/client/BindingITCase.java | 6 +-
.../fit/tecsvc/client/ConditionalITCase.java | 4 +-
.../fit/tecsvc/client/DeepInsertITCase.java | 6 +-
.../tecsvc/client/EdmEnabledClientITCase.java | 63 ----
.../tecsvc/client/EntityReferencesITCase.java | 4 +-
.../fit/tecsvc/client/ExpandSelectITCase.java | 12 +
.../ExpandWithSystemQueryOptionsITCase.java | 4 +-
.../tecsvc/client/FilterSystemQueryITCase.java | 4 +-
.../fit/tecsvc/client/FunctionImportITCase.java | 4 +-
.../olingo/fit/tecsvc/client/MediaITCase.java | 3 +-
.../fit/tecsvc/client/NavigationITCase.java | 4 +-
.../tecsvc/client/OrderBySystemQueryITCase.java | 4 +-
.../tecsvc/client/PrimitiveComplexITCase.java | 3 +-
.../tecsvc/client/SystemQueryOptionITCase.java | 4 +-
.../fit/tecsvc/http/BasicBatchITCase.java | 15 +-
.../olingo/fit/tecsvc/http/BasicHttpITCase.java | 79 ++--
.../fit/tecsvc/http/EntityReferenceITCase.java | 54 +--
.../olingo/fit/tecsvc/http/PingITCase.java | 12 +-
.../olingo/fit/v4/AbstractTestITCase.java | 17 +-
.../apache/olingo/fit/v4/AsyncTestITCase.java | 20 +-
.../olingo/fit/v4/AuthBatchTestITCase.java | 5 +-
.../apache/olingo/fit/v4/BatchTestITCase.java | 21 +-
.../fit/v4/BoundOperationInvokeTestITCase.java | 52 +--
.../olingo/fit/v4/ConformanceTestITCase.java | 30 +-
.../apache/olingo/fit/v4/DeltaTestITCase.java | 8 +-
.../olingo/fit/v4/DerivedTypeTestITCase.java | 22 +-
.../olingo/fit/v4/EntityCreateTestITCase.java | 26 +-
.../olingo/fit/v4/EntityRetrieveTestITCase.java | 90 ++---
.../olingo/fit/v4/EntitySetTestITCase.java | 38 +-
.../olingo/fit/v4/EntityUpdateTestITCase.java | 32 +-
.../olingo/fit/v4/ErrorResponseTestITCase.java | 4 +-
.../olingo/fit/v4/FilterFactoryTestITCase.java | 4 +-
.../fit/v4/JSONFormatConformanceTestITCase.java | 12 +-
.../olingo/fit/v4/KeyAsSegmentTestITCase.java | 24 +-
.../olingo/fit/v4/MediaEntityTestITCase.java | 28 +-
.../apache/olingo/fit/v4/OAuth2TestITCase.java | 14 +-
.../olingo/fit/v4/OpenTypeTestITCase.java | 26 +-
.../fit/v4/OperationImportInvokeTestITCase.java | 38 +-
.../olingo/fit/v4/PropertyTestITCase.java | 42 +--
.../olingo/fit/v4/PropertyValueTestITCase.java | 22 +-
.../olingo/fit/v4/QueryOptionsTestITCase.java | 6 +-
.../fit/v4/ServiceDocumentTestITCase.java | 10 +-
.../olingo/fit/v4/SingletonTestITCase.java | 30 +-
.../apache/olingo/client/api/Configuration.java | 17 +-
.../apache/olingo/client/api/ODataClient.java | 9 +-
.../olingo/client/api/ODataClientBuilder.java | 8 +-
.../request/ODataBasicRequest.java | 8 +-
.../streamed/ODataStreamedEntityRequest.java | 7 +-
.../api/domain/ClientEntitySetIterator.java | 32 +-
.../client/api/domain/ClientPrimitiveValue.java | 3 +
.../client/api/serialization/ODataReader.java | 28 +-
.../client/api/serialization/ODataWriter.java | 26 +-
.../olingo/client/core/ConfigurationImpl.java | 31 +-
.../olingo/client/core/ODataClientFactory.java | 4 +-
.../olingo/client/core/ODataClientImpl.java | 19 +-
.../header/ODataErrorResponseChecker.java | 37 +-
.../request/AbstractODataBasicRequest.java | 8 +-
.../request/AbstractODataRequest.java | 8 +-
.../request/cud/ODataDeleteRequestImpl.java | 4 +-
.../cud/ODataEntityCreateRequestImpl.java | 10 +-
.../cud/ODataEntityUpdateRequestImpl.java | 10 +-
.../cud/ODataPropertyUpdateRequestImpl.java | 10 +-
.../cud/ODataReferenceAddingRequestImpl.java | 6 +-
.../cud/ODataValueUpdateRequestImpl.java | 12 +-
.../invoke/AbstractODataInvokeRequest.java | 30 +-
.../request/invoke/ODataInvokeRequestImpl.java | 14 +-
.../retrieve/AbstractMetadataRequestImpl.java | 5 +-
.../request/retrieve/ODataDeltaRequestImpl.java | 8 +-
.../retrieve/ODataEntityRequestImpl.java | 8 +-
.../ODataEntitySetIteratorRequestImpl.java | 8 +-
.../retrieve/ODataEntitySetRequestImpl.java | 8 +-
.../request/retrieve/ODataMediaRequestImpl.java | 8 +-
.../retrieve/ODataPropertyRequestImpl.java | 8 +-
.../request/retrieve/ODataRawRequestImpl.java | 4 +-
.../ODataServiceDocumentRequestImpl.java | 8 +-
.../request/retrieve/ODataValueRequestImpl.java | 10 +-
.../retrieve/XMLMetadataRequestImpl.java | 4 +-
.../AbstractODataStreamedEntityRequest.java | 16 +-
.../streamed/AbstractODataStreamedRequest.java | 3 +-
.../core/domain/ClientPrimitiveValueImpl.java | 6 +
.../ClientODataDeserializerImpl.java | 25 +-
.../serialization/JsonEntitySerializer.java | 16 +-
.../serialization/JsonEntitySetSerializer.java | 7 +-
.../serialization/JsonPropertySerializer.java | 5 +-
.../core/serialization/JsonSerializer.java | 57 +--
.../core/serialization/ODataBinderImpl.java | 16 +-
.../core/serialization/ODataReaderImpl.java | 50 +--
.../core/serialization/ODataWriterImpl.java | 30 +-
.../apache/olingo/client/core/AbstractTest.java | 8 +-
.../apache/olingo/client/core/v4/AtomTest.java | 22 +-
.../olingo/client/core/v4/EntitySetTest.java | 42 +--
.../olingo/client/core/v4/EntityTest.java | 105 +++---
.../apache/olingo/client/core/v4/ErrorTest.java | 22 +-
.../apache/olingo/client/core/v4/JSONTest.java | 52 +--
.../olingo/client/core/v4/MetadataTest.java | 14 +-
.../olingo/client/core/v4/PropertyTest.java | 58 +--
.../client/core/v4/ServiceDocumentTest.java | 34 +-
.../olingo/commons/api/format/AcceptType.java | 33 +-
.../olingo/commons/api/format/ContentType.java | 146 ++++---
.../olingo/commons/api/format/ODataFormat.java | 126 -------
.../olingo/commons/api/format/TypeUtil.java | 36 +-
.../olingo/commons/api/http/HttpHeader.java | 63 ++--
.../commons/api/format/AcceptTypeTest.java | 6 +-
.../commons/api/format/ContentTypeTest.java | 17 +-
.../org/apache/olingo/server/api/OData.java | 10 +-
.../exception/BatchDeserializerException.java | 65 ----
.../exception/BatchSerializerException.java | 46 ---
.../deserializer/FixedFormatDeserializer.java | 9 +-
.../batch/BatchDeserializerException.java | 77 ++++
.../server/api/processor/DefaultProcessor.java | 7 +-
.../serializer/BatchSerializerException.java | 45 +++
.../serializer/ComplexSerializerOptions.java | 6 +-
.../EntityCollectionSerializerOptions.java | 4 +-
.../api/serializer/EntitySerializerOptions.java | 4 +-
.../api/serializer/FixedFormatSerializer.java | 8 +-
.../server/api/serializer/ODataSerializer.java | 15 +-
.../serializer/PrimitiveSerializerOptions.java | 6 +-
.../ReferenceCollectionSerializerOptions.java | 71 ++++
.../serializer/ReferenceSerializerOptions.java | 57 +++
.../apache/olingo/server/core/ErrorHandler.java | 10 +-
.../olingo/server/core/ServiceRequest.java | 16 +-
.../server/core/requests/BatchRequest.java | 14 +-
.../server/core/requests/DataRequest.java | 12 +-
.../olingo/server/example/TripPinDataModel.java | 3 +-
.../olingo/server/core/ContentNegotiator.java | 41 +-
.../apache/olingo/server/core/ODataHandler.java | 3 +-
.../apache/olingo/server/core/ODataImpl.java | 61 +--
.../core/batchhandler/BatchFacadeImpl.java | 5 +-
.../server/core/batchhandler/BatchHandler.java | 14 +-
.../core/batchhandler/BatchPartHandler.java | 8 +-
.../BatchReferenceRewriter.java | 13 +-
.../FixedFormatDeserializerImpl.java | 2 +-
.../core/deserializer/batch/BatchBodyPart.java | 35 +-
.../deserializer/batch/BatchChangeSetPart.java | 2 +-
.../core/deserializer/batch/BatchParser.java | 2 +-
.../deserializer/batch/BatchParserCommon.java | 121 +++---
.../deserializer/batch/BatchQueryOperation.java | 2 +-
.../batch/BatchRequestTransformator.java | 35 +-
.../batch/BatchTransformatorCommon.java | 38 +-
.../server/core/deserializer/batch/Header.java | 9 -
.../batch/HttpRequestStatusLine.java | 32 +-
.../json/ODataJsonDeserializer.java | 60 ++-
.../serializer/BatchResponseSerializer.java | 18 +-
.../serializer/FixedFormatSerializerImpl.java | 2 +-
.../serializer/json/ODataJsonSerializer.java | 250 ++++++------
.../json/ServiceDocumentJsonSerializer.java | 32 +-
.../serializer/utils/ContentTypeHelper.java | 28 ++
.../serializer/xml/ODataXmlSerializerImpl.java | 8 +-
.../olingo/server/core/uri/parser/Parser.java | 10 +-
.../server/core/ContentNegotiatorTest.java | 49 +--
.../olingo/server/core/ODataImplTest.java | 57 +++
.../batchhandler/MockedBatchHandlerTest.java | 18 +-
.../batch/BatchParserCommonTest.java | 4 +-
.../batch/BatchRequestParserTest.java | 32 +-
.../core/deserializer/batch/HeaderTest.java | 16 -
.../batch/HttpRequestStatusLineTest.java | 4 +-
.../json/ODataJsonDeserializerBasicTest.java | 106 +++---
.../serializer/BatchResponseSerializerTest.java | 16 +-
.../json/ODataJsonSerializerTest.java | 4 +-
.../json/ServerErrorSerializerTest.java | 6 +-
.../xml/MetadataDocumentXmlSerializerTest.java | 4 +-
.../processor/TechnicalActionProcessor.java | 53 ++-
.../processor/TechnicalEntityProcessor.java | 80 ++--
.../TechnicalPrimitiveComplexProcessor.java | 15 +-
.../tecsvc/processor/TechnicalProcessor.java | 10 +-
.../olingo/server/core/ODataHandlerTest.java | 3 +-
.../json/AbstractODataDeserializerTest.java | 6 +-
.../json/ODataDeserializerDeepInsertTest.java | 24 +-
.../ODataDeserializerEntityCollectionTest.java | 31 +-
...ataJsonDeserializerActionParametersTest.java | 5 +-
.../json/ODataJsonDeserializerEntityTest.java | 225 ++++++++---
.../json/ODataJsonSerializerTest.java | 299 ++++++++++++++-
.../serializer/json/ServiceDocumentTest.java | 15 +-
.../serializer/xml/MetadataDocumentTest.java | 4 +-
pom.xml | 7 +
samples/osgi/server/README.txt | 183 +++++++++
samples/osgi/server/pom.xml | 112 ++++++
samples/pom.xml | 1 +
.../server/sample/processor/CarsProcessor.java | 21 +-
samples/tutorials/p4_navigation/pom.xml | 80 ++++
.../myservice/mynamespace/data/Storage.java | 260 +++++++++++++
.../mynamespace/service/DemoEdmProvider.java | 216 +++++++++++
.../service/DemoEntityCollectionProcessor.java | 154 ++++++++
.../service/DemoEntityProcessor.java | 189 ++++++++++
.../service/DemoPrimitiveProcessor.java | 154 ++++++++
.../java/myservice/mynamespace/util/Util.java | 145 +++++++
.../myservice/mynamespace/web/DemoServlet.java | 76 ++++
.../src/main/webapp/WEB-INF/web.xml | 34 ++
.../p4_navigation/src/main/webapp/index.jsp | 26 ++
samples/tutorials/pom.xml | 1 +
211 files changed, 5373 insertions(+), 2227 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b5111747/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b5111747/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
----------------------------------------------------------------------
diff --cc fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
index 8e44289,2efba8a..96413cd
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
@@@ -414,8 -434,10 +433,10 @@@ public class BasicITCase extends Abstra
final ODataEntityCreateResponse<ClientEntity> response = request.execute();
assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
- assertEquals("return=minimal", response.getHeader(HeaderName.preferenceApplied).iterator().next());
+ assertEquals("return=minimal", response.getHeader(HttpHeader.PREFERENCE_APPLIED).iterator().next());
- assertEquals(SERVICE_URI + "/ESTwoPrim(1)", response.getHeader(HttpHeader.LOCATION).iterator().next());
+ final String location = SERVICE_URI + "/ESTwoPrim(1)";
+ assertEquals(location, response.getHeader(HttpHeader.LOCATION).iterator().next());
+ assertEquals(location, response.getHeader(HttpHeader.ODATA_ENTITY_ID).iterator().next());
}
@Test
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b5111747/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/PrimitiveComplexITCase.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b5111747/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/SystemQueryOptionITCase.java
----------------------------------------------------------------------
diff --cc fit/src/test/java/org/apache/olingo/fit/tecsvc/client/SystemQueryOptionITCase.java
index 7fa83be,94f0d11..3944f34
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/SystemQueryOptionITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/SystemQueryOptionITCase.java
@@@ -30,8 -31,7 +30,8 @@@ import org.apache.olingo.client.api.com
import org.apache.olingo.client.api.domain.ClientEntity;
import org.apache.olingo.client.api.domain.ClientEntitySet;
import org.apache.olingo.client.core.ODataClientFactory;
- import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.http.HttpHeader;
+ import org.apache.olingo.commons.api.format.ContentType;
import org.apache.olingo.commons.api.http.HttpStatusCode;
import org.apache.olingo.fit.AbstractBaseTestITCase;
import org.apache.olingo.fit.tecsvc.TecSvcConst;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b5111747/fit/src/test/java/org/apache/olingo/fit/v4/AuthBatchTestITCase.java
----------------------------------------------------------------------
diff --cc fit/src/test/java/org/apache/olingo/fit/v4/AuthBatchTestITCase.java
index f6964b3,123dcd9..81050a4
--- a/fit/src/test/java/org/apache/olingo/fit/v4/AuthBatchTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/AuthBatchTestITCase.java
@@@ -38,8 -39,6 +38,7 @@@ import org.apache.olingo.client.core.ht
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.format.ContentType;
- import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.http.HttpHeader;
import org.junit.Test;
public class AuthBatchTestITCase extends AbstractTestITCase {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b5111747/fit/src/test/java/org/apache/olingo/fit/v4/BatchTestITCase.java
----------------------------------------------------------------------
diff --cc fit/src/test/java/org/apache/olingo/fit/v4/BatchTestITCase.java
index 26c38f9,d039ab2..5007c2c
--- a/fit/src/test/java/org/apache/olingo/fit/v4/BatchTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/BatchTestITCase.java
@@@ -66,8 -67,6 +66,7 @@@ import org.apache.olingo.commons.api.ed
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.format.ContentType;
- import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.http.HttpHeader;
import org.junit.Test;
public class BatchTestITCase extends AbstractTestITCase {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b5111747/fit/src/test/java/org/apache/olingo/fit/v4/ConformanceTestITCase.java
----------------------------------------------------------------------
diff --cc fit/src/test/java/org/apache/olingo/fit/v4/ConformanceTestITCase.java
index 9579239,2e9fe5a..32ce435
--- a/fit/src/test/java/org/apache/olingo/fit/v4/ConformanceTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/ConformanceTestITCase.java
@@@ -53,8 -54,7 +53,8 @@@ import org.apache.olingo.client.core.ht
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
- import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.http.HttpHeader;
+ import org.apache.olingo.commons.api.format.ContentType;
import org.junit.Test;
/**
@@@ -117,17 -118,21 +117,17 @@@ public class ConformanceTestITCase exte
final ODataEntityCreateRequest<ClientEntity> req = getClient().getCUDRequestFactory().getEntityCreateRequest(
getClient().newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Orders").build(), order);
- req.setFormat(ODataFormat.JSON_FULL_METADATA);
+ req.setFormat(ContentType.JSON_FULL_METADATA);
// check for OData-Version
- assertEquals("4.0", req.getHeader("OData-Version"));
- assertEquals("4.0", req.getHeader(HeaderName.odataVersion.toString()));
+ assertEquals("4.0", req.getHeader(HttpHeader.ODATA_VERSION));
// check for Content-Type
assertEquals(
- ODataFormat.JSON_FULL_METADATA.getContentType().toContentTypeString(),
- req.getHeader(HttpHeader.CONTENT_TYPE));
+ ContentType.JSON_FULL_METADATA.toContentTypeString(),
+ req.getHeader("Content-Type"));
assertEquals(
- ODataFormat.JSON_FULL_METADATA.getContentType().toContentTypeString(),
+ ContentType.JSON_FULL_METADATA.toContentTypeString(),
- req.getHeader(HeaderName.contentType.toString()));
- assertEquals(
- ContentType.JSON_FULL_METADATA.toContentTypeString(),
req.getContentType());
final ClientEntity created = req.execute().getBody();
@@@ -402,9 -408,10 +402,9 @@@
final ODataEntityRequest<ClientEntity> req =
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- req.setFormat(ODataFormat.JSON);
+ req.setFormat(ContentType.JSON);
assertEquals("application/json;odata.metadata=minimal", req.getHeader("Accept"));
- assertEquals("application/json;odata.metadata=minimal", req.getHeader(HeaderName.accept.toString()));
assertEquals("application/json;odata.metadata=minimal", req.getAccept());
final ODataRetrieveResponse<ClientEntity> res = req.execute();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b5111747/fit/src/test/java/org/apache/olingo/fit/v4/MediaEntityTestITCase.java
----------------------------------------------------------------------
diff --cc fit/src/test/java/org/apache/olingo/fit/v4/MediaEntityTestITCase.java
index cdc3c12,0c6352d..268939e
--- a/fit/src/test/java/org/apache/olingo/fit/v4/MediaEntityTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/MediaEntityTestITCase.java
@@@ -51,8 -52,7 +51,8 @@@ import org.apache.olingo.client.core.OD
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
- import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.http.HttpHeader;
+ import org.apache.olingo.commons.api.format.ContentType;
import org.junit.Test;
public class MediaEntityTestITCase extends AbstractTestITCase {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b5111747/lib/client-core/src/main/java/org/apache/olingo/client/core/ODataClientImpl.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/ODataClientImpl.java
index 4ee8924,6c3bb4c..811b63f
--- 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
@@@ -52,8 -53,7 +52,8 @@@ import org.apache.olingo.client.core.se
import org.apache.olingo.client.core.uri.FilterFactoryImpl;
import org.apache.olingo.client.core.uri.URIBuilderImpl;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
- import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.http.HttpHeader;
+ import org.apache.olingo.commons.api.format.ContentType;
public class ODataClientImpl implements ODataClient {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b5111747/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java
index bf198de,4037a6f..4bd2d83
--- 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
@@@ -40,8 -41,7 +40,8 @@@ import org.apache.olingo.client.api.com
import org.apache.olingo.client.api.communication.response.ODataResponse;
import org.apache.olingo.client.api.http.HttpClientException;
import org.apache.olingo.commons.api.ODataRuntimeException;
- import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.http.HttpHeader;
+ import org.apache.olingo.commons.api.format.ContentType;
import org.apache.olingo.commons.api.http.HttpMethod;
/**
@@@ -169,11 -169,17 +169,11 @@@ public abstract class AbstractODataRequ
}
@Override
- public ODataRequest addCustomHeader(final HeaderName name, final String value) {
- odataHeaders.setHeader(name, value);
- return this;
- }
-
- @Override
public String getAccept() {
- final String acceptHead = odataHeaders.getHeader(HeaderName.accept);
- return StringUtils.isBlank(acceptHead)
- ? getDefaultFormat().toContentTypeString()
- : acceptHead;
+ final String acceptHead = odataHeaders.getHeader(HttpHeader.ACCEPT);
+ return StringUtils.isBlank(acceptHead) ?
- getDefaultFormat().getContentType().toContentTypeString() :
++ getDefaultFormat().toContentTypeString() :
+ acceptHead;
}
@Override
@@@ -193,10 -199,10 +193,10 @@@
@Override
public String getContentType() {
- final String contentTypeHead = odataHeaders.getHeader(HeaderName.contentType);
- return StringUtils.isBlank(contentTypeHead)
- ? getDefaultFormat().toContentTypeString()
- : contentTypeHead;
+ final String contentTypeHead = odataHeaders.getHeader(HttpHeader.CONTENT_TYPE);
+ return StringUtils.isBlank(contentTypeHead) ?
- getDefaultFormat().getContentType().toContentTypeString() :
++ getDefaultFormat().toContentTypeString() :
+ contentTypeHead;
}
@Override
[02/12] olingo-odata4 git commit: [OLINGO-659] support for
OData-EntityID header, more clean-up
Posted by mi...@apache.org.
[OLINGO-659] support for OData-EntityID header, more clean-up
Change-Id: I168a6efac6fc9ad85865f71dd534fd850d8e777e
Signed-off-by: Christian Amend <ch...@sap.com>
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/abf5bf79
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/abf5bf79
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/abf5bf79
Branch: refs/heads/OLINGO-708_AsyncSupportTec
Commit: abf5bf79aa865c6dbcd5e0af8b521a7ae6341af2
Parents: 2a84155
Author: Klaus Straubinger <kl...@sap.com>
Authored: Fri Jun 26 15:34:23 2015 +0200
Committer: Christian Amend <ch...@sap.com>
Committed: Fri Jun 26 16:38:46 2015 +0200
----------------------------------------------------------------------
.../fit/tecsvc/client/ActionImportITCase.java | 20 ++++
.../BasicHttpExceptionHandlingITCase.java | 4 +-
.../olingo/fit/tecsvc/client/BasicITCase.java | 14 +--
.../fit/tecsvc/client/BatchClientITCase.java | 96 ++++++++++----------
.../tecsvc/client/EdmEnabledClientITCase.java | 63 -------------
.../fit/tecsvc/client/ExpandSelectITCase.java | 12 +++
.../fit/tecsvc/http/BasicBatchITCase.java | 15 ++-
.../olingo/fit/tecsvc/http/BasicHttpITCase.java | 89 +++++++-----------
.../fit/tecsvc/http/EntityReferenceITCase.java | 54 ++++-------
.../olingo/fit/tecsvc/http/PingITCase.java | 12 +--
.../olingo/fit/v4/EntityRetrieveTestITCase.java | 3 +-
.../api/domain/ClientEntitySetIterator.java | 14 +--
.../olingo/client/core/ODataClientImpl.java | 12 +--
.../invoke/AbstractODataInvokeRequest.java | 7 +-
.../ClientODataDeserializerImpl.java | 11 ++-
.../apache/olingo/client/core/AbstractTest.java | 5 +-
.../olingo/client/core/v4/EntityTest.java | 3 +-
.../olingo/commons/api/format/AcceptType.java | 26 ++----
.../olingo/commons/api/format/ContentType.java | 85 ++++-------------
.../olingo/commons/api/format/TypeUtil.java | 36 ++++++--
.../olingo/commons/api/http/HttpHeader.java | 20 ++--
.../commons/api/format/ContentTypeTest.java | 1 -
.../processor/TechnicalActionProcessor.java | 9 +-
.../processor/TechnicalEntityProcessor.java | 6 +-
.../tecsvc/processor/TechnicalProcessor.java | 4 +-
25 files changed, 259 insertions(+), 362 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abf5bf79/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
index 22aea29..2a05021 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
@@ -45,6 +45,7 @@ import org.apache.olingo.client.api.domain.ClientValue;
import org.apache.olingo.client.core.ODataClientFactory;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.commons.api.http.HttpHeader;
import org.apache.olingo.commons.api.http.HttpStatusCode;
import org.apache.olingo.fit.AbstractBaseTestITCase;
import org.apache.olingo.fit.tecsvc.TecSvcConst;
@@ -304,6 +305,25 @@ public class ActionImportITCase extends AbstractBaseTestITCase {
getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ClientEntity.class, parameters)
.execute();
assertEquals(HttpStatusCode.CREATED.getStatusCode(), response.getStatusCode());
+ assertEquals(TecSvcConst.BASE_URI + "/ESAllPrim(1)", response.getHeader(HttpHeader.LOCATION).iterator().next());
+ }
+
+ @Test
+ public void entityActionETAllPrimNoContent() throws Exception {
+ final URI actionURI = getClient().newURIBuilder(TecSvcConst.BASE_URI)
+ .appendActionCallSegment("AIRTESAllPrimParam").build();
+ final Map<String, ClientValue> parameters = Collections.singletonMap(
+ "ParameterDate",
+ (ClientValue) getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("2000-02-29"));
+ ODataInvokeRequest<ClientEntity> request = getClient().getInvokeRequestFactory()
+ .getActionInvokeRequest(actionURI, ClientEntity.class, parameters);
+ request.setPrefer(getClient().newPreferences().returnMinimal());
+ final ODataInvokeResponse<ClientEntity> response = request.execute();
+ assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
+ assertEquals("return=minimal", response.getHeader(HttpHeader.PREFERENCE_APPLIED).iterator().next());
+ final String location = TecSvcConst.BASE_URI + "/ESAllPrim(1)";
+ assertEquals(location, response.getHeader(HttpHeader.LOCATION).iterator().next());
+ assertEquals(location, response.getHeader(HttpHeader.ODATA_ENTITY_ID).iterator().next());
}
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abf5bf79/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicHttpExceptionHandlingITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicHttpExceptionHandlingITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicHttpExceptionHandlingITCase.java
index 2166235..c0b1c69 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicHttpExceptionHandlingITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicHttpExceptionHandlingITCase.java
@@ -25,6 +25,7 @@ import java.net.URL;
import org.apache.olingo.client.api.ODataClient;
import org.apache.olingo.commons.api.http.HttpHeader;
+import org.apache.olingo.commons.api.http.HttpStatusCode;
import org.apache.olingo.fit.AbstractBaseTestITCase;
import org.apache.olingo.fit.tecsvc.TecSvcConst;
import org.junit.Test;
@@ -44,8 +45,7 @@ public class BasicHttpExceptionHandlingITCase extends AbstractBaseTestITCase {
connection.setRequestProperty(HttpHeader.X_HTTP_METHOD_OVERRIDE, "differentValue");
connection.connect();
- int code = connection.getResponseCode();
- assertEquals(400, code);
+ assertEquals(HttpStatusCode.BAD_REQUEST.getStatusCode(), connection.getResponseCode());
}
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abf5bf79/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
index 3466d46..2efba8a 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
@@ -84,18 +84,18 @@ import org.junit.Test;
public class BasicITCase extends AbstractBaseTestITCase {
- private static final String CONTENT_TYPE_JSON_IEEE754_COMPATIBLE = "application/json;odata.metadata=minimal;"
- + "IEEE754Compatible=true";
+ private static final String CONTENT_TYPE_JSON_IEEE754_COMPATIBLE =
+ ContentType.create(ContentType.JSON, ContentType.PARAMETER_IEEE754_COMPATIBLE, "true").toContentTypeString();
private static final String SERVICE_NAMESPACE = "olingo.odata.test1";
private static final String ET_ALL_PRIM_NAME = "ETAllPrim";
private static final FullQualifiedName ET_ALL_PRIM = new FullQualifiedName(SERVICE_NAMESPACE, ET_ALL_PRIM_NAME);
-
+
private static final String PROPERTY_INT16 = "PropertyInt16";
private static final String PROPERTY_INT64 = "PropertyInt64";
private static final String PROPERTY_DECIMAL = "PropertyDecimal";
private static final String PROPERTY_COMP_ALL_PRIM = "PropertyCompAllPrim";
private static final String NAV_PROPERTY_ET_TWO_PRIM_ONE = "NavPropertyETTwoPrimOne";
-
+
private static final String SERVICE_URI = TecSvcConst.BASE_URI;
private static final String ES_ALL_PRIM = "ESAllPrim";
private static final String ES_TWO_PRIM = "ESTwoPrim";
@@ -435,7 +435,9 @@ public class BasicITCase extends AbstractBaseTestITCase {
final ODataEntityCreateResponse<ClientEntity> response = request.execute();
assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
assertEquals("return=minimal", response.getHeader(HeaderName.preferenceApplied).iterator().next());
- assertEquals(SERVICE_URI + "/ESTwoPrim(1)", response.getHeader(HttpHeader.LOCATION).iterator().next());
+ final String location = SERVICE_URI + "/ESTwoPrim(1)";
+ assertEquals(location, response.getHeader(HttpHeader.LOCATION).iterator().next());
+ assertEquals(location, response.getHeader(HttpHeader.ODATA_ENTITY_ID).iterator().next());
}
@Test
@@ -1291,7 +1293,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
assertEquals(BigDecimal.valueOf(34), response.getBody().getPrimitiveValue().toValue());
}
-
+
@Override
protected ODataClient getClient() {
ODataClient odata = ODataClientFactory.getClient();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abf5bf79/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java
index 0039db6..3ab94da 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java
@@ -48,6 +48,7 @@ import org.apache.olingo.client.api.domain.ClientObjectFactory;
import org.apache.olingo.client.api.http.HttpClientException;
import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.client.core.communication.request.batch.ODataChangesetResponseItem;
+import org.apache.olingo.commons.api.ODataPreferenceNames;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.format.ContentType;
@@ -160,14 +161,14 @@ public class BatchClientITCase extends AbstractTestITCase {
ODataBatchResponseItem item = iter.next();
assertFalse(item.isChangeset());
- ODataResponse oDataResonse = item.next();
- assertNotNull(oDataResonse);
- assertEquals(HttpStatusCode.OK.getStatusCode(), oDataResonse.getStatusCode());
- assertEquals(1, oDataResonse.getHeader("OData-Version").size());
- assertEquals("4.0", oDataResonse.getHeader("OData-Version").toArray()[0]);
- assertEquals(1, oDataResonse.getHeader("Content-Length").size());
- assertEquals("605", oDataResonse.getHeader("Content-Length").toArray()[0]);
- assertEquals("application/json;odata.metadata=minimal", oDataResonse.getContentType());
+ ODataResponse oDataResponse = item.next();
+ assertNotNull(oDataResponse);
+ assertEquals(HttpStatusCode.OK.getStatusCode(), oDataResponse.getStatusCode());
+ assertEquals(1, oDataResponse.getHeader("OData-Version").size());
+ assertEquals("4.0", oDataResponse.getHeader("OData-Version").toArray()[0]);
+ assertEquals(1, oDataResponse.getHeader("Content-Length").size());
+ assertEquals("605", oDataResponse.getHeader("Content-Length").toArray()[0]);
+ assertEquals(ContentType.JSON.toContentTypeString(), oDataResponse.getContentType());
}
@Test
@@ -191,14 +192,14 @@ public class BatchClientITCase extends AbstractTestITCase {
ODataBatchResponseItem item = iter.next();
assertFalse(item.isChangeset());
- ODataResponse oDataResonse = item.next();
- assertNotNull(oDataResonse);
- assertEquals(HttpStatusCode.OK.getStatusCode(), oDataResonse.getStatusCode());
- assertEquals(1, oDataResonse.getHeader("OData-Version").size());
- assertEquals("4.0", oDataResonse.getHeader("OData-Version").toArray()[0]);
- assertEquals(1, oDataResonse.getHeader("Content-Length").size());
- assertEquals("605", oDataResonse.getHeader("Content-Length").toArray()[0]);
- assertEquals("application/json;odata.metadata=minimal", oDataResonse.getContentType());
+ ODataResponse oDataResponse = item.next();
+ assertNotNull(oDataResponse);
+ assertEquals(HttpStatusCode.OK.getStatusCode(), oDataResponse.getStatusCode());
+ assertEquals(1, oDataResponse.getHeader("OData-Version").size());
+ assertEquals("4.0", oDataResponse.getHeader("OData-Version").toArray()[0]);
+ assertEquals(1, oDataResponse.getHeader("Content-Length").size());
+ assertEquals("605", oDataResponse.getHeader("Content-Length").toArray()[0]);
+ assertEquals(ContentType.JSON.toContentTypeString(), oDataResponse.getContentType());
}
@Test
@@ -222,23 +223,23 @@ public class BatchClientITCase extends AbstractTestITCase {
ODataBatchResponseItem item = iter.next();
assertFalse(item.isChangeset());
- ODataResponse oDataResonse = item.next();
- assertNotNull(oDataResonse);
- assertEquals(HttpStatusCode.OK.getStatusCode(), oDataResonse.getStatusCode());
- assertEquals(1, oDataResonse.getHeader("OData-Version").size());
- assertEquals("4.0", oDataResonse.getHeader("OData-Version").toArray()[0]);
- assertEquals(1, oDataResonse.getHeader("Content-Length").size());
- assertEquals("605", oDataResonse.getHeader("Content-Length").toArray()[0]);
- assertEquals("application/json;odata.metadata=minimal", oDataResonse.getContentType());
+ ODataResponse oDataResponse = item.next();
+ assertNotNull(oDataResponse);
+ assertEquals(HttpStatusCode.OK.getStatusCode(), oDataResponse.getStatusCode());
+ assertEquals(1, oDataResponse.getHeader("OData-Version").size());
+ assertEquals("4.0", oDataResponse.getHeader("OData-Version").toArray()[0]);
+ assertEquals(1, oDataResponse.getHeader("Content-Length").size());
+ assertEquals("605", oDataResponse.getHeader("Content-Length").toArray()[0]);
+ assertEquals(ContentType.JSON.toContentTypeString(), oDataResponse.getContentType());
// Check second get request
assertTrue(iter.hasNext());
item = iter.next();
assertFalse(item.isChangeset());
- oDataResonse = item.next();
- assertNotNull(oDataResonse);
- assertEquals(HttpStatusCode.NOT_FOUND.getStatusCode(), oDataResonse.getStatusCode());
+ oDataResponse = item.next();
+ assertNotNull(oDataResponse);
+ assertEquals(HttpStatusCode.NOT_FOUND.getStatusCode(), oDataResponse.getStatusCode());
// Check if third request is available
assertFalse(iter.hasNext());
@@ -310,7 +311,8 @@ public class BatchClientITCase extends AbstractTestITCase {
// Fetch result
final ODataBatchResponse response = payload.getResponse();
assertEquals(HttpStatusCode.ACCEPTED.getStatusCode(), response.getStatusCode());
- assertEquals("odata.continue-on-error", response.getHeader(HttpHeader.PREFERENCE_APPLIED).iterator().next());
+ assertEquals(ODataPreferenceNames.CONTINUE_ON_ERROR.toString(),
+ response.getHeader(HttpHeader.PREFERENCE_APPLIED).iterator().next());
final Iterator<ODataBatchResponseItem> bodyIterator = response.getBody();
@@ -319,37 +321,37 @@ public class BatchClientITCase extends AbstractTestITCase {
ODataBatchResponseItem item = bodyIterator.next();
assertFalse(item.isChangeset());
- ODataResponse oDataResonse = item.next();
- assertNotNull(oDataResonse);
- assertEquals(HttpStatusCode.OK.getStatusCode(), oDataResonse.getStatusCode());
- assertEquals(1, oDataResonse.getHeader(HttpHeader.ODATA_VERSION).size());
- assertEquals("4.0", oDataResonse.getHeader(HttpHeader.ODATA_VERSION).toArray()[0]);
- assertEquals(1, oDataResonse.getHeader(HttpHeader.CONTENT_LENGTH).size());
- assertEquals("605", oDataResonse.getHeader(HttpHeader.CONTENT_LENGTH).toArray()[0]);
- assertEquals("application/json;odata.metadata=minimal", oDataResonse.getContentType());
+ ODataResponse oDataResponse = item.next();
+ assertNotNull(oDataResponse);
+ assertEquals(HttpStatusCode.OK.getStatusCode(), oDataResponse.getStatusCode());
+ assertEquals(1, oDataResponse.getHeader(HttpHeader.ODATA_VERSION).size());
+ assertEquals("4.0", oDataResponse.getHeader(HttpHeader.ODATA_VERSION).toArray()[0]);
+ assertEquals(1, oDataResponse.getHeader(HttpHeader.CONTENT_LENGTH).size());
+ assertEquals("605", oDataResponse.getHeader(HttpHeader.CONTENT_LENGTH).toArray()[0]);
+ assertEquals(ContentType.JSON.toContentTypeString(), oDataResponse.getContentType());
// Check second get request
assertTrue(bodyIterator.hasNext());
item = bodyIterator.next();
assertFalse(item.isChangeset());
- oDataResonse = item.next();
- assertNotNull(oDataResonse);
- assertEquals(HttpStatusCode.NOT_FOUND.getStatusCode(), oDataResonse.getStatusCode());
+ oDataResponse = item.next();
+ assertNotNull(oDataResponse);
+ assertEquals(HttpStatusCode.NOT_FOUND.getStatusCode(), oDataResponse.getStatusCode());
// Check if third request is available
assertTrue(bodyIterator.hasNext());
item = bodyIterator.next();
assertFalse(item.isChangeset());
- oDataResonse = item.next();
- assertNotNull(oDataResonse);
- assertEquals(HttpStatusCode.OK.getStatusCode(), oDataResonse.getStatusCode());
- assertEquals(1, oDataResonse.getHeader(HttpHeader.ODATA_VERSION).size());
- assertEquals("4.0", oDataResonse.getHeader(HttpHeader.ODATA_VERSION).toArray()[0]);
- assertEquals(1, oDataResonse.getHeader(HttpHeader.CONTENT_LENGTH).size());
- assertEquals("513", oDataResonse.getHeader(HttpHeader.CONTENT_LENGTH).toArray()[0]);
- assertEquals("application/json;odata.metadata=minimal", oDataResonse.getContentType());
+ oDataResponse = item.next();
+ assertNotNull(oDataResponse);
+ assertEquals(HttpStatusCode.OK.getStatusCode(), oDataResponse.getStatusCode());
+ assertEquals(1, oDataResponse.getHeader(HttpHeader.ODATA_VERSION).size());
+ assertEquals("4.0", oDataResponse.getHeader(HttpHeader.ODATA_VERSION).toArray()[0]);
+ assertEquals(1, oDataResponse.getHeader(HttpHeader.CONTENT_LENGTH).size());
+ assertEquals("513", oDataResponse.getHeader(HttpHeader.CONTENT_LENGTH).toArray()[0]);
+ assertEquals(ContentType.JSON.toContentTypeString(), oDataResponse.getContentType());
}
@Test
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abf5bf79/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/EdmEnabledClientITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/EdmEnabledClientITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/EdmEnabledClientITCase.java
deleted file mode 100644
index 05622bf..0000000
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/EdmEnabledClientITCase.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * 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
- *
- * 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
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.fit.tecsvc.client;
-
-import static org.junit.Assert.*;
-
-import java.net.URI;
-
-import org.apache.olingo.client.api.EdmEnabledODataClient;
-import org.apache.olingo.client.api.ODataClient;
-import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
-import org.apache.olingo.client.api.domain.ClientEntity;
-import org.apache.olingo.client.core.ODataClientFactory;
-import org.apache.olingo.fit.AbstractBaseTestITCase;
-import org.apache.olingo.fit.tecsvc.TecSvcConst;
-import org.junit.Test;
-
-public class EdmEnabledClientITCase extends AbstractBaseTestITCase {
-
- private static final String SERVICE_URI = TecSvcConst.BASE_URI;
- private static final String ES_KEY_NAV = "ESKeyNav";
- private static final String NAV_PROPERTY_ET_KEY_NAV_ONE = "NavPropertyETKeyNavOne";
-
- @Test
- public void readSingleValuedNavigationPropertyWithNullValue() {
- final ODataClient client = getClient();
- final URI uri = client.newURIBuilder(SERVICE_URI)
- .appendEntitySetSegment(ES_KEY_NAV)
- .appendKeySegment(3)
- .expand(NAV_PROPERTY_ET_KEY_NAV_ONE)
- .build();
-
-
- final ODataRetrieveResponse<ClientEntity> response = getClient().getRetrieveRequestFactory()
- .getEntityRequest(uri)
- .execute();
-
- assertEquals(0, response.getBody().getNavigationLinks().size());
- assertNull(response.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE));
- }
-
- @Override
- protected ODataClient getClient() {
- final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
- return client;
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abf5bf79/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ExpandSelectITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ExpandSelectITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ExpandSelectITCase.java
index 1ae1f22..df95a6e 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ExpandSelectITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ExpandSelectITCase.java
@@ -149,6 +149,18 @@ public final class ExpandSelectITCase extends AbstractBaseTestITCase {
assertEquals("Test String4", innerEntity.getProperty("PropertyString").getPrimitiveValue().toValue());
}
+ @Test
+ public void expandSingleValuedNavigationPropertyWithNullValue() {
+ final ODataClient client = getClient();
+ final ODataRetrieveResponse<ClientEntity> response = client.getRetrieveRequestFactory()
+ .getEntityRequest(client.newURIBuilder(TecSvcConst.BASE_URI)
+ .appendEntitySetSegment("ESKeyNav").appendKeySegment(3).expand("NavPropertyETKeyNavOne").build())
+ .execute();
+
+ assertEquals(0, response.getBody().getNavigationLinks().size());
+ assertNull(response.getBody().getNavigationLink("NavPropertyETKeyNavOne"));
+ }
+
@Override
protected ODataClient getClient() {
return ODataClientFactory.getEdmEnabledClient(TecSvcConst.BASE_URI);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abf5bf79/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/BasicBatchITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/BasicBatchITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/BasicBatchITCase.java
index 65d8830..38b3cf6 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/BasicBatchITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/BasicBatchITCase.java
@@ -31,6 +31,7 @@ import java.net.ProtocolException;
import java.net.URL;
import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.commons.api.format.ContentType;
import org.apache.olingo.commons.api.http.HttpHeader;
import org.apache.olingo.commons.api.http.HttpMethod;
import org.apache.olingo.commons.api.http.HttpStatusCode;
@@ -40,12 +41,16 @@ import org.junit.Test;
public class BasicBatchITCase extends AbstractBaseTestITCase {
- private static final String HEADER_CONTENT_TRANSFER_ENCODING_BINARY = "Content-Transfer-Encoding: binary";
- private static final String HEADER_CONTENT_TYPE_HTTP = "Content-Type: application/http";
private static final String SERVICE_URI = TecSvcConst.BASE_URI + "/";
- private static final String CONTENT_TYPE_HEADER_VALUE = " multipart/mixed;boundary=batch_123";
+
+ private static final String HEADER_CONTENT_TRANSFER_ENCODING_BINARY = "Content-Transfer-Encoding: binary";
+ private static final String HEADER_CONTENT_TYPE_HTTP =
+ HttpHeader.CONTENT_TYPE + ": " + ContentType.APPLICATION_HTTP.toContentTypeString();
+ private static final String CONTENT_TYPE_HEADER_VALUE = " "
+ + ContentType.create(ContentType.MULTIPART_MIXED, "boundary", "batch_123").toContentTypeString();
+ private static final String ACCEPT_HEADER_VALUE = ContentType.APPLICATION_JSON.toContentTypeString();
+
private static final String CRLF = "\r\n";
- private static final String ACCEPT_HEADER_VALUE = "application/json";
@Test
public void test() throws IOException {
@@ -110,7 +115,7 @@ public class BasicBatchITCase extends AbstractBaseTestITCase {
}
private void blankLine(final BufferedReader reader) throws IOException {
- assertEquals("", reader.readLine()); // CRLF becomes to an empty string
+ assertEquals("", reader.readLine()); // CRLF becomes an empty string
}
private String getRequest(final String uri) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abf5bf79/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/BasicHttpITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/BasicHttpITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/BasicHttpITCase.java
index dc32808..e097581 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/BasicHttpITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/BasicHttpITCase.java
@@ -21,18 +21,17 @@ package org.apache.olingo.fit.tecsvc.http;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import java.io.InputStream;
-import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
+import org.apache.commons.io.IOUtils;
import org.apache.olingo.client.api.ODataClient;
import org.apache.olingo.commons.api.format.ContentType;
import org.apache.olingo.commons.api.http.HttpHeader;
+import org.apache.olingo.commons.api.http.HttpMethod;
import org.apache.olingo.commons.api.http.HttpStatusCode;
import org.apache.olingo.fit.AbstractBaseTestITCase;
import org.apache.olingo.fit.tecsvc.TecSvcConst;
-import org.apache.olingo.server.core.deserializer.batch.BufferedReaderIncludingLineEndings;
import org.junit.Test;
public class BasicHttpITCase extends AbstractBaseTestITCase {
@@ -44,13 +43,11 @@ public class BasicHttpITCase extends AbstractBaseTestITCase {
URL url = new URL(SERVICE_URI + "?$format=json");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection.setRequestMethod("GET");
+ connection.setRequestMethod(HttpMethod.GET.name());
connection.connect();
- int code = connection.getResponseCode();
- assertEquals(200, code);
- String ct = connection.getHeaderField(HttpHeader.CONTENT_TYPE);
- assertEquals(ContentType.create("application/json;odata.metadata=minimal"), ContentType.create(ct));
+ assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode());
+ assertEquals(ContentType.JSON, ContentType.create(connection.getHeaderField(HttpHeader.CONTENT_TYPE)));
}
@Test
@@ -59,15 +56,13 @@ public class BasicHttpITCase extends AbstractBaseTestITCase {
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection.setRequestMethod("GET");
+ connection.setRequestMethod(HttpMethod.GET.name());
connection.setRequestProperty(HttpHeader.ACCEPT, "application/json;q=0.2;odata.metadata=minimal");
connection.connect();
- int code = connection.getResponseCode();
- assertEquals(200, code);
- String ct = connection.getHeaderField(HttpHeader.CONTENT_TYPE);
- assertEquals(ContentType.create("application/json;odata.metadata=minimal"), ContentType.create(ct));
+ assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode());
+ assertEquals(ContentType.JSON, ContentType.create(connection.getHeaderField(HttpHeader.CONTENT_TYPE)));
}
@Test
@@ -76,15 +71,13 @@ public class BasicHttpITCase extends AbstractBaseTestITCase {
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection.setRequestMethod("GET");
+ connection.setRequestMethod(HttpMethod.GET.name());
connection.setRequestProperty(HttpHeader.ACCEPT, "application/json");
connection.connect();
- int code = connection.getResponseCode();
- assertEquals(200, code);
- String ct = connection.getHeaderField(HttpHeader.CONTENT_TYPE);
- assertEquals(ContentType.create("application/json;odata.metadata=minimal"), ContentType.create(ct));
+ assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode());
+ assertEquals(ContentType.JSON, ContentType.create(connection.getHeaderField(HttpHeader.CONTENT_TYPE)));
}
@Test
@@ -93,15 +86,14 @@ public class BasicHttpITCase extends AbstractBaseTestITCase {
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection.setRequestMethod("GET");
+ connection.setRequestMethod(HttpMethod.GET.name());
connection.setRequestProperty(HttpHeader.ACCEPT, "application/json;q=0.2;odata.metadata=minimal;charset=utf-8");
connection.connect();
- int code = connection.getResponseCode();
- assertEquals(200, code);
- String ct = connection.getHeaderField(HttpHeader.CONTENT_TYPE);
- assertEquals(ContentType.create("application/json;odata.metadata=minimal;charset=utf-8"), ContentType.create(ct));
+ assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode());
+ assertEquals(ContentType.create(ContentType.JSON, ContentType.PARAMETER_CHARSET, "utf-8"),
+ ContentType.create(connection.getHeaderField(HttpHeader.CONTENT_TYPE)));
}
@Test
@@ -110,65 +102,50 @@ public class BasicHttpITCase extends AbstractBaseTestITCase {
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection.setRequestMethod("GET");
+ connection.setRequestMethod(HttpMethod.GET.name());
connection.setRequestProperty(HttpHeader.ODATA_MAX_VERSION, "4.0");
connection.setRequestProperty(HttpHeader.ACCEPT, "*/*");
connection.connect();
- int code = connection.getResponseCode();
- assertEquals(200, code);
- String v = connection.getHeaderField(HttpHeader.ODATA_VERSION);
- assertEquals("4.0", v);
+ assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode());
+ assertEquals("4.0", connection.getHeaderField(HttpHeader.ODATA_VERSION));
}
-
+
@Test
public void testIEEE754ParameterContentNegotiation() throws Exception {
final URL url = new URL(SERVICE_URI + "/ESAllPrim(32767)?$format=application/json;IEEE754Compatible=true");
final HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection.setRequestMethod("GET");
+ connection.setRequestMethod(HttpMethod.GET.name());
connection.setRequestProperty(HttpHeader.ACCEPT, "application/json;IEEE754Compatible=false");
connection.connect();
-
+
assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode());
- assertEquals(ContentType.create("application/json;IEEE754Compatible=true;odata.metadata=minimal"),
- ContentType.create(connection.getContentType()));
- final String content = inputStreamToString(connection.getInputStream());
-
+ assertEquals(ContentType.create(ContentType.JSON, ContentType.PARAMETER_IEEE754_COMPATIBLE, "true"),
+ ContentType.create(connection.getContentType()));
+ final String content = IOUtils.toString(connection.getInputStream());
+
assertTrue(content.contains("\"PropertyDecimal\":\"34\""));
assertTrue(content.contains("\"PropertyInt64\":\"9223372036854775807\""));
}
-
+
@Test
public void testIEEE754ParameterViaAcceptHeader() throws Exception {
final URL url = new URL(SERVICE_URI + "/ESAllPrim(32767)");
final HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection.setRequestMethod("GET");
+ connection.setRequestMethod(HttpMethod.GET.name());
connection.setRequestProperty(HttpHeader.ACCEPT, "application/json;IEEE754Compatible=true");
connection.connect();
-
+
assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode());
- assertEquals(ContentType.create("application/json;IEEE754Compatible=true;odata.metadata=minimal"),
- ContentType.create(connection.getContentType()));
- final String content = inputStreamToString(connection.getInputStream());
-
+ assertEquals(ContentType.create(ContentType.JSON, ContentType.PARAMETER_IEEE754_COMPATIBLE, "true"),
+ ContentType.create(connection.getContentType()));
+ final String content = IOUtils.toString(connection.getInputStream());
+
assertTrue(content.contains("\"PropertyDecimal\":\"34\""));
assertTrue(content.contains("\"PropertyInt64\":\"9223372036854775807\""));
}
-
- private String inputStreamToString(final InputStream in) throws Exception {
- final BufferedReaderIncludingLineEndings reader = new BufferedReaderIncludingLineEndings(new InputStreamReader(in));
- final StringBuffer buffer = new StringBuffer();
- String current;
-
- while((current = reader.readLine()) != null) {
- buffer.append(current);
- }
-
- reader.close();
- return buffer.toString();
- }
-
+
@Override
protected ODataClient getClient() {
return null;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abf5bf79/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/EntityReferenceITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/EntityReferenceITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/EntityReferenceITCase.java
index bcfc096..359feb7 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/EntityReferenceITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/EntityReferenceITCase.java
@@ -21,16 +21,17 @@ package org.apache.olingo.fit.tecsvc.http;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import java.io.InputStream;
-import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
+import org.apache.commons.io.IOUtils;
import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.commons.api.format.ContentType;
import org.apache.olingo.commons.api.http.HttpHeader;
+import org.apache.olingo.commons.api.http.HttpMethod;
+import org.apache.olingo.commons.api.http.HttpStatusCode;
import org.apache.olingo.fit.AbstractBaseTestITCase;
import org.apache.olingo.fit.tecsvc.TecSvcConst;
-import org.apache.olingo.server.core.deserializer.batch.BufferedReaderIncludingLineEndings;
import org.junit.Test;
public class EntityReferenceITCase extends AbstractBaseTestITCase {
@@ -41,49 +42,34 @@ public class EntityReferenceITCase extends AbstractBaseTestITCase {
@Test
public void testContextURlSingleEntity() throws Exception {
- URL url = new URL(SERVICE_URI + "/ESAllPrim(0)/$ref");
+ URL url = new URL(SERVICE_URI + "/ESAllPrim(0)/$ref");
- HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection.setRequestProperty(HttpHeader.ACCEPT, "application/json");
- connection.setRequestMethod("GET");
- connection.connect();
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ connection.setRequestProperty(HttpHeader.ACCEPT, ContentType.APPLICATION_JSON.toContentTypeString());
+ connection.setRequestMethod(HttpMethod.GET.name());
+ connection.connect();
- int code = connection.getResponseCode();
- assertEquals(200, code);
-
- final String content = getString(connection.getInputStream());
- assertTrue(content.contains(CONTEXT_ENTITY_REFERENCE));
- }
+ assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode());
+
+ final String content = IOUtils.toString(connection.getInputStream());
+ assertTrue(content.contains(CONTEXT_ENTITY_REFERENCE));
+ }
@Test
public void testContextURLEntityCollection() throws Exception {
URL url = new URL(SERVICE_URI + "/ESAllPrim/$ref");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection.setRequestProperty(HttpHeader.ACCEPT, "application/json");
- connection.setRequestMethod("GET");
+ connection.setRequestProperty(HttpHeader.ACCEPT, ContentType.APPLICATION_JSON.toContentTypeString());
+ connection.setRequestMethod(HttpMethod.GET.name());
connection.connect();
- int code = connection.getResponseCode();
- assertEquals(200, code);
-
- final String content = getString(connection.getInputStream());
+ assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode());
+
+ final String content = IOUtils.toString(connection.getInputStream());
assertTrue(content.contains(CONTEXT_COLLECTION_REFERENCE));
}
-
- private String getString(final InputStream in) throws Exception {
- final StringBuilder builder = new StringBuilder();
- final BufferedReaderIncludingLineEndings reader = new BufferedReaderIncludingLineEndings(new InputStreamReader(in));
-
- String line;
- while((line = reader.readLine()) != null) {
- builder.append(line);
- }
-
- reader.close();
- return builder.toString();
- }
-
+
@Override
protected ODataClient getClient() {
return null;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abf5bf79/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/PingITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/PingITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/PingITCase.java
index b016a4b..5a20f29 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/PingITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/PingITCase.java
@@ -25,6 +25,8 @@ import java.net.URL;
import org.apache.olingo.client.api.ODataClient;
import org.apache.olingo.commons.api.http.HttpHeader;
+import org.apache.olingo.commons.api.http.HttpMethod;
+import org.apache.olingo.commons.api.http.HttpStatusCode;
import org.apache.olingo.fit.AbstractBaseTestITCase;
import org.apache.olingo.fit.tecsvc.TecSvcConst;
import org.junit.Test;
@@ -41,12 +43,11 @@ public class PingITCase extends AbstractBaseTestITCase {
LOG.debug("ping request: " + SERVICE_URI);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection.setRequestMethod("GET");
+ connection.setRequestMethod(HttpMethod.GET.name());
connection.setRequestProperty(HttpHeader.ACCEPT, "*/*");
connection.connect();
- int code = connection.getResponseCode();
- assertEquals(200, code);
+ assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode());
}
@Test
@@ -57,12 +58,11 @@ public class PingITCase extends AbstractBaseTestITCase {
LOG.debug("redirect request: " + REDIRECT_URI);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection.setRequestMethod("GET");
+ connection.setRequestMethod(HttpMethod.GET.name());
connection.setRequestProperty(HttpHeader.ACCEPT, "*/*");
connection.connect();
- int code = connection.getResponseCode();
- assertEquals(200, code);
+ assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode());
}
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abf5bf79/fit/src/test/java/org/apache/olingo/fit/v4/EntityRetrieveTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/EntityRetrieveTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/EntityRetrieveTestITCase.java
index 58fc160..7831bd7 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/EntityRetrieveTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/EntityRetrieveTestITCase.java
@@ -70,7 +70,8 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
assertEquals("Edm.GeographyPoint", entity.getProperty("Home").getPrimitiveValue().getTypeName());
// In JSON with minimal metadata, links are not provided
- if(contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC, ContentType.APPLICATION_ATOM_XML)
+ if (contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC)
+ || contentType.isCompatible(ContentType.APPLICATION_ATOM_XML)
|| (contentType.isCompatible(ContentType.JSON)
&& ContentType.VALUE_ODATA_METADATA_FULL
.equals(contentType.getParameter(ContentType.PARAMETER_ODATA_METADATA)))) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abf5bf79/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ClientEntitySetIterator.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ClientEntitySetIterator.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ClientEntitySetIterator.java
index added7a..376404b 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ClientEntitySetIterator.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ClientEntitySetIterator.java
@@ -85,7 +85,8 @@ public class ClientEntitySetIterator<ES extends ClientEntitySet, E extends Clien
this.contentType = contentType;
this.osEntitySet = new ByteArrayOutputStream();
- if(contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC, ContentType.APPLICATION_ATOM_XML)) {
+ if(contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC)
+ || contentType.isCompatible(ContentType.APPLICATION_ATOM_XML)) {
namespaces = getAllElementAttributes(stream, "feed", osEntitySet);
} else {
namespaces = null;
@@ -103,14 +104,12 @@ public class ClientEntitySetIterator<ES extends ClientEntitySet, E extends Clien
}
}
- /**
- * {@inheritDoc }
- */
- @Override
@SuppressWarnings("unchecked")
+ @Override
public boolean hasNext() {
if (available && cached == null) {
- if (contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC, ContentType.APPLICATION_ATOM_XML)) {
+ if (contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC)
+ || contentType.isCompatible(ContentType.APPLICATION_ATOM_XML)) {
cached = nextAtomEntityFromEntitySet(stream, osEntitySet, namespaces);
} else {
cached = nextJSONEntityFromEntitySet(stream, osEntitySet);
@@ -131,9 +130,6 @@ public class ClientEntitySetIterator<ES extends ClientEntitySet, E extends Clien
return available;
}
- /**
- * {@inheritDoc }
- */
@Override
public E next() {
if (hasNext()) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abf5bf79/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 b00d3a8..6c3bb4c 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
@@ -95,7 +95,7 @@ public class ODataClientImpl implements ODataClient {
public ODataWriter getWriter() {
return writer;
}
-
+
@Override
public ODataServiceVersion getServiceVersion() {
return ODataServiceVersion.V40;
@@ -113,7 +113,7 @@ public class ODataClientImpl implements ODataClient {
public URIBuilder newURIBuilder(final String serviceRoot) {
return new URIBuilderImpl(getConfiguration(), serviceRoot);
}
-
+
@Override
public FilterFactory getFilterFactory() {
return filterFactory;
@@ -131,10 +131,10 @@ public class ODataClientImpl implements ODataClient {
@Override
public ODataSerializer getSerializer(final ContentType contentType) {
- return contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC, ContentType.APPLICATION_ATOM_XML,
- ContentType.APPLICATION_XML) ?
- new AtomSerializer() : new JsonSerializer(false, contentType);
-
+ return contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC)
+ || contentType.isCompatible(ContentType.APPLICATION_ATOM_XML)
+ || contentType.isCompatible(ContentType.APPLICATION_XML) ?
+ new AtomSerializer() : new JsonSerializer(false, contentType);
}
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abf5bf79/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 f28130d..8bd3363 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
@@ -96,9 +96,10 @@ public abstract class AbstractODataInvokeRequest<T extends ClientInvokeResult>
}
private String getActualFormat(final ContentType contentType) {
- return ((ClientProperty.class.isAssignableFrom(reference)
- && contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC, ContentType.APPLICATION_ATOM_XML))
- ? ContentType.APPLICATION_XML : contentType).toContentTypeString();
+ return (ClientProperty.class.isAssignableFrom(reference)
+ && (contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC)
+ || contentType.isCompatible(ContentType.APPLICATION_ATOM_XML)) ?
+ ContentType.APPLICATION_XML : contentType).toContentTypeString();
}
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abf5bf79/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 b6c233f..4a2f078 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
@@ -54,13 +54,13 @@ import com.fasterxml.jackson.dataformat.xml.XmlMapper;
public class ClientODataDeserializerImpl implements ClientODataDeserializer {
private final ODataDeserializer deserializer;
-
private final ContentType contentType;
public ClientODataDeserializerImpl(final boolean serverMode, final ContentType contentType) {
this.contentType = contentType;
- if(contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC, ContentType.APPLICATION_ATOM_XML,
- ContentType.APPLICATION_XML )) {
+ if (contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC)
+ || contentType.isCompatible(ContentType.APPLICATION_ATOM_XML)
+ || contentType.isCompatible(ContentType.APPLICATION_XML)) {
deserializer = new AtomDeserializer();
} else {
deserializer = new JsonDeserializer(serverMode);
@@ -127,10 +127,11 @@ public class ClientODataDeserializerImpl implements ClientODataDeserializer {
@Override
public ResWrap<Delta> toDelta(final InputStream input) throws ODataDeserializerException {
try {
- return contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC, ContentType.APPLICATION_ATOM_XML) ?
+ return contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC)
+ || contentType.isCompatible(ContentType.APPLICATION_ATOM_XML) ?
new AtomDeserializer().delta(input) :
new JsonDeltaDeserializer(false).toDelta(input);
- } catch (XMLStreamException e) {
+ } catch (final XMLStreamException e) {
throw new ODataDeserializerException(e);
} catch (final EdmPrimitiveTypeException e) {
throw new ODataDeserializerException(e);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abf5bf79/lib/client-core/src/test/java/org/apache/olingo/client/core/AbstractTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/AbstractTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/AbstractTest.java
index beeda7e..bc116a8 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/AbstractTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/AbstractTest.java
@@ -44,7 +44,8 @@ public abstract class AbstractTest {
}
protected String getSuffix(final ContentType contentType) {
- return contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC, ContentType.APPLICATION_ATOM_XML,
- ContentType.APPLICATION_XML) ? "xml": "json";
+ return contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC)
+ || contentType.isCompatible(ContentType.APPLICATION_ATOM_XML)
+ || contentType.isCompatible(ContentType.APPLICATION_XML) ? "xml": "json";
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abf5bf79/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
index a21cc15..6b69135 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
@@ -102,7 +102,8 @@ public class EntityTest extends AbstractTest {
}
if ("Orders".equals(link.getName())) {
checked++;
- if(contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC, ContentType.APPLICATION_ATOM_XML)) {
+ if (contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC)
+ || contentType.isCompatible(ContentType.APPLICATION_ATOM_XML)) {
assertEquals(ClientLinkType.ENTITY_SET_NAVIGATION, link.getType());
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abf5bf79/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/AcceptType.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/AcceptType.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/AcceptType.java
index ec273be..caf52ba 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/AcceptType.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/AcceptType.java
@@ -24,7 +24,6 @@ import java.util.Comparator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
-import java.util.TreeMap;
/**
* Internally used {@link AcceptType} for OData library.
@@ -55,26 +54,17 @@ public class AcceptType {
final Float quality) {
this.type = type;
this.subtype = subtype;
- this.parameters = createParameterMap();
+ this.parameters = TypeUtil.createParameterMap();
this.parameters.putAll(parameters);
this.quality = quality;
}
- private static TreeMap<String, String> createParameterMap() {
- return new TreeMap<String, String>(new Comparator<String>() {
- @Override
- public int compare(final String o1, final String o2) {
- return o1.compareToIgnoreCase(o2);
- }
- });
- }
-
private AcceptType(final String type) {
if (type == null) {
throw new IllegalArgumentException("Type parameter MUST NOT be null.");
}
List<String> typeSubtype = new ArrayList<String>();
- parameters = createParameterMap();
+ parameters = TypeUtil.createParameterMap();
parse(type, typeSubtype, parameters);
this.type = typeSubtype.get(0);
@@ -122,15 +112,15 @@ public class AcceptType {
}
/**
- * Creates a list of {@link AcceptType} objects based on given input string (<code>format</code>).
- * @param contentType accept types, comma-separated, as specified for the HTTP header <code>Accept</code>
+ * Creates a list of {@link AcceptType} objects based on given input string.
+ * @param acceptTypes accept types, comma-separated, as specified for the HTTP header <code>Accept</code>
* @return a list of <code>AcceptType</code> objects
* @throws IllegalArgumentException if input string is not parseable
*/
- public static List<AcceptType> create(final String contentType) {
+ public static List<AcceptType> create(final String acceptTypes) {
List<AcceptType> result = new ArrayList<AcceptType>();
- String[] values = contentType.split(",");
+ String[] values = acceptTypes.split(",");
for (String value : values) {
result.add(new AcceptType(value.trim()));
}
@@ -220,12 +210,12 @@ public class AcceptType {
}
/**
- * Sort given list of Accept types
+ * Sorts given list of Accept types
* according to their quality-parameter values and their specificity
* as defined in RFC 7231, chapters 3.1.1.1, 5.3.1, and 5.3.2.
* @param toSort list which is sorted and hence re-arranged
*/
- private static void sort(final List<AcceptType> toSort) {
+ private static void sort(List<AcceptType> toSort) {
Collections.sort(toSort,
new Comparator<AcceptType>() {
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abf5bf79/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java
index 473ff58..2ff035d 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java
@@ -20,14 +20,12 @@ package org.apache.olingo.commons.api.format;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.TreeMap;
/**
* Internally used {@link ContentType} for OData library.
@@ -96,10 +94,9 @@ public final class ContentType {
/**
* Creates a content type from type, subtype, and parameters.
- *
- * @param type
- * @param subtype
- * @param parameters
+ * @param type type
+ * @param subtype subtype
+ * @param parameters parameters as map from names to values
*/
private ContentType(final String type, final String subtype, final Map<String, String> parameters) {
this.type = validateType(type);
@@ -108,17 +105,12 @@ public final class ContentType {
if (parameters == null) {
this.parameters = Collections.emptyMap();
} else {
- this.parameters = new TreeMap<String, String>(new Comparator<String>() {
- @Override
- public int compare(final String o1, final String o2) {
- return o1.compareToIgnoreCase(o2);
- }
- });
+ this.parameters = TypeUtil.createParameterMap();
this.parameters.putAll(parameters);
}
}
- private String validateType(final String type) {
+ private String validateType(final String type) throws IllegalArgumentException {
if (type == null || type.isEmpty() || "*".equals(type)) {
throw new IllegalArgumentException("Illegal type '" + type + "'.");
}
@@ -129,20 +121,6 @@ public final class ContentType {
}
/**
- * Validates if given <code>format</code> is parseable and can be used as input for {@link #create(String)} method.
- *
- * @param format to be validated string
- * @return <code>true</code> if format is parseable otherwise <code>false</code>
- */
- public static boolean isParseable(final String format) {
- try {
- return ContentType.create(format) != null;
- } catch (IllegalArgumentException e) {
- return false;
- }
- }
-
- /**
* Creates a content type from an existing content type and an additional parameter as key-value pair.
* @param contentType an existing content type
* @param parameterName the name of the additional parameter
@@ -150,17 +128,12 @@ public final class ContentType {
* @return a new {@link ContentType} object
*/
public static ContentType create(final ContentType contentType,
- final String parameterName, final String parameterValue) {
- if (parameterName == null || parameterName.isEmpty() || parameterName.indexOf(TypeUtil.WHITESPACE_CHAR) >= 0) {
- throw new IllegalArgumentException("Illegal parameter name '" + parameterName + "'.");
- }
- if (Character.isWhitespace(parameterValue.charAt(0))) {
- throw new IllegalArgumentException("Value of parameter '" + parameterName + "' starts with whitespace.");
- }
+ final String parameterName, final String parameterValue) throws IllegalArgumentException {
+ TypeUtil.validateParameterNameAndValue(parameterName, parameterValue);
- ContentType ct = new ContentType(contentType.type, contentType.subtype, contentType.parameters);
- ct.parameters.put(parameterName.toLowerCase(Locale.ROOT), parameterValue);
- return ct;
+ ContentType type = new ContentType(contentType.type, contentType.subtype, contentType.parameters);
+ type.parameters.put(parameterName.toLowerCase(Locale.ROOT), parameterValue);
+ return type;
}
/**
@@ -168,15 +141,15 @@ public final class ContentType {
* <code>Media Type</code> format as defined in RFC 7231, chapter 3.1.1.1.
*
* @param format a string in format as defined in RFC 7231, chapter 3.1.1.1
- * @return a new <code>ContentType</code> object
+ * @return a new {@link ContentType} object
* @throws IllegalArgumentException if input string is not parseable
*/
- public static ContentType create(final String format) {
+ public static ContentType create(final String format) throws IllegalArgumentException {
if (format == null) {
throw new IllegalArgumentException("Parameter format MUST NOT be NULL.");
}
- final List<String> typeSubtype = new ArrayList<String>();
- final Map<String, String> parameters = new HashMap<String, String>();
+ List<String> typeSubtype = new ArrayList<String>();
+ Map<String, String> parameters = new HashMap<String, String>();
parse(format, typeSubtype, parameters);
return new ContentType(typeSubtype.get(0), typeSubtype.get(1), parameters);
}
@@ -198,7 +171,8 @@ public final class ContentType {
}
}
- private static void parse(final String format, final List<String> typeSubtype, final Map<String, String> parameters) {
+ private static void parse(final String format, List<String> typeSubtype, Map<String, String> parameters)
+ throws IllegalArgumentException {
final String[] typesAndParameters = format.split(TypeUtil.PARAMETER_SEPARATOR, 2);
final String types = typesAndParameters[0];
final String params = (typesAndParameters.length > 1 ? typesAndParameters[1] : null);
@@ -246,8 +220,7 @@ public final class ContentType {
/**
* Returns the value of a given parameter.
- * If the parameter does not exists the method returns null.
- *
+ * If the parameter does not exist the method returns null.
* @param name the name of the parameter to get (case-insensitive)
* @return the value of the parameter or <code>null</code> if the parameter is not present
*/
@@ -311,25 +284,7 @@ public final class ContentType {
}
/**
- * <p>{@link ContentType}s are <b>compatible</b>
- * if <code>type</code> and <code>subtype</code> have the same value.</p>
- * <p>The set <code>parameters</code> are <b>always</b> ignored
- * (for compare with parameters see {@link #equals(Object)}).</p>
- * @return <code>true</code> if both instances are compatible (see definition above), otherwise <code>false</code>.
- */
- public boolean isCompatible(final ContentType... otherTypes) {
- for (final ContentType otherType : otherTypes) {
- if (isCompatible(otherType)) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
* Checks whether both strings are equal ignoring the case of the strings.
- *
* @param first first string
* @param second second string
* @return <code>true</code> if both strings are equal (ignoring the case), otherwise <code>false</code>
@@ -340,10 +295,8 @@ public final class ContentType {
/**
* Gets {@link ContentType} as string as defined in
- * <a href="http://www.ietf.org/rfc/rfc7231.txt">RFC 7231</a>, chapter 3.1.1.1:
- * Media Type.
- *
- * @return string representation of <code>ContentType</code> object
+ * <a href="http://www.ietf.org/rfc/rfc7231.txt">RFC 7231</a>, chapter 3.1.1.1: Media Type.
+ * @return string representation of {@link ContentType} object
*/
public String toContentTypeString() {
final StringBuilder sb = new StringBuilder();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abf5bf79/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/TypeUtil.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/TypeUtil.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/TypeUtil.java
index 03fd078..64b2672 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/TypeUtil.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/TypeUtil.java
@@ -18,8 +18,10 @@
*/
package org.apache.olingo.commons.api.format;
+import java.util.Comparator;
import java.util.Locale;
import java.util.Map;
+import java.util.TreeMap;
class TypeUtil {
@@ -32,6 +34,16 @@ class TypeUtil {
static final String TYPE_SUBTYPE_SEPARATOR = "/";
static final String TYPE_SUBTYPE_WILDCARD = "*";
+ /** Creates a parameter map with predictable order. */
+ protected static Map<String, String> createParameterMap() {
+ return new TreeMap<String, String>(new Comparator<String>() {
+ @Override
+ public int compare(final String o1, final String o2) {
+ return o1.compareToIgnoreCase(o2);
+ }
+ });
+ }
+
/**
* Valid input are <code>;</code> separated <code>key=value</code> pairs
* without spaces between key and value.
@@ -60,19 +72,23 @@ class TypeUtil {
if (parameter.isEmpty()) {
throw new IllegalArgumentException("An empty parameter is not allowed.");
}
- String[] keyValue = parameter.trim().split(TypeUtil.PARAMETER_KEY_VALUE_SEPARATOR);
- if (keyValue.length != 2 || keyValue[0].isEmpty()) {
- throw new IllegalArgumentException(
- "Parameter '" + parameter + "' must have exactly one '" + TypeUtil.PARAMETER_KEY_VALUE_SEPARATOR +
- "' that separates the name and the value.");
+ String[] keyValue = parameter.trim().split(PARAMETER_KEY_VALUE_SEPARATOR);
+ if (keyValue.length != 2) {
+ throw new IllegalArgumentException("Parameter '" + parameter + "' must have exactly one '"
+ + PARAMETER_KEY_VALUE_SEPARATOR + "' that separates the name and the value.");
}
+ validateParameterNameAndValue(keyValue[0], keyValue[1]);
keyValue[0] = keyValue[0].toLowerCase(Locale.ENGLISH);
- if (keyValue[0].indexOf(WHITESPACE_CHAR) >= 0) {
- throw new IllegalArgumentException("Parameter name '" + keyValue[0] + "' contains whitespace.");
+ return keyValue;
+ }
+
+ protected static void validateParameterNameAndValue(final String parameterName, final String parameterValue)
+ throws IllegalArgumentException {
+ if (parameterName == null || parameterName.isEmpty() || parameterName.indexOf(WHITESPACE_CHAR) >= 0) {
+ throw new IllegalArgumentException("Illegal parameter name '" + parameterName + "'.");
}
- if (Character.isWhitespace(keyValue[1].charAt(0))) {
- throw new IllegalArgumentException("Value of parameter '" + keyValue[0] + "' starts with whitespace.");
+ if (Character.isWhitespace(parameterValue.charAt(0))) {
+ throw new IllegalArgumentException("Value of parameter '" + parameterName + "' starts with whitespace.");
}
- return keyValue;
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abf5bf79/lib/commons-api/src/main/java/org/apache/olingo/commons/api/http/HttpHeader.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/http/HttpHeader.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/http/HttpHeader.java
index 1036b88..d9ebe1b 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/http/HttpHeader.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/http/HttpHeader.java
@@ -165,23 +165,15 @@ public interface HttpHeader {
*/
public static final String SET_COOKIE = "Set-Cookie";
- /**
- * non standard header
- */
+ /** Non standard header. */
public static final String X_HTTP_METHOD = "X-HTTP-Method";
-
- /**
- * non standard header
- */
+ /** Non standard header. */
public static final String X_HTTP_METHOD_OVERRIDE = "X-HTTP-Method-Override";
- /**
- * OData Custom Header
- */
+ /** Custom Header defined in the OData standard. */
public static final String ODATA_VERSION = "OData-Version";
-
- /**
- * OData Custom Header
- */
+ /** Custom Header defined in the OData standard. */
public static final String ODATA_MAX_VERSION = "OData-MaxVersion";
+ /** Custom Header defined in the OData standard. */
+ public static final String ODATA_ENTITY_ID = "OData-EntityID";
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abf5bf79/lib/commons-api/src/test/java/org/apache/olingo/commons/api/format/ContentTypeTest.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/test/java/org/apache/olingo/commons/api/format/ContentTypeTest.java b/lib/commons-api/src/test/java/org/apache/olingo/commons/api/format/ContentTypeTest.java
index 6f7460b..f173a76 100644
--- a/lib/commons-api/src/test/java/org/apache/olingo/commons/api/format/ContentTypeTest.java
+++ b/lib/commons-api/src/test/java/org/apache/olingo/commons/api/format/ContentTypeTest.java
@@ -100,7 +100,6 @@ public class ContentTypeTest {
@Test
public void testParse() {
assertNull(ContentType.parse("a"));
- assertFalse(ContentType.isParseable("a"));
}
@Test(expected = IllegalArgumentException.class)
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abf5bf79/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalActionProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalActionProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalActionProcessor.java
index 663a7eb..9eb836c 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalActionProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalActionProcessor.java
@@ -158,9 +158,12 @@ public class TechnicalActionProcessor extends TechnicalProcessor
PreferencesApplied.with().returnRepresentation(returnPreference).build().toValueString());
}
if (entityResult.isCreated()) {
- response.setHeader(HttpHeader.LOCATION,
- request.getRawBaseUri() + '/'
- + odata.createUriHelper().buildCanonicalURL(edmEntitySet, entityResult.getEntity()));
+ final String location = request.getRawBaseUri() + '/'
+ + odata.createUriHelper().buildCanonicalURL(edmEntitySet, entityResult.getEntity());
+ response.setHeader(HttpHeader.LOCATION, location);
+ if (returnPreference == Return.MINIMAL) {
+ response.setHeader(HttpHeader.ODATA_ENTITY_ID, location);
+ }
}
if (entityResult.getEntity().getETag() != null) {
response.setHeader(HttpHeader.ETAG, entityResult.getEntity().getETag());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abf5bf79/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
index 9844d71..2904e18 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
@@ -164,6 +164,8 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
expand = deserializerResult.getExpandTree();
}
+ final String location = request.getRawBaseUri() + '/'
+ + odata.createUriHelper().buildCanonicalURL(edmEntitySet, entity);
final Return returnPreference = odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).getReturn();
if (returnPreference == null || returnPreference == Return.REPRESENTATION) {
response.setContent(serializeEntity(entity, edmEntitySet, edmEntityType, responseFormat, expand, null)
@@ -172,13 +174,13 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
response.setStatusCode(HttpStatusCode.CREATED.getStatusCode());
} else {
response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
+ response.setHeader(HttpHeader.ODATA_ENTITY_ID, location);
}
if (returnPreference != null) {
response.setHeader(HttpHeader.PREFERENCE_APPLIED,
PreferencesApplied.with().returnRepresentation(returnPreference).build().toValueString());
}
- response.setHeader(HttpHeader.LOCATION,
- request.getRawBaseUri() + '/' + odata.createUriHelper().buildCanonicalURL(edmEntitySet, entity));
+ response.setHeader(HttpHeader.LOCATION, location);
if (entity.getETag() != null) {
response.setHeader(HttpHeader.ETAG, entity.getETag());
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abf5bf79/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java
index e9761dc..55c0761 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java
@@ -50,12 +50,12 @@ import org.apache.olingo.server.tecsvc.data.DataProvider;
*/
public abstract class TechnicalProcessor implements Processor {
+ protected final DataProvider dataProvider;
protected OData odata;
- protected DataProvider dataProvider;
protected ServiceMetadata serviceMetadata;
protected TechnicalProcessor(final DataProvider dataProvider) {
- this.dataProvider = dataProvider;
+ this(dataProvider, null);
}
protected TechnicalProcessor(final DataProvider dataProvider, final ServiceMetadata serviceMetadata) {
[07/12] olingo-odata4 git commit: [OLINGO-631] Updated AntLR to
version 4.5 and resolved Java8 compilation errors
Posted by mi...@apache.org.
[OLINGO-631] Updated AntLR to version 4.5 and resolved Java8 compilation
errors
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/eae41fc7
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/eae41fc7
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/eae41fc7
Branch: refs/heads/OLINGO-708_AsyncSupportTec
Commit: eae41fc7c80eb9436daf86af6688ddfe3c6c0dc0
Parents: de64c31
Author: Christian Holzer <c....@sap.com>
Authored: Mon Jul 6 14:07:06 2015 +0200
Committer: Christian Holzer <c....@sap.com>
Committed: Mon Jul 6 17:45:51 2015 +0200
----------------------------------------------------------------------
.../apache/olingo/fit/v4/BatchTestITCase.java | 16 +++------
.../olingo/server/core/uri/antlr/UriLexer.g4 | 16 ++++-----
.../olingo/server/core/uri/antlr/UriParser.g4 | 2 +-
.../olingo/server/core/uri/antlr/TestLexer.java | 35 +++++++++++++++++---
pom.xml | 10 +++++-
5 files changed, 53 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/eae41fc7/fit/src/test/java/org/apache/olingo/fit/v4/BatchTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/BatchTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/BatchTestITCase.java
index 5007c2c..db196c3 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/BatchTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/BatchTestITCase.java
@@ -26,6 +26,7 @@ import static org.junit.Assert.fail;
import java.io.IOException;
import java.math.BigDecimal;
import java.net.URI;
+import java.net.URISyntaxException;
import java.util.Calendar;
import java.util.Collection;
import java.util.HashMap;
@@ -239,7 +240,7 @@ public class BatchTestITCase extends AbstractTestITCase {
@Test
@SuppressWarnings("unchecked")
- public void changesetWithReference() throws EdmPrimitiveTypeException {
+ public void changesetWithReference() throws Exception {
// create your request
final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(testStaticServiceRootURL);
request.setAccept(ACCEPT);
@@ -262,17 +263,8 @@ public class BatchTestITCase extends AbstractTestITCase {
// add update request: link CustomerInfo(17) to the new customer
final ClientEntity customerChanges = client.getObjectFactory().newEntity(order.getTypeName());
customerChanges.addLink(client.getObjectFactory().newEntitySetNavigationLink(
- "OrderDetails",
- client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("OrderDetails").
- appendKeySegment(new HashMap<String, Object>() {
- private static final long serialVersionUID = 3109256773218160485L;
-
- {
- put("OrderID", 7);
- put("ProductID", 5);
- }
- }).build()));
-
+ "OrderDetails", new URI(testStaticServiceRootURL + "/OrderDetails(OrderID=7,ProductID=5)")));
+
final ODataEntityUpdateRequest<ClientEntity> updateReq = client.getCUDRequestFactory().getEntityUpdateRequest(
URI.create("$" + createRequestRef), UpdateType.PATCH, customerChanges);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/eae41fc7/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriLexer.g4
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriLexer.g4 b/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriLexer.g4
index f74e721..a74fd2f 100644
--- a/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriLexer.g4
+++ b/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriLexer.g4
@@ -112,13 +112,13 @@ REF : '$ref';
COUNT : '$count';
//inlined query parameters ( e.g. $skip)
-TOP_I : '$top' -> type(TOP);
-SKIP_I : '$skip' -> type(SKIP);
-FILTER_I : '$filter' -> type(FILTER);
-ORDERBY_I: '$orderby' -> type(ORDERBY);
-SELECT_I : '$select' -> type(SELECT);
-EXPAND_I : '$expand' -> type(EXPAND);
-LEVELS_I : '$levels' -> type(LEVELS);
+TOP_I : '$top' -> type(TOP);
+SKIP_QO_I : '$skip' -> type(SKIP_QO);
+FILTER_I : '$filter' -> type(FILTER);
+ORDERBY_I : '$orderby' -> type(ORDERBY);
+SELECT_I : '$select' -> type(SELECT);
+EXPAND_I : '$expand' -> type(EXPAND);
+LEVELS_I : '$levels' -> type(LEVELS);
MAX: 'max';
ROOT : '$root/';
@@ -254,7 +254,7 @@ FILTER : '$filter' -> pushMode(DEFAULT_MODE)
ORDERBY : '$orderby' -> pushMode(DEFAULT_MODE);
EXPAND : '$expand' -> pushMode(DEFAULT_MODE);
SELECT : '$select' -> pushMode(DEFAULT_MODE);
-SKIP : '$skip' -> pushMode(DEFAULT_MODE);
+SKIP_QO : '$skip' -> pushMode(DEFAULT_MODE);
SKIPTOKEN : '$skiptoken' -> pushMode(MODE_SYSTEM_QUERY_REST);
TOP : '$top' -> pushMode(DEFAULT_MODE);
LEVELS_q : '$levels' -> type(LEVELS), pushMode(DEFAULT_MODE);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/eae41fc7/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriParser.g4
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriParser.g4 b/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriParser.g4
index 7efc14c..e7572dc 100644
--- a/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriParser.g4
+++ b/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriParser.g4
@@ -144,7 +144,7 @@ orderList : vlOI+=orderByItem ( WSP* COMMA WSP* vlOI+=orderByItem )*;
orderByItem : vC=commonExpr ( WSP ( vA=ASC | vD=DESC ) )?;
-skip : SKIP EQ INT;
+skip : SKIP_QO EQ INT;
top : TOP EQ INT;
//format : FORMAT EQ ( ATOM | JSON | XML | PCHARS SLASH PCHARS);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/eae41fc7/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestLexer.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestLexer.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestLexer.java
index 4b32be5..e529eae 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestLexer.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestLexer.java
@@ -69,9 +69,9 @@ public class TestLexer {
public void testQueryOptionsTokens() {
test.globalMode(UriLexer.MODE_QUERY);
- test.run("$skip=1").isAllText("$skip=1").isType(UriLexer.SKIP);
- test.run("$skip=2").isAllText("$skip=2").isType(UriLexer.SKIP);
- test.run("$skip=123").isAllText("$skip=123").isType(UriLexer.SKIP);
+ test.run("$skip=1").isAllText("$skip=1").isType(UriLexer.SKIP_QO);
+ test.run("$skip=2").isAllText("$skip=2").isType(UriLexer.SKIP_QO);
+ test.run("$skip=123").isAllText("$skip=123").isType(UriLexer.SKIP_QO);
test.run("$top=1").isAllText("$top=1").isType(UriLexer.TOP);
test.run("$top=2").isAllText("$top=2").isType(UriLexer.TOP);
@@ -97,7 +97,34 @@ public class TestLexer {
test.run("$search=ABC").isAllText("$search=ABC").isType(UriLexer.SEARCH);
test.run("$search=\"A%20B%20C\"").isAllText("$search=\"A%20B%20C\"").isType(UriLexer.SEARCH);
}
-
+
+ @Test
+ public void testQueryOptionsDefaultMode() {
+ // First set query mode, than use expand(switches to default mode) and use nested system query options
+ test.globalMode(UriLexer.MODE_QUERY);
+ test.run("$expand=ABC($skip=1)").isAllText("$expand=ABC($skip=1)").at(4).isType(UriLexer.SKIP_QO);
+ test.run("$expand=ABC($skip=2)").isAllText("$expand=ABC($skip=2)").at(4).isType(UriLexer.SKIP_QO);
+ test.run("$expand=ABC($skip=123)").isAllText("$expand=ABC($skip=123)").at(4).isType(UriLexer.SKIP_QO);
+
+ test.run("$expand=ABC($top=1)").isAllText("$expand=ABC($top=1)").at(4).isType(UriLexer.TOP);
+ test.run("$expand=ABC($top=2)").isAllText("$expand=ABC($top=2)").at(4).isType(UriLexer.TOP);
+ test.run("$expand=ABC($top=123)").isAllText("$expand=ABC($top=123)").at(4).isType(UriLexer.TOP);
+
+ test.run("$expand=ABC($expand=DEF($skip=1))").isAllText("$expand=ABC($expand=DEF($skip=1))")
+ .at(8).isType(UriLexer.SKIP_QO);
+ test.run("$expand=ABC($expand=DEF($skip=2))").isAllText("$expand=ABC($expand=DEF($skip=2))")
+ .at(8).isType(UriLexer.SKIP_QO);
+ test.run("$expand=ABC($expand=DEF($skip=123))").isAllText("$expand=ABC($expand=DEF($skip=123))")
+ .at(8).isType(UriLexer.SKIP_QO);
+
+ test.run("$expand=ABC($expand=DEF($top=1))").isAllText("$expand=ABC($expand=DEF($top=1))")
+ .at(8).isType(UriLexer.TOP);
+ test.run("$expand=ABC($expand=DEF($top=2))").isAllText("$expand=ABC($expand=DEF($top=2))")
+ .at(8).isType(UriLexer.TOP);
+ test.run("$expand=ABC($expand=DEF($top=123))").isAllText("$expand=ABC($expand=DEF($top=123))")
+ .at(8).isType(UriLexer.TOP);
+ }
+
// ;------------------------------------------------------------------------------
// ; 4. Expressions
// ;------------------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/eae41fc7/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 7c867e4..92d14a2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -86,7 +86,7 @@
<jackson.version>2.4.2</jackson.version>
<aalto-xml.version>0.9.10</aalto-xml.version>
- <antlr.version>4.1</antlr.version>
+ <antlr.version>4.5</antlr.version>
<android.platform.version>4.1.1.4</android.platform.version>
<stax.api.version>1.0-2</stax.api.version>
@@ -403,6 +403,14 @@
</plugin>
<plugin>
<artifactId>maven-remote-resources-plugin</artifactId>
+ <version>1.5</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-filtering</artifactId>
+ <version>1.2</version>
+ </dependency>
+ </dependencies>
<executions>
<execution>
<goals>
[11/12] olingo-odata4 git commit: [OLINGO-729]
java.lang.NoClassDefFoundError in test Karaf
Posted by mi...@apache.org.
[OLINGO-729] java.lang.NoClassDefFoundError in test Karaf
Signed-off-by: mibo <mi...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/3a103d53
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/3a103d53
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/3a103d53
Branch: refs/heads/OLINGO-708_AsyncSupportTec
Commit: 3a103d534203e28cb0252c0eaea415382f21de2c
Parents: f1a4074
Author: Aki Yoshida <el...@gmail.com>
Authored: Tue Jul 7 14:05:17 2015 +0200
Committer: mibo <mi...@apache.org>
Committed: Tue Jul 7 21:03:45 2015 +0200
----------------------------------------------------------------------
ext/karaf/karaf-fit/pom.xml | 2 +-
.../java/org/apache/olingo/osgi/itests/OlingoOSGiTestSupport.java | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3a103d53/ext/karaf/karaf-fit/pom.xml
----------------------------------------------------------------------
diff --git a/ext/karaf/karaf-fit/pom.xml b/ext/karaf/karaf-fit/pom.xml
index 14a7238..4cd50c1 100644
--- a/ext/karaf/karaf-fit/pom.xml
+++ b/ext/karaf/karaf-fit/pom.xml
@@ -37,7 +37,7 @@
<!-- Karaf features -->
<dependency>
<groupId>org.apache.olingo</groupId>
- <artifactId>odata-karaf-feature</artifactId>
+ <artifactId>odata-karaf-features</artifactId>
<version>${project.version}</version>
<type>xml</type>
<classifier>features</classifier>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3a103d53/ext/karaf/karaf-fit/src/test/java/org/apache/olingo/osgi/itests/OlingoOSGiTestSupport.java
----------------------------------------------------------------------
diff --git a/ext/karaf/karaf-fit/src/test/java/org/apache/olingo/osgi/itests/OlingoOSGiTestSupport.java b/ext/karaf/karaf-fit/src/test/java/org/apache/olingo/osgi/itests/OlingoOSGiTestSupport.java
index b055071..b95bd13 100644
--- a/ext/karaf/karaf-fit/src/test/java/org/apache/olingo/osgi/itests/OlingoOSGiTestSupport.java
+++ b/ext/karaf/karaf-fit/src/test/java/org/apache/olingo/osgi/itests/OlingoOSGiTestSupport.java
@@ -99,7 +99,7 @@ public class OlingoOSGiTestSupport {
protected Option olingoBaseConfig() {
karafUrl = maven().groupId("org.apache.karaf").artifactId("apache-karaf").version(getKarafVersion())
.type("tar.gz");
- olingoUrl = maven().groupId("org.apache.olingo").artifactId("odata-karaf-feature").versionAsInProject()
+ olingoUrl = maven().groupId("org.apache.olingo").artifactId("odata-karaf-features").versionAsInProject()
.type("xml").classifier("features");
String localRepo = System.getProperty("localRepository");
return composite(karafDistributionConfiguration()
[08/12] olingo-odata4 git commit: [OLINGO-701] Fixed version in
client sample
Posted by mi...@apache.org.
[OLINGO-701] Fixed version in client sample
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/4e405938
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/4e405938
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/4e405938
Branch: refs/heads/OLINGO-708_AsyncSupportTec
Commit: 4e405938e74d01c0d676ee9d4e924f52856cd07a
Parents: eae41fc
Author: Michael Bolz <mi...@sap.com>
Authored: Tue Jul 7 08:57:32 2015 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Tue Jul 7 08:57:32 2015 +0200
----------------------------------------------------------------------
samples/client/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4e405938/samples/client/pom.xml
----------------------------------------------------------------------
diff --git a/samples/client/pom.xml b/samples/client/pom.xml
index b55a1ae..7e4c7ff 100644
--- a/samples/client/pom.xml
+++ b/samples/client/pom.xml
@@ -31,7 +31,7 @@
<parent>
<groupId>org.apache.olingo</groupId>
<artifactId>odata-samples</artifactId>
- <version>4.0.0-beta-03-SNAPSHOT</version>
+ <version>4.0.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
[09/12] olingo-odata4 git commit: [OLINGO-659] Delete pretty printer
from service document json
Posted by mi...@apache.org.
[OLINGO-659] Delete pretty printer from service document json
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/d18cbcce
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/d18cbcce
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/d18cbcce
Branch: refs/heads/OLINGO-708_AsyncSupportTec
Commit: d18cbcceeb64edd5cfbb54b2b8e90b8eebbba6e5
Parents: 4e40593
Author: Christian Amend <ch...@sap.com>
Authored: Tue Jul 7 15:41:58 2015 +0200
Committer: Christian Amend <ch...@sap.com>
Committed: Tue Jul 7 15:42:39 2015 +0200
----------------------------------------------------------------------
.../olingo/server/core/serializer/json/ODataJsonSerializer.java | 3 +--
.../java/org/apache/olingo/server/core/ODataHandlerTest.java | 4 ++--
2 files changed, 3 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d18cbcce/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
index a3b7805..c1292de 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
@@ -91,8 +91,7 @@ public class ODataJsonSerializer implements ODataSerializer {
try {
buffer = new CircleStreamBuffer();
- gen = new JsonFactory().createGenerator(buffer.getOutputStream())
- .setPrettyPrinter(new DefaultPrettyPrinter());
+ gen = new JsonFactory().createGenerator(buffer.getOutputStream());
new ServiceDocumentJsonSerializer(metadata, serviceRoot, isODataMetadataNone).writeServiceDocument(gen);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d18cbcce/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
index a3f75eb..236c1b7 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
@@ -112,8 +112,8 @@ public class ODataHandlerTest {
assertNotNull(response.getContent());
String doc = IOUtils.toString(response.getContent());
- assertThat(doc, containsString("\"@odata.context\" : \"$metadata\""));
- assertThat(doc, containsString("\"value\" :"));
+ assertThat(doc, containsString("\"@odata.context\":\"$metadata\""));
+ assertThat(doc, containsString("\"value\":"));
}
@Test