olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sklev...@apache.org
Subject [08/19] git commit: api review in order to avoid to append value segment explicitely in case of media entity retrieve and property value retrieve
Date Thu, 22 May 2014 10:35:51 GMT
api review in order to avoid to append value segment explicitely in case of media entity retrieve
and property value retrieve


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/859a7e89
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/859a7e89
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/859a7e89

Branch: refs/heads/olingo-266-tecsvc
Commit: 859a7e893ce9554eef3539152dad5b9048657b0e
Parents: a12b2b1
Author: fmartelli <fabio.martelli@gmail.com>
Authored: Tue May 20 16:55:41 2014 +0200
Committer: fmartelli <fabio.martelli@gmail.com>
Committed: Tue May 20 16:55:41 2014 +0200

----------------------------------------------------------------------
 .../proxy/commons/EntityInvocationHandler.java  |  2 +-
 .../apache/olingo/fit/v3/AsyncTestITCase.java   |  5 +-
 .../olingo/fit/v3/MediaEntityTestITCase.java    | 26 ++++-----
 .../olingo/fit/v3/PropertyTestITCase.java       |  7 +--
 .../olingo/fit/v3/PropertyValueTestITCase.java  | 32 +++++------
 .../olingo/fit/v4/MediaEntityTestITCase.java    |  7 ++-
 .../olingo/fit/v4/PropertyValueTestITCase.java  | 47 +++++++--------
 .../retrieve/CommonRetrieveRequestFactory.java  | 17 ++++++
 .../request/cud/AbstractCUDRequestFactory.java  |  9 +--
 .../AbstractRetrieveRequestFactory.java         | 11 ++++
 .../request/retrieve/ODataValueRequestImpl.java |  2 +-
 .../apache/olingo/client/core/uri/URIUtils.java | 60 +++++++++++++-------
 12 files changed, 129 insertions(+), 96 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/859a7e89/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java
b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java
index 924d155..5be9bb8 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java
@@ -322,7 +322,7 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler
       final String contentType =
               StringUtils.isBlank(getEntity().getMediaContentType()) ? "*/*" : getEntity().getMediaContentType();
 
-      final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaRequest(contentSource);
+      final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaEntityRequest(contentSource);
       retrieveReq.setFormat(ODataMediaFormat.fromFormat(contentType));
 
       this.stream = retrieveReq.execute().getBody();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/859a7e89/fit/src/test/java/org/apache/olingo/fit/v3/AsyncTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/AsyncTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/AsyncTestITCase.java
