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/07/10 15:48:39 UTC

[2/2] git commit: [OLINGO-349] Use commons ODataError

[OLINGO-349] Use commons ODataError

Transformed the ODataError interface to a bean class and used it for
serialization and deserialization.


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

Branch: refs/heads/master
Commit: d1e5d2265463339cfb2a6a7ecec7973b2b995686
Parents: 9403aec
Author: Christian Amend <ch...@apache.org>
Authored: Thu Jul 10 15:42:57 2014 +0200
Committer: Christian Amend <ch...@apache.org>
Committed: Thu Jul 10 15:48:02 2014 +0200

----------------------------------------------------------------------
 .../communication/request/AbstractRequest.java  |   3 +-
 .../olingo/commons/api/domain/ODataError.java   | 101 ++++++++++++++++---
 .../commons/api/domain/ODataErrorDetail.java    |  33 +++++-
 .../commons/core/data/ODataErrorDetailImpl.java |  57 -----------
 .../commons/core/data/ODataErrorImpl.java       |  89 ----------------
 .../core/serialization/AtomDeserializer.java    |   3 +-
 .../JsonODataErrorDeserializer.java             |   8 +-
 .../JsonODataErrorDetailDeserializer.java       |   3 +-
 .../server/api/serializer/ODataError.java       |  88 ----------------
 .../server/api/serializer/ODataSerializer.java  |   5 +-
 .../core/serializer/ODataXmlSerializerImpl.java |   5 +-
 .../serializer/json/ODataErrorSerializer.java   |  31 +++---
 .../serializer/json/ODataJsonSerializer.java    |  38 ++++---
 .../json/ODataErrorSerializerTest.java          |  33 +++---
 .../tecsvc/data/JsonDataProviderTest.java       |   6 +-
 15 files changed, 187 insertions(+), 316 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d1e5d226/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractRequest.java
index 69fa29c..8d75a31 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractRequest.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractRequest.java
@@ -28,7 +28,6 @@ import org.apache.olingo.client.api.http.HttpClientException;
 import org.apache.olingo.commons.api.domain.ODataError;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
