You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by fm...@apache.org on 2014/03/07 14:49:58 UTC
[25/25] git commit: OLINGO-175 provided v3 post service
OLINGO-175 provided v3 post service
Project: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/commit/744a3713
Tree: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/tree/744a3713
Diff: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/diff/744a3713
Branch: refs/heads/master
Commit: 744a37136ac96801666398c6444d45604eb885c9
Parents: 3df91bf
Author: fmartelli <fa...@gmail.com>
Authored: Fri Mar 7 14:49:10 2014 +0100
Committer: fmartelli <fa...@gmail.com>
Committed: Fri Mar 7 14:49:10 2014 +0100
----------------------------------------------------------------------
.../engine/it/AbstractTestITCase.java | 7 +-
.../engine/it/EntityCreateTestITCase.java | 28 +-
.../it/ODataLibEntityCreateTestITCase.java | 27 -
.../it/ODataLibEntityRetrieveTestITCase.java | 27 -
.../engine/it/ODataLibEntitySetTestITCase.java | 27 -
.../it/ODataLibEntityUpdateTestITCase.java | 27 -
.../engine/it/ODataLibLinkTestITCase.java | 27 -
.../engine/it/ODataLibPropertyTestITCase.java | 27 -
ODataJClient/pom.xml | 12 -
ODataJClient/proxy/pom.xml | 4 -
.../odatajclient/proxy/api/impl/Container.java | 12 +-
.../testservice/AbstractServices.java | 217 +++-
.../odatajclient/testservice/Accept.java | 77 --
.../odatajclient/testservice/Constants.java | 59 -
.../odatajclient/testservice/ODataVersion.java | 26 -
.../odatajclient/testservice/Utilities.java | 823 ------------
.../odatajclient/testservice/V3Services.java | 4 +-
.../odatajclient/testservice/V4Services.java | 4 +-
.../testservice/utils/AbstractUtilities.java | 495 ++++++++
.../odatajclient/testservice/utils/Accept.java | 78 ++
.../odatajclient/testservice/utils/Commons.java | 217 ++++
.../testservice/utils/Constants.java | 87 ++
.../testservice/utils/FSManager.java | 171 +++
.../testservice/utils/JSONUtilities.java | 307 +++++
.../testservice/utils/NavigationLinks.java | 114 ++
.../testservice/utils/ODataVersion.java | 26 +
.../testservice/utils/XMLUtilities.java | 909 ++++++++++++++
.../testservice/utils/XmlElement.java | 207 +++
.../resources/v3/Car/16/entity.minimal.json | 8 -
.../src/main/resources/v3/Car/16/entity.no.json | 4 -
.../src/main/resources/v3/Car/feed.minimal.json | 153 ---
.../src/main/resources/v3/Car/feed.no.json | 101 --
.../Car/filter/((1 add VIN) eq 16).minimal.json | 1 -
.../Car/filter/((VIN add 1) eq 16).minimal.json | 1 -
.../((VIN lt 16) and (VIN gt 12)).minimal.json | 1 -
.../Car/filter/(16 eq (1 add VIN)).minimal.json | 1 -
.../v3/Car/filter/(VIN lt 16).minimal.json | 1 -
...h(Description) gt (VIN add 10)).minimal.json | 1 -
.../v3/Car/filter/VIN add 5 lt 11.minimal.json | 1 -
.../v3/Car/filter/VIN add 5 lt 11.no.json | 1 -
.../v3/Car/filter/VIN div 2 le 8.minimal.json | 1 -
.../v3/Car/filter/VIN div 2 le 8.no.json | 1 -
.../filter/VIN le 18 and VIN gt 12.minimal.json | 1 -
.../Car/filter/VIN le 18 and VIN gt 12.no.json | 1 -
.../v3/Car/filter/VIN mul 2 le 30.minimal.json | 1 -
.../v3/Car/filter/VIN mul 2 le 30.no.json | 1 -
... (((VIN ge 16) or (VIN le 12))).minimal.json | 1 -
.../startswith(Description,'cen').minimal.json | 1 -
.../VIN desc/filter/(VIN lt 16).minimal.json | 10 -
.../(month(PurchaseDate) eq 12).minimal.json | 1 -
.../filter/day(PurchaseDate) eq 15.minimal.json | 1 -
.../filter/day(PurchaseDate) eq 15.no.json | 1 -
.../filter/hour(PurchaseDate) eq 1.minimal.json | 1 -
.../filter/hour(PurchaseDate) eq 1.no.json | 1 -
.../minute(PurchaseDate) eq 33.minimal.json | 1 -
.../filter/minute(PurchaseDate) eq 33.no.json | 1 -
.../month(PurchaseDate) eq 12.minimal.json | 1 -
.../filter/month(PurchaseDate) eq 12.no.json | 1 -
.../second(PurchaseDate) eq 35.minimal.json | 1 -
.../filter/second(PurchaseDate) eq 35.no.json | 1 -
.../year(PurchaseDate) eq 2020.minimal.json | 1 -
.../filter/year(PurchaseDate) eq 2020.no.json | 1 -
.../v3/Customer/-10/entity.minimal.json | 548 --------
.../resources/v3/Customer/-10/entity.no.json | 547 --------
.../v3/Customer/-10/inline/Info.full.json | 10 -
.../v3/Customer/-10/inline/Info.minimal.json | 6 -
.../v3/Customer/-10/inline/Info.no.json | 4 -
.../resources/v3/Customer/-10/inline/Info.xml | 36 -
.../v3/Customer/-10/inline/Orders.full.json | 28 -
.../v3/Customer/-10/inline/Orders.minimal.json | 16 -
.../Customer/-10/inline/Orders.next.full.json | 1 -
.../-10/inline/Orders.next.minimal.json | 1 -
.../v3/Customer/-10/inline/Orders.next.no.json | 1 -
.../v3/Customer/-10/inline/Orders.no.json | 16 -
.../resources/v3/Customer/-10/inline/Orders.xml | 68 -
.../resources/v3/Customer/-10/links/Info.xml | 22 +
.../v3/Customer/-10/links/Logins.minimal.json | 12 -
.../Customer/-10/links/Orders(-10).minimal.json | 4 -
.../v3/Customer/-10/links/Orders.minimal.json | 13 -
.../v3/Customer/-10/links/Orders.no.json | 12 -
.../resources/v3/Customer/feed.minimal.json | 735 -----------
.../src/main/resources/v3/Customer/feed.no.json | 734 -----------
...oneNumber,'ODataJClient') eq 1).minimal.json | 1 -
...PhoneNumber,'lccvussrv') ne -1).minimal.json | 1 -
.../filter/CustomerId eq -10.minimal.json | 553 ---------
.../Customer/filter/CustomerId eq -10.no.json | 552 --------
.../filter/CustomerId gt -10.minimal.json | 1 -
.../Customer/filter/CustomerId gt -10.no.json | 1 -
.../filter/CustomerId lt -10.minimal.json | 1 -
.../Customer/filter/CustomerId lt -10.no.json | 1 -
...isof(Name,'Edm.String') eq true.minimal.json | 1 -
.../isof(Name,'Edm.String') eq true.no.json | 1 -
.../not endswith(Name,'Chandan').minimal.json | 1 -
.../filter/not endswith(Name,'Chandan').no.json | 1 -
.../v3/Customer/skiptoken/-1.minimal.json | 6 -
.../resources/v3/Customer/skiptoken/-1.no.json | 5 -
.../v3/Customer/skiptoken/-3.minimal.json | 624 ----------
.../resources/v3/Customer/skiptoken/-3.no.json | 623 ----------
.../v3/Customer/skiptoken/-5.minimal.json | 1174 ------------------
.../resources/v3/Customer/skiptoken/-5.no.json | 1173 -----------------
.../v3/Customer/skiptoken/-7.minimal.json | 1052 ----------------
.../resources/v3/Customer/skiptoken/-7.no.json | 1051 ----------------
.../v3/Customer/skiptoken/-9.minimal.json | 574 ---------
.../resources/v3/Customer/skiptoken/-9.no.json | 573 ---------
.../v3/CustomerInfo/11/entity.full.json | 11 +
.../resources/v3/CustomerInfo/11/entity.xml | 37 +
.../v3/CustomerInfo/12/entity.full.json | 11 +
.../resources/v3/CustomerInfo/12/entity.xml | 37 +
.../v3/EdmBooleanSet/true/entity.full.json | 1 +
.../v3/EdmBooleanSet/true/entity.minimal.json | 1 -
.../v3/EdmByteSet/255/entity.full.json | 1 +
.../v3/EdmByteSet/255/entity.minimal.json | 1 -
.../entity.full.json | 1 +
.../entity.minimal.json | 1 -
.../1.7976931348623157E308D/entity.full.json | 1 +
.../1.7976931348623157E308D/entity.minimal.json | 1 -
.../entity.full.json | 1 +
.../entity.minimal.json | 1 -
.../v3/EdmInt16Set/32767/entity.full.json | 1 +
.../v3/EdmInt16Set/32767/entity.minimal.json | 1 -
.../v3/EdmInt32Set/-2147483648/entity.full.json | 1 +
.../EdmInt32Set/-2147483648/entity.minimal.json | 1 -
.../9223372036854775807L/entity.full.json | 1 +
.../9223372036854775807L/entity.minimal.json | 1 -
.../EdmSingleSet/3.4028235E38f/entity.full.json | 1 +
.../3.4028235E38f/entity.minimal.json | 1 -
.../v3/EdmStringSet/'$'/entity.full.json | 1 +
.../v3/EdmStringSet/'$'/entity.minimal.json | 1 -
.../entity.full.json | 1 +
.../entity.minimal.json | 1 -
.../v3/InStreamErrorGetCustomer.full.json | 1 +
.../v3/InStreamErrorGetCustomer.minimal.json | 1 -
.../v3/Message/1 -10/entity.minimal.json | 10 -
.../resources/v3/Order/-10/entity.full.json | 11 +
.../src/main/resources/v3/Order/-10/entity.xml | 40 +
.../main/resources/v3/Order/-7/entity.full.json | 17 +
.../src/main/resources/v3/Order/-7/entity.xml | 43 +
.../resources/v3/Order/-9/entity.minimal.json | 10 -
.../main/resources/v3/Order/-9/entity.no.json | 9 -
.../filter/PersonId sub 2 lt -10.minimal.json | 1 -
.../Person/filter/PersonId sub 2 lt -10.no.json | 1 -
...efaultService.SpecialEmployee').minimal.json | 1 -
.../resources/v3/Product/-6/entity.minimal.json | 27 -
.../main/resources/v3/Product/-6/entity.no.json | 26 -
.../resources/v3/Product/-7/entity.minimal.json | 27 -
.../main/resources/v3/Product/-7/entity.no.json | 26 -
.../v3/Product/-7/links/Photos.full.json | 12 +
.../v3/Product/-7/links/Photos.minimal.json | 12 -
.../resources/v3/Product/-9/entity.minimal.json | 36 -
.../main/resources/v3/Product/-9/entity.no.json | 34 -
.../main/resources/v3/Product/feed.minimal.json | 244 ----
.../src/main/resources/v3/Product/feed.no.json | 238 ----
...iling(Dimensions.Width) eq 7338.minimal.json | 1 -
.../ceiling(Dimensions.Width) eq 7338.no.json | 1 -
...newname') eq 'kdcuklu, newname'.minimal.json | 1 -
..., ', newname') eq 'kdcuklu, newname'.no.json | 1 -
...floor(Dimensions.Width) eq 7337.minimal.json | 1 -
.../floor(Dimensions.Width) eq 7337.no.json | 1 -
.../indexof(Description, 'k') eq 0.minimal.json | 1 -
.../indexof(Description, 'k') eq 0.no.json | 1 -
.../length(Description) eq 7.minimal.json | 1 -
.../filter/length(Description) eq 7.no.json | 1 -
...round(Dimensions.Width) eq 7338.minimal.json | 1 -
.../round(Dimensions.Width) eq 7338.no.json | 1 -
...swith(Description, 'k') eq true.minimal.json | 1 -
...startswith(Description, 'k') eq true.no.json | 1 -
...'kdcuklu', Description) eq true.minimal.json | 1 -
...ngof('kdcuklu', Description) eq true.no.json | 1 -
...upper(Description) eq 'KDCUKLU'.minimal.json | 1 -
.../toupper(Description) eq 'KDCUKLU'.no.json | 1 -
.../v3/ProductPhoto/-2 -2/entity.minimal.json | 6 -
.../v3/ProductPhoto/-2 -2/entity.no.json | 5 -
.../v3/ProductPhoto/-3 -3/entity.minimal.json | 6 -
.../v3/ProductPhoto/-3 -3/entity.no.json | 5 -
.../src/main/resources/v3/services.minimal.json | 102 --
.../src/main/resources/v3/services.no.json | 101 --
176 files changed, 3047 insertions(+), 13276 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/744a3713/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/AbstractTestITCase.java
----------------------------------------------------------------------
diff --git a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/AbstractTestITCase.java b/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/AbstractTestITCase.java
index 6340a75..6c4a259 100644
--- a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/AbstractTestITCase.java
+++ b/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/AbstractTestITCase.java
@@ -68,6 +68,7 @@ import java.util.HashSet;
import java.util.Locale;
import java.util.Properties;
import java.util.Set;
+import java.util.logging.Level;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.junit.BeforeClass;
@@ -96,7 +97,7 @@ public abstract class AbstractTestITCase {
protected static String testKeyAsSegmentServiceRootURL;
- protected static String testODataWriterDefaultServiceRootURL;
+// protected static String testODataWriterDefaultServiceRootURL;
protected static String testOpenTypeServiceRootURL;
@@ -130,7 +131,7 @@ public abstract class AbstractTestITCase {
testStaticServiceRootURL = "http://localhost:9080/StaticService/V3/Static.svc";
testActionOverloadingServiceRootURL = testBaseURL + "/ActionOverloadingService.svc";
testKeyAsSegmentServiceRootURL = testBaseURL + "/KeyAsSegmentService.svc";
- testODataWriterDefaultServiceRootURL = testBaseURL + "/ODataWriterDefaultService.svc";
+// testODataWriterDefaultServiceRootURL = testBaseURL + "/ODataWriterDefaultService.svc";
testOpenTypeServiceRootURL = testBaseURL + "/OpenTypeService.svc";
testPrimitiveKeysServiceRootURL = "http://localhost:9080/StaticService/V3/Static.svc";
testLargeModelServiceRootURL = "http://localhost:9080/StaticService/V3/Static.svc/large";
@@ -460,7 +461,7 @@ public abstract class AbstractTestITCase {
final ODataRetrieveResponse<ODataEntity> res = req.execute();
assertEquals(200, res.getStatusCode());
-
+
final ODataEntity actual = res.getBody();
assertNotNull(actual);
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/744a3713/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/EntityCreateTestITCase.java
----------------------------------------------------------------------
diff --git a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/EntityCreateTestITCase.java b/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/EntityCreateTestITCase.java
index ed3eac1..d5edfcd 100644
--- a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/EntityCreateTestITCase.java
+++ b/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/EntityCreateTestITCase.java
@@ -18,7 +18,7 @@
*/
package com.msopentech.odatajclient.engine.it;
-import static com.msopentech.odatajclient.engine.it.AbstractTestITCase.testDefaultServiceRootURL;
+import static com.msopentech.odatajclient.engine.it.AbstractTestITCase.testStaticServiceRootURL;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -58,6 +58,10 @@ import org.junit.Test;
public class EntityCreateTestITCase extends AbstractTestITCase {
protected String getServiceRoot() {
+ return testStaticServiceRootURL;
+ }
+
+ protected String getOldServiceRoot() {
return testDefaultServiceRootURL;
}
@@ -200,7 +204,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
public void createWithBackNavigationAsAtom() {
final ODataPubFormat format = ODataPubFormat.ATOM;
final ODataEntity actual = createWithBackNavigationLink(format, 9);
- cleanAfterCreate(format, actual, true, getServiceRoot());
+ cleanAfterCreate(format, actual, true, getOldServiceRoot());
}
@Test
@@ -208,7 +212,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
// this needs to be full, otherwise there is no mean to recognize links
final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
final ODataEntity actual = createWithBackNavigationLink(format, 10);
- cleanAfterCreate(format, actual, true, getServiceRoot());
+ cleanAfterCreate(format, actual, true, getOldServiceRoot());
}
@Test
@@ -253,7 +257,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
final int id = 2;
final ODataEntity original = getSampleCustomerProfile(id, "Sample customer for issue 135", false);
- final URIBuilder uriBuilder = client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Customer");
+ final URIBuilder uriBuilder = client.getURIBuilder(getOldServiceRoot()).appendEntitySetSegment("Customer");
final ODataEntityCreateRequest createReq =
client.getCUDRequestFactory().getEntityCreateRequest(uriBuilder.build(), original);
createReq.setFormat(ODataPubFormat.JSON_FULL_METADATA);
@@ -267,7 +271,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
fail(e.getMessage());
} finally {
final ODataDeleteResponse deleteRes = client.getCUDRequestFactory().getDeleteRequest(
- client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Customer").appendKeySegment(id).
+ client.getURIBuilder(getOldServiceRoot()).appendEntitySetSegment("Customer").appendKeySegment(id).
build()).
execute();
assertEquals(204, deleteRes.getStatusCode());
@@ -375,7 +379,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
final String sampleName = "Sample customer";
ODataEntity customer = getSampleCustomerProfile(id, sampleName, false);
- customer = createEntity(getServiceRoot(), format, customer, "Customer");
+ customer = createEntity(getOldServiceRoot(), format, customer, "Customer");
ODataEntity order = client.getObjectFactory().newEntity(
"Microsoft.Test.OData.Services.AstoriaDefaultService.Order");
@@ -385,19 +389,19 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
client.getPrimitiveValueBuilder().setValue(id).setType(EdmSimpleType.Int32).build()));
order.addLink(client.getObjectFactory().newEntityNavigationLink(
- "Customer", URIUtils.getURI(getServiceRoot(), customer.getEditLink().toASCIIString())));
+ "Customer", URIUtils.getURI(getOldServiceRoot(), customer.getEditLink().toASCIIString())));
- order = createEntity(getServiceRoot(), format, order, "Order");
+ order = createEntity(getOldServiceRoot(), format, order, "Order");
ODataEntity changes = client.getObjectFactory().newEntity(
"Microsoft.Test.OData.Services.AstoriaDefaultService.Customer");
changes.setEditLink(customer.getEditLink());
changes.addLink(client.getObjectFactory().newFeedNavigationLink(
- "Orders", URIUtils.getURI(getServiceRoot(), order.getEditLink().toASCIIString())));
+ "Orders", URIUtils.getURI(getOldServiceRoot(), order.getEditLink().toASCIIString())));
update(UpdateType.PATCH, changes, format, null);
final ODataEntityRequest customerreq = client.getRetrieveRequestFactory().getEntityRequest(
- URIUtils.getURI(getServiceRoot(), order.getEditLink().toASCIIString() + "/Customer"));
+ URIUtils.getURI(getOldServiceRoot(), order.getEditLink().toASCIIString() + "/Customer"));
customerreq.setFormat(format);
customer = customerreq.execute().getBody();
@@ -406,7 +410,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
Integer.valueOf(id), customer.getProperty("CustomerId").getPrimitiveValue().<Integer>toCastValue());
final ODataEntitySetRequest orderreq = client.getRetrieveRequestFactory().getEntitySetRequest(
- URIUtils.getURI(getServiceRoot(), customer.getEditLink().toASCIIString() + "/Orders"));
+ URIUtils.getURI(getOldServiceRoot(), customer.getEditLink().toASCIIString() + "/Orders"));
orderreq.setFormat(format);
final ODataRetrieveResponse<ODataEntitySet> orderres = orderreq.execute();
@@ -417,7 +421,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
<Integer>toCastValue());
final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(
- URIUtils.getURI(getServiceRoot(), customer.getEditLink().toASCIIString() + "?$expand=Orders"));
+ URIUtils.getURI(getOldServiceRoot(), customer.getEditLink().toASCIIString() + "?$expand=Orders"));
req.setFormat(format);
customer = req.execute().getBody();
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/744a3713/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/ODataLibEntityCreateTestITCase.java
----------------------------------------------------------------------
diff --git a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/ODataLibEntityCreateTestITCase.java b/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/ODataLibEntityCreateTestITCase.java
deleted file mode 100644
index 86d9006..0000000
--- a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/ODataLibEntityCreateTestITCase.java
+++ /dev/null
@@ -1,27 +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 com.msopentech.odatajclient.engine.it;
-
-public class ODataLibEntityCreateTestITCase extends EntityCreateTestITCase {
-
- @Override
- protected String getServiceRoot() {
- return testODataWriterDefaultServiceRootURL;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/744a3713/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/ODataLibEntityRetrieveTestITCase.java
----------------------------------------------------------------------
diff --git a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/ODataLibEntityRetrieveTestITCase.java b/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/ODataLibEntityRetrieveTestITCase.java
deleted file mode 100644
index 307d8c7..0000000
--- a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/ODataLibEntityRetrieveTestITCase.java
+++ /dev/null
@@ -1,27 +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 com.msopentech.odatajclient.engine.it;
-
-public class ODataLibEntityRetrieveTestITCase extends EntityRetrieveTestITCase {
-
- @Override
- protected String getServiceRoot() {
- return testODataWriterDefaultServiceRootURL;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/744a3713/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/ODataLibEntitySetTestITCase.java
----------------------------------------------------------------------
diff --git a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/ODataLibEntitySetTestITCase.java b/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/ODataLibEntitySetTestITCase.java
deleted file mode 100644
index 355cefd..0000000
--- a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/ODataLibEntitySetTestITCase.java
+++ /dev/null
@@ -1,27 +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 com.msopentech.odatajclient.engine.it;
-
-public class ODataLibEntitySetTestITCase extends EntitySetTestITCase {
-
- @Override
- protected String getServiceRoot() {
- return testODataWriterDefaultServiceRootURL;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/744a3713/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/ODataLibEntityUpdateTestITCase.java
----------------------------------------------------------------------
diff --git a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/ODataLibEntityUpdateTestITCase.java b/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/ODataLibEntityUpdateTestITCase.java
deleted file mode 100644
index 0924793..0000000
--- a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/ODataLibEntityUpdateTestITCase.java
+++ /dev/null
@@ -1,27 +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 com.msopentech.odatajclient.engine.it;
-
-public class ODataLibEntityUpdateTestITCase extends EntityUpdateTestITCase {
-
- @Override
- protected String getServiceRoot() {
- return testODataWriterDefaultServiceRootURL;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/744a3713/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/ODataLibLinkTestITCase.java
----------------------------------------------------------------------
diff --git a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/ODataLibLinkTestITCase.java b/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/ODataLibLinkTestITCase.java
deleted file mode 100644
index 6cdde85..0000000
--- a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/ODataLibLinkTestITCase.java
+++ /dev/null
@@ -1,27 +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 com.msopentech.odatajclient.engine.it;
-
-public class ODataLibLinkTestITCase extends LinkTestITCase {
-
- @Override
- protected String getServiceRoot() {
- return testODataWriterDefaultServiceRootURL;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/744a3713/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/ODataLibPropertyTestITCase.java
----------------------------------------------------------------------
diff --git a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/ODataLibPropertyTestITCase.java b/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/ODataLibPropertyTestITCase.java
deleted file mode 100644
index c80ffd4..0000000
--- a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/ODataLibPropertyTestITCase.java
+++ /dev/null
@@ -1,27 +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 com.msopentech.odatajclient.engine.it;
-
-public class ODataLibPropertyTestITCase extends PropertyTestITCase {
-
- @Override
- protected String getServiceRoot() {
- return testODataWriterDefaultServiceRootURL;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/744a3713/ODataJClient/pom.xml
----------------------------------------------------------------------
diff --git a/ODataJClient/pom.xml b/ODataJClient/pom.xml
index 405ab47..0b37e23 100644
--- a/ODataJClient/pom.xml
+++ b/ODataJClient/pom.xml
@@ -84,7 +84,6 @@
<commons.io.version>2.4</commons.io.version>
<commons.lang3.version>3.2.1</commons.lang3.version>
<commons.beanutils.version>1.8.3</commons.beanutils.version>
- <xstream.version>1.4.6</xstream.version>
<sl4j.version>1.7.5</sl4j.version>
@@ -114,17 +113,6 @@
<artifactId>commons-beanutils-core</artifactId>
<version>${commons.beanutils.version}</version>
</dependency>
- <dependency>
- <groupId>com.thoughtworks.xstream</groupId>
- <artifactId>xstream</artifactId>
- <version>${xstream.version}</version>
- <exclusions>
- <exclusion>
- <groupId>xmlpull</groupId>
- <artifactId>xmlpull</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/744a3713/ODataJClient/proxy/pom.xml
----------------------------------------------------------------------
diff --git a/ODataJClient/proxy/pom.xml b/ODataJClient/proxy/pom.xml
index c9e5c59..74cd27f 100644
--- a/ODataJClient/proxy/pom.xml
+++ b/ODataJClient/proxy/pom.xml
@@ -41,10 +41,6 @@
<dependencies>
<dependency>
- <groupId>com.thoughtworks.xstream</groupId>
- <artifactId>xstream</artifactId>
- </dependency>
- <dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/744a3713/ODataJClient/proxy/src/main/java/com/msopentech/odatajclient/proxy/api/impl/Container.java
----------------------------------------------------------------------
diff --git a/ODataJClient/proxy/src/main/java/com/msopentech/odatajclient/proxy/api/impl/Container.java b/ODataJClient/proxy/src/main/java/com/msopentech/odatajclient/proxy/api/impl/Container.java
index 4130d09..0f46e35 100644
--- a/ODataJClient/proxy/src/main/java/com/msopentech/odatajclient/proxy/api/impl/Container.java
+++ b/ODataJClient/proxy/src/main/java/com/msopentech/odatajclient/proxy/api/impl/Container.java
@@ -46,8 +46,6 @@ import com.msopentech.odatajclient.proxy.api.context.AttachedEntity;
import com.msopentech.odatajclient.proxy.api.context.AttachedEntityStatus;
import com.msopentech.odatajclient.proxy.api.context.EntityLinkDesc;
import com.msopentech.odatajclient.proxy.utils.EngineUtils;
-import com.thoughtworks.xstream.XStream;
-import com.thoughtworks.xstream.io.xml.Xpp3Driver;
import java.io.InputStream;
import java.lang.reflect.Proxy;
import java.net.URI;
@@ -72,8 +70,6 @@ class Container implements AbstractContainer {
*/
private static final Logger LOG = LoggerFactory.getLogger(Container.class);
- private final XStream xstream = new XStream(new Xpp3Driver());
-
private final ODataClient client;
private final EntityContainerFactory factory;
@@ -288,7 +284,7 @@ class Container implements AbstractContainer {
items.put(handler, null);
- final ODataEntity entity = (ODataEntity) xstream.fromXML(xstream.toXML(handler.getEntity()));
+ final ODataEntity entity = handler.getEntity();
entity.getNavigationLinks().clear();
final AttachedEntityStatus currentStatus = EntityContainerFactory.getContext().entityContext().
@@ -378,7 +374,7 @@ class Container implements AbstractContainer {
final URI targetURI = currentStatus == AttachedEntityStatus.NEW
? URI.create("$" + startingPos + "/$value")
: URIUtils.getURI(
- factory.getServiceRoot(), handler.getEntity().getEditLink().toASCIIString() + "/$value");
+ factory.getServiceRoot(), handler.getEntity().getEditLink().toASCIIString() + "/$value");
batchUpdateMediaEntity(handler, targetURI, handler.getStreamChanges(), changeset);
@@ -391,8 +387,8 @@ class Container implements AbstractContainer {
for (Map.Entry<String, InputStream> streamedChanges : handler.getStreamedPropertyChanges().entrySet()) {
final URI targetURI = currentStatus == AttachedEntityStatus.NEW
? URI.create("$" + startingPos) : URIUtils.getURI(
- factory.getServiceRoot(),
- EngineUtils.getEditMediaLink(streamedChanges.getKey(), entity).toASCIIString());
+ factory.getServiceRoot(),
+ EngineUtils.getEditMediaLink(streamedChanges.getKey(), entity).toASCIIString());
batchUpdateMediaResource(handler, targetURI, streamedChanges.getValue(), changeset);
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/744a3713/ODataJClient/test-service/src/main/java/com/msopentech/odatajclient/testservice/AbstractServices.java
----------------------------------------------------------------------
diff --git a/ODataJClient/test-service/src/main/java/com/msopentech/odatajclient/testservice/AbstractServices.java b/ODataJClient/test-service/src/main/java/com/msopentech/odatajclient/testservice/AbstractServices.java
index a0772fd..bd968e9 100644
--- a/ODataJClient/test-service/src/main/java/com/msopentech/odatajclient/testservice/AbstractServices.java
+++ b/ODataJClient/test-service/src/main/java/com/msopentech/odatajclient/testservice/AbstractServices.java
@@ -18,10 +18,21 @@
*/
package com.msopentech.odatajclient.testservice;
-import static com.msopentech.odatajclient.testservice.Constants.*;
-
+import com.msopentech.odatajclient.testservice.utils.Accept;
+import com.msopentech.odatajclient.testservice.utils.Commons;
+import com.msopentech.odatajclient.testservice.utils.XMLUtilities;
+import com.msopentech.odatajclient.testservice.utils.JSONUtilities;
+import com.msopentech.odatajclient.testservice.utils.ODataVersion;
+import com.msopentech.odatajclient.testservice.utils.FSManager;
+
+import static com.msopentech.odatajclient.testservice.utils.Constants.*;
import java.io.File;
import java.io.InputStream;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
@@ -31,9 +42,10 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.vfs2.FileSystemException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -46,10 +58,13 @@ public abstract class AbstractServices {
protected abstract ODataVersion getVersion();
- protected final Utilities utils;
+ protected final XMLUtilities atom;
+
+ protected final JSONUtilities json;
- public AbstractServices() throws FileSystemException {
- this.utils = new Utilities(getVersion());
+ public AbstractServices() throws Exception {
+ this.atom = new XMLUtilities(getVersion());
+ this.json = new JSONUtilities(getVersion());
}
/**
@@ -67,9 +82,10 @@ public abstract class AbstractServices {
throw new UnsupportedMediaTypeException("Unsupported media type");
}
- return utils.createResponse(utils.readFile(SERVICES, acceptType), null, acceptType);
+ return atom.createResponse(
+ FSManager.instance(getVersion()).readFile(SERVICES, acceptType), null, acceptType);
} catch (Exception e) {
- return utils.createFaultResponse(accept, e);
+ return atom.createFaultResponse(accept, e);
}
}
@@ -99,9 +115,10 @@ public abstract class AbstractServices {
private Response getMetadata(final String filename) {
try {
- return utils.createResponse(utils.readFile(filename, Accept.XML), null, Accept.XML);
+ return atom.
+ createResponse(FSManager.instance(getVersion()).readFile(filename, Accept.XML), null, Accept.XML);
} catch (Exception e) {
- return utils.createFaultResponse(Accept.XML.toString(), e);
+ return atom.createFaultResponse(Accept.XML.toString(), e);
}
}
@@ -115,21 +132,41 @@ public abstract class AbstractServices {
*/
@POST
@Path("/{entitySetName}")
+ @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON })
+ @Consumes({ MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON })
public Response postNewEntity(
@HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
- @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
- @PathParam("entitySetName") String entitySetName) {
+ @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) String prefer,
+ @PathParam("entitySetName") String entitySetName,
+ final String entity) {
try {
+
final Accept acceptType = Accept.parse(accept, getVersion());
if (acceptType == Accept.XML || acceptType == Accept.TEXT) {
throw new UnsupportedMediaTypeException("Unsupported media type");
}
- throw new Exception("Bad request ...");
+ final InputStream res;
+ if (acceptType == Accept.ATOM) {
+ res = atom.createEntity(
+ null, null, ENTITY, IOUtils.toInputStream(entity), entitySetName, acceptType);
+ } else {
+ res = json.createEntity(
+ null, null, ENTITY, IOUtils.toInputStream(entity), entitySetName, acceptType);
+ }
+
+ if (prefer.equalsIgnoreCase("return-no-content")) {
+ res.close();
+ Response response = atom.createResponse(null, null, acceptType, Response.Status.NO_CONTENT);
+ response.getHeaders().put("Preference-Applied", Collections.<Object>singletonList(prefer));
+ return response;
+ } else {
+ return atom.createResponse(res, null, acceptType, Response.Status.CREATED);
+ }
} catch (Exception e) {
- return utils.createFaultResponse(accept, e);
+ return atom.createFaultResponse(accept, e);
}
}
@@ -170,8 +207,8 @@ public abstract class AbstractServices {
try {
// search for function ...
- final InputStream func = utils.readFile(name, acceptType);
- return utils.createResponse(func, null, acceptType);
+ final InputStream func = FSManager.instance(getVersion()).readFile(name, acceptType);
+ return atom.createResponse(func, null, acceptType);
} catch (NotFoundException e) {
// search for entitySet ...
final String basePath = name + File.separatorChar;
@@ -191,27 +228,27 @@ public abstract class AbstractServices {
builder.append(FEED);
}
- InputStream feed = utils.readFile(builder.toString(), acceptType);
+ InputStream feed = FSManager.instance(getVersion()).readFile(builder.toString(), acceptType);
if ("allpages".equals(inlinecount)) {
- int count = utils.countAllElements(name);
+ int count = atom.countAllElements(name);
feed.close();
if (acceptType == Accept.ATOM) {
- feed = utils.addAtomInlinecount(
- utils.readFile(builder.toString(), acceptType),
+ feed = atom.addAtomInlinecount(
+ FSManager.instance(getVersion()).readFile(builder.toString(), acceptType),
count,
acceptType);
} else {
- feed = utils.addJsonInlinecount(
- utils.readFile(builder.toString(), acceptType),
+ feed = json.addJsonInlinecount(
+ FSManager.instance(getVersion()).readFile(builder.toString(), acceptType),
count,
acceptType);
}
}
- return utils.createResponse(feed, utils.getETag(basePath), acceptType);
+ return atom.createResponse(feed, Commons.getETag(basePath, getVersion()), acceptType);
}
} catch (Exception e) {
- return utils.createFaultResponse(accept, e);
+ return atom.createFaultResponse(accept, e);
}
}
@@ -244,30 +281,62 @@ public abstract class AbstractServices {
acceptType = Accept.parse(accept, getVersion());
}
- if (acceptType == Accept.XML || acceptType == Accept.TEXT) {
- throw new UnsupportedMediaTypeException("Unsupported media type");
- }
-
- final String basePath =
- entitySetName + File.separatorChar + utils.getEntityKey(entityId) + File.separatorChar;
+ final Map.Entry<String, InputStream> entityInfo = atom.readEntity(entitySetName, entityId, acceptType);
- InputStream entity = utils.readFile(basePath + ENTITY, acceptType);
+ InputStream entity = entityInfo.getValue();
if (StringUtils.isNotBlank(select)) {
if (acceptType == Accept.ATOM) {
- entity = utils.selectAtomEntity(entity, select.split(","), acceptType);
+ entity = atom.selectEntity(entity, select.split(","));
} else {
- entity = utils.selectJsonEntity(entity, select.split(","), acceptType);
+ entity = json.selectEntity(entity, select.split(","));
}
}
if (StringUtils.isNotBlank(expand)) {
- entity = utils.expandLinks(entity, basePath, expand, acceptType);
+ if (acceptType == Accept.XML || acceptType == Accept.TEXT) {
+ throw new UnsupportedMediaTypeException("Unsupported media type");
+ } else if (acceptType == Accept.ATOM) {
+ for (String exp : expand.split(",")) {
+ entity = atom.expandEntity(
+ entitySetName,
+ entityId,
+ entity,
+ exp);
+ }
+ } else {
+ for (String exp : expand.split(",")) {
+ entity = json.expandEntity(
+ entitySetName,
+ entityId,
+ entity,
+ exp);
+ }
+ }
}
- return utils.createResponse(entity, utils.getETag(basePath), acceptType);
+ return atom.createResponse(entity, Commons.getETag(entityInfo.getKey(), getVersion()), acceptType);
} catch (Exception e) {
- return utils.createFaultResponse(accept, e);
+ LOG.error("Error retrieving entity", e);
+ return atom.createFaultResponse(accept, e);
+ }
+ }
+
+ @DELETE
+ @Path("/{entitySetName}({entityId})")
+ public Response removeEntity(
+ @PathParam("entitySetName") String entitySetName,
+ @PathParam("entityId") String entityId) {
+
+ try {
+ final String basePath =
+ entitySetName + File.separatorChar + Commons.getEntityKey(entityId) + File.separatorChar;
+
+ FSManager.instance(getVersion()).deleteFile(basePath + ENTITY);
+
+ return atom.createResponse(null, null, null, Response.Status.NO_CONTENT);
+ } catch (Exception e) {
+ return atom.createFaultResponse(Accept.XML.toString(), e);
}
}
@@ -300,32 +369,56 @@ public abstract class AbstractServices {
}
final String basePath =
- entitySetName + File.separatorChar + utils.getEntityKey(entityId) + File.separatorChar;
+ entitySetName + File.separatorChar + Commons.getEntityKey(entityId) + File.separatorChar;
- InputStream stream = utils.readFile(basePath + ENTITY, acceptType == null ? Accept.XML : acceptType);
+ InputStream stream;
- if (searchForValue) {
- stream = utils.getAtomPropertyValue(stream, path.split("/"));
- } else {
- if (acceptType == null || acceptType == Accept.XML || acceptType == Accept.ATOM) {
- // retrieve xml
- stream = utils.getAtomProperty(stream, path.split("/"));
+ try {
+ final Map.Entry<String, List<String>> linkInfo = XMLUtilities.extractLinkURIs(
+ atom.readLinks(entitySetName, entityId, path, Accept.XML).getValue());
+
+ switch (acceptType) {
+ case JSON:
+ case JSON_FULLMETA:
+ case JSON_NOMETA:
+ stream = json.readEntities(linkInfo.getValue(), path, linkInfo.getKey());
+ stream = json.wrapJsonEntities(stream);
+ break;
+ default:
+ stream = atom.readEntities(linkInfo.getValue(), path, linkInfo.getKey());
+ }
+ } catch (NotFoundException e) {
+ // if the given path is not about any link then search for property
+ LOG.info("Retrieve property {}", path);
+
+ stream = FSManager.instance(getVersion()).readFile(
+ basePath + ENTITY, acceptType == null || acceptType == Accept.ATOM.TEXT
+ ? Accept.XML : acceptType);
+
+ if (searchForValue) {
+ stream = atom.getAtomPropertyValue(stream, path.split("/"));
} else {
- // retrieve Edm type from xml
- final String edmType = utils.getEdmTypeFromXML(utils.readFile(basePath + ENTITY, Accept.XML),
- path.split("/"));
- // retrieve json property
- stream = utils.getJsonProperty(stream, path.split("/"), edmType);
+ if (acceptType == null || acceptType == Accept.XML || acceptType == Accept.ATOM) {
+ // retrieve xml
+ stream = atom.getAtomProperty(stream, path.split("/"));
+ } else {
+ // retrieve Edm type from xml
+ final String edmType = atom.getEdmTypeFromXML(
+ FSManager.instance(getVersion()).readFile(basePath + ENTITY, Accept.XML),
+ path.split("/"));
+ // retrieve json property
+ stream = json.getJsonProperty(stream, path.split("/"), edmType);
+ }
}
- }
- if ((searchForValue && acceptType != null && acceptType != Accept.TEXT) || acceptType == Accept.ATOM) {
- throw new UnsupportedMediaTypeException("Unsupported media type " + acceptType);
+ if ((searchForValue && acceptType != null && acceptType != Accept.TEXT) || acceptType == Accept.ATOM) {
+ throw new UnsupportedMediaTypeException("Unsupported media type " + acceptType);
+ }
}
- return utils.createResponse(stream, utils.getETag(basePath), acceptType);
+ return atom.createResponse(stream, Commons.getETag(basePath, getVersion()), acceptType);
} catch (Exception e) {
- return utils.createFaultResponse(accept, e);
+ return atom.createFaultResponse(accept, e);
}
}
@@ -359,14 +452,14 @@ public abstract class AbstractServices {
throw new UnsupportedMediaTypeException("Unsupported media type");
}
- final String basePath =
- entitySetName + File.separatorChar + utils.getEntityKey(entityId) + File.separatorChar
- + "links" + File.separatorChar;
+ final Map.Entry<String, InputStream> links = atom.readLinks(entitySetName, entityId, linkName, acceptType);
- return utils.createResponse(
- utils.readFile(basePath + linkName, acceptType), utils.getETag(basePath), acceptType);
+ return atom.createResponse(
+ links.getValue(),
+ links.getKey(),
+ acceptType);
} catch (Exception e) {
- return utils.createFaultResponse(accept, e);
+ return atom.createFaultResponse(accept, e);
}
}
@@ -389,14 +482,14 @@ public abstract class AbstractServices {
throw new UnsupportedMediaTypeException("Unsupported type " + accept);
}
- int count = utils.countAllElements(entitySetName);
+ int count = atom.countAllElements(entitySetName);
final Response.ResponseBuilder builder = Response.ok();
builder.entity(count);
return builder.build();
} catch (Exception e) {
- return utils.createFaultResponse(accept, e);
+ return atom.createFaultResponse(accept, e);
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/744a3713/ODataJClient/test-service/src/main/java/com/msopentech/odatajclient/testservice/Accept.java
----------------------------------------------------------------------
diff --git a/ODataJClient/test-service/src/main/java/com/msopentech/odatajclient/testservice/Accept.java b/ODataJClient/test-service/src/main/java/com/msopentech/odatajclient/testservice/Accept.java
deleted file mode 100644
index 2c4c1c5..0000000
--- a/ODataJClient/test-service/src/main/java/com/msopentech/odatajclient/testservice/Accept.java
+++ /dev/null
@@ -1,77 +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 com.msopentech.odatajclient.testservice;
-
-import java.util.regex.Pattern;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.http.entity.ContentType;
-
-public enum Accept {
-
- TEXT(ContentType.TEXT_PLAIN.getMimeType(), ".xml"),
- XML(ContentType.APPLICATION_XML.getMimeType(), ".xml"),
- ATOM(ContentType.APPLICATION_ATOM_XML.getMimeType(), ".xml"),
- JSON(ContentType.APPLICATION_JSON.getMimeType() + ";odata=minimalmetadata", ".minimal.json"),
- JSON_NOMETA(ContentType.APPLICATION_JSON.getMimeType() + ";odata=nometadata", ".no.json"),
- JSON_FULLMETA(ContentType.APPLICATION_JSON.getMimeType() + ";odata=fullmetadata", ".full.json");
-
- private final String contentType;
-
- private final String fileExtension;
-
- private static Pattern allTypesPattern = Pattern.compile("(.*,)?\\*/\\*([,;].*)?");
-
- Accept(final String contentType, final String fileExtension) {
- this.contentType = contentType;
- this.fileExtension = fileExtension;
- }
-
- @Override
- public String toString() {
- return contentType;
- }
-
- public String getExtension() {
- return fileExtension;
- }
-
- public static Accept parse(final String contentType, final ODataVersion version) {
- return parse(contentType, version, ODataVersion.v3 == version ? ATOM : JSON_NOMETA);
- }
-
- public static Accept parse(final String contentType, final ODataVersion version, final Accept def) {
- if (StringUtils.isBlank(contentType) || allTypesPattern.matcher(contentType).matches()) {
- return def;
- } else if (JSON_NOMETA.toString().equals(contentType)) {
- return JSON_NOMETA;
- } else if (JSON.toString().equals(contentType) || "application/json".equals(contentType)) {
- return JSON;
- } else if (JSON_FULLMETA.toString().equals(contentType)) {
- return JSON_FULLMETA;
- } else if (XML.toString().equals(contentType)) {
- return XML;
- } else if (ATOM.toString().equals(contentType)) {
- return ATOM;
- } else if (TEXT.toString().equals(contentType)) {
- return TEXT;
- } else {
- throw new UnsupportedMediaTypeException("Unsupported media type");
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/744a3713/ODataJClient/test-service/src/main/java/com/msopentech/odatajclient/testservice/Constants.java
----------------------------------------------------------------------
diff --git a/ODataJClient/test-service/src/main/java/com/msopentech/odatajclient/testservice/Constants.java b/ODataJClient/test-service/src/main/java/com/msopentech/odatajclient/testservice/Constants.java
deleted file mode 100644
index faa4fe9..0000000
--- a/ODataJClient/test-service/src/main/java/com/msopentech/odatajclient/testservice/Constants.java
+++ /dev/null
@@ -1,59 +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 com.msopentech.odatajclient.testservice;
-
-public class Constants {
-
- protected final static String DEFAULT_SERVICE_URL = "http://localhost:9080/StaticService/V3/Static.svc/";
-
- protected final static String ODATA_METADATA_NAME = "odata.metadata";
-
- protected final static String ODATA_COUNT_NAME = "odata.count";
-
- protected final static String ODATA_METADATA_PREFIX = DEFAULT_SERVICE_URL + "$metadata#";
-
- protected final static String ATOM_PROPERTY_PREFIX = "d:";
-
- protected final static String ATOM_METADATA_PREFIX = "m:";
-
- protected final static String TYPE = ATOM_METADATA_PREFIX + "type";
-
- protected final static String PROPERTIES = ATOM_METADATA_PREFIX + "properties";
-
- protected final static String DATASERVICES_NS = "http://schemas.microsoft.com/ado/2007/08/dataservices";
-
- protected final static String METADATA_NS = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata";
-
- protected final static String METADATA = "metadata";
-
- protected final static String SERVICES = "services";
-
- protected final static String FEED = "feed";
-
- protected final static String ENTITY = "entity";
-
- protected final static String SKIP_TOKEN = "skiptoken";
-
- protected final static String FILTER = "filter";
-
- protected final static String INLINE = "inline";
-
- protected final static String ORDERBY = "orderby";
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/744a3713/ODataJClient/test-service/src/main/java/com/msopentech/odatajclient/testservice/ODataVersion.java
----------------------------------------------------------------------
diff --git a/ODataJClient/test-service/src/main/java/com/msopentech/odatajclient/testservice/ODataVersion.java b/ODataJClient/test-service/src/main/java/com/msopentech/odatajclient/testservice/ODataVersion.java
deleted file mode 100644
index e399227..0000000
--- a/ODataJClient/test-service/src/main/java/com/msopentech/odatajclient/testservice/ODataVersion.java
+++ /dev/null
@@ -1,26 +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 com.msopentech.odatajclient.testservice;
-
-public enum ODataVersion {
-
- v3,
- v4;
-
-};