index ac43372..e9ac0e3 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v3/AsyncTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v3/AsyncTestITCase.java
@@ -119,10 +119,9 @@ public class AsyncTestITCase extends AbstractTestITCase {
             ? created.getProperties().get(0).getPrimitiveValue().toCastValue(Integer.class)
             : created.getProperties().get(1).getPrimitiveValue().toCastValue(Integer.class);
 
-    builder = client.getURIBuilder(testStaticServiceRootURL).
-            appendEntitySetSegment("Car").appendKeySegment(id).appendValueSegment();
+    builder = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Car").appendKeySegment(id);
 
-    final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaRequest(builder.build());
+    final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaEntityRequest(builder.build());
 
     final ODataRetrieveResponse<InputStream> retrieveRes = retrieveReq.execute();
     assertEquals(200, retrieveRes.getStatusCode());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/859a7e89/fit/src/test/java/org/apache/olingo/fit/v3/MediaEntityTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/MediaEntityTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/MediaEntityTestITCase.java
index cc88cf1..5ae7e9e 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v3/MediaEntityTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v3/MediaEntityTestITCase.java
@@ -48,9 +48,9 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
   @Test
   public void read() throws Exception {
     final URIBuilder builder = client.getURIBuilder(testStaticServiceRootURL).
-            appendEntitySetSegment("Car").appendKeySegment(12).appendValueSegment();
+            appendEntitySetSegment("Car").appendKeySegment(12);
 
-    final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaRequest(builder.build());
+    final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaEntityRequest(builder.build());
     retrieveReq.setFormat(ODataMediaFormat.WILDCARD);
 
     final ODataRetrieveResponse<InputStream> retrieveRes = retrieveReq.execute();
@@ -62,10 +62,10 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
 
   @Test(expected = ODataClientErrorException.class)
   public void readWithXmlError() throws Exception {
-    final URIBuilder builder = client.getURIBuilder(testStaticServiceRootURL).
-            appendEntitySetSegment("Car").appendKeySegment(12).appendValueSegment();
+    final URIBuilder builder =
+            client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Car").appendKeySegment(12);
 
-    final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaRequest(builder.build());
+    final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaEntityRequest(builder.build());
     retrieveReq.setFormat(ODataMediaFormat.APPLICATION_XML);
 
     retrieveReq.execute();
@@ -73,18 +73,18 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
 
   @Test(expected = ODataClientErrorException.class)
   public void readWithJsonError() throws Exception {
-    final URIBuilder builder = client.getURIBuilder(testStaticServiceRootURL).
-            appendEntitySetSegment("Car").appendKeySegment(12).appendValueSegment();
+    final URIBuilder builder =
+            client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Car").appendKeySegment(12);
 
-    final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaRequest(builder.build());
+    final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaEntityRequest(builder.build());
     retrieveReq.setFormat(ODataMediaFormat.APPLICATION_JSON);
 
     retrieveReq.execute();
   }
 
   private void updateMediaEntity(final ODataPubFormat format, final int id) throws Exception
{
-    final URIBuilder builder = client.getURIBuilder(testStaticServiceRootURL).
-            appendEntitySetSegment("Car").appendKeySegment(id).appendValueSegment();
+    final URIBuilder builder =
+            client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Car").appendKeySegment(id);
 
     final String TO_BE_UPDATED = "new buffered stream sample";
     final InputStream input = IOUtils.toInputStream(TO_BE_UPDATED);
@@ -97,7 +97,7 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
     final ODataMediaEntityUpdateResponse<ODataEntity> updateRes = streamManager.getResponse();
     assertEquals(204, updateRes.getStatusCode());
 
-    final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaRequest(builder.build());
+    final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaEntityRequest(builder.build());
 
     final ODataRetrieveResponse<InputStream> retrieveRes = retrieveReq.execute();
     assertEquals(200, retrieveRes.getStatusCode());
@@ -137,9 +137,9 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
     }
     assertNotNull(id);
 
-    builder.appendKeySegment(id).appendValueSegment();
+    builder.appendKeySegment(id);
 
-    final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaRequest(builder.build());
+    final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaEntityRequest(builder.build());
 
     final ODataRetrieveResponse<InputStream> retrieveRes = retrieveReq.execute();
     assertEquals(200, retrieveRes.getStatusCode());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/859a7e89/fit/src/test/java/org/apache/olingo/fit/v3/PropertyTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/PropertyTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/PropertyTestITCase.java
index c46efc0..c9c1c00 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v3/PropertyTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v3/PropertyTestITCase.java
@@ -166,10 +166,9 @@ public class PropertyTestITCase extends AbstractTestITCase {
             appendEntitySetSegment("Customer").appendKeySegment(-9).
             appendPropertySegment("PrimaryContactInfo").
             appendPropertySegment("HomePhone").
-            appendPropertySegment("PhoneNumber").
-            appendValueSegment();
+            appendPropertySegment("PhoneNumber");
 
-    ODataValueRequest retrieveReq = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
+    ODataValueRequest retrieveReq = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
     retrieveReq.setFormat(format);
 
     ODataRetrieveResponse<ODataPrimitiveValue> retrieveRes = retrieveReq.execute();
@@ -192,7 +191,7 @@ public class PropertyTestITCase extends AbstractTestITCase {
     final ODataValueUpdateResponse updateRes = updateReq.execute();
     assertEquals(204, updateRes.getStatusCode());
 
-    retrieveReq = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
+    retrieveReq = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
     retrieveReq.setFormat(format);
 
     retrieveRes = retrieveReq.execute();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/859a7e89/fit/src/test/java/org/apache/olingo/fit/v3/PropertyValueTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/PropertyValueTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/PropertyValueTestITCase.java
index cffcec5..4914eb5 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v3/PropertyValueTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v3/PropertyValueTestITCase.java
@@ -35,9 +35,8 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
   @Test
   public void retrieveIntPropertyValueTest() {
     CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
-            appendEntitySetSegment("Product").appendKeySegment(-10).appendPropertySegment("ProductId").
-            appendValueSegment();
-    final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
+            appendEntitySetSegment("Product").appendKeySegment(-10).appendPropertySegment("ProductId");
+    final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
     req.setFormat(ODataValueFormat.TEXT);
     final ODataValue value = req.execute().getBody();
     assertNotNull(value);
@@ -47,9 +46,8 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
   @Test
   public void retrieveBooleanPropertyValueTest() {
     CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
-            appendEntitySetSegment("Product").appendKeySegment(-10).appendPropertySegment("ProductId").
-            appendValueSegment();
-    final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
+            appendEntitySetSegment("Product").appendKeySegment(-10).appendPropertySegment("ProductId");
+    final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
     req.setFormat(ODataValueFormat.TEXT);
     final ODataValue value = req.execute().getBody();
     assertNotNull(value);
@@ -59,9 +57,8 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
   @Test
   public void retrieveStringPropertyValueTest() {
     CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
-            appendEntitySetSegment("Product").appendKeySegment(-6).appendPropertySegment("Description").
-            appendValueSegment();
-    final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
+            appendEntitySetSegment("Product").appendKeySegment(-6).appendPropertySegment("Description");
+    final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
     req.setFormat(ODataValueFormat.TEXT);
     final ODataValue value = req.execute().getBody();
     assertNotNull(value);
@@ -72,8 +69,8 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
   public void retrieveDatePropertyValueTest() {
     CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
             appendEntitySetSegment("Product").appendKeySegment(-7).appendPropertySegment(
-                    "NestedComplexConcurrency/ModifiedDate").appendValueSegment();
-    final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
+                    "NestedComplexConcurrency/ModifiedDate");
+    final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
     req.setFormat(ODataValueFormat.TEXT);
     final ODataValue value = req.execute().getBody();
     assertNotNull(value);
@@ -83,9 +80,8 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
   @Test
   public void retrieveDecimalPropertyValueTest() {
     CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
-            appendEntitySetSegment("Product").appendKeySegment(-6).appendPropertySegment("Dimensions/Height").
-            appendValueSegment();
-    final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
+            appendEntitySetSegment("Product").appendKeySegment(-6).appendPropertySegment("Dimensions/Height");
+    final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
     req.setFormat(ODataValueFormat.TEXT);
     final ODataValue value = req.execute().getBody();
     assertNotNull(value);
@@ -141,8 +137,8 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
   public void retrieveCollectionPropertyValueTest() {
     CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
             appendEntitySetSegment("Product").appendKeySegment(-7).appendPropertySegment(
-                    "ComplexConcurrency/QueriedDateTime").appendValueSegment();
-    final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
+                    "ComplexConcurrency/QueriedDateTime");
+    final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
     req.setFormat(ODataValueFormat.TEXT);
     final ODataValue value = req.execute().getBody();
     if (value.isPrimitive()) {
@@ -155,8 +151,8 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
   public void retrieveNullPropertyValueTest() {
     CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
             appendEntitySetSegment("Product").appendKeySegment(-10).appendPropertySegment(
-                    "ComplexConcurrency/Token").appendValueSegment();
-    final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
+                    "ComplexConcurrency/Token");
+    final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
     try {
       req.execute().getBody();
     } catch (ODataClientErrorException e) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/859a7e89/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 d9f3935..ecd8c52 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
@@ -62,6 +62,7 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
             appendKeySegment(UUID.fromString("f89dee73-af9f-4cd4-b330-db93c25ff3c7"));
     final ODataEntityRequest<ODataEntity> entityReq =
             client.getRetrieveRequestFactory().getEntityRequest(builder.build());
+    entityReq.setFormat(format);
 
     final ODataEntity entity = entityReq.execute().getBody();
     assertNotNull(entity);
@@ -124,7 +125,7 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
     assertEquals(204, updateRes.getStatusCode());
 
     final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().
-            getMediaRequest(client.getURIBuilder(createdLocation.toASCIIString()).appendValueSegment().build());
+            getMediaEntityRequest(client.getURIBuilder(createdLocation.toASCIIString()).build());
     final ODataRetrieveResponse<InputStream> retrieveRes = retrieveReq.execute();
     assertEquals(200, retrieveRes.getStatusCode());
 
@@ -146,7 +147,7 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
   private void update(final ODataPubFormat format) throws IOException, EdmPrimitiveTypeException
{
     final URI uri = client.getURIBuilder(testDemoServiceRootURL).
             appendEntitySetSegment("Advertisements").
-            appendKeySegment(UUID.fromString("f89dee73-af9f-4cd4-b330-db93c25ff3c7")).appendValueSegment().build();
+            appendKeySegment(UUID.fromString("f89dee73-af9f-4cd4-b330-db93c25ff3c7")).build();
 
     final String random = RandomStringUtils.random(124);
 
@@ -160,7 +161,7 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
     assertEquals(204, createRes.getStatusCode());
 
     // 2. check that media content was effectively uploaded
-    final ODataMediaRequest streamReq = client.getRetrieveRequestFactory().getMediaRequest(uri);
+    final ODataMediaRequest streamReq = client.getRetrieveRequestFactory().getMediaEntityRequest(uri);
     final ODataRetrieveResponse<InputStream> streamRes = streamReq.execute();
     assertEquals(200, streamRes.getStatusCode());
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/859a7e89/fit/src/test/java/org/apache/olingo/fit/v4/PropertyValueTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/PropertyValueTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/PropertyValueTestITCase.java
index 5f76153..01834a4 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/PropertyValueTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/PropertyValueTestITCase.java
@@ -42,9 +42,8 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
   @Test
   public void retrieveIntPropertyValueTest() throws EdmPrimitiveTypeException {
     final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
-            appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PersonID").
-            appendValueSegment();
-    final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
+            appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PersonID");
+    final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
     req.setFormat(ODataValueFormat.TEXT);
     assertEquals("5", req.execute().getBody().toString());
   }
@@ -52,9 +51,8 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
   @Test
   public void retrieveBooleanPropertyValueTest() throws EdmPrimitiveTypeException {
     final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
-            appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("IsRegistered").
-            appendValueSegment();
-    final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
+            appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("IsRegistered");
+    final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
     req.setFormat(ODataValueFormat.TEXT);
     assertEquals("true", req.execute().getBody().toString());
   }
@@ -62,9 +60,8 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
   @Test
   public void retrieveStringPropertyValueTest() throws EdmPrimitiveTypeException {
     final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
-            appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("FirstName").
-            appendValueSegment();
-    final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
+            appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("FirstName");
+    final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
     req.setFormat(ODataValueFormat.TEXT);
     assertEquals("Peter", req.execute().getBody().toString());
   }
@@ -72,9 +69,8 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
   @Test
   public void retrieveDatePropertyValueTest() {
     final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
-            appendEntitySetSegment("Orders").appendKeySegment(8).appendPropertySegment("OrderDate").
-            appendValueSegment();
-    final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
+            appendEntitySetSegment("Orders").appendKeySegment(8).appendPropertySegment("OrderDate");
+    final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
     req.setFormat(ODataValueFormat.TEXT);
     final ODataPrimitiveValue property = req.execute().getBody();
     assertEquals("2011-03-04T16:03:57Z", property.toString());
@@ -83,9 +79,8 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
   @Test
   public void retrieveDecimalPropertyValueTest() throws EdmPrimitiveTypeException {
     final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
-            appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("Height").
-            appendValueSegment();
-    final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
+            appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("Height");
+    final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
     req.setFormat(ODataValueFormat.TEXT);
     final ODataPrimitiveValue property = req.execute().getBody();
     assertEquals("179", property.toString());
@@ -94,9 +89,8 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
   @Test
   public void retrieveBinaryPropertyValueTest() throws IOException {
     final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
-            appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC").
-            appendValueSegment();
-    final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
+            appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC");
+    final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
     req.setFormat(ODataValueFormat.TEXT);
     final ODataPrimitiveValue property = req.execute().getBody();
     assertEquals("fi653p3+MklA/LdoBlhWgnMTUUEo8tEgtbMXnF0a3CUNL9BZxXpSRiD9ebTnmNR0zWPjJ"
@@ -106,9 +100,8 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
   @Test(expected = ODataClientErrorException.class)
   public void retrieveBinaryPropertyValueTestWithAtom() throws IOException {
     final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
-            appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC").
-            appendValueSegment();
-    final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
+            appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC");
+    final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
     req.setAccept(ODataPubFormat.ATOM.toString(ODataServiceVersion.V40));
     req.execute().getBody();
   }
@@ -116,9 +109,8 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
   @Test(expected = ODataClientErrorException.class)
   public void retrieveBinaryPropertyValueTestWithXML() throws IOException {
     final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
-            appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC").
-            appendValueSegment();
-    final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
+            appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC");
+    final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
     req.setAccept(ODataFormat.XML.toString(client.getServiceVersion()));
     req.execute().getBody();
   }
@@ -132,16 +124,15 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
     req.setFormat(ODataFormat.XML);
     final ODataProperty property = req.execute().getBody();
     // cast to workaround JDK 6 bug, fixed in JDK 7
-    assertTrue(((ODataValuable)property).getValue().isCollection());
+    assertTrue(((ODataValuable) property).getValue().isCollection());
     assertEquals("555-555-5555", property.getCollectionValue().iterator().next().asPrimitive().toString());
   }
 
   @Test
   public void retrieveNullPropertyValueTest() {
     final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
-            appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("HomeAddress").
-            appendValueSegment();
-    final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
+            appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("HomeAddress");
+    final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
     req.setFormat(ODataValueFormat.TEXT);
     final ODataPrimitiveValue property = req.execute().getBody();
     assertTrue(StringUtils.isBlank(property.toString()));

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/859a7e89/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/CommonRetrieveRequestFactory.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/CommonRetrieveRequestFactory.java
b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/CommonRetrieveRequestFactory.java
index 69e53e7..0c99298 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/CommonRetrieveRequestFactory.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/CommonRetrieveRequestFactory.java
@@ -99,6 +99,15 @@ public interface CommonRetrieveRequestFactory extends Serializable {
    * @return new {@link ODataPropertyRequest} instance.
    */
   <T extends CommonODataProperty> ODataPropertyRequest<T> getPropertyRequest(URI
uri);
+  
+  /**
+   * Gets a uri request returning a single OData entity property value.
+   *
+   * @param <T> concrete ODataProperty implementation.
+   * @param uri request URI.
+   * @return new {@link ODataValueRequest} instance.
+   */
+  ODataValueRequest getPropertyValueRequest(URI uri);
 
   /**
    * Gets a uri request returning a single OData entity property value.
@@ -115,6 +124,14 @@ public interface CommonRetrieveRequestFactory extends Serializable {
    * @return new {@link ODataMediaRequest} instance.
    */
   ODataMediaRequest getMediaRequest(URI uri);
+  
+  /**
+   * Gets a uri request returning a media entity.
+   *
+   * @param uri request URI.
+   * @return new {@link ODataMediaRequest} instance.
+   */
+  ODataMediaRequest getMediaEntityRequest(URI uri);
 
   /**
    * Implements a raw request request without specifying any return type.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/859a7e89/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/AbstractCUDRequestFactory.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/AbstractCUDRequestFactory.java
b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/AbstractCUDRequestFactory.java
index 43de94e..1a7e5b1 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/AbstractCUDRequestFactory.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/AbstractCUDRequestFactory.java
@@ -35,6 +35,7 @@ import org.apache.olingo.client.api.http.HttpMethod;
 import org.apache.olingo.client.core.communication.request.streamed.ODataMediaEntityCreateRequestImpl;
 import org.apache.olingo.client.core.communication.request.streamed.ODataMediaEntityUpdateRequestImpl;
 import org.apache.olingo.client.core.communication.request.streamed.ODataStreamUpdateRequestImpl;
+import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.commons.api.domain.CommonODataEntity;
 import org.apache.olingo.commons.api.domain.CommonODataProperty;
 import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
@@ -99,10 +100,10 @@ public abstract class AbstractCUDRequestFactory<UT extends CommonUpdateType>
imp
     final ODataValueUpdateRequest req;
 
     if (client.getConfiguration().isUseXHTTPMethod()) {
-      req = new ODataValueUpdateRequestImpl(client, HttpMethod.POST, targetURI, value);
+      req = new ODataValueUpdateRequestImpl(client, HttpMethod.POST, URIUtils.addValueSegment(targetURI),
value);
       req.setXHTTPMethod(type.getMethod().name());
     } else {
-      req = new ODataValueUpdateRequestImpl(client, type.getMethod(), targetURI, value);
+      req = new ODataValueUpdateRequestImpl(client, type.getMethod(), URIUtils.addValueSegment(targetURI),
value);
     }
 
     return req;
@@ -210,10 +211,10 @@ public abstract class AbstractCUDRequestFactory<UT extends CommonUpdateType>
imp
     final ODataMediaEntityUpdateRequest<E> req;
 
     if (client.getConfiguration().isUseXHTTPMethod()) {
-      req = new ODataMediaEntityUpdateRequestImpl<E>(client, HttpMethod.POST, editURI,
media);
+      req = new ODataMediaEntityUpdateRequestImpl<E>(client, HttpMethod.POST, URIUtils.addValueSegment(editURI),
media);
       req.setXHTTPMethod(HttpMethod.PUT.name());
     } else {
-      req = new ODataMediaEntityUpdateRequestImpl<E>(client, HttpMethod.PUT, editURI,
media);
+      req = new ODataMediaEntityUpdateRequestImpl<E>(client, HttpMethod.PUT, URIUtils.addValueSegment(editURI),
media);
     }
 
     return req;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/859a7e89/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractRetrieveRequestFactory.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractRetrieveRequestFactory.java
b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractRetrieveRequestFactory.java
index b5ba1a9..abf2a8c 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractRetrieveRequestFactory.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractRetrieveRequestFactory.java
@@ -27,6 +27,7 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataRawReque
 import org.apache.olingo.client.api.communication.request.retrieve.ODataServiceDocumentRequest;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataValueRequest;
 import org.apache.olingo.client.api.communication.request.retrieve.CommonRetrieveRequestFactory;
+import org.apache.olingo.client.core.uri.URIUtils;
 
 public abstract class AbstractRetrieveRequestFactory implements CommonRetrieveRequestFactory
{
 
@@ -44,11 +45,21 @@ public abstract class AbstractRetrieveRequestFactory implements CommonRetrieveRe
   }
 
   @Override
+  public ODataValueRequest getPropertyValueRequest(final URI uri) {
+    return getValueRequest(URIUtils.addValueSegment(uri));
+  }
+
+  @Override
   public ODataMediaRequest getMediaRequest(final URI uri) {
     return new ODataMediaRequestImpl(client, uri);
   }
 
   @Override
+  public ODataMediaRequest getMediaEntityRequest(final URI uri) {
+    return getMediaRequest(URIUtils.addValueSegment(uri));
+  }
+
+  @Override
   public ODataRawRequest getRawRequest(final URI uri) {
     return new ODataRawRequestImpl(client, uri);
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/859a7e89/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataValueRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataValueRequestImpl.java
b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataValueRequestImpl.java
index 460b695..7bc9fdf 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataValueRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataValueRequestImpl.java
@@ -42,7 +42,7 @@ public class ODataValueRequestImpl extends AbstractODataRetrieveRequest<ODataPri
    * @param odataClient client instance getting this request
    * @param query query to be executed.
    */
-  ODataValueRequestImpl(final CommonODataClient odataClient, final URI query) {
+  ODataValueRequestImpl(final CommonODataClient<?> odataClient, final URI query) {
     super(odataClient, ODataValueFormat.class, query);
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/859a7e89/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java
b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java
index 017041b..4ecced4 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java
@@ -23,6 +23,7 @@ import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 import java.math.BigDecimal;
 import java.net.URI;
+import java.net.URISyntaxException;
 import java.net.URLEncoder;
 import java.sql.Timestamp;
 import java.util.Calendar;
@@ -39,11 +40,13 @@ import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.BooleanUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.http.HttpEntity;
+import org.apache.http.client.utils.URIBuilder;
 import org.apache.http.entity.AbstractHttpEntity;
 import org.apache.http.entity.ByteArrayEntity;
 import org.apache.http.entity.InputStreamEntity;
 import org.apache.olingo.client.api.CommonODataClient;
 import org.apache.olingo.client.api.http.HttpClientFactory;
+import org.apache.olingo.client.api.uri.SegmentType;
 import org.apache.olingo.client.core.http.BasicAuthHttpClientFactory;
 import org.apache.olingo.client.core.http.ProxyWrapperHttpClientFactory;
 import org.apache.olingo.commons.api.Constants;
@@ -230,12 +233,12 @@ public final class URIUtils {
     return version.compareTo(ODataServiceVersion.V40) < 0
             ? prefix(version, EdmPrimitiveTypeKind.DateTime)
             + URLEncoder.encode(EdmDateTime.getInstance().
-                    valueToString(timestamp, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE,
null),
-                    Constants.UTF8)
+            valueToString(timestamp, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE,
null),
+            Constants.UTF8)
             + suffix(version, EdmPrimitiveTypeKind.DateTime)
             : URLEncoder.encode(EdmDateTimeOffset.getInstance().
-                    valueToString(timestamp, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE,
null),
-                    Constants.UTF8);
+            valueToString(timestamp, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE,
null),
+            Constants.UTF8);
   }
 
   private static String calendar(final ODataServiceVersion version, final Calendar calendar)
@@ -246,8 +249,8 @@ public final class URIUtils {
       if (version.compareTo(ODataServiceVersion.V40) < 0) {
         result = prefix(version, EdmPrimitiveTypeKind.DateTime)
                 + URLEncoder.encode(EdmDateTime.getInstance().
-                        valueToString(calendar, null, null, Constants.DEFAULT_PRECISION,
Constants.DEFAULT_SCALE, null),
-                        Constants.UTF8)
+                valueToString(calendar, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE,
null),
+                Constants.UTF8)
                 + suffix(version, EdmPrimitiveTypeKind.DateTime);
       } else {
         if (calendar.get(Calendar.YEAR) == 0 && calendar.get(Calendar.MONTH) == 0
@@ -265,8 +268,8 @@ public final class URIUtils {
     } else {
       result = prefix(version, EdmPrimitiveTypeKind.DateTimeOffset)
               + URLEncoder.encode(EdmDateTimeOffset.getInstance().
-                      valueToString(calendar, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE,
null),
-                      Constants.UTF8)
+              valueToString(calendar, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE,
null),
+              Constants.UTF8)
               + suffix(version, EdmPrimitiveTypeKind.DateTimeOffset);
     }
 
@@ -278,11 +281,11 @@ public final class URIUtils {
 
     return version.compareTo(ODataServiceVersion.V40) < 0
             ? EdmTime.getInstance().toUriLiteral(URLEncoder.encode(EdmTime.getInstance().
-                            valueToString(duration, null, null,
-                                    Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE,
null), Constants.UTF8))
+            valueToString(duration, null, null,
+            Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), Constants.UTF8))
             : EdmDuration.getInstance().toUriLiteral(URLEncoder.encode(EdmDuration.getInstance().
-                            valueToString(duration, null, null,
-                                    Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE,
null), Constants.UTF8));
+            valueToString(duration, null, null,
+            Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), Constants.UTF8));
   }
 
   private static String quoteString(final String string, final boolean singleQuoteEscape)
@@ -360,24 +363,24 @@ public final class URIUtils {
                 ? duration(version, (Duration) obj)
                 : (obj instanceof BigDecimal)
                 ? EdmDecimal.getInstance().valueToString(obj, null, null,
-                        Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null)
+                Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null)
                 + suffix(version, EdmPrimitiveTypeKind.Decimal)
                 : (obj instanceof Double)
                 ? EdmDouble.getInstance().valueToString(obj, null, null,
-                        Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null)
+                Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null)
                 + suffix(version, EdmPrimitiveTypeKind.Double)
                 : (obj instanceof Float)
                 ? EdmSingle.getInstance().valueToString(obj, null, null,
-                        Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null)
+                Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null)
                 + suffix(version, EdmPrimitiveTypeKind.Single)
                 : (obj instanceof Long)
                 ? EdmInt64.getInstance().valueToString(obj, null, null,
-                        Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null)
+                Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null)
                 + suffix(version, EdmPrimitiveTypeKind.Int64)
                 : (obj instanceof Geospatial)
                 ? URLEncoder.encode(EdmPrimitiveTypeFactory.getInstance(((Geospatial) obj).getEdmPrimitiveTypeKind()).
-                        valueToString(obj, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE,
null),
-                        Constants.UTF8)
+                valueToString(obj, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE,
null),
+                Constants.UTF8)
                 : (obj instanceof String)
                 ? quoteString((String) obj, singleQuoteEscape)
                 : obj.toString();
@@ -407,18 +410,18 @@ public final class URIUtils {
 
   public static HttpEntity buildInputStreamEntity(final CommonODataClient<?> client,
final InputStream input) {
     HttpEntity entity;
-    
+
     // --------------------------
     // Check just required by batch requests since their ansynchronous entity specification
mechanism
     // --------------------------
     boolean contentAvailable;
     try {
-      contentAvailable = input.available()>0;
+      contentAvailable = input.available() > 0;
     } catch (IOException ex) {
       contentAvailable = false;
     }
     // --------------------------
-    
+
     boolean repeatableRequired = shouldUseRepeatableHttpBodyEntry(client);
     if (!contentAvailable || !repeatableRequired) {
       entity = new InputStreamEntity(input, -1);
@@ -437,4 +440,19 @@ public final class URIUtils {
     ((AbstractHttpEntity) entity).setChunked(client.getConfiguration().isUseChuncked());
     return entity;
   }
+
+  public static URI addValueSegment(final URI uri) {
+    final URI res;
+    if (uri.getPath().endsWith(SegmentType.VALUE.getValue())) {
+      res = uri;
+    } else {
+      try {
+        res = new URIBuilder(uri).setPath(uri.getPath() + "/" + SegmentType.VALUE.getValue()).build();
+      } catch (URISyntaxException e) {
+        throw new IllegalArgumentException(e);
+      }
+    }
+
+    return res;
+  }
 }


Mime
View raw message