olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chri...@apache.org
Subject [1/2] olingo-odata4 git commit: [OLINGO-603] Action Parameter deserialization based on type kind
Date Wed, 01 Apr 2015 12:53:42 GMT
Repository: olingo-odata4
Updated Branches:
  refs/heads/master 26be7d2e7 -> d067037f4


[OLINGO-603] Action Parameter deserialization based on type kind


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

Branch: refs/heads/master
Commit: ef6ed4e3efea2464faa5c08bdffad6f50bf2cccd
Parents: 26be7d2
Author: Christian Amend <chrisam@apache.org>
Authored: Wed Apr 1 10:18:52 2015 +0200
Committer: Christian Amend <chrisam@apache.org>
Committed: Wed Apr 1 14:29:02 2015 +0200

----------------------------------------------------------------------
 .../commons/api/edm/constants/EdmTypeKind.java  |  2 +-
 .../api/deserializer/DeserializerException.java |  4 +++-
 .../json/ODataJsonDeserializer.java             | 20 ++++++++++++++++----
 .../server-core-exceptions-i18n.properties      |  2 ++
 .../core/edm/provider/EdmTypeImplTest.java      |  4 ++--
 5 files changed, 24 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef6ed4e3/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/constants/EdmTypeKind.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/constants/EdmTypeKind.java
b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/constants/EdmTypeKind.java
index bf24673..b55ec16 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/constants/EdmTypeKind.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/constants/EdmTypeKind.java
@@ -23,6 +23,6 @@ package org.apache.olingo.commons.api.edm.constants;
  */
 public enum EdmTypeKind {
 
-  UNDEFINED, PRIMITIVE, ENUM, DEFINITION, COMPLEX, ENTITY, NAVIGATION, ACTION, FUNCTION,
SYSTEM
+  PRIMITIVE, ENUM, DEFINITION, COMPLEX, ENTITY, NAVIGATION, ACTION, FUNCTION
 
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef6ed4e3/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/DeserializerException.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/DeserializerException.java
b/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/DeserializerException.java
index 8ccb253..1989df1 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/DeserializerException.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/DeserializerException.java
@@ -45,7 +45,9 @@ public class DeserializerException extends ODataTranslatedException {
     /** parameter: navigationPropertyName */NAVIGATION_PROPERTY_NOT_FOUND, 
     /** parameter: annotationName */INVALID_ANNOTATION_TYPE, 
     /** parameter: annotationName */INVALID_NULL_ANNOTATION, 
-    /** parameter: binding link */INVALID_ENTITY_BINDING_LINK;
+    /** parameter: binding link */INVALID_ENTITY_BINDING_LINK, 
+    /** parameter: action parameter name */INVALID_ACTION_PARAMETER_TYPE, 
+    /** parameter: parameterName */ INVALID_NULL_PARAMETER;
 
     @Override
     public String getKey() {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef6ed4e3/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
index 74c73c8..b9fe770 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
@@ -215,13 +215,17 @@ public class ODataJsonDeserializer implements ODataDeserializer {
       ParameterImpl parameter = new ParameterImpl();
       parameter.setName(name);
       JsonNode jsonNode = node.get(name);
-      if (jsonNode == null) {
+      if (jsonNode == null || jsonNode.isNull()) {
         if (!edmParameter.isNullable()) {
-          // TODO: new message key.
           throw new DeserializerException("Non-nullable parameter not present or null",
-              DeserializerException.MessageKeys.INVALID_NULL_PROPERTY, name);
+              DeserializerException.MessageKeys.INVALID_NULL_PARAMETER, name);
         }
-      } else {
+      }
+
+      switch (edmParameter.getType().getKind()) {
+      case PRIMITIVE:
+      case DEFINITION:
+      case ENUM:
         Property consumePropertyNode =
             consumePropertyNode(edmParameter.getName(), edmParameter.getType(), edmParameter.isCollection(),
                 edmParameter.isNullable(), edmParameter.getMaxLength(), edmParameter.getPrecision(),
edmParameter
@@ -231,6 +235,14 @@ public class ODataJsonDeserializer implements ODataDeserializer {
         parameter.setValue(consumePropertyNode.getValueType(), consumePropertyNode.getValue());
         parameters.add(parameter);
         node.remove(name);
+        break;
+      case COMPLEX:
+      case ENTITY:
+        throw new DeserializerException("Entity an complex parameters currently not Implemented",
+            DeserializerException.MessageKeys.NOT_IMPLEMENTED);
+      default:
+        throw new DeserializerException("Invalid type kind " + edmParameter.getType().getKind().toString()
+            + " for action parameter: " + name, DeserializerException.MessageKeys.INVALID_ACTION_PARAMETER_TYPE,
name);
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef6ed4e3/lib/server-core/src/main/resources/server-core-exceptions-i18n.properties
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/resources/server-core-exceptions-i18n.properties b/lib/server-core/src/main/resources/server-core-exceptions-i18n.properties
index 76266ea..71013d2 100644
--- a/lib/server-core/src/main/resources/server-core-exceptions-i18n.properties
+++ b/lib/server-core/src/main/resources/server-core-exceptions-i18n.properties
@@ -115,6 +115,8 @@ DeserializerException.UNKNOWN_PRIMITIVE_TYPE=Unknown primitive type '%1$s'
for p
 DeserializerException.NAVIGATION_PROPERTY_NOT_FOUND=Can`t find navigation property with name:
'%1$s'.
 DeserializerException.INVALID_ANNOTATION_TYPE=The annotation '%1$s' has the wrong JSON type.
 DeserializerException.INVALID_ENTITY_BINDING_LINK=The binding link '%1$s' is malformed.
+DeserializerException.INVALID_ACTION_PARAMETER_TYPE=The action parameter '%1$s' must be either
primitive, complex or an entity or a collection of those types.
+DeserializerException.INVALID_NULL_PARAMETER=The parameter '%1$s' must not be null.
 
 BatchDeserializerException.INVALID_BOUNDARY=Invalid boundary at line '%1$s'.
 BatchDeserializerException.INVALID_CHANGESET_METHOD=Invalid method: a ChangeSet cannot contain
retrieve requests at line '%1$s'.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef6ed4e3/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmTypeImplTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmTypeImplTest.java
b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmTypeImplTest.java
index ddfd15d..b9f6db6 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmTypeImplTest.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmTypeImplTest.java
@@ -37,10 +37,10 @@ public class EdmTypeImplTest {
 
   @Test
   public void getterTest() {
-    EdmType type = new EdmTypeImplTester(new FullQualifiedName("namespace", "name"), EdmTypeKind.UNDEFINED);
+    EdmType type = new EdmTypeImplTester(new FullQualifiedName("namespace", "name"), EdmTypeKind.PRIMITIVE);
     assertEquals("name", type.getName());
     assertEquals("namespace", type.getNamespace());
-    assertEquals(EdmTypeKind.UNDEFINED, type.getKind());
+    assertEquals(EdmTypeKind.PRIMITIVE, type.getKind());
     EdmAnnotatable an = (EdmAnnotatable) type;
     assertNotNull(an.getAnnotations().get(0));
   }


Mime
View raw message