You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2014/06/08 08:02:18 UTC

[1/3] git commit: [OLINGO-315] handle the case of zero container in EDM schema

Repository: olingo-odata4
Updated Branches:
  refs/heads/master 8ad297f9a -> cf360e657


[OLINGO-315] handle the case of zero container in EDM schema


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

Branch: refs/heads/master
Commit: 80c2f83acc83a7b83231f2ac26964d499a23b3a7
Parents: 8ad297f
Author: challenh <ch...@microsoft.com>
Authored: Fri Jun 6 17:03:58 2014 +0800
Committer: challenh <ch...@microsoft.com>
Committed: Fri Jun 6 17:03:58 2014 +0800

----------------------------------------------------------------------
 .../client/core/op/AbstractODataBinder.java     | 33 ++++++++++----------
 1 file changed, 17 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/80c2f83a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
index 14c49a8..c52b0c1 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
@@ -347,22 +347,23 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
       if (contextURL.getDerivedEntity() == null) {
         for (EdmSchema schema : edm.getSchemas()) {
           final EdmEntityContainer container = schema.getEntityContainer();
-
-          EdmBindingTarget bindingTarget = container.getEntitySet(contextURL.getEntitySetOrSingletonOrType());
-          if (bindingTarget == null) {
-            bindingTarget = container.getSingleton(contextURL.getEntitySetOrSingletonOrType());
-          }
-          if (bindingTarget != null) {
-            if (contextURL.getNavOrPropertyPath() == null) {
-              type = bindingTarget.getEntityType();
-            } else {
-              final EdmNavigationProperty navProp = bindingTarget.getEntityType().
-                      getNavigationProperty(contextURL.getNavOrPropertyPath());
-
-              type = navProp == null
-                      ? bindingTarget.getEntityType()
-                      : navProp.getType();
-            }
+          if(container != null) {
+	          EdmBindingTarget bindingTarget = container.getEntitySet(contextURL.getEntitySetOrSingletonOrType());
+	          if (bindingTarget == null) {
+	            bindingTarget = container.getSingleton(contextURL.getEntitySetOrSingletonOrType());
+	          }
+	          if (bindingTarget != null) {
+	            if (contextURL.getNavOrPropertyPath() == null) {
+	              type = bindingTarget.getEntityType();
+	            } else {
+	              final EdmNavigationProperty navProp = bindingTarget.getEntityType().
+	                      getNavigationProperty(contextURL.getNavOrPropertyPath());
+	
+	              type = navProp == null
+	                      ? bindingTarget.getEntityType()
+	                      : navProp.getType();
+	            }
+	          }
           }
         }
         if (type == null) {


[3/3] git commit: [OLINGO-319] fix java.lang.IllegalStateException: Content has been consumed

Posted by ch...@apache.org.
[OLINGO-319] fix java.lang.IllegalStateException: Content has been consumed


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

Branch: refs/heads/master
Commit: cf360e6573630cd432fec89ab00b87a606939392
Parents: 5959dfb
Author: challenh <ch...@microsoft.com>
Authored: Sun Jun 8 13:35:01 2014 +0800
Committer: challenh <ch...@microsoft.com>
Committed: Sun Jun 8 13:35:01 2014 +0800

----------------------------------------------------------------------
 .../invoke/AbstractODataInvokeRequest.java      | 24 ++++++++++++--------
 1 file changed, 14 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/cf360e65/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
index 5cf9308..361741b 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
@@ -204,16 +204,20 @@ public abstract class AbstractODataInvokeRequest<T extends ODataInvokeResult>
         try {
           if (ODataNoContent.class.isAssignableFrom(reference)) {
             invokeResult = reference.cast(new ODataNoContent());
-          } else if (CommonODataEntitySet.class.isAssignableFrom(reference)) {
-            invokeResult = reference.cast(odataClient.getReader().readEntitySet(res.getEntity().getContent(),
-                    ODataPubFormat.fromString(getContentType())));
-          } else if (CommonODataEntity.class.isAssignableFrom(reference)) {
-            invokeResult = reference.cast(odataClient.getReader().readEntity(res.getEntity().getContent(),
-                    ODataPubFormat.fromString(getContentType())));
-          } else if (CommonODataProperty.class.isAssignableFrom(reference)) {
-            invokeResult = reference.cast(odataClient.getReader().readProperty(res.getEntity().getContent(),
-                    ODataFormat.fromString(getContentType())));
-          }
+          } else {
+             // avoid getContent() twice:IllegalStateException: Content has been consumed
+             InputStream responseStream = this.payload == null ? res.getEntity().getContent() : this.payload;
+             if (CommonODataEntitySet.class.isAssignableFrom(reference)) {
+	        invokeResult = reference.cast(odataClient.getReader().readEntitySet(responseStream,
+	            ODataPubFormat.fromString(getContentType())));
+	      } else if (CommonODataEntity.class.isAssignableFrom(reference)) {
+	        invokeResult = reference.cast(odataClient.getReader().readEntity(responseStream,
+	            ODataPubFormat.fromString(getContentType())));
+	      } else if (CommonODataProperty.class.isAssignableFrom(reference)) {
+	        invokeResult = reference.cast(odataClient.getReader().readProperty(responseStream,
+	            ODataFormat.fromString(getContentType())));
+	      }
+           }
         } catch (IOException e) {
           throw new HttpClientException(e);
         } finally {


[2/3] git commit: [OLINGO-318]client should base64encode edm.binary data, not as URLSafeString

Posted by ch...@apache.org.
[OLINGO-318]client should base64encode edm.binary data, not as URLSafeString


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

Branch: refs/heads/master
Commit: 5959dfb02a80d067c2141e26ea26028e74cab1f0
Parents: 80c2f83
Author: challenh <ch...@microsoft.com>
Authored: Fri Jun 6 23:40:06 2014 +0800
Committer: challenh <ch...@microsoft.com>
Committed: Fri Jun 6 23:40:06 2014 +0800

----------------------------------------------------------------------
 .../olingo/commons/core/edm/primitivetype/EdmBinary.java     | 7 ++++++-
 .../olingo/commons/core/edm/primitivetype/EdmBinaryTest.java | 8 ++++----
 2 files changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5959dfb0/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmBinary.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmBinary.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmBinary.java
index ee85d17..f7cf9af 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmBinary.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmBinary.java
@@ -19,6 +19,7 @@
 package org.apache.olingo.commons.core.edm.primitivetype;
 
 import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.codec.binary.StringUtils;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 
 /**
@@ -124,6 +125,10 @@ public class EdmBinary extends SingletonPrimitiveType {
               "EdmPrimitiveTypeException.VALUE_FACETS_NOT_MATCHED.addContent(value, facets)");
     }
 
-    return Base64.encodeBase64URLSafeString(byteArrayValue);
+    return base64EncodeToString(byteArrayValue);
+  }
+  
+  private static String base64EncodeToString(byte[] bytes){
+    return StringUtils.newStringUtf8(Base64.encodeBase64(bytes, false));
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5959dfb0/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmBinaryTest.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmBinaryTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmBinaryTest.java
index 95c93f8..f52c32f 100644
--- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmBinaryTest.java
+++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmBinaryTest.java
@@ -66,12 +66,12 @@ public class EdmBinaryTest extends PrimitiveTypeBaseTest {
   public void valueToString() throws Exception {
     final byte[] binary = new byte[]{(byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF};
 
-    assertEquals("qrvM3e7_", instance.valueToString(binary, null, null, null, null, null));
+    assertEquals("qrvM3e7/", instance.valueToString(binary, null, null, null, null, null));
 
-    assertEquals("qrvM3e7_", instance.valueToString(binary, null, 6, null, null, null));
-    assertEquals("qrvM3e7_", instance.valueToString(binary, null, Integer.MAX_VALUE, null, null, null));
+    assertEquals("qrvM3e7/", instance.valueToString(binary, null, 6, null, null, null));
+    assertEquals("qrvM3e7/", instance.valueToString(binary, null, Integer.MAX_VALUE, null, null, null));
 
-    assertEquals("qg", instance.valueToString(new Byte[]{new Byte((byte) 170)}, null, null, null, null, null));
+    assertEquals("qg==", instance.valueToString(new Byte[]{new Byte((byte) 170)}, null, null, null, null, null));
 
     expectFacetsErrorInValueToString(instance, binary, null, 3, null, null, null);