-import org.apache.olingo.commons.core.data.ODataErrorImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -40,7 +39,7 @@ public abstract class AbstractRequest {
   protected static final Logger LOG = LoggerFactory.getLogger(AbstractRequest.class);
 
   private ODataError getGenericError(final int code, final String errorMsg) {
-    final ODataErrorImpl error = new ODataErrorImpl();
+    final ODataError error = new ODataError();
     error.setCode(String.valueOf(code));
     error.setMessage(errorMsg);
     return error;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d1e5d226/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataError.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataError.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataError.java
index 856bda7..a910f08 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataError.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataError.java
@@ -24,40 +24,109 @@ import java.util.Map;
 /**
  * OData error.
  */
-public interface ODataError {
+public class ODataError {
+
+  private String code;
+  private String message;
+  private String target;
+  private List<ODataErrorDetail> details;
+  private Map<String, String> innerError;
 
   /**
-   * Gets error code.
-   * 
-   * @return error code.
+   * The value for the code name/value pair is a language-independent string. Its value is a service-defined error code.
+   * This code serves as a sub-status for the HTTP error code specified in the response. MAY be null.
+   * @return the error code as a string
    */
-  String getCode();
+  public String getCode() {
+    return code;
+  }
 
   /**
-   * Gets error message.
-   * 
-   * @return error message.
+   * The value for the code name/value pair is a language-independent string. Its value is a service-defined error code.
+   * This code serves as a sub-status for the HTTP error code specified in the response. MAY be null.
+   * @param code
+   * @return this for method chaining
    */
-  String getMessage();
+  public ODataError setCode(String code) {
+    this.code = code;
+    return this;
+  }
 
   /**
-   * Gets error target.
-   * 
-   * @return error message.
+   * The value for the message name/value pair MUST be a human-readable, language-dependent representation of the error.
+   * MUST not be null
+   * @return the message string
    */
-  String getTarget();
+  public String getMessage() {
+    return message;
+  }
+
+  /**
+   * The value for the message name/value pair MUST be a human-readable, language-dependent representation of the error.
+   * MUST not be null
+   * @param message
+   * @return this for method chaining
+   */
+  public ODataError setMessage(String message) {
+    this.message = message;
+    return this;
+  }
+
+  /**
+   * The value for the target name/value pair is the target of the particular error (for example, the name of the
+   * property in error). MAY be null.
+   * @return the target string
+   */
+  public String getTarget() {
+    return target;
+  }
+
+  /**
+   * The value for the target name/value pair is the target of the particular error (for example, the name of the
+   * property in error). MAY be null.
+   * @param target
+   * @return this for method chaining
+   */
+  public ODataError setTarget(String target) {
+    this.target = target;
+    return this;
+  }
 
   /**
    * Gets error details.
    * 
    * @return ODataErrorDetail list.
    */
-  List<ODataErrorDetail> getDetails();
+  public List<ODataErrorDetail> getDetails() {
+    return details;
+  }
+
+  /**
+   * Sets error details.
+   * 
+   * @return this for method chaining.
+   */
+  public ODataError setDetails(List<ODataErrorDetail> details) {
+    this.details = details;
+    return this;
+  }
 
   /**
    * Gets server defined key-value pairs for debug environment only.
    * 
-   * @return a pair representing server defined object.
+   * @return a pair representing server defined object. MAY be null.
+   */
+  public Map<String, String> getInnerError() {
+    return innerError;
+  }
+
+  /**
+   * Sets server defined key-value pairs for debug environment only.
+   * 
+   * @return this for method chaining.
    */
-  Map<String, String> getInnerError();
+  public ODataError setInnerError(Map<String, String> innerError) {
+    this.innerError = innerError;
+    return this;
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d1e5d226/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataErrorDetail.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataErrorDetail.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataErrorDetail.java
index 90f9ddb..573525d 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataErrorDetail.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataErrorDetail.java
@@ -23,26 +23,51 @@ package org.apache.olingo.commons.api.domain;
  * {"code": "301","target": "$search" ,"message": "$search query option not supported"}
  * ],...}}</tt>.
  */
-public interface ODataErrorDetail {
+public class ODataErrorDetail {
+
+  private String code;
+  private String message;
+  private String target;
 
   /**
    * Gets error code.
    * 
    * @return error code.
    */
-  String getCode();
+  public String getCode() {
+    return code;
+  }
+
+  public ODataErrorDetail setCode(final String code) {
+    this.code = code;
+    return this;
+  }
 
   /**
    * Gets error message.
    * 
    * @return error message.
    */
-  String getMessage();
+  public String getMessage() {
+    return message;
+  }
+
+  public ODataErrorDetail setMessage(final String message) {
+    this.message = message;
+    return this;
+  }
 
   /**
    * Gets error target.
    * 
    * @return error message.
    */
-  String getTarget();
+  public String getTarget() {
+    return target;
+  }
+
+  public ODataErrorDetail setTarget(final String target) {
+    this.target = target;
+    return this;
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d1e5d226/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataErrorDetailImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataErrorDetailImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataErrorDetailImpl.java
deleted file mode 100755
index 3347e07..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataErrorDetailImpl.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.commons.core.data;
-
-import org.apache.olingo.commons.api.domain.ODataErrorDetail;
-
-public class ODataErrorDetailImpl implements ODataErrorDetail {
-
-  private String code;
-
-  private String message;
-
-  private String target;
-
-  @Override
-  public String getCode() {
-    return code;
-  }
-
-  public void setCode(final String code) {
-    this.code = code;
-  }
-
-  @Override
-  public String getMessage() {
-    return message;
-  }
-
-  public void setMessage(final String message) {
-    this.message = message;
-  }
-
-  @Override
-  public String getTarget() {
-    return target;
-  }
-
-  public void setTarget(final String target) {
-    this.target = target;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d1e5d226/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataErrorImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataErrorImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataErrorImpl.java
deleted file mode 100755
index cb5df5d..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataErrorImpl.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * 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.commons.core.data;
-
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.olingo.commons.api.domain.ODataError;
-import org.apache.olingo.commons.api.domain.ODataErrorDetail;
-
-/**
- * Example:
- * <tt>
- * {
- * "error": { "code": "501", "message": "Unsupported functionality", "target": "query", "details": [ { "code": "301",
- * "target": "$search", "message": "$search query option not supported" } ], "innererror": { "trace": [...], "context":
- * {...} } } }
- * </tt>.
- */
-public class ODataErrorImpl implements ODataError {
-
-  private String code;
-
-  private String message;
-
-  private String target;
-
-  private List<ODataErrorDetail> details;
-
-  private Map<String, String> innerError = new LinkedHashMap<String, String>();
-
-  @Override
-  public String getCode() {
-    return code;
-  }
-
-  public void setCode(final String code) {
-    this.code = code;
-  }
-
-  @Override
-  public String getMessage() {
-    return message;
-  }
-
-  public void setMessage(final String message) {
-    this.message = message;
-  }
-
-  @Override
-  public String getTarget() {
-    return target;
-  }
-
-  public void setTarget(final String target) {
-    this.target = target;
-  }
-
-  @Override
-  public List<ODataErrorDetail> getDetails() {
-    return details;
-  }
-
-  public void setDetails(final List<ODataErrorDetail> detail) {
-    details = detail;
-  }
-
-  @Override
-  public Map<String, String> getInnerError() {
-    return innerError;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d1e5d226/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java
index df78213..3f38331 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java
@@ -66,7 +66,6 @@ import org.apache.olingo.commons.core.data.EntityImpl;
 import org.apache.olingo.commons.core.data.EntitySetImpl;
 import org.apache.olingo.commons.core.data.LinkImpl;
 import org.apache.olingo.commons.core.data.LinkedComplexValueImpl;
-import org.apache.olingo.commons.core.data.ODataErrorImpl;
 import org.apache.olingo.commons.core.data.PropertyImpl;
 import org.apache.olingo.commons.core.data.v3.LinkCollectionImpl;
 import org.apache.olingo.commons.core.data.v4.DeltaImpl;
@@ -849,7 +848,7 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
   }
 
   private ODataError error(final XMLEventReader reader, final StartElement start) throws XMLStreamException {
-    final ODataErrorImpl error = new ODataErrorImpl();
+    final ODataError error = new ODataError();
 
     boolean setCode = false;
     boolean codeSet = false;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d1e5d226/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonODataErrorDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonODataErrorDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonODataErrorDeserializer.java
index 7260314..e75fe8a 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonODataErrorDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonODataErrorDeserializer.java
@@ -20,6 +20,7 @@ package org.apache.olingo.commons.core.serialization;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 
@@ -27,7 +28,6 @@ import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.domain.ODataError;
 import org.apache.olingo.commons.api.domain.ODataErrorDetail;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.core.data.ODataErrorImpl;
 
 import com.fasterxml.jackson.core.JsonParser;
 import com.fasterxml.jackson.databind.JsonNode;
@@ -41,7 +41,7 @@ public class JsonODataErrorDeserializer extends JsonDeserializer {
 
   protected ODataError doDeserialize(final JsonParser parser) throws IOException {
 
-    final ODataErrorImpl error = new ODataErrorImpl();
+    final ODataError error = new ODataError();
 
     final ObjectNode tree = parser.getCodec().readTree(parser);
     if (tree.has(jsonError)) {
@@ -73,12 +73,14 @@ public class JsonODataErrorDeserializer extends JsonDeserializer {
         error.setDetails(details);
       }
       if (errorNode.hasNonNull(Constants.ERROR_INNERERROR)) {
+        HashMap<String, String> innerErrorMap = new HashMap<String, String>();
         final JsonNode innerError = errorNode.get(Constants.ERROR_INNERERROR);
         for (final Iterator<String> itor = innerError.fieldNames(); itor.hasNext();) {
           final String keyTmp = itor.next();
           final String val = innerError.get(keyTmp).toString();
-          error.getInnerError().put(keyTmp, val);
+          innerErrorMap.put(keyTmp, val);
         }
+        error.setInnerError(innerErrorMap);
       }
     }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d1e5d226/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonODataErrorDetailDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonODataErrorDetailDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonODataErrorDetailDeserializer.java
index 17821db..f79f154 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonODataErrorDetailDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonODataErrorDetailDeserializer.java
@@ -25,7 +25,6 @@ import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.domain.ODataErrorDetail;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.core.data.ODataErrorDetailImpl;
 
 import com.fasterxml.jackson.core.JsonParser;
 import com.fasterxml.jackson.databind.JsonNode;
@@ -38,7 +37,7 @@ public class JsonODataErrorDetailDeserializer extends JsonDeserializer {
 
   protected ResWrap<ODataErrorDetail> doDeserialize(final JsonParser parser) throws IOException {
 
-    final ODataErrorDetailImpl error = new ODataErrorDetailImpl();
+    final ODataErrorDetail error = new ODataErrorDetail();
     final JsonNode errorNode = parser.getCodec().readTree(parser);
     if (errorNode.has(Constants.ERROR_CODE)) {
       error.setCode(errorNode.get(Constants.ERROR_CODE).textValue());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d1e5d226/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataError.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataError.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataError.java
deleted file mode 100644
index a28a843..0000000
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataError.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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;
-
-//TODO: Where to put this class
-public class ODataError {
-
-  String code;
-  String message;
-  String target;
-
-  /**
-   * The value for the code name/value pair is a language-independent string. Its value is a service-defined error code.
-   * This code serves as a sub-status for the HTTP error code specified in the response. MAY be null.
-   * @return the error code as a string
-   */
-  public String getCode() {
-    return code;
-  }
-
-  /**
-   * The value for the code name/value pair is a language-independent string. Its value is a service-defined error code.
-   * This code serves as a sub-status for the HTTP error code specified in the response. MAY be null.
-   * @param code
-   * @return this for method chaining
-   */
-  public ODataError setCode(String code) {
-    this.code = code;
-    return this;
-  }
-
-  /**
-   * The value for the message name/value pair MUST be a human-readable, language-dependent representation of the error.
-   * MUST not be null
-   * @return the message string
-   */
-  public String getMessage() {
-    return message;
-  }
-
-  /**
-   * The value for the message name/value pair MUST be a human-readable, language-dependent representation of the error.
-   * MUST not be null
-   * @param message
-   * @return this for method chaining
-   */
-  public ODataError setMessage(String message) {
-    this.message = message;
-    return this;
-  }
-
-  /**
-   * The value for the target name/value pair is the target of the particular error (for example, the name of the
-   * property in error). MAY be null.
-   * @return the target string
-   */
-  public String getTarget() {
-    return target;
-  }
-
-  /**
-   * The value for the target name/value pair is the target of the particular error (for example, the name of the
-   * property in error). MAY be null.
-   * @param target
-   * @return this for method chaining
-   */
-  public ODataError setTarget(String target) {
-    this.target = target;
-    return this;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d1e5d226/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 6752096..d1037c5 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
@@ -19,11 +19,11 @@
 package org.apache.olingo.server.api.serializer;
 
 import java.io.InputStream;
-import java.util.List;
 
 import org.apache.olingo.commons.api.data.ContextURL;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.domain.ODataError;
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.EdmEntitySet;
 import org.apache.olingo.commons.api.edm.EdmEntityType;
@@ -43,8 +43,7 @@ public interface ODataSerializer {
   /**
    * Writes an ODataError into an InputStream
    * @param error the main error
-   * @param details a list of details. MAY be null or empty.
    * @return inputStream containing the OData formatted error
    */
-  InputStream error(ODataError error, List<ODataError> details);
+  InputStream error(ODataError error);
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d1e5d226/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 122af0c..2f2afeb 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
@@ -19,7 +19,6 @@
 package org.apache.olingo.server.core.serializer;
 
 import java.io.InputStream;
-import java.util.List;
 
 import javax.xml.stream.XMLOutputFactory;
 import javax.xml.stream.XMLStreamException;
@@ -29,10 +28,10 @@ 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;
+import org.apache.olingo.commons.api.domain.ODataError;
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.EdmEntitySet;
 import org.apache.olingo.commons.api.edm.EdmEntityType;
-import org.apache.olingo.server.api.serializer.ODataError;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
 import org.apache.olingo.server.core.serializer.utils.CircleStreamBuffer;
 import org.apache.olingo.server.core.serializer.xml.MetadataDocumentXmlSerializer;
@@ -89,7 +88,7 @@ public class ODataXmlSerializerImpl implements ODataSerializer {
   }
 
   @Override
-  public InputStream error(ODataError error, List<ODataError> details) {
+  public InputStream error(ODataError error) {
     throw new ODataRuntimeException("error serialization not implemented for XML format");
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d1e5d226/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataErrorSerializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataErrorSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataErrorSerializer.java
index 2325481..6d565ac 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataErrorSerializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataErrorSerializer.java
@@ -19,10 +19,10 @@
 package org.apache.olingo.server.core.serializer.json;
 
 import java.io.IOException;
-import java.util.List;
 
 import org.apache.olingo.commons.api.ODataRuntimeException;
-import org.apache.olingo.server.api.serializer.ODataError;
+import org.apache.olingo.commons.api.domain.ODataError;
+import org.apache.olingo.commons.api.domain.ODataErrorDetail;
 
 import com.fasterxml.jackson.core.JsonGenerationException;
 import com.fasterxml.jackson.core.JsonGenerator;
@@ -35,7 +35,7 @@ public class ODataErrorSerializer {
   private static final String TARGET = "target";
   private static final String DETAILS = "details";
 
-  public void writeErrorDocument(JsonGenerator json, ODataError error, List<ODataError> details) throws IOException {
+  public void writeErrorDocument(JsonGenerator json, ODataError error) throws IOException {
     if (error == null) {
       throw new ODataRuntimeException("ODataError object MUST NOT be null!");
     }
@@ -43,13 +43,13 @@ public class ODataErrorSerializer {
     json.writeFieldName(ERROR);
 
     json.writeStartObject();
-    writeODataError(json, error);
-    
-    if(details != null){
+    writeODataError(json, error.getCode(), error.getMessage(), error.getTarget());
+
+    if (error.getDetails() != null) {
       json.writeArrayFieldStart(DETAILS);
-      for(ODataError detailedError : details){
+      for (ODataErrorDetail detail : error.getDetails()) {
         json.writeStartObject();
-        writeODataError(json, detailedError);
+        writeODataError(json, detail.getCode(), detail.getMessage(), detail.getTarget());
         json.writeEndObject();
       }
       json.writeEndArray();
@@ -59,20 +59,21 @@ public class ODataErrorSerializer {
     json.writeEndObject();
   }
 
-  private void writeODataError(JsonGenerator json, ODataError error) throws IOException, JsonGenerationException {
-    if (error.getCode() == null) {
+  private void writeODataError(JsonGenerator json, String code, String message, String target) throws IOException,
+      JsonGenerationException {
+    if (code == null) {
       json.writeNullField(CODE);
     } else {
-      json.writeStringField(CODE, error.getCode());
+      json.writeStringField(CODE, code);
     }
-    if (error.getMessage() == null) {
+    if (message == null) {
       json.writeNullField(MESSAGE);
     } else {
-      json.writeStringField(MESSAGE, error.getMessage());
+      json.writeStringField(MESSAGE, message);
     }
 
-    if (error.getTarget() != null) {
-      json.writeStringField(TARGET, error.getTarget());
+    if (target != null) {
+      json.writeStringField(TARGET, target);
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d1e5d226/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 62b9287..4870a5c 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
@@ -18,25 +18,37 @@
  */
 package org.apache.olingo.server.core.serializer.json;
 
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStreamWriter;
+import java.util.List;
+
 import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.ODataRuntimeException;
-import org.apache.olingo.commons.api.data.*;
-import org.apache.olingo.commons.api.edm.*;
+import org.apache.olingo.commons.api.data.ContextURL;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.LinkedComplexValue;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.domain.ODataError;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmComplexType;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
+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.core.edm.primitivetype.EdmPrimitiveTypeFactory;
-import org.apache.olingo.server.api.serializer.ODataError;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
 import org.apache.olingo.server.core.serializer.utils.CircleStreamBuffer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStreamWriter;
-import java.util.List;
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
 
 public class ODataJsonSerializer implements ODataSerializer {
 
@@ -265,12 +277,12 @@ public class ODataJsonSerializer implements ODataSerializer {
   }
 
   @Override
-  public InputStream error(ODataError error, List<ODataError> details) {
+  public InputStream error(ODataError error) {
     CircleStreamBuffer buffer = new CircleStreamBuffer();
     try {
       JsonGenerator json = new JsonFactory().createGenerator(buffer.getOutputStream());
       ODataErrorSerializer ser = new ODataErrorSerializer();
-      ser.writeErrorDocument(json, error, details);
+      ser.writeErrorDocument(json, error);
       json.close();
     } catch (final IOException e) {
       throw new ODataRuntimeException(e);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d1e5d226/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataErrorSerializerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataErrorSerializerTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataErrorSerializerTest.java
index 6e383fc..3eb2c32 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataErrorSerializerTest.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataErrorSerializerTest.java
@@ -27,9 +27,10 @@ import java.util.List;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.olingo.commons.api.ODataRuntimeException;
+import org.apache.olingo.commons.api.domain.ODataError;
+import org.apache.olingo.commons.api.domain.ODataErrorDetail;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.server.api.OData;
-import org.apache.olingo.server.api.serializer.ODataError;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
 import org.junit.Before;
 import org.junit.Test;
@@ -51,7 +52,7 @@ public class ODataErrorSerializerTest {
   public void basicODataErrorNoCode() throws Exception {
     ODataError error = new ODataError();
     error.setMessage("ErrorMessage");
-    InputStream stream = ser.error(error, null);
+    InputStream stream = ser.error(error);
     String jsonString = IOUtils.toString(stream);
     assertEquals("{\"error\":{\"code\":null,\"message\":\"ErrorMessage\"}}", jsonString);
   }
@@ -60,7 +61,7 @@ public class ODataErrorSerializerTest {
   public void basicODataErrorWithCode() throws Exception {
     ODataError error = new ODataError();
     error.setCode("Code").setMessage("ErrorMessage");
-    InputStream stream = ser.error(error, null);
+    InputStream stream = ser.error(error);
     String jsonString = IOUtils.toString(stream);
     assertEquals("{\"error\":{\"code\":\"Code\",\"message\":\"ErrorMessage\"}}", jsonString);
   }
@@ -69,21 +70,21 @@ public class ODataErrorSerializerTest {
   public void basicODataErrorWithCodeAndTarget() throws Exception {
     ODataError error = new ODataError();
     error.setCode("Code").setMessage("ErrorMessage").setTarget("Target");
-    InputStream stream = ser.error(error, null);
+    InputStream stream = ser.error(error);
     String jsonString = IOUtils.toString(stream);
     assertEquals("{\"error\":{\"code\":\"Code\",\"message\":\"ErrorMessage\",\"target\":\"Target\"}}", jsonString);
   }
 
   @Test(expected = ODataRuntimeException.class)
   public void nullErrorResultsInException() throws Exception {
-    ser.error(null, null);
+    ser.error(null);
   }
 
   @Test
   public void emptyDetailsList() throws Exception {
     ODataError error = new ODataError();
-    error.setMessage("ErrorMessage");
-    InputStream stream = ser.error(error, new ArrayList<ODataError>());
+    error.setMessage("ErrorMessage").setDetails(new ArrayList<ODataErrorDetail>());
+    InputStream stream = ser.error(error);
     String jsonString = IOUtils.toString(stream);
     assertEquals("{\"error\":{\"code\":null,\"message\":\"ErrorMessage\",\"details\":[]}}", jsonString);
   }
@@ -91,17 +92,17 @@ public class ODataErrorSerializerTest {
   @Test
   public void nothingSetAtODataErrorObject() throws Exception {
     ODataError error = new ODataError();
-    InputStream stream = ser.error(error, null);
+    InputStream stream = ser.error(error);
     String jsonString = IOUtils.toString(stream);
     assertEquals("{\"error\":{\"code\":null,\"message\":null}}", jsonString);
   }
 
   @Test
   public void singleDetailNothingSet() throws Exception {
-    List<ODataError> details = new ArrayList<ODataError>();
-    details.add(new ODataError());
-    ODataError error = new ODataError();
-    InputStream stream = ser.error(error, details);
+    List<ODataErrorDetail> details = new ArrayList<ODataErrorDetail>();
+    details.add(new ODataErrorDetail());
+    ODataError error = new ODataError().setDetails(details);
+    InputStream stream = ser.error(error);
     String jsonString = IOUtils.toString(stream);
     assertEquals("{\"error\":{\"code\":null,\"message\":null,\"details\":[{\"code\":null,\"message\":null}]}}",
         jsonString);
@@ -109,10 +110,10 @@ public class ODataErrorSerializerTest {
 
   @Test
   public void verifiedWithJacksonParser() throws Exception {
-    List<ODataError> details = new ArrayList<ODataError>();
-    details.add(new ODataError().setCode("detailCode").setMessage("detailMessage").setTarget("detailTarget"));
-    ODataError error = new ODataError().setCode("Code").setMessage("Message").setTarget("Target");
-    InputStream stream = ser.error(error, details);
+    List<ODataErrorDetail> details = new ArrayList<ODataErrorDetail>();
+    details.add(new ODataErrorDetail().setCode("detailCode").setMessage("detailMessage").setTarget("detailTarget"));
+    ODataError error = new ODataError().setCode("Code").setMessage("Message").setTarget("Target").setDetails(details);
+    InputStream stream = ser.error(error);
     JsonNode tree = new ObjectMapper().readTree(stream);
     assertNotNull(tree);
     tree = tree.get("error");

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d1e5d226/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/JsonDataProviderTest.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/JsonDataProviderTest.java b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/JsonDataProviderTest.java
index 23536ff..cc8ddce 100644
--- a/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/JsonDataProviderTest.java
+++ b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/JsonDataProviderTest.java
@@ -18,6 +18,9 @@
  */
 package org.apache.olingo.server.tecsvc.data;
 
+import java.io.InputStream;
+import java.util.List;
+
 import org.apache.olingo.commons.api.data.ContextURL;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntitySet;
@@ -39,9 +42,6 @@ import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
 import org.junit.Assert;
 import org.junit.Test;
 
-import java.io.InputStream;
-import java.util.List;
-
 /**
  */
 public class JsonDataProviderTest {