You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2015/08/04 14:12:46 UTC

[1/2] olingo-odata2 git commit: [OLINGO-745] Improved checkConditions method

Repository: olingo-odata2
Updated Branches:
  refs/heads/master d6fe9bf6e -> 23ee868b0


[OLINGO-745] Improved checkConditions method


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

Branch: refs/heads/master
Commit: 80b32fb9ddf85f4aceb33815389de4106ab3c849
Parents: d6fe9bf
Author: Michael Bolz <mi...@sap.com>
Authored: Tue Aug 4 13:58:29 2015 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Tue Aug 4 13:58:29 2015 +0200

----------------------------------------------------------------------
 .../olingo/odata2/core/ODataRequestHandler.java | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/80b32fb9/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ODataRequestHandler.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ODataRequestHandler.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ODataRequestHandler.java
index 2f169aa..38b8852 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ODataRequestHandler.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ODataRequestHandler.java
@@ -19,6 +19,7 @@
 package org.apache.olingo.odata2.core;
 
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
@@ -199,8 +200,8 @@ public class ODataRequestHandler {
       try {
         final boolean isValid = ODataServiceVersion.validateDataServiceVersion(requestDataServiceVersion);
         if (!isValid || ODataServiceVersion.isBiggerThan(requestDataServiceVersion, serverDataServiceVersion)) {
-          throw new ODataBadRequestException(ODataBadRequestException.VERSIONERROR.addContent(requestDataServiceVersion
-              .toString()));
+          throw new ODataBadRequestException(ODataBadRequestException.VERSIONERROR
+              .addContent(requestDataServiceVersion));
         }
       } catch (final IllegalArgumentException e) {
         throw new ODataBadRequestException(ODataBadRequestException.PARSEVERSIONERROR
@@ -473,9 +474,10 @@ public class ODataRequestHandler {
   }
 
   private static List<ContentType> getSupportedContentTypes(final EdmProperty property) throws EdmException {
-    return property.getType() == EdmSimpleTypeKind.Binary.getEdmSimpleTypeInstance() ? Arrays.asList(property
-        .getMimeType() == null ? ContentType.WILDCARD : ContentType.create(property.getMimeType())) : Arrays.asList(
-        ContentType.TEXT_PLAIN, ContentType.TEXT_PLAIN_CS_UTF_8);
+    return property.getType() == EdmSimpleTypeKind.Binary.getEdmSimpleTypeInstance()
+        ? Collections.singletonList(property.getMimeType() == null
+          ? ContentType.WILDCARD : ContentType.create(property.getMimeType()))
+          : Arrays.asList(ContentType.TEXT_PLAIN, ContentType.TEXT_PLAIN_CS_UTF_8);
   }
 
   private List<String> getSupportedContentTypes(final UriInfoImpl uriInfo, final ODataHttpMethod method)
@@ -510,13 +512,17 @@ public class ODataRequestHandler {
     if ((method == ODataHttpMethod.PUT || method == ODataHttpMethod.PATCH || method == ODataHttpMethod.MERGE
         || method == ODataHttpMethod.DELETE)
         && ifMatch == null && ifNoneMatch == null && ifModifiedSince == null && ifUnmodifiedSince == null
-        && Arrays.asList(UriType.URI2, UriType.URI6A, UriType.URI3, UriType.URI4, UriType.URI5, UriType.URI17)
-            .contains(uriInfo.getUriType())
+        && checkUriType(uriInfo.getUriType())
         && hasConcurrencyControl(uriInfo.getTargetEntitySet().getEntityType())) {
       throw new ODataPreconditionRequiredException(ODataPreconditionRequiredException.COMMON);
     }
   }
 
+  private static boolean checkUriType(UriType uriType) {
+    return uriType == UriType.URI2 || uriType == UriType.URI6A || uriType == UriType.URI3
+         || uriType == UriType.URI4 || uriType == UriType.URI5 || uriType == UriType.URI17;
+  }
+
   private static boolean hasConcurrencyControl(final EdmEntityType entityType) throws EdmException {
     boolean concurrency = false;
     for (final String propertyName : entityType.getPropertyNames()) {


[2/2] olingo-odata2 git commit: [OLINGO-733] Minor code clean up

Posted by mi...@apache.org.
[OLINGO-733] Minor code clean up


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

Branch: refs/heads/master
Commit: 23ee868b0c811e01f7c09a00a14610aa785d4d32
Parents: 80b32fb
Author: Michael Bolz <mi...@sap.com>
Authored: Tue Aug 4 14:05:38 2015 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Tue Aug 4 14:05:38 2015 +0200

----------------------------------------------------------------------
 .../odata2/core/batch/BatchResponseWriter.java  | 26 --------------------
 1 file changed, 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/23ee868b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchResponseWriter.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchResponseWriter.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchResponseWriter.java
index 7ca0260..0ef6f0e 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchResponseWriter.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchResponseWriter.java
@@ -130,30 +130,4 @@ public class BatchResponseWriter {
       }
     }
   }
-
-//  private String readBody(final InputStream in) throws BatchException {
-//    byte[] tmp = new byte[2048];
-//    int count;
-//    BatchException cachedException = null;
-//    StringBuffer b = new StringBuffer();
-//    try {
-//      count = in.read(tmp);
-//      while (count >= 0) {
-//        b.append(new String(tmp, 0, count, BatchHelper.DEFAULT_ENCODING));
-//        count = in.read(tmp);
-//      }
-//    } catch (IOException e) {
-//      cachedException = new BatchException(ODataMessageException.COMMON, e);
-//      throw cachedException;
-//    } finally {// NOPMD (suppress DoNotThrowExceptionInFinally)
-//      try {
-//        in.close();
-//      } catch (IOException e) {
-//        if (cachedException != null) {
-//          throw cachedException;
-//        }
-//      }
-//    }
-//    return b.toString();
-//  }
 }