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 2014/07/24 10:13:05 UTC

git commit: [OLINGO-317] Translatable ODataSerializerException

Repository: olingo-odata4
Updated Branches:
  refs/heads/master b89182115 -> 327873253


[OLINGO-317] Translatable ODataSerializerException


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

Branch: refs/heads/master
Commit: 327873253c77312de1bf501da667badb0288a705
Parents: b891821
Author: Michael Bolz <mi...@sap.com>
Authored: Thu Jul 24 10:07:34 2014 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Thu Jul 24 10:07:34 2014 +0200

----------------------------------------------------------------------
 .../server/api/ODataTranslatedException.java    | 13 ++--
 .../server/api/processor/DefaultProcessor.java  |  2 +-
 .../server/api/serializer/ODataSerializer.java  |  1 -
 .../serializer/ODataSerializerException.java    | 50 ++++++++++++++
 .../src/main/resources/i18n.properties          | 37 +++++++----
 .../server/core/ODataExceptionHandler.java      |  2 +-
 .../core/serializer/ODataXmlSerializerImpl.java | 31 +++++----
 .../serializer/json/ODataJsonSerializer.java    | 70 +++++++++++---------
 .../olingo/server/tecsvc/data/DataProvider.java | 11 +--
 .../tecsvc/processor/TechnicalProcessor.java    |  2 +-
 .../json/ODataJsonSerializerTest.java           | 22 ++++--
 .../serializer/xml/MetadataDocumentTest.java    |  2 +-
 12 files changed, 165 insertions(+), 78 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/32787325/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataTranslatedException.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataTranslatedException.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataTranslatedException.java
index 9eac1e1..8e1a092 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataTranslatedException.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataTranslatedException.java
@@ -51,15 +51,20 @@ public class ODataTranslatedException extends ODataException {
     this.parameters = parameters;
   }
 
+  public ODataTranslatedException(String developmentMessage, Throwable cause, String messageKey, String... parameters) {
+    super(developmentMessage, cause);
+    this.messageKey = messageKey;
+    this.parameters = parameters;
+  }
+
   @Override
   public String getLocalizedMessage() {
     return getTranslatedMessage(DEFAULT_LOCALE).getMessage();
   }
 
