olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject [1/2] olingo-odata2 git commit: [OLINGO-745] Improved checkConditions method
Date Tue, 04 Aug 2015 12:12:46 GMT
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 <michael.bolz@sap.com>
Authored: Tue Aug 4 13:58:29 2015 +0200
Committer: Michael Bolz <michael.bolz@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()) {


Mime
View raw message