-  public ODataTranslatedException(String developmentMessage, Throwable cause, String messageKey, String... parameters) {
-    super(developmentMessage, cause);
-    this.messageKey = messageKey;
-    this.parameters = parameters;
+  @Override
+  public String toString() {
+    return getMessage();
   }
 
   public String getMessageKey() {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/32787325/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java
index 462a803..ca790b9 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java
@@ -26,12 +26,12 @@ import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.http.HttpHeader;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
-import org.apache.olingo.commons.api.serialization.ODataSerializerException;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
 import org.apache.olingo.server.api.ODataServerError;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
+import org.apache.olingo.server.api.serializer.ODataSerializerException;
 import org.apache.olingo.server.api.uri.UriInfo;
 
 /**

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/32787325/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java
index 4ec5197..073dfd5 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java
@@ -25,7 +25,6 @@ import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntitySet;
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.EdmEntitySet;
-import org.apache.olingo.commons.api.serialization.ODataSerializerException;
 import org.apache.olingo.server.api.ODataServerError;
 
 public interface ODataSerializer {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/32787325/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializerException.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializerException.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializerException.java
new file mode 100644
index 0000000..10f023f
--- /dev/null
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializerException.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.server.api.serializer;
+
+import org.apache.olingo.server.api.ODataTranslatedException;
+
+public class ODataSerializerException extends ODataTranslatedException {
+
+  private static final long serialVersionUID = 5358683245923127425L;
+
+  // MessageKeys
+  public static final String NOT_IMPLEMENTED = "ODataSerializerException.NOT_IMPLEMENTED";
+  public static final String JSON_METADATA = "ODataSerializerException.JSON_METADATA";
+  public static final String IO_EXCEPTION = "ODataSerializerException.IO_EXCEPTION";
+  public static final String NO_CONTEXT_URL = "ODataSerializerException.NO_CONTEXT_URL";
+  /** parameter: property name */
+  public static final String UNSUPPORTED_PROPERTY_TYPE = "ODataSerializerException.UNSUPPORTED_PROPERTY_TYPE";
+  /** parameter: property name */
+  public static final String INCONSISTENT_PROPERTY_TYPE = "ODataSerializerException.INCONSISTENT_PROPERTY_TYPE";
+  /** parameter: property name */
+  public static final String MISSING_PROPERTY = "ODataSerializerException.MISSING_PROPERTY";
+  /** parameters: property name, property value */
+  public static final String WRONG_PROPERTY_VALUE = "ODataSerializerException.WRONG_PROPERTY_VALUE";
+
+  public ODataSerializerException(final String developmentMessage,
+      final String messageKey, final String... parameters) {
+    super(developmentMessage, messageKey, parameters);
+  }
+
+  public ODataSerializerException(final String developmentMessage, final Throwable cause,
+      final String messageKey, final String... parameters) {
+    super(developmentMessage, cause, messageKey, parameters);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/32787325/lib/server-api/src/main/resources/i18n.properties
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/resources/i18n.properties b/lib/server-api/src/main/resources/i18n.properties
index 9b2133c..4759884 100644
--- a/lib/server-api/src/main/resources/i18n.properties
+++ b/lib/server-api/src/main/resources/i18n.properties
@@ -1,24 +1,33 @@
 #-------------------------------------------------------------------------------
 # Licensed to the Apache Software Foundation (ASF) under one
-#        or more contributor license agreements.  See the NOTICE file
-#        distributed with this work for additional information
-#        regarding copyright ownership.  The ASF licenses this file
-#        to you under the Apache License, Version 2.0 (the
-#        "License"); you may not use this file except in compliance
-#        with the License.  You may obtain a copy of the License at
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
 # 
-#          http://www.apache.org/licenses/LICENSE-2.0
+#   http://www.apache.org/licenses/LICENSE-2.0
 # 
-#        Unless required by applicable law or agreed to in writing,
-#        software distributed under the License is distributed on an
-#        "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-#        KIND, either express or implied.  See the License for the
-#        specific language governing permissions and limitations
-#        under the License.
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
 #-------------------------------------------------------------------------------
 # Basic Apache Olingo exception messages
 #
 ODataTranslatedException.AMBIGUOUS_XHTTP_METHOD=x-http-method header '%1$s' and x-http-method-override header '%2$s' are not the same.
 ODataTranslatedException.HTTP_METHOD_NOT_IMPLEMENTED=Invalid http method given: '%1$s'.
 ODataTranslatedException.PROCESSOR_NOT_IMPLEMENTED=No processor for interface '%1$s' registered.
-ODataTranslatedException.ODATA_VERSION_NOT_SUPPORTED=OData version '%1$s' is not supported.
\ No newline at end of file
+ODataTranslatedException.ODATA_VERSION_NOT_SUPPORTED=OData version '%1$s' is not supported.
+
+ODataSerializerException.NOT_IMPLEMENTED=The requested serialization method has not been implemented yet.
+ODataSerializerException.JSON_METADATA=The metadata document cannot be provided in JSON format.
+ODataSerializerException.IO_EXCEPTION=An I/O exception occurred.
+ODataSerializerException.NO_CONTEXT_URL=No context URL has been provided.
+ODataSerializerException.UNSUPPORTED_PROPERTY_TYPE=The type of the property '%1$s' is not yet supported.
+ODataSerializerException.INCONSISTENT_PROPERTY_TYPE=An inconsistency has been detected in the type definition of property '%1$s'.
+ODataSerializerException.MISSING_PROPERTY=The non-nullable property '%1$s' is missing.
+ODataSerializerException.WRONG_PROPERTY_VALUE=The value '%2$s' is not valid for property '%1$s'.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/32787325/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataExceptionHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataExceptionHandler.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataExceptionHandler.java
index 20fffe4..3d32424 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataExceptionHandler.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataExceptionHandler.java
@@ -22,12 +22,12 @@ import java.util.Locale;
 
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
-import org.apache.olingo.commons.api.serialization.ODataSerializerException;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ODataResponse;
 import org.apache.olingo.server.api.ODataServerError;
 import org.apache.olingo.server.api.ODataTranslatedException;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
+import org.apache.olingo.server.api.serializer.ODataSerializerException;
 
 public class ODataExceptionHandler {
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/32787325/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataXmlSerializerImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataXmlSerializerImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataXmlSerializerImpl.java
index 40f96a9..40ceddf 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataXmlSerializerImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataXmlSerializerImpl.java
@@ -24,7 +24,6 @@ import javax.xml.stream.XMLOutputFactory;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 
-import org.apache.olingo.commons.api.ODataRuntimeException;
 import org.apache.olingo.commons.api.data.ContextURL;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntitySet;
@@ -32,6 +31,7 @@ import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.EdmEntitySet;
 import org.apache.olingo.server.api.ODataServerError;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
+import org.apache.olingo.server.api.serializer.ODataSerializerException;
 import org.apache.olingo.server.core.serializer.utils.CircleStreamBuffer;
 import org.apache.olingo.server.core.serializer.xml.MetadataDocumentXmlSerializer;
 import org.slf4j.Logger;
@@ -42,12 +42,13 @@ public class ODataXmlSerializerImpl implements ODataSerializer {
   private static final Logger log = LoggerFactory.getLogger(ODataXmlSerializerImpl.class);
 
   @Override
-  public InputStream serviceDocument(final Edm edm, final String serviceRoot) {
-    throw new ODataRuntimeException("Service Document not implemented for XML format");
+  public InputStream serviceDocument(final Edm edm, final String serviceRoot) throws ODataSerializerException {
+    throw new ODataSerializerException("Service Document not implemented for XML format",
+        ODataSerializerException.NOT_IMPLEMENTED);
   }
 
   @Override
-  public InputStream metadataDocument(final Edm edm) {
+  public InputStream metadataDocument(final Edm edm) throws ODataSerializerException {
     CircleStreamBuffer buffer;
     XMLStreamWriter xmlStreamWriter = null;
 
@@ -61,34 +62,38 @@ public class ODataXmlSerializerImpl implements ODataSerializer {
       xmlStreamWriter.close();
 
       return buffer.getInputStream();
-    } catch (Exception e) {
+    } catch (final XMLStreamException e) {
       log.error(e.getMessage(), e);
-      throw new ODataRuntimeException(e);
+      throw new ODataSerializerException("An I/O exception occurred.", e, ODataSerializerException.IO_EXCEPTION);
     } finally {
       if (xmlStreamWriter != null) {
         try {
           xmlStreamWriter.close();
         } catch (XMLStreamException e) {
-          throw new ODataRuntimeException(e);
+          throw new ODataSerializerException("An I/O exception occurred.", e, ODataSerializerException.IO_EXCEPTION);
         }
       }
     }
   }
 
   @Override
-  public InputStream entity(final EdmEntitySet edmEntitySet, final Entity entity, final ContextURL contextURL) {
-    throw new ODataRuntimeException("Entity serialization not implemented for XML format");
+  public InputStream entity(final EdmEntitySet edmEntitySet, final Entity entity, final ContextURL contextURL)
+      throws ODataSerializerException {
+    throw new ODataSerializerException("Entity serialization not implemented for XML format",
+        ODataSerializerException.NOT_IMPLEMENTED);
   }
 
   @Override
   public InputStream entitySet(final EdmEntitySet edmEntitySet, final EntitySet entitySet,
-      final ContextURL contextURL) {
-    throw new ODataRuntimeException("Entityset serialization not implemented for XML format");
+      final ContextURL contextURL) throws ODataSerializerException {
+    throw new ODataSerializerException("Entityset serialization not implemented for XML format",
+        ODataSerializerException.NOT_IMPLEMENTED);
   }
 
   @Override
-  public InputStream error(ODataServerError error) {
-    throw new ODataRuntimeException("error serialization not implemented for XML format");
+  public InputStream error(ODataServerError error) throws ODataSerializerException {
+    throw new ODataSerializerException("error serialization not implemented for XML format",
+        ODataSerializerException.NOT_IMPLEMENTED);
   }
 
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/32787325/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
index d8128a8..05471f1 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
@@ -37,10 +37,10 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.EdmProperty;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.serialization.ODataSerializerException;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
 import org.apache.olingo.server.api.ODataServerError;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
+import org.apache.olingo.server.api.serializer.ODataSerializerException;
 import org.apache.olingo.server.core.serializer.utils.CircleStreamBuffer;
 import org.apache.olingo.server.core.serializer.utils.ContextURLBuilder;
 import org.slf4j.Logger;
@@ -81,15 +81,15 @@ public class ODataJsonSerializer implements ODataSerializer {
 
       return buffer.getInputStream();
 
-    } catch (Exception e) {
+    } catch (final IOException e) {
       log.error(e.getMessage(), e);
-      throw new ODataSerializerException(e);
+      throw new ODataSerializerException("An I/O exception occurred.", e, ODataSerializerException.IO_EXCEPTION);
     } finally {
       if (gen != null) {
         try {
           gen.close();
         } catch (IOException e) {
-          throw new ODataSerializerException(e);
+          throw new ODataSerializerException("An I/O exception occurred.", e, ODataSerializerException.IO_EXCEPTION);
         }
       }
     }
@@ -97,7 +97,8 @@ public class ODataJsonSerializer implements ODataSerializer {
 
   @Override
   public InputStream metadataDocument(final Edm edm) throws ODataSerializerException {
-    throw new ODataSerializerException("Metadata in JSON format not supported!");
+    throw new ODataSerializerException("Metadata in JSON format not supported!",
+        ODataSerializerException.JSON_METADATA);
   }
 
   @Override
@@ -108,7 +109,7 @@ public class ODataJsonSerializer implements ODataSerializer {
       new ODataErrorSerializer().writeErrorDocument(json, error);
       json.close();
     } catch (final IOException e) {
-      throw new ODataSerializerException(e);
+      throw new ODataSerializerException("An I/O exception occurred.", e, ODataSerializerException.IO_EXCEPTION);
     }
     return buffer.getInputStream();
   }
@@ -122,7 +123,7 @@ public class ODataJsonSerializer implements ODataSerializer {
       json.writeStartObject();
       if (format != ODataFormat.JSON_NO_METADATA) {
         if (contextURL == null) {
-          throw new ODataSerializerException("ContextURL null!");
+          throw new ODataSerializerException("ContextURL null!", ODataSerializerException.NO_CONTEXT_URL);
         } else {
           json.writeStringField(Constants.JSON_CONTEXT, ContextURLBuilder.create(contextURL).toASCIIString());
         }
@@ -141,9 +142,7 @@ public class ODataJsonSerializer implements ODataSerializer {
       }
       json.close();
     } catch (final IOException e) {
-      throw new ODataSerializerException(e);
-    } catch (final EdmPrimitiveTypeException e) {
-      throw new ODataSerializerException(e);
+      throw new ODataSerializerException("An I/O exception occurred.", e, ODataSerializerException.IO_EXCEPTION);
     }
     return buffer.getInputStream();
   }
@@ -152,7 +151,7 @@ public class ODataJsonSerializer implements ODataSerializer {
   public InputStream entity(final EdmEntitySet edmEntitySet, final Entity entity, final ContextURL contextURL)
       throws ODataSerializerException {
     if (format != ODataFormat.JSON_NO_METADATA && contextURL == null) {
-      throw new ODataSerializerException("ContextURL null!");
+      throw new ODataSerializerException("ContextURL null!", ODataSerializerException.NO_CONTEXT_URL);
     }
     CircleStreamBuffer buffer = new CircleStreamBuffer();
     try {
@@ -160,15 +159,13 @@ public class ODataJsonSerializer implements ODataSerializer {
       writeEntity(edmEntitySet, entity, contextURL, json);
       json.close();
     } catch (final IOException e) {
-      throw new ODataSerializerException(e);
-    } catch (final EdmPrimitiveTypeException e) {
-      throw new ODataSerializerException(e);
+      throw new ODataSerializerException("An I/O exception occurred.", e, ODataSerializerException.IO_EXCEPTION);
     }
     return buffer.getInputStream();
   }
 
   protected void writeEntity(final EdmEntitySet entitySet, final Entity entity, final ContextURL contextURL,
-      final JsonGenerator json) throws IOException, EdmPrimitiveTypeException, ODataSerializerException {
+      final JsonGenerator json) throws IOException, ODataSerializerException {
     final EdmEntityType entityType = entitySet.getEntityType();
     json.writeStartObject();
     if (format != ODataFormat.JSON_NO_METADATA) {
@@ -196,25 +193,32 @@ public class ODataJsonSerializer implements ODataSerializer {
   }
 
   protected void writeProperty(final EdmProperty edmProperty, final Property property, final JsonGenerator json)
-      throws IOException, EdmPrimitiveTypeException, ODataSerializerException {
+      throws IOException, ODataSerializerException {
     json.writeFieldName(edmProperty.getName());
     if (property == null || property.isNull()) {
       if (edmProperty.isNullable() == Boolean.FALSE) {
-        throw new ODataSerializerException("Non-nullable property not present!");
+        throw new ODataSerializerException("Non-nullable property not present!",
+            ODataSerializerException.MISSING_PROPERTY, edmProperty.getName());
       } else {
         json.writeNull();
       }
     } else {
-      if (edmProperty.isCollection()) {
-        writeCollection(edmProperty, property, json);
-      } else if (edmProperty.isPrimitive()) {
-        writePrimitive(edmProperty, property, json);
-      } else if (property.isLinkedComplex()) {
-        writeComplexValue(edmProperty, property.asLinkedComplex().getValue(), json);
-      } else if (property.isComplex()) {
-        writeComplexValue(edmProperty, property.asComplex(), json);
-      } else {
-        throw new ODataSerializerException("Property type not yet supported!");
+      try {
+        if (edmProperty.isCollection()) {
+          writeCollection(edmProperty, property, json);
+        } else if (edmProperty.isPrimitive()) {
+          writePrimitive(edmProperty, property, json);
+        } else if (property.isLinkedComplex()) {
+          writeComplexValue(edmProperty, property.asLinkedComplex().getValue(), json);
+        } else if (property.isComplex()) {
+          writeComplexValue(edmProperty, property.asComplex(), json);
+        } else {
+          throw new ODataSerializerException("Property type not yet supported!",
+              ODataSerializerException.UNSUPPORTED_PROPERTY_TYPE, edmProperty.getName());
+        }
+      } catch (final EdmPrimitiveTypeException e) {
+        throw new ODataSerializerException("Wrong value for property!", e,
+            ODataSerializerException.WRONG_PROPERTY_VALUE, edmProperty.getName(), property.getValue().toString());
       }
     }
   }
@@ -228,7 +232,8 @@ public class ODataJsonSerializer implements ODataSerializer {
         writePrimitiveValue(edmProperty, value, json);
         break;
       case COLLECTION_GEOSPATIAL:
-        throw new ODataSerializerException("Property type not yet supported!");
+        throw new ODataSerializerException("Property type not yet supported!",
+            ODataSerializerException.UNSUPPORTED_PROPERTY_TYPE, edmProperty.getName());
       case COLLECTION_ENUM:
         json.writeString(value.toString());
         break;
@@ -239,7 +244,8 @@ public class ODataJsonSerializer implements ODataSerializer {
         writeComplexValue(edmProperty, property.asComplex(), json);
         break;
       default:
-        throw new ODataSerializerException("Property type not yet supported!");
+        throw new ODataSerializerException("Property type not yet supported!",
+            ODataSerializerException.UNSUPPORTED_PROPERTY_TYPE, edmProperty.getName());
       }
     }
     json.writeEndArray();
@@ -250,11 +256,13 @@ public class ODataJsonSerializer implements ODataSerializer {
     if (property.isPrimitive()) {
       writePrimitiveValue(edmProperty, property.asPrimitive(), json);
     } else if (property.isGeospatial()) {
-      throw new ODataSerializerException("Property type not yet supported!");
+      throw new ODataSerializerException("Property type not yet supported!",
+          ODataSerializerException.UNSUPPORTED_PROPERTY_TYPE, edmProperty.getName());
     } else if (property.isEnum()) {
       writePrimitiveValue(edmProperty, property.asEnum(), json);
     } else {
-      throw new ODataSerializerException("Inconsistent property type!");
+      throw new ODataSerializerException("Inconsistent property type!",
+          ODataSerializerException.INCONSISTENT_PROPERTY_TYPE, edmProperty.getName());
     }
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/32787325/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
index 71bdf7a..3c31fc2 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
@@ -28,6 +28,7 @@ import java.util.Map;
 import java.util.TimeZone;
 import java.util.UUID;
 
+import org.apache.olingo.commons.api.ODataException;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntitySet;
 import org.apache.olingo.commons.api.data.LinkedComplexValue;
@@ -99,7 +100,7 @@ public class DataProvider {
     }
   }
 
-  public static class DataProviderException extends Exception {
+  public static class DataProviderException extends ODataException {
     private static final long serialVersionUID = 5098059649321796156L;
 
     public DataProviderException(String message, Throwable throwable) {
@@ -286,7 +287,7 @@ public class DataProvider {
     Entity entity = new EntityImpl();
     entity.addProperty(createPrimitive("PropertyInt16", 1));
     entity.addProperty(createCollection("CollPropertyString",
-        "spiderman@comic.com", "spidermaus@comic.com", "spidergirl@comic.com"));
+        "Employee1@company.example", "Employee2@company.example", "Employee3@company.example"));
     entity.addProperty(createCollection("CollPropertyBoolean", true, false, true));
     entity.addProperty(createCollection("CollPropertyByte", 50, 200, 249));
     entity.addProperty(createCollection("CollPropertySByte", -120, 120, 126));
@@ -333,7 +334,7 @@ public class DataProvider {
     Entity entity = new EntityImpl();
     entity.addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE));
     entity.addProperty(createCollection("CollPropertyString",
-        "spiderman@comic.com", "spidermaus@comic.com", "spidergirl@comic.com"));
+        "Employee1@company.example", "Employee2@company.example", "Employee3@company.example"));
     LinkedComplexValue complexValue = new LinkedComplexValueImpl();
     complexValue.getValue().add(createPrimitive("PropertyInt16", 111));
     complexValue.getValue().add(createPrimitive("PropertyString", "TEST A"));
@@ -358,7 +359,7 @@ public class DataProvider {
     entity = new EntityImpl();
     entity.addProperty(createPrimitive("PropertyInt16", 7));
     entity.addProperty(createCollection("CollPropertyString",
-        "spiderman@comic.com", "spidermaus@comic.com", "spidergirl@comic.com"));
+        "Employee1@company.example", "Employee2@company.example", "Employee3@company.example"));
     complexValue = new LinkedComplexValueImpl();
     complexValue.getValue().add(createPrimitive("PropertyInt16", 222));
     complexValue.getValue().add(createPrimitive("PropertyString", "TEST B"));
@@ -370,7 +371,7 @@ public class DataProvider {
     entity = new EntityImpl();
     entity.addProperty(createPrimitive("PropertyInt16", 0));
     entity.addProperty(createCollection("CollPropertyString",
-        "spiderman@comic.com", "spidermaus@comic.com", "spidergirl@comic.com"));
+        "Employee1@company.example", "Employee2@company.example", "Employee3@company.example"));
     complexValue = new LinkedComplexValueImpl();
     complexValue.getValue().add(createPrimitive("PropertyInt16", 333));
     complexValue.getValue().add(createPrimitive("PropertyString", "TEST C"));

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/32787325/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java
index 03434d9..1ec8cec 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java
@@ -27,13 +27,13 @@ import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.http.HttpHeader;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
-import org.apache.olingo.commons.api.serialization.ODataSerializerException;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
 import org.apache.olingo.server.api.processor.CollectionProcessor;
 import org.apache.olingo.server.api.processor.EntityProcessor;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
+import org.apache.olingo.server.api.serializer.ODataSerializerException;
 import org.apache.olingo.server.api.uri.UriInfo;
 import org.apache.olingo.server.api.uri.UriInfoResource;
 import org.apache.olingo.server.api.uri.UriResource;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/32787325/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
index 6ddb14d..b9ac7d9 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
@@ -33,9 +33,9 @@ import org.apache.olingo.commons.api.edm.EdmEntityContainer;
 import org.apache.olingo.commons.api.edm.EdmEntitySet;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.serialization.ODataSerializerException;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
+import org.apache.olingo.server.api.serializer.ODataSerializerException;
 import org.apache.olingo.server.tecsvc.data.DataProvider;
 import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
 import org.junit.Assert;
@@ -106,13 +106,21 @@ public class ODataJsonSerializerTest {
         ContextURL.Builder.create().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build());
   }
 
-  @Test(expected = ODataSerializerException.class)
+  @Test
   public void entityWrongData() throws Exception {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
     Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
     entity.getProperties().get(0).setValue(ValueType.PRIMITIVE, false);
-    serializer.entity(edmEntitySet, entity,
-        ContextURL.Builder.create().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build());
+    try {
+      serializer.entity(edmEntitySet, entity,
+          ContextURL.Builder.create().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build());
+      Assert.fail("Expected exception not thrown!");
+    } catch (final ODataSerializerException e) {
+      Assert.assertEquals(ODataSerializerException.WRONG_PROPERTY_VALUE, e.getMessageKey());
+      // final String message = e.getLocalizedMessage();
+      // Assert.assertThat(message, CoreMatchers.containsString("PropertyInt16"));
+      // Assert.assertThat(message, CoreMatchers.containsString("false"));
+    }
   }
 
   @Test
@@ -151,7 +159,8 @@ public class ODataJsonSerializerTest {
     final String expectedResult = "{"
         + "\"@odata.context\":\"http://host/service/$metadata#ESCollAllPrim/$entity\","
         + "\"PropertyInt16\":1,"
-        + "\"CollPropertyString\":[\"spiderman@comic.com\",\"spidermaus@comic.com\",\"spidergirl@comic.com\"],"
+        + "\"CollPropertyString\":"
+        + "[\"Employee1@company.example\",\"Employee2@company.example\",\"Employee3@company.example\"],"
         + "\"CollPropertyBoolean\":[true,false,true],"
         + "\"CollPropertyByte\":[50,200,249],"
         + "\"CollPropertySByte\":[-120,120,126],"
@@ -214,7 +223,8 @@ public class ODataJsonSerializerTest {
     final String expectedResult = "{"
         + "\"@odata.context\":\"$metadata#ESMixPrimCollComp/$entity\","
         + "\"PropertyInt16\":32767,"
-        + "\"CollPropertyString\":[\"spiderman@comic.com\",\"spidermaus@comic.com\",\"spidergirl@comic.com\"],"
+        + "\"CollPropertyString\":"
+        + "[\"Employee1@company.example\",\"Employee2@company.example\",\"Employee3@company.example\"],"
         + "\"PropertyComp\":{\"PropertyInt16\":111,\"PropertyString\":\"TEST A\"},"
         + "\"CollPropertyComp\":["
         + "{\"PropertyInt16\":123,\"PropertyString\":\"TEST 1\"},"

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/32787325/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
index 821ff47..609d33e 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
@@ -34,7 +34,6 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.api.edm.Target;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.serialization.ODataSerializerException;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.edm.provider.Action;
 import org.apache.olingo.server.api.edm.provider.ActionImport;
@@ -56,6 +55,7 @@ import org.apache.olingo.server.api.edm.provider.Schema;
 import org.apache.olingo.server.api.edm.provider.Singleton;
 import org.apache.olingo.server.api.edm.provider.TypeDefinition;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
+import org.apache.olingo.server.api.serializer.ODataSerializerException;
 import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
 import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
 import org.junit.Test;