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/06/12 13:01:28 UTC

[1/9] [OLINGO-317] Rename and move of some packages and classes

Repository: olingo-odata4
Updated Branches:
  refs/heads/Olingo-317_DeSerializerRefactoring 634d75b79 -> b15439ffc


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonSerializer.java
new file mode 100755
index 0000000..39b2d65
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonSerializer.java
@@ -0,0 +1,314 @@
+/*
+ * 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.serialization;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.math.NumberUtils;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.Annotatable;
+import org.apache.olingo.commons.api.data.Annotation;
+import org.apache.olingo.commons.api.data.CollectionValue;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.Link;
+import org.apache.olingo.commons.api.data.Linked;
+import org.apache.olingo.commons.api.data.PrimitiveValue;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.data.Valuable;
+import org.apache.olingo.commons.api.data.Value;
+import org.apache.olingo.commons.api.domain.ODataLinkType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.api.serialization.ODataSerializer;
+import org.apache.olingo.commons.api.serialization.ODataSerializerException;
+import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonGenerator;
+
+public class JsonSerializer implements ODataSerializer {
+
+  protected ODataServiceVersion version;
+  protected boolean serverMode;
+
+  private static final EdmPrimitiveTypeKind[] NUMBER_TYPES = {
+    EdmPrimitiveTypeKind.Byte, EdmPrimitiveTypeKind.SByte,
+    EdmPrimitiveTypeKind.Single, EdmPrimitiveTypeKind.Double,
+    EdmPrimitiveTypeKind.Int16, EdmPrimitiveTypeKind.Int32, EdmPrimitiveTypeKind.Int64,
+    EdmPrimitiveTypeKind.Decimal
+  };
+
+  private final JsonGeoValueSerializer geoSerializer = new JsonGeoValueSerializer();
+
+  public JsonSerializer(final ODataServiceVersion version, final boolean serverMode) {
+    this.version = version;
+    this.serverMode = serverMode;
+  }
+
+  @Override
+  public <T> void write(Writer writer, T obj) throws ODataSerializerException {
+    try {
+      JsonGenerator json = new JsonFactory().createGenerator(writer);
+      if (obj instanceof EntitySet) {
+        new JsonEntitySetSerializer(version, serverMode).doSerialize((EntitySet) obj, json);
+      } else if (obj instanceof Entity) {
+        new JsonEntitySerializer(version, serverMode).doSerialize((Entity) obj, json);
+      } else if (obj instanceof Property) {
+        new JsonPropertySerializer(version, serverMode).doSerialize((Property) obj, json);
+      } else if (obj instanceof Link) {
+        link((Link) obj, json);
+      }
+      json.flush();
+    } catch (final IOException e) {
+      throw new ODataSerializerException(e);
+    }
+  }
+
+  @SuppressWarnings("unchecked")
+  @Override
+  public <T> void write(Writer writer, ResWrap<T> container) throws ODataSerializerException {
+    final T obj = container == null ? null : container.getPayload();
+    try {
+      JsonGenerator json = new JsonFactory().createGenerator(writer);
+      if (obj instanceof EntitySet) {
+        new JsonEntitySetSerializer(version, serverMode).doContainerSerialize((ResWrap<EntitySet>) container, json);
+      } else if (obj instanceof Entity) {
+        new JsonEntitySerializer(version, serverMode).doContainerSerialize((ResWrap<Entity>) container, json);
+      } else if (obj instanceof Property) {
+        new JsonPropertySerializer(version, serverMode).doContainerSerialize((ResWrap<Property>) container, json);
+      } else if (obj instanceof Link) {
+        link((Link) obj, json);
+      }
+      json.flush();
+    } catch (final IOException e) {
+      throw new ODataSerializerException(e);
+    }
+  }
+
+  protected void link(final Link link, JsonGenerator jgen) throws IOException {
+    jgen.writeStartObject();
+    jgen.writeStringField(Constants.JSON_URL, link.getHref());
+    jgen.writeEndObject();
+  }
+
+  protected void links(final Linked linked, final JsonGenerator jgen) throws IOException {
+    if (serverMode) {
+      serverLinks(linked, jgen);
+    } else {
+      clientLinks(linked, jgen);
+    }
+  }
+
+  protected void clientLinks(final Linked linked, final JsonGenerator jgen) throws IOException {
+    final Map<String, List<String>> entitySetLinks = new HashMap<String, List<String>>();
+    for (Link link : linked.getNavigationLinks()) {
+      for (Annotation annotation : link.getAnnotations()) {
+        valuable(jgen, annotation, link.getTitle() + "@" + annotation.getTerm());
+      }
+
+      ODataLinkType type = null;
+      try {
+        type = ODataLinkType.fromString(version, link.getRel(), link.getType());
+      } catch (IllegalArgumentException e) {
+        // ignore
+      }
+
+      if (type == ODataLinkType.ENTITY_SET_NAVIGATION) {
+        final List<String> uris;
+        if (entitySetLinks.containsKey(link.getTitle())) {
+          uris = entitySetLinks.get(link.getTitle());
+        } else {
+          uris = new ArrayList<String>();
+          entitySetLinks.put(link.getTitle(), uris);
+        }
+        if (StringUtils.isNotBlank(link.getHref())) {
+          uris.add(link.getHref());
+        }
+      } else {
+        if (StringUtils.isNotBlank(link.getHref())) {
+          jgen.writeStringField(link.getTitle() + Constants.JSON_BIND_LINK_SUFFIX, link.getHref());
+        }
+      }
+
+      if (link.getInlineEntity() != null) {
+        jgen.writeFieldName(link.getTitle());
+        new JsonEntitySerializer(version, serverMode).doSerialize(link.getInlineEntity(), jgen);
+      } else if (link.getInlineEntitySet() != null) {
+        jgen.writeArrayFieldStart(link.getTitle());
+        JsonEntitySerializer entitySerializer = new JsonEntitySerializer(version, serverMode);
+        for (Entity subEntry : link.getInlineEntitySet().getEntities()) {
+          entitySerializer.doSerialize(subEntry, jgen);
+        }
+        jgen.writeEndArray();
+      }
+    }
+    for (Map.Entry<String, List<String>> entitySetLink : entitySetLinks.entrySet()) {
+      if (!entitySetLink.getValue().isEmpty()) {
+        jgen.writeArrayFieldStart(entitySetLink.getKey() + Constants.JSON_BIND_LINK_SUFFIX);
+        for (String uri : entitySetLink.getValue()) {
+          jgen.writeString(uri);
+        }
+        jgen.writeEndArray();
+      }
+    }
+  }
+
+  protected void serverLinks(final Linked linked, final JsonGenerator jgen) throws IOException {
+    if (linked instanceof Entity) {
+      for (Link link : ((Entity) linked).getMediaEditLinks()) {
+        if (StringUtils.isNotBlank(link.getHref())) {
+          jgen.writeStringField(
+                  link.getTitle() + StringUtils.prependIfMissing(
+                          version.getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK), "@"),
+                  link.getHref());
+        }
+      }
+    }
+
+    for (Link link : linked.getAssociationLinks()) {
+      if (StringUtils.isNotBlank(link.getHref())) {
+        jgen.writeStringField(
+                link.getTitle() + version.getJSONMap().get(ODataServiceVersion.JSON_ASSOCIATION_LINK),
+                link.getHref());
+      }
+    }
+
+    for (Link link : linked.getNavigationLinks()) {
+      for (Annotation annotation : link.getAnnotations()) {
+        valuable(jgen, annotation, link.getTitle() + "@" + annotation.getTerm());
+      }
+
+      if (StringUtils.isNotBlank(link.getHref())) {
+        jgen.writeStringField(
+                link.getTitle() + version.getJSONMap().get(ODataServiceVersion.JSON_NAVIGATION_LINK),
+                link.getHref());
+      }
+
+      if (link.getInlineEntity() != null) {
+        jgen.writeFieldName(link.getTitle());
+        new JsonEntitySerializer(version, serverMode).doSerialize(link.getInlineEntity(), jgen);
+      } else if (link.getInlineEntitySet() != null) {
+        jgen.writeArrayFieldStart(link.getTitle());
+        JsonEntitySerializer entitySerializer = new JsonEntitySerializer(version, serverMode);
+        for (Entity subEntry : link.getInlineEntitySet().getEntities()) {
+          entitySerializer.doSerialize(subEntry, jgen);
+        }
+        jgen.writeEndArray();
+      }
+    }
+  }
+
+  private void collection(final JsonGenerator jgen, final String itemType, final CollectionValue value)
+          throws IOException {
+
+    jgen.writeStartArray();
+    for (Value item : value.get()) {
+      value(jgen, itemType, item);
+    }
+    jgen.writeEndArray();
+  }
+
+  protected void primitiveValue(final JsonGenerator jgen, final EdmTypeInfo typeInfo, final PrimitiveValue value)
+          throws IOException {
+
+    final boolean isNumber = typeInfo == null
+            ? NumberUtils.isNumber(value.get())
+            : ArrayUtils.contains(NUMBER_TYPES, typeInfo.getPrimitiveTypeKind());
+    final boolean isBoolean = typeInfo == null
+            ? (value.get().equalsIgnoreCase(Boolean.TRUE.toString())
+            || value.get().equalsIgnoreCase(Boolean.FALSE.toString()))
+            : typeInfo.getPrimitiveTypeKind() == EdmPrimitiveTypeKind.Boolean;
+
+    if (isNumber) {
+      jgen.writeNumber(value.get());
+    } else if (isBoolean) {
+      jgen.writeBoolean(BooleanUtils.toBoolean(value.get()));
+    } else {
+      jgen.writeString(value.get());
+    }
+  }
+
+  private void value(final JsonGenerator jgen, final String type, final Value value) throws IOException {
+    final EdmTypeInfo typeInfo = type == null
+            ? null
+            : new EdmTypeInfo.Builder().setTypeExpression(type).build();
+
+    if (value == null || value.isNull()) {
+      jgen.writeNull();
+    } else if (value.isPrimitive()) {
+      primitiveValue(jgen, typeInfo, value.asPrimitive());
+    } else if (value.isEnum()) {
+      jgen.writeString(value.asEnum().get());
+    } else if (value.isGeospatial()) {
+      jgen.writeStartObject();
+      geoSerializer.serialize(jgen, value.asGeospatial().get());
+      jgen.writeEndObject();
+    } else if (value.isCollection()) {
+      collection(jgen, typeInfo == null ? null : typeInfo.getFullQualifiedName().toString(), value.asCollection());
+    } else if (value.isComplex()) {
+      jgen.writeStartObject();
+
+      if (typeInfo != null) {
+        jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_TYPE), typeInfo.external(version));
+      }
+
+      for (Property property : value.asComplex().get()) {
+        valuable(jgen, property, property.getName());
+      }
+      if (value.isLinkedComplex()) {
+        links(value.asLinkedComplex(), jgen);
+      }
+
+      jgen.writeEndObject();
+    }
+  }
+
+  protected void valuable(final JsonGenerator jgen, final Valuable valuable, final String name) throws IOException {
+    if (!Constants.VALUE.equals(name) && !(valuable instanceof Annotation) && !valuable.getValue().isComplex()) {
+      String type = valuable.getType();
+      if (StringUtils.isBlank(type) && valuable.getValue().isPrimitive() || valuable.getValue().isNull()) {
+        type = EdmPrimitiveTypeKind.String.getFullQualifiedName().toString();
+      }
+      if (StringUtils.isNotBlank(type)) {
+        jgen.writeFieldName(
+                name + StringUtils.prependIfMissing(version.getJSONMap().get(ODataServiceVersion.JSON_TYPE), "@"));
+        jgen.writeString(new EdmTypeInfo.Builder().setTypeExpression(type).build().external(version));
+      }
+    }
+
+    if (valuable instanceof Annotatable) {
+      for (Annotation annotation : ((Annotatable) valuable).getAnnotations()) {
+        valuable(jgen, annotation, name + "@" + annotation.getTerm());
+      }
+    }
+
+    jgen.writeFieldName(name);
+    value(jgen, valuable.getType(), valuable.getValue());
+  }
+}


[7/9] [OLINGO-317] Rename and move of some packages and classes

Posted by mi...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataDeserializerImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataDeserializerImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataDeserializerImpl.java
deleted file mode 100644
index 61e6ac6..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataDeserializerImpl.java
+++ /dev/null
@@ -1,78 +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.client.core.op.impl.v4;
-
-import java.io.InputStream;
-
-import javax.xml.stream.XMLStreamException;
-
-import org.apache.olingo.client.api.data.ServiceDocument;
-import org.apache.olingo.client.api.edm.xml.v4.XMLMetadata;
-import org.apache.olingo.client.api.op.v4.ODataDeserializer;
-import org.apache.olingo.client.core.data.JSONServiceDocumentDeserializer;
-import org.apache.olingo.client.core.data.XMLServiceDocumentDeserializer;
-import org.apache.olingo.client.core.edm.xml.v4.EdmxImpl;
-import org.apache.olingo.client.core.edm.xml.v4.XMLMetadataImpl;
-import org.apache.olingo.commons.api.data.Delta;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.api.format.Format;
-import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
-import org.apache.olingo.commons.core.data.AtomDeserializer;
-import org.apache.olingo.commons.core.data.JSONDeltaDeserializer;
-import org.apache.olingo.commons.core.op.AbstractODataDeserializer;
-
-public class ODataDeserializerImpl extends AbstractODataDeserializer implements ODataDeserializer {
-
-  private final Format format;
-
-  public ODataDeserializerImpl(final ODataServiceVersion version, final boolean serverMode, final Format format) {
-    super(version, serverMode, format);
-    this.format = format;
-  }
-
-  @Override
-  public XMLMetadata toMetadata(final InputStream input) {
-    try {
-      return new XMLMetadataImpl(getXmlMapper().readValue(input, EdmxImpl.class));
-    } catch (Exception e) {
-      throw new IllegalArgumentException("Could not parse as Edmx document", e);
-    }
-  }
-
-  @Override
-  public ResWrap<ServiceDocument> toServiceDocument(final InputStream input) throws ODataDeserializerException {
-    return format == ODataFormat.XML ?
-        new XMLServiceDocumentDeserializer(version, false).toServiceDocument(input) :
-        new JSONServiceDocumentDeserializer(version, false).toServiceDocument(input);
-  }
-
-  @Override
-  public ResWrap<Delta> toDelta(final InputStream input) throws ODataDeserializerException {
-    try {
-      return format == ODataPubFormat.ATOM ?
-          new AtomDeserializer(version).delta(input) :
-          new JSONDeltaDeserializer(version, false).toDelta(input);
-    } catch (XMLStreamException e) {
-      throw new ODataDeserializerException(e);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataReaderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataReaderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataReaderImpl.java
deleted file mode 100644
index ce146e5..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataReaderImpl.java
+++ /dev/null
@@ -1,56 +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.client.core.op.impl.v4;
-
-import java.io.InputStream;
-
-import org.apache.olingo.client.api.op.v4.ODataReader;
-import org.apache.olingo.client.api.v4.ODataClient;
-import org.apache.olingo.client.core.op.AbstractODataReader;
-import org.apache.olingo.commons.api.domain.v4.ODataEntity;
-import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
-import org.apache.olingo.commons.api.domain.v4.ODataProperty;
-import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
-
-public class ODataReaderImpl extends AbstractODataReader implements ODataReader {
-
-  public ODataReaderImpl(final ODataClient client) {
-    super(client);
-  }
-
-  @Override
-  public ODataEntitySet readEntitySet(final InputStream input, final ODataPubFormat format)
-      throws ODataDeserializerException {
-    return ((ODataClient) client).getBinder().getODataEntitySet(client.getDeserializer(format).toEntitySet(input));
-  }
-
-  @Override
-  public ODataEntity readEntity(final InputStream input, final ODataPubFormat format)
-      throws ODataDeserializerException {
-    return ((ODataClient) client).getBinder().getODataEntity(client.getDeserializer(format).toEntity(input));
-  }
-
-  @Override
-  public ODataProperty readProperty(final InputStream input, final ODataFormat format)
-      throws ODataDeserializerException {
-    return ((ODataClient) client).getBinder().getODataProperty(client.getDeserializer(format).toProperty(input));
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AbstractODataBinder.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AbstractODataBinder.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AbstractODataBinder.java
new file mode 100644
index 0000000..620204a
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AbstractODataBinder.java
@@ -0,0 +1,528 @@
+/*
+ * 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.client.core.serialization;
+
+import java.io.StringWriter;
+import java.net.URI;
+import java.util.Iterator;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.client.api.CommonODataClient;
+import org.apache.olingo.client.api.data.ServiceDocument;
+import org.apache.olingo.client.api.data.ServiceDocumentItem;
+import org.apache.olingo.client.api.serialization.CommonODataBinder;
+import org.apache.olingo.client.api.v4.EdmEnabledODataClient;
+import org.apache.olingo.client.core.uri.URIUtils;
+import org.apache.olingo.commons.api.Constants;
+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.Link;
+import org.apache.olingo.commons.api.data.Linked;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.data.Valuable;
+import org.apache.olingo.commons.api.data.Value;
+import org.apache.olingo.commons.api.domain.CommonODataEntity;
+import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
+import org.apache.olingo.commons.api.domain.CommonODataProperty;
+import org.apache.olingo.commons.api.domain.ODataCollectionValue;
+import org.apache.olingo.commons.api.domain.ODataComplexValue;
+import org.apache.olingo.commons.api.domain.ODataInlineEntity;
+import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
+import org.apache.olingo.commons.api.domain.ODataLink;
+import org.apache.olingo.commons.api.domain.ODataLinkType;
+import org.apache.olingo.commons.api.domain.ODataLinked;
+import org.apache.olingo.commons.api.domain.ODataOperation;
+import org.apache.olingo.commons.api.domain.ODataServiceDocument;
+import org.apache.olingo.commons.api.domain.ODataValue;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmBindingTarget;
+import org.apache.olingo.commons.api.edm.EdmElement;
+import org.apache.olingo.commons.api.edm.EdmEntityContainer;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
+import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.EdmProperty;
+import org.apache.olingo.commons.api.edm.EdmSchema;
+import org.apache.olingo.commons.api.edm.EdmStructuredType;
+import org.apache.olingo.commons.api.edm.EdmType;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.geo.Geospatial;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.serialization.ODataSerializerException;
+import org.apache.olingo.commons.core.data.CollectionValueImpl;
+import org.apache.olingo.commons.core.data.ComplexValueImpl;
+import org.apache.olingo.commons.core.data.EntityImpl;
+import org.apache.olingo.commons.core.data.EntitySetImpl;
+import org.apache.olingo.commons.core.data.GeospatialValueImpl;
+import org.apache.olingo.commons.core.data.LinkImpl;
+import org.apache.olingo.commons.core.data.NullValueImpl;
+import org.apache.olingo.commons.core.data.PrimitiveValueImpl;
+import org.apache.olingo.commons.core.data.PropertyImpl;
+import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class AbstractODataBinder implements CommonODataBinder {
+
+  /**
+   * Logger.
+   */
+  protected final Logger LOG = LoggerFactory.getLogger(AbstractODataBinder.class);
+
+  protected final CommonODataClient<?> client;
+
+  protected AbstractODataBinder(final CommonODataClient<?> client) {
+    this.client = client;
+  }
+
+  @Override
+  public ODataServiceDocument getODataServiceDocument(final ServiceDocument resource) {
+    final ODataServiceDocument serviceDocument = new ODataServiceDocument();
+
+    for (ServiceDocumentItem entitySet : resource.getEntitySets()) {
+      serviceDocument.getEntitySets().
+          put(entitySet.getName(), URIUtils.getURI(resource.getBaseURI(), entitySet.getUrl()));
+    }
+
+    return serviceDocument;
+  }
+
+  @Override
+  public EntitySet getEntitySet(final CommonODataEntitySet odataEntitySet) {
+    final EntitySet entitySet = new EntitySetImpl();
+
+    entitySet.setCount(odataEntitySet.getCount());
+
+    final URI next = odataEntitySet.getNext();
+    if (next != null) {
+      entitySet.setNext(next);
+    }
+
+    for (CommonODataEntity entity : odataEntitySet.getEntities()) {
+      entitySet.getEntities().add(getEntity(entity));
+    }
+
+    return entitySet;
+  }
+
+  protected void links(final ODataLinked odataLinked, final Linked linked) {
+    // -------------------------------------------------------------
+    // Append navigation links (handling inline entity / entity set as well)
+    // -------------------------------------------------------------
+    // handle navigation links
+    for (ODataLink link : odataLinked.getNavigationLinks()) {
+      // append link
+      LOG.debug("Append navigation link\n{}", link);
+      linked.getNavigationLinks().add(getLink(link));
+    }
+    // -------------------------------------------------------------
+
+    // -------------------------------------------------------------
+    // Append association links
+    // -------------------------------------------------------------
+    for (ODataLink link : odataLinked.getAssociationLinks()) {
+      LOG.debug("Append association link\n{}", link);
+      linked.getAssociationLinks().add(getLink(link));
+    }
+    // -------------------------------------------------------------
+  }
+
+  @Override
+  public Entity getEntity(final CommonODataEntity odataEntity) {
+    final Entity entity = new EntityImpl();
+
+    entity.setType(odataEntity.getTypeName() == null ? null : odataEntity.getTypeName().toString());
+
+    // -------------------------------------------------------------
+    // Add edit and self link
+    // -------------------------------------------------------------
+    final URI odataEditLink = odataEntity.getEditLink();
+    if (odataEditLink != null) {
+      final LinkImpl editLink = new LinkImpl();
+      editLink.setTitle(entity.getType());
+      editLink.setHref(odataEditLink.toASCIIString());
+      editLink.setRel(Constants.EDIT_LINK_REL);
+      entity.setEditLink(editLink);
+    }
+
+    if (odataEntity.isReadOnly()) {
+      final LinkImpl selfLink = new LinkImpl();
+      selfLink.setTitle(entity.getType());
+      selfLink.setHref(odataEntity.getLink().toASCIIString());
+      selfLink.setRel(Constants.SELF_LINK_REL);
+      entity.setSelfLink(selfLink);
+    }
+    // -------------------------------------------------------------
+
+    links(odataEntity, entity);
+
+    // -------------------------------------------------------------
+    // Append edit-media links
+    // -------------------------------------------------------------
+    for (ODataLink link : odataEntity.getMediaEditLinks()) {
+      LOG.debug("Append edit-media link\n{}", link);
+      entity.getMediaEditLinks().add(getLink(link));
+    }
+    // -------------------------------------------------------------
+
+    if (odataEntity.isMediaEntity()) {
+      entity.setMediaContentSource(odataEntity.getMediaContentSource());
+      entity.setMediaContentType(odataEntity.getMediaContentType());
+      entity.setMediaETag(odataEntity.getMediaETag());
+    }
+
+    for (CommonODataProperty property : odataEntity.getProperties()) {
+      entity.getProperties().add(getProperty(property));
+    }
+
+    return entity;
+  }
+
+  @Override
+  public Link getLink(final ODataLink link) {
+    final Link linkResource = new LinkImpl();
+    linkResource.setRel(link.getRel());
+    linkResource.setTitle(link.getName());
+    linkResource.setHref(link.getLink() == null ? null : link.getLink().toASCIIString());
+    linkResource.setType(link.getType().toString());
+    linkResource.setMediaETag(link.getMediaETag());
+
+    if (link instanceof ODataInlineEntity) {
+      // append inline entity
+      final CommonODataEntity inlineEntity = ((ODataInlineEntity) link).getEntity();
+      LOG.debug("Append in-line entity\n{}", inlineEntity);
+
+      linkResource.setInlineEntity(getEntity(inlineEntity));
+    } else if (link instanceof ODataInlineEntitySet) {
+      // append inline entity set
+      final CommonODataEntitySet InlineEntitySet = ((ODataInlineEntitySet) link).getEntitySet();
+      LOG.debug("Append in-line entity set\n{}", InlineEntitySet);
+
+      linkResource.setInlineEntitySet(getEntitySet(InlineEntitySet));
+    }
+
+    return linkResource;
+  }
+
+  protected Value getValue(final ODataValue value) {
+    Value valueResource = null;
+
+    if (value == null) {
+      valueResource = new NullValueImpl();
+    } else if (value.isPrimitive()) {
+      valueResource = value.asPrimitive().getTypeKind().isGeospatial()
+          ? new GeospatialValueImpl((Geospatial) value.asPrimitive().toValue())
+          : new PrimitiveValueImpl(value.asPrimitive().toString());
+    } else if (value.isComplex()) {
+      final ODataComplexValue<? extends CommonODataProperty> _value = value.asComplex();
+      valueResource = new ComplexValueImpl();
+
+      for (final Iterator<? extends CommonODataProperty> itor = _value.iterator(); itor.hasNext();) {
+        valueResource.asComplex().get().add(getProperty(itor.next()));
+      }
+    } else if (value.isCollection()) {
+      final ODataCollectionValue<? extends ODataValue> _value = value.asCollection();
+      valueResource = new CollectionValueImpl();
+
+      for (final Iterator<? extends ODataValue> itor = _value.iterator(); itor.hasNext();) {
+        valueResource.asCollection().get().add(getValue(itor.next()));
+      }
+    }
+
+    return valueResource;
+  }
+
+  protected abstract boolean add(CommonODataEntitySet entitySet, CommonODataEntity entity);
+
+  @Override
+  public CommonODataEntitySet getODataEntitySet(final ResWrap<EntitySet> resource) {
+    if (LOG.isDebugEnabled()) {
+      final StringWriter writer = new StringWriter();
+      try {
+        client.getSerializer(ODataFormat.JSON).write(writer, resource.getPayload());
+      } catch (final ODataSerializerException e) {}
+      writer.flush();
+      LOG.debug("EntitySet -> ODataEntitySet:\n{}", writer.toString());
+    }
+
+    final URI base = resource.getContextURL() == null
+        ? resource.getPayload().getBaseURI() : resource.getContextURL().getServiceRoot();
+
+    final URI next = resource.getPayload().getNext();
+
+    final CommonODataEntitySet entitySet = next == null
+        ? client.getObjectFactory().newEntitySet()
+        : client.getObjectFactory().newEntitySet(URIUtils.getURI(base, next.toASCIIString()));
+
+    if (resource.getPayload().getCount() != null) {
+      entitySet.setCount(resource.getPayload().getCount());
+    }
+
+    for (Entity entityResource : resource.getPayload().getEntities()) {
+      add(entitySet, getODataEntity(
+          new ResWrap<Entity>(resource.getContextURL(), resource.getMetadataETag(), entityResource)));
+    }
+
+    return entitySet;
+  }
+
+  protected void odataNavigationLinks(final EdmType edmType,
+      final Linked linked, final ODataLinked odataLinked, final String metadataETag, final URI base) {
+
+    for (Link link : linked.getNavigationLinks()) {
+      final Entity inlineEntity = link.getInlineEntity();
+      final EntitySet inlineEntitySet = link.getInlineEntitySet();
+
+      if (inlineEntity == null && inlineEntitySet == null) {
+        ODataLinkType linkType = null;
+        if (edmType instanceof EdmStructuredType) {
+          final EdmNavigationProperty navProp = ((EdmStructuredType) edmType).getNavigationProperty(link.getTitle());
+          if (navProp != null) {
+            linkType = navProp.isCollection()
+                ? ODataLinkType.ENTITY_SET_NAVIGATION
+                : ODataLinkType.ENTITY_NAVIGATION;
+          }
+        }
+        if (linkType == null) {
+          linkType = link.getType() == null
+              ? ODataLinkType.ENTITY_NAVIGATION
+              : ODataLinkType.fromString(client.getServiceVersion(), link.getRel(), link.getType());
+        }
+
+        odataLinked.addLink(linkType == ODataLinkType.ENTITY_NAVIGATION
+            ? client.getObjectFactory().
+                newEntityNavigationLink(link.getTitle(), URIUtils.getURI(base, link.getHref()))
+            : client.getObjectFactory().
+                newEntitySetNavigationLink(link.getTitle(), URIUtils.getURI(base, link.getHref())));
+      } else if (inlineEntity != null) {
+        odataLinked.addLink(new ODataInlineEntity(client.getServiceVersion(),
+            URIUtils.getURI(base, link.getHref()), ODataLinkType.ENTITY_NAVIGATION, link.getTitle(),
+            getODataEntity(new ResWrap<Entity>(
+                inlineEntity.getBaseURI() == null ? base : inlineEntity.getBaseURI(),
+                metadataETag,
+                inlineEntity))));
+      } else {
+        odataLinked.addLink(new ODataInlineEntitySet(client.getServiceVersion(),
+            URIUtils.getURI(base, link.getHref()), ODataLinkType.ENTITY_SET_NAVIGATION, link.getTitle(),
+            getODataEntitySet(new ResWrap<EntitySet>(
+                inlineEntitySet.getBaseURI() == null ? base : inlineEntitySet.getBaseURI(),
+                metadataETag,
+                inlineEntitySet))));
+      }
+    }
+  }
+
+  /**
+   * Infer type name from various sources of information including Edm and context URL, if available.
+   *
+   * @param contextURL context URL
+   * @param metadataETag metadata ETag
+   * @return Edm type information
+   */
+  private EdmType findType(final ContextURL contextURL, final String metadataETag) {
+    EdmType type = null;
+
+    if (client instanceof EdmEnabledODataClient && contextURL != null) {
+      final Edm edm = ((EdmEnabledODataClient) client).getEdm(metadataETag);
+
+      if (contextURL.getDerivedEntity() == null) {
+        for (EdmSchema schema : edm.getSchemas()) {
+          final EdmEntityContainer container = schema.getEntityContainer();
+          if (container != null) {
+            EdmBindingTarget bindingTarget = container.getEntitySet(contextURL.getEntitySetOrSingletonOrType());
+            if (bindingTarget == null) {
+              bindingTarget = container.getSingleton(contextURL.getEntitySetOrSingletonOrType());
+            }
+            if (bindingTarget != null) {
+              if (contextURL.getNavOrPropertyPath() == null) {
+                type = bindingTarget.getEntityType();
+              } else {
+                final EdmNavigationProperty navProp = bindingTarget.getEntityType().
+                    getNavigationProperty(contextURL.getNavOrPropertyPath());
+
+                type = navProp == null
+                    ? bindingTarget.getEntityType()
+                    : navProp.getType();
+              }
+            }
+          }
+        }
+        if (type == null) {
+          type = new EdmTypeInfo.Builder().setEdm(edm).
+              setTypeExpression(contextURL.getEntitySetOrSingletonOrType()).build().getType();
+        }
+      } else {
+        type = edm.getEntityType(new FullQualifiedName(contextURL.getDerivedEntity()));
+      }
+    }
+
+    return type;
+  }
+
+  @Override
+  public CommonODataEntity getODataEntity(final ResWrap<Entity> resource) {
+    if (LOG.isDebugEnabled()) {
+      final StringWriter writer = new StringWriter();
+      try {
+        client.getSerializer(ODataFormat.JSON).write(writer, resource.getPayload());
+      } catch (final ODataSerializerException e) {}
+      writer.flush();
+      LOG.debug("EntityResource -> ODataEntity:\n{}", writer.toString());
+    }
+
+    final URI base = resource.getContextURL() == null
+        ? resource.getPayload().getBaseURI() : resource.getContextURL().getServiceRoot();
+
+    final EdmType edmType = findType(resource.getContextURL(), resource.getMetadataETag());
+    FullQualifiedName typeName = null;
+    if (resource.getPayload().getType() == null) {
+      if (edmType != null) {
+        typeName = edmType.getFullQualifiedName();
+      }
+    } else {
+      typeName = new FullQualifiedName(resource.getPayload().getType());
+    }
+
+    final CommonODataEntity entity = resource.getPayload().getSelfLink() == null
+        ? client.getObjectFactory().newEntity(typeName)
+        : client.getObjectFactory().newEntity(typeName,
+            URIUtils.getURI(base, resource.getPayload().getSelfLink().getHref()));
+
+    if (StringUtils.isNotBlank(resource.getPayload().getETag())) {
+      entity.setETag(resource.getPayload().getETag());
+    }
+
+    if (resource.getPayload().getEditLink() != null) {
+      entity.setEditLink(URIUtils.getURI(base, resource.getPayload().getEditLink().getHref()));
+    }
+
+    for (Link link : resource.getPayload().getAssociationLinks()) {
+      entity.addLink(client.getObjectFactory().
+          newAssociationLink(link.getTitle(), URIUtils.getURI(base, link.getHref())));
+    }
+
+    odataNavigationLinks(edmType, resource.getPayload(), entity, resource.getMetadataETag(), base);
+
+    for (Link link : resource.getPayload().getMediaEditLinks()) {
+      entity.addLink(client.getObjectFactory().
+          newMediaEditLink(link.getTitle(), URIUtils.getURI(base, link.getHref())));
+    }
+
+    for (ODataOperation operation : resource.getPayload().getOperations()) {
+      operation.setTarget(URIUtils.getURI(base, operation.getTarget()));
+      entity.getOperations().add(operation);
+    }
+
+    if (resource.getPayload().isMediaEntity()) {
+      entity.setMediaEntity(true);
+      entity.setMediaContentSource(URIUtils.getURI(base, resource.getPayload().getMediaContentSource()));
+      entity.setMediaContentType(resource.getPayload().getMediaContentType());
+      entity.setMediaETag(resource.getPayload().getMediaETag());
+    }
+
+    for (Property property : resource.getPayload().getProperties()) {
+      EdmType propertyType = null;
+      if (edmType instanceof EdmEntityType) {
+        final EdmElement edmProperty = ((EdmEntityType) edmType).getProperty(property.getName());
+        if (edmProperty != null) {
+          propertyType = edmProperty.getType();
+        }
+      }
+      add(entity, getODataProperty(propertyType, property));
+    }
+
+    return entity;
+  }
+
+  protected EdmTypeInfo buildTypeInfo(final ContextURL contextURL, final String metadataETag,
+      final String propertyName, final String propertyType) {
+
+    FullQualifiedName typeName = null;
+    final EdmType type = findType(contextURL, metadataETag);
+    if (type instanceof EdmStructuredType) {
+      final EdmProperty edmProperty = ((EdmStructuredType) type).getStructuralProperty(propertyName);
+      if (edmProperty != null) {
+        typeName = edmProperty.getType().getFullQualifiedName();
+      }
+    }
+    if (typeName == null && type != null) {
+      typeName = type.getFullQualifiedName();
+    }
+
+    return buildTypeInfo(typeName, propertyType);
+  }
+
+  protected EdmTypeInfo buildTypeInfo(final FullQualifiedName typeName, final String propertyType) {
+    EdmTypeInfo typeInfo = null;
+    if (typeName == null) {
+      if (propertyType != null) {
+        typeInfo = new EdmTypeInfo.Builder().setTypeExpression(propertyType).build();
+      }
+    } else {
+      if (propertyType == null || propertyType.equals(EdmPrimitiveTypeKind.String.getFullQualifiedName().toString())) {
+        typeInfo = new EdmTypeInfo.Builder().setTypeExpression(typeName.toString()).build();
+      } else {
+        typeInfo = new EdmTypeInfo.Builder().setTypeExpression(propertyType).build();
+      }
+    }
+    return typeInfo;
+  }
+
+  protected abstract CommonODataProperty getODataProperty(EdmType type, Property resource);
+
+  protected ODataValue getODataValue(final FullQualifiedName type,
+      final Valuable valuable, final ContextURL contextURL, final String metadataETag) {
+
+    ODataValue value = null;
+    if (valuable.getValue().isGeospatial()) {
+      value = client.getObjectFactory().newPrimitiveValueBuilder().
+          setValue(valuable.getValue().asGeospatial().get()).
+          setType(type == null
+              || EdmPrimitiveTypeKind.Geography.getFullQualifiedName().equals(type)
+              || EdmPrimitiveTypeKind.Geometry.getFullQualifiedName().equals(type)
+              ? valuable.getValue().asGeospatial().get().getEdmPrimitiveTypeKind()
+              : EdmPrimitiveTypeKind.valueOfFQN(client.getServiceVersion(), type.toString())).build();
+    } else if (valuable.getValue().isPrimitive()) {
+      value = client.getObjectFactory().newPrimitiveValueBuilder().
+          setText(valuable.getValue().asPrimitive().get()).
+          setType(type == null || !EdmPrimitiveType.EDM_NAMESPACE.equals(type.getNamespace())
+              ? null
+              : EdmPrimitiveTypeKind.valueOfFQN(client.getServiceVersion(), type.toString())).build();
+    } else if (valuable.getValue().isComplex()) {
+      value = client.getObjectFactory().newComplexValue(type == null ? null : type.toString());
+
+      for (Property property : valuable.getValue().asComplex().get()) {
+        value.asComplex().add(getODataProperty(new ResWrap<Property>(contextURL, metadataETag, property)));
+      }
+    } else if (valuable.getValue().isCollection()) {
+      value = client.getObjectFactory().newCollectionValue(type == null ? null : "Collection(" + type.toString() + ")");
+
+      for (Value _value : valuable.getValue().asCollection().get()) {
+        final Property fake = new PropertyImpl();
+        fake.setValue(_value);
+        value.asCollection().add(getODataValue(type, fake, contextURL, metadataETag));
+      }
+    }
+
+    return value;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AbstractODataDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AbstractODataDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AbstractODataDeserializer.java
new file mode 100644
index 0000000..18850e3
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AbstractODataDeserializer.java
@@ -0,0 +1,101 @@
+/*
+ * 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.client.core.serialization;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.domain.ODataError;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.api.format.Format;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.serialization.ODataDeserializer;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+import org.apache.olingo.commons.core.serialization.AtomDeserializer;
+import org.apache.olingo.commons.core.serialization.JsonDeserializer;
+
+import com.fasterxml.aalto.stax.InputFactoryImpl;
+import com.fasterxml.aalto.stax.OutputFactoryImpl;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.InjectableValues;
+import com.fasterxml.jackson.databind.deser.DeserializationProblemHandler;
+import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule;
+import com.fasterxml.jackson.dataformat.xml.XmlFactory;
+import com.fasterxml.jackson.dataformat.xml.XmlMapper;
+
+public abstract class AbstractODataDeserializer {
+
+  protected final ODataServiceVersion version;
+  protected final ODataDeserializer deserializer;
+
+  public AbstractODataDeserializer(final ODataServiceVersion version, final boolean serverMode, final Format format) {
+    this.version = version;
+    if (format == ODataFormat.XML || format == ODataPubFormat.ATOM) {
+      deserializer = new AtomDeserializer(version);
+    } else {
+      deserializer = new JsonDeserializer(version, serverMode);
+    }
+  }
+
+  public ResWrap<EntitySet> toEntitySet(final InputStream input) throws ODataDeserializerException {
+    return deserializer.toEntitySet(input);
+  }
+
+  public ResWrap<Entity> toEntity(final InputStream input) throws ODataDeserializerException {
+    return deserializer.toEntity(input);
+  }
+
+  public ResWrap<Property> toProperty(final InputStream input) throws ODataDeserializerException {
+    return deserializer.toProperty(input);
+  }
+
+  public ODataError toError(final InputStream input) throws ODataDeserializerException {
+    return deserializer.toError(input);
+  }
+
+  protected XmlMapper getXmlMapper() {
+    final XmlMapper xmlMapper = new XmlMapper(
+        new XmlFactory(new InputFactoryImpl(), new OutputFactoryImpl()), new JacksonXmlModule());
+
+    xmlMapper.setInjectableValues(new InjectableValues.Std().
+        addValue(ODataServiceVersion.class, version).
+        addValue(Boolean.class, Boolean.FALSE));
+
+    xmlMapper.addHandler(new DeserializationProblemHandler() {
+      @Override
+      public boolean handleUnknownProperty(final DeserializationContext ctxt, final JsonParser jp,
+          final com.fasterxml.jackson.databind.JsonDeserializer<?> deserializer,
+          final Object beanOrClass, final String propertyName)
+          throws IOException, JsonProcessingException {
+
+        // skip any unknown property
+        ctxt.getParser().skipChildren();
+        return true;
+      }
+    });
+    return xmlMapper;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AbstractODataReader.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AbstractODataReader.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AbstractODataReader.java
new file mode 100644
index 0000000..94634d4
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AbstractODataReader.java
@@ -0,0 +1,159 @@
+/*
+ * 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.client.core.serialization;
+
+import java.io.InputStream;
+import java.net.URI;
+import java.util.Map;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.olingo.client.api.CommonODataClient;
+import org.apache.olingo.client.api.data.ServiceDocument;
+import org.apache.olingo.commons.api.domain.ODataError;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.domain.CommonODataEntity;
+import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
+import org.apache.olingo.client.api.domain.ODataEntitySetIterator;
+import org.apache.olingo.client.api.edm.xml.Schema;
+import org.apache.olingo.commons.api.domain.CommonODataProperty;
+import org.apache.olingo.commons.api.domain.ODataServiceDocument;
+import org.apache.olingo.commons.api.domain.ODataValue;
+import org.apache.olingo.client.api.edm.xml.XMLMetadata;
+import org.apache.olingo.client.api.serialization.CommonODataReader;
+import org.apache.olingo.client.core.edm.EdmClientImpl;
+import org.apache.olingo.commons.api.data.ResWrap;
+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.format.ODataFormat;
+import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataValueFormat;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class AbstractODataReader implements CommonODataReader {
+
+  /**
+   * Logger.
+   */
+  protected static final Logger LOG = LoggerFactory.getLogger(AbstractODataReader.class);
+
+  protected final CommonODataClient<?> client;
+
+  protected AbstractODataReader(final CommonODataClient<?> client) {
+    this.client = client;
+  }
+
+  @Override
+  public Edm readMetadata(final InputStream input) {
+    return readMetadata(client.getDeserializer(ODataFormat.XML).toMetadata(input).getSchemaByNsOrAlias());
+  }
+
+  @Override
+  public Edm readMetadata(final Map<String, Schema> xmlSchemas) {
+    return new EdmClientImpl(client.getServiceVersion(), xmlSchemas);
+  }
+
+  @Override
+  public ODataServiceDocument readServiceDocument(final InputStream input, final ODataFormat format)
+      throws ODataDeserializerException {
+    return client.getBinder().getODataServiceDocument(
+            client.getDeserializer(format).toServiceDocument(input).getPayload());
+  }
+
+  @Override
+  public ODataError readError(final InputStream inputStream, final ODataFormat format )
+      throws ODataDeserializerException {
+    return client.getDeserializer(format).toError(inputStream);
+  }
+
+  @Override
+  public <T> ResWrap<T> read(final InputStream src, final String format, final Class<T> reference)
+      throws ODataDeserializerException {
+    ResWrap<T> res;
+
+    try {
+      if (ODataEntitySetIterator.class.isAssignableFrom(reference)) {
+        res = new ResWrap<T>(
+                (URI) null,
+                null,
+                reference.cast(new ODataEntitySetIterator<CommonODataEntitySet, CommonODataEntity>(
+                                client, src, ODataPubFormat.fromString(format))));
+      } else if (CommonODataEntitySet.class.isAssignableFrom(reference)) {
+        final ResWrap<EntitySet> resource = client.getDeserializer(ODataPubFormat.fromString(format))
+            .toEntitySet(src);
+        res = new ResWrap<T>(
+                resource.getContextURL(),
+                resource.getMetadataETag(),
+                reference.cast(client.getBinder().getODataEntitySet(resource)));
+      } else if (CommonODataEntity.class.isAssignableFrom(reference)) {
+        final ResWrap<Entity> container = client.getDeserializer(ODataPubFormat.fromString(format)).toEntity(src);
+        res = new ResWrap<T>(
+                container.getContextURL(),
+                container.getMetadataETag(),
+                reference.cast(client.getBinder().getODataEntity(container)));
+      } else if (CommonODataProperty.class.isAssignableFrom(reference)) {
+        final ResWrap<Property> container = client.getDeserializer(ODataFormat.fromString(format)).toProperty(src);
+        res = new ResWrap<T>(
+                container.getContextURL(),
+                container.getMetadataETag(),
+                reference.cast(client.getBinder().getODataProperty(container)));
+      } else if (ODataValue.class.isAssignableFrom(reference)) {
+        res = new ResWrap<T>(
+                (URI) null,
+                null,
+                reference.cast(client.getObjectFactory().newPrimitiveValueBuilder().
+                        setType(ODataValueFormat.fromString(format) == ODataValueFormat.TEXT
+                                ? EdmPrimitiveTypeKind.String : EdmPrimitiveTypeKind.Stream).
+                        setText(IOUtils.toString(src)).
+                        build()));
+      } else if (XMLMetadata.class.isAssignableFrom(reference)) {
+        res = new ResWrap<T>(
+                (URI) null,
+                null,
+                reference.cast(readMetadata(src)));
+      } else if (ODataServiceDocument.class.isAssignableFrom(reference)) {
+        final ResWrap<ServiceDocument> resource =
+                client.getDeserializer(ODataFormat.fromString(format)).toServiceDocument(src);
+        res = new ResWrap<T>(
+                resource.getContextURL(),
+                resource.getMetadataETag(),
+                reference.cast(client.getBinder().getODataServiceDocument(resource.getPayload())));
+      } else if (ODataError.class.isAssignableFrom(reference)) {
+        res = new ResWrap<T>(
+                (URI) null,
+                null,
+                reference.cast(readError(src, ODataFormat.fromString(format))));
+      } else {
+        throw new IllegalArgumentException("Invalid reference type " + reference);
+      }
+    } catch (Exception e) {
+      LOG.warn("Cast error", e);
+      res = null;
+    } finally {
+      if (!ODataEntitySetIterator.class.isAssignableFrom(reference)) {
+        IOUtils.closeQuietly(src);
+      }
+    }
+
+    return res;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataWriterImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataWriterImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataWriterImpl.java
new file mode 100644
index 0000000..da6c4e4
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataWriterImpl.java
@@ -0,0 +1,111 @@
+/*
+ * 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.client.core.serialization;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.util.Collection;
+import java.util.Collections;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.olingo.client.api.CommonODataClient;
+import org.apache.olingo.client.api.serialization.ODataWriter;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.domain.CommonODataEntity;
+import org.apache.olingo.commons.api.domain.CommonODataProperty;
+import org.apache.olingo.commons.api.domain.ODataLink;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.serialization.ODataSerializerException;
+
+public class ODataWriterImpl implements ODataWriter {
+
+  protected final CommonODataClient<?> client;
+
+  public ODataWriterImpl(final CommonODataClient<?> client) {
+    this.client = client;
+  }
+
+  @Override
+  public InputStream writeEntities(final Collection<CommonODataEntity> entities, final ODataPubFormat format)
+      throws ODataSerializerException {
+    ByteArrayOutputStream output = new ByteArrayOutputStream();
+    OutputStreamWriter writer;
+    try {
+      writer = new OutputStreamWriter(output, Constants.UTF8);
+    } catch (final UnsupportedEncodingException e) {
+      writer = null;
+    }
+    try {
+      for (CommonODataEntity entity : entities) {
+        client.getSerializer(format).write(writer, client.getBinder().getEntity(entity));
+      }
+
+      return new ByteArrayInputStream(output.toByteArray());
+    } finally {
+      IOUtils.closeQuietly(output);
+    }
+  }
+
+  @Override
+  public InputStream writeEntity(final CommonODataEntity entity, final ODataPubFormat format)
+      throws ODataSerializerException {
+    return writeEntities(Collections.<CommonODataEntity>singleton(entity), format);
+  }
+
+  @Override
+  public InputStream writeProperty(final CommonODataProperty property, final ODataFormat format)
+      throws ODataSerializerException {
+    final ByteArrayOutputStream output = new ByteArrayOutputStream();
+    OutputStreamWriter writer;
+    try {
+      writer = new OutputStreamWriter(output, Constants.UTF8);
+    } catch (final UnsupportedEncodingException e) {
+      writer = null;
+    }
+    try {
+      client.getSerializer(format).write(writer, client.getBinder().getProperty(property));
+
+      return new ByteArrayInputStream(output.toByteArray());
+    } finally {
+      IOUtils.closeQuietly(output);
+    }
+  }
+
+  @Override
+  public InputStream writeLink(final ODataLink link, final ODataFormat format) throws ODataSerializerException {
+    final ByteArrayOutputStream output = new ByteArrayOutputStream();
+    OutputStreamWriter writer;
+    try {
+      writer = new OutputStreamWriter(output, Constants.UTF8);
+    } catch (final UnsupportedEncodingException e) {
+      writer = null;
+    }
+    try {
+      client.getSerializer(format).write(writer, client.getBinder().getLink(link));
+
+      return new ByteArrayInputStream(output.toByteArray());
+    } finally {
+      IOUtils.closeQuietly(output);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v3/ODataBinderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v3/ODataBinderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v3/ODataBinderImpl.java
new file mode 100644
index 0000000..77ea315
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v3/ODataBinderImpl.java
@@ -0,0 +1,117 @@
+/*
+ * 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.client.core.serialization.v3;
+
+import org.apache.olingo.client.api.domain.v3.ODataLinkCollection;
+import org.apache.olingo.client.api.serialization.v3.ODataBinder;
+import org.apache.olingo.client.core.serialization.AbstractODataBinder;
+import org.apache.olingo.client.core.v3.ODataClientImpl;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.data.v3.LinkCollection;
+import org.apache.olingo.commons.api.domain.CommonODataEntity;
+import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
+import org.apache.olingo.commons.api.domain.CommonODataProperty;
+import org.apache.olingo.commons.api.domain.ODataComplexValue;
+import org.apache.olingo.commons.api.domain.v3.ODataEntity;
+import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
+import org.apache.olingo.commons.api.domain.v3.ODataProperty;
+import org.apache.olingo.commons.api.edm.EdmType;
+import org.apache.olingo.commons.core.data.PropertyImpl;
+import org.apache.olingo.commons.core.domain.v3.ODataPropertyImpl;
+import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+
+public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder {
+
+  public ODataBinderImpl(final ODataClientImpl client) {
+    super(client);
+  }
+
+  @Override
+  public void add(final ODataComplexValue<CommonODataProperty> complex, final CommonODataProperty property) {
+    complex.add(property);
+  }
+
+  @Override
+  public boolean add(final CommonODataEntity entity, final CommonODataProperty property) {
+    return ((ODataEntity) entity).getProperties().add((ODataProperty) property);
+  }
+
+  @Override
+  protected boolean add(final CommonODataEntitySet entitySet, final CommonODataEntity entity) {
+    return ((ODataEntitySet) entitySet).getEntities().add((ODataEntity) entity);
+  }
+
+  @Override
+  public Property getProperty(final CommonODataProperty property) {
+    final Property propertyResource = new PropertyImpl();
+    propertyResource.setName(property.getName());
+    propertyResource.setValue(getValue(property.getValue()));
+
+    if (property.hasPrimitiveValue()) {
+      propertyResource.setType(property.getPrimitiveValue().getTypeName());
+    } else if (property.hasComplexValue()) {
+      propertyResource.setType(((ODataProperty) property).getComplexValue().getTypeName());
+    } else if (property.hasCollectionValue()) {
+      propertyResource.setType(((ODataProperty) property).getCollectionValue().getTypeName());
+    }
+
+    return propertyResource;
+  }
+
+  @Override
+  public ODataEntitySet getODataEntitySet(final ResWrap<EntitySet> resource) {
+    return (ODataEntitySet) super.getODataEntitySet(resource);
+  }
+
+  @Override
+  public ODataEntity getODataEntity(final ResWrap<Entity> resource) {
+    return (ODataEntity) super.getODataEntity(resource);
+  }
+
+  @Override
+  public ODataProperty getODataProperty(final ResWrap<Property> property) {
+    final EdmTypeInfo typeInfo = buildTypeInfo(property.getContextURL(), property.getMetadataETag(),
+            property.getPayload().getName(), property.getPayload().getType());
+
+    return new ODataPropertyImpl(property.getPayload().getName(),
+            getODataValue(typeInfo == null ? null : typeInfo.getFullQualifiedName(),
+                    property.getPayload(), property.getContextURL(), property.getMetadataETag()));
+  }
+
+  @Override
+  protected ODataProperty getODataProperty(final EdmType type, final Property resource) {
+    final EdmTypeInfo typeInfo = buildTypeInfo(type == null ? null : type.getFullQualifiedName(), resource.getType());
+
+    return new ODataPropertyImpl(resource.getName(),
+            getODataValue(typeInfo == null
+                    ? null
+                    : typeInfo.getFullQualifiedName(),
+                    resource, null, null));
+  }
+
+  @Override
+  public ODataLinkCollection getLinkCollection(final LinkCollection linkCollection) {
+    final ODataLinkCollection collection = new ODataLinkCollection(linkCollection.getNext());
+    collection.setLinks(linkCollection.getLinks());
+    return collection;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v3/ODataDeserializerImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v3/ODataDeserializerImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v3/ODataDeserializerImpl.java
new file mode 100644
index 0000000..b99d170
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v3/ODataDeserializerImpl.java
@@ -0,0 +1,77 @@
+/*
+ * 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.client.core.serialization.v3;
+
+import java.io.InputStream;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.olingo.client.api.data.ServiceDocument;
+import org.apache.olingo.client.api.edm.xml.XMLMetadata;
+import org.apache.olingo.client.api.serialization.v3.ODataDeserializer;
+import org.apache.olingo.client.core.data.JSONServiceDocumentDeserializer;
+import org.apache.olingo.client.core.data.XMLServiceDocumentDeserializer;
+import org.apache.olingo.client.core.edm.xml.v3.EdmxImpl;
+import org.apache.olingo.client.core.edm.xml.v3.XMLMetadataImpl;
+import org.apache.olingo.client.core.serialization.AbstractODataDeserializer;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.data.v3.LinkCollection;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.api.format.Format;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+import org.apache.olingo.commons.core.serialization.AtomDeserializer;
+import org.apache.olingo.commons.core.serialization.JsonLinkCollectionDeserializer;
+
+public class ODataDeserializerImpl extends AbstractODataDeserializer implements ODataDeserializer {
+
+  private final Format format;
+
+  public ODataDeserializerImpl(final ODataServiceVersion version, final boolean serverMode, final Format format) {
+    super(version, serverMode, format);
+    this.format = format;
+  }
+
+  @Override
+  public XMLMetadata toMetadata(final InputStream input) {
+    try {
+      return new XMLMetadataImpl(getXmlMapper().readValue(input, EdmxImpl.class));
+    } catch (Exception e) {
+      throw new IllegalArgumentException("Could not parse as Edmx document", e);
+    }
+  }
+
+  @Override
+  public ResWrap<ServiceDocument> toServiceDocument(final InputStream input) throws ODataDeserializerException {
+    return format == ODataFormat.XML ?
+        new XMLServiceDocumentDeserializer(version, false).toServiceDocument(input) :
+        new JSONServiceDocumentDeserializer(version, false).toServiceDocument(input);
+  }
+
+  @Override
+  public ResWrap<LinkCollection> toLinkCollection(final InputStream input) throws ODataDeserializerException {
+    try {
+      return format == ODataFormat.XML ?
+          new AtomDeserializer(version).linkCollection(input) :
+          new JsonLinkCollectionDeserializer(version, false).toLinkCollection(input);
+    } catch (final XMLStreamException e) {
+      throw new ODataDeserializerException(e);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v3/ODataReaderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v3/ODataReaderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v3/ODataReaderImpl.java
new file mode 100644
index 0000000..2297d4d
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v3/ODataReaderImpl.java
@@ -0,0 +1,83 @@
+/*
+ * 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.client.core.serialization.v3;
+
+import java.io.InputStream;
+
+import org.apache.olingo.client.api.domain.v3.ODataLinkCollection;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.client.api.serialization.v3.ODataReader;
+import org.apache.olingo.client.api.v3.ODataClient;
+import org.apache.olingo.client.core.serialization.AbstractODataReader;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.data.v3.LinkCollection;
+import org.apache.olingo.commons.api.domain.v3.ODataEntity;
+import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
+import org.apache.olingo.commons.api.domain.v3.ODataProperty;
+import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+
+public class ODataReaderImpl extends AbstractODataReader implements ODataReader {
+
+  public ODataReaderImpl(final ODataClient client) {
+    super(client);
+  }
+
+  @Override
+  public ODataEntitySet readEntitySet(final InputStream input, final ODataPubFormat format)
+      throws ODataDeserializerException {
+    return ((ODataClient) client).getBinder().getODataEntitySet(client.getDeserializer(format).toEntitySet(input));
+  }
+
+  @Override
+  public ODataEntity readEntity(final InputStream input, final ODataPubFormat format)
+      throws ODataDeserializerException {
+    return ((ODataClient) client).getBinder().getODataEntity(client.getDeserializer(format).toEntity(input));
+  }
+
+  @Override
+  public ODataProperty readProperty(final InputStream input, final ODataFormat format)
+      throws ODataDeserializerException {
+    return ((ODataClient) client).getBinder().getODataProperty(client.getDeserializer(format).toProperty(input));
+  }
+
+  @Override
+  public ODataLinkCollection readLinks(final InputStream input, final ODataFormat format)
+      throws ODataDeserializerException {
+    return ((ODataClient) client).getBinder().getLinkCollection(
+            ((ODataClient) client).getDeserializer(format).toLinkCollection(input).getPayload());
+  }
+
+  @Override
+  @SuppressWarnings("unchecked")
+  public <T> ResWrap<T> read(final InputStream src, final String format, final Class<T> reference)
+      throws ODataDeserializerException {
+    if (ODataLinkCollection.class.isAssignableFrom(reference)) {
+      final ResWrap<LinkCollection> container =
+              ((ODataClient) client).getDeserializer(ODataFormat.fromString(format)).toLinkCollection(src);
+
+      return new ResWrap<T>(
+              container.getContextURL(),
+              container.getMetadataETag(),
+              (T) ((ODataClient) client).getBinder().getLinkCollection(container.getPayload()));
+    } else {
+      return super.read(src, format, reference);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataBinderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataBinderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataBinderImpl.java
new file mode 100644
index 0000000..2362a9a
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataBinderImpl.java
@@ -0,0 +1,405 @@
+/*
+ * 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.client.core.serialization.v4;
+
+import java.net.URI;
+
+import org.apache.olingo.client.api.data.ServiceDocument;
+import org.apache.olingo.client.api.data.ServiceDocumentItem;
+import org.apache.olingo.client.api.serialization.v4.ODataBinder;
+import org.apache.olingo.client.api.v4.EdmEnabledODataClient;
+import org.apache.olingo.client.api.v4.ODataClient;
+import org.apache.olingo.client.core.serialization.AbstractODataBinder;
+import org.apache.olingo.client.core.uri.URIUtils;
+import org.apache.olingo.commons.api.data.Annotatable;
+import org.apache.olingo.commons.api.data.Annotation;
+import org.apache.olingo.commons.api.data.ContextURL;
+import org.apache.olingo.commons.api.data.DeletedEntity;
+import org.apache.olingo.commons.api.data.Delta;
+import org.apache.olingo.commons.api.data.DeltaLink;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.Link;
+import org.apache.olingo.commons.api.data.Linked;
+import org.apache.olingo.commons.api.data.LinkedComplexValue;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.data.Valuable;
+import org.apache.olingo.commons.api.data.Value;
+import org.apache.olingo.commons.api.domain.CommonODataEntity;
+import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
+import org.apache.olingo.commons.api.domain.CommonODataProperty;
+import org.apache.olingo.commons.api.domain.ODataComplexValue;
+import org.apache.olingo.commons.api.domain.ODataInlineEntity;
+import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
+import org.apache.olingo.commons.api.domain.ODataLinked;
+import org.apache.olingo.commons.api.domain.ODataServiceDocument;
+import org.apache.olingo.commons.api.domain.ODataValue;
+import org.apache.olingo.commons.api.domain.v4.ODataAnnotatable;
+import org.apache.olingo.commons.api.domain.v4.ODataAnnotation;
+import org.apache.olingo.commons.api.domain.v4.ODataDeletedEntity.Reason;
+import org.apache.olingo.commons.api.domain.v4.ODataDelta;
+import org.apache.olingo.commons.api.domain.v4.ODataDeltaLink;
+import org.apache.olingo.commons.api.domain.v4.ODataEntity;
+import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
+import org.apache.olingo.commons.api.domain.v4.ODataLink;
+import org.apache.olingo.commons.api.domain.v4.ODataLinkedComplexValue;
+import org.apache.olingo.commons.api.domain.v4.ODataProperty;
+import org.apache.olingo.commons.api.domain.v4.ODataValuable;
+import org.apache.olingo.commons.api.edm.EdmComplexType;
+import org.apache.olingo.commons.api.edm.EdmEnumType;
+import org.apache.olingo.commons.api.edm.EdmTerm;
+import org.apache.olingo.commons.api.edm.EdmType;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.core.data.AnnotationImpl;
+import org.apache.olingo.commons.core.data.EnumValueImpl;
+import org.apache.olingo.commons.core.data.LinkedComplexValueImpl;
+import org.apache.olingo.commons.core.data.PropertyImpl;
+import org.apache.olingo.commons.core.domain.v4.ODataAnnotationImpl;
+import org.apache.olingo.commons.core.domain.v4.ODataDeletedEntityImpl;
+import org.apache.olingo.commons.core.domain.v4.ODataDeltaLinkImpl;
+import org.apache.olingo.commons.core.domain.v4.ODataPropertyImpl;
+import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+
+public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder {
+
+  public ODataBinderImpl(final ODataClient client) {
+    super(client);
+  }
+
+  @Override
+  public void add(final ODataComplexValue<CommonODataProperty> complex, final CommonODataProperty property) {
+    complex.add(property);
+  }
+
+  @Override
+  public boolean add(final CommonODataEntity entity, final CommonODataProperty property) {
+    return ((ODataEntity) entity).getProperties().add((ODataProperty) property);
+  }
+
+  @Override
+  protected boolean add(final CommonODataEntitySet entitySet, final CommonODataEntity entity) {
+    return ((ODataEntitySet) entitySet).getEntities().add((ODataEntity) entity);
+  }
+
+  @Override
+  public ODataServiceDocument getODataServiceDocument(final ServiceDocument resource) {
+    final ODataServiceDocument serviceDocument = super.getODataServiceDocument(resource);
+
+    for (ServiceDocumentItem functionImport : resource.getFunctionImports()) {
+      serviceDocument.getFunctionImports().put(
+              functionImport.getName() == null ? functionImport.getUrl() : functionImport.getName(),
+              URIUtils.getURI(resource.getBaseURI(), functionImport.getUrl()));
+    }
+    for (ServiceDocumentItem singleton : resource.getSingletons()) {
+      serviceDocument.getSingletons().put(
+              singleton.getName() == null ? singleton.getUrl() : singleton.getName(),
+              URIUtils.getURI(resource.getBaseURI(), singleton.getUrl()));
+    }
+    for (ServiceDocumentItem sdoc : resource.getRelatedServiceDocuments()) {
+      serviceDocument.getRelatedServiceDocuments().put(
+              sdoc.getName() == null ? sdoc.getUrl() : sdoc.getName(),
+              URIUtils.getURI(resource.getBaseURI(), sdoc.getUrl()));
+    }
+
+    return serviceDocument;
+  }
+
+  private void updateValuable(final Valuable propertyResource, final ODataValuable odataValuable) {
+
+    propertyResource.setValue(getValue(odataValuable.getValue()));
+
+    if (odataValuable.hasPrimitiveValue()) {
+      propertyResource.setType(odataValuable.getPrimitiveValue().getTypeName());
+    } else if (odataValuable.hasEnumValue()) {
+      propertyResource.setType(odataValuable.getEnumValue().getTypeName());
+    } else if (odataValuable.hasComplexValue()) {
+      propertyResource.setType(odataValuable.getComplexValue().getTypeName());
+    } else if (odataValuable.hasCollectionValue()) {
+      propertyResource.setType(odataValuable.getCollectionValue().getTypeName());
+    }
+  }
+
+  private void annotations(final ODataAnnotatable odataAnnotatable, final Annotatable annotatable) {
+
+    for (ODataAnnotation odataAnnotation : odataAnnotatable.getAnnotations()) {
+      final Annotation annotation = new AnnotationImpl();
+
+      annotation.setTerm(odataAnnotation.getTerm());
+      annotation.setType(odataAnnotation.getValue().getTypeName());
+      updateValuable(annotation, odataAnnotation);
+
+      annotatable.getAnnotations().add(annotation);
+    }
+  }
+
+  @Override
+  public EntitySet getEntitySet(final CommonODataEntitySet odataEntitySet) {
+    final EntitySet entitySet = super.getEntitySet(odataEntitySet);
+    entitySet.setDeltaLink(((ODataEntitySet) odataEntitySet).getDeltaLink());
+    annotations((ODataEntitySet) odataEntitySet, entitySet);
+    return entitySet;
+  }
+
+  @Override
+  protected void links(final ODataLinked odataLinked, final Linked linked) {
+    super.links(odataLinked, linked);
+
+    for (Link link : linked.getNavigationLinks()) {
+      final org.apache.olingo.commons.api.domain.ODataLink odataLink = odataLinked.getNavigationLink(link.getTitle());
+      if (!(odataLink instanceof ODataInlineEntity) && !(odataLink instanceof ODataInlineEntitySet)) {
+        annotations((ODataLink) odataLink, link);
+      }
+    }
+  }
+
+  @Override
+  public Entity getEntity(final CommonODataEntity odataEntity) {
+    final Entity entity = super.getEntity(odataEntity);
+    entity.setId(((ODataEntity) odataEntity).getId());
+    annotations((ODataEntity) odataEntity, entity);
+    return entity;
+  }
+
+  @Override
+  public Property getProperty(final CommonODataProperty property) {
+    final ODataProperty _property = (ODataProperty) property;
+
+    final Property propertyResource = new PropertyImpl();
+    propertyResource.setName(_property.getName());
+    updateValuable(propertyResource, _property);
+    annotations(_property, propertyResource);
+
+    return propertyResource;
+  }
+
+  @Override
+  protected Value getValue(final ODataValue value) {
+    Value valueResource;
+    if (value instanceof org.apache.olingo.commons.api.domain.v4.ODataValue
+            && ((org.apache.olingo.commons.api.domain.v4.ODataValue) value).isEnum()) {
+
+      valueResource = new EnumValueImpl(
+              ((org.apache.olingo.commons.api.domain.v4.ODataValue) value).asEnum().getValue());
+    } else {
+      valueResource = super.getValue(value);
+
+      if (value instanceof org.apache.olingo.commons.api.domain.v4.ODataValue
+              && ((org.apache.olingo.commons.api.domain.v4.ODataValue) value).isLinkedComplex()) {
+
+        final LinkedComplexValue lcValueResource = new LinkedComplexValueImpl();
+        lcValueResource.get().addAll(valueResource.asComplex().get());
+
+        final ODataLinkedComplexValue linked =
+                ((org.apache.olingo.commons.api.domain.v4.ODataValue) value).asLinkedComplex();
+        annotations(linked, lcValueResource);
+        links(linked, lcValueResource);
+
+        valueResource = lcValueResource;
+      }
+    }
+    return valueResource;
+  }
+
+  private void odataAnnotations(final Annotatable annotatable, final ODataAnnotatable odataAnnotatable) {
+    for (Annotation annotation : annotatable.getAnnotations()) {
+      FullQualifiedName fqn = null;
+      if (client instanceof EdmEnabledODataClient) {
+        final EdmTerm term = ((EdmEnabledODataClient) client).getEdm(null).
+                getTerm(new FullQualifiedName(annotation.getTerm()));
+        if (term != null) {
+          fqn = term.getType().getFullQualifiedName();
+        }
+      }
+
+      if (fqn == null && annotation.getType() != null) {
+        final EdmTypeInfo typeInfo = new EdmTypeInfo.Builder().setTypeExpression(annotation.getType()).build();
+        if (typeInfo.isPrimitiveType()) {
+          fqn = typeInfo.getPrimitiveTypeKind().getFullQualifiedName();
+        }
+      }
+
+      final ODataAnnotation odataAnnotation = new ODataAnnotationImpl(annotation.getTerm(),
+              (org.apache.olingo.commons.api.domain.v4.ODataValue) getODataValue(fqn, annotation, null, null));
+      odataAnnotatable.getAnnotations().add(odataAnnotation);
+    }
+  }
+
+  @Override
+  public ODataEntitySet getODataEntitySet(final ResWrap<EntitySet> resource) {
+    final ODataEntitySet entitySet = (ODataEntitySet) super.getODataEntitySet(resource);
+
+    if (resource.getPayload().getDeltaLink() != null) {
+      final URI base = resource.getContextURL() == null
+              ? resource.getPayload().getBaseURI() : resource.getContextURL().getServiceRoot();
+      entitySet.setDeltaLink(URIUtils.getURI(base, resource.getPayload().getDeltaLink()));
+    }
+    odataAnnotations(resource.getPayload(), entitySet);
+
+    return entitySet;
+  }
+
+  @Override
+  protected void odataNavigationLinks(final EdmType edmType,
+          final Linked linked, final ODataLinked odataLinked, final String metadataETag, final URI base) {
+
+    super.odataNavigationLinks(edmType, linked, odataLinked, metadataETag, base);
+    for (org.apache.olingo.commons.api.domain.ODataLink link : odataLinked.getNavigationLinks()) {
+      if (!(link instanceof ODataInlineEntity) && !(link instanceof ODataInlineEntitySet)) {
+        odataAnnotations(linked.getNavigationLink(link.getName()), (ODataAnnotatable) link);
+      }
+    }
+  }
+
+  @Override
+  public ODataEntity getODataEntity(final ResWrap<Entity> resource) {
+    final ODataEntity entity = (ODataEntity) super.getODataEntity(resource);
+
+    entity.setId(resource.getPayload().getId());
+    odataAnnotations(resource.getPayload(), entity);
+
+    return entity;
+  }
+
+  @Override
+  public ODataProperty getODataProperty(final ResWrap<Property> resource) {
+    final Property payload = resource.getPayload();
+    final EdmTypeInfo typeInfo = buildTypeInfo(resource.getContextURL(), resource.getMetadataETag(),
+        payload.getName(), payload.getType());
+
+    final ODataProperty property = new ODataPropertyImpl(payload.getName(),
+        getODataValue(typeInfo == null ? null : typeInfo.getFullQualifiedName(),
+            payload, resource.getContextURL(), resource.getMetadataETag()));
+    odataAnnotations(payload, property);
+
+    return property;
+  }
+
+  @Override
+  protected ODataProperty getODataProperty(final EdmType type, final Property resource) {
+    final EdmTypeInfo typeInfo = buildTypeInfo(type == null ? null : type.getFullQualifiedName(), resource.getType());
+
+    final ODataProperty property = new ODataPropertyImpl(resource.getName(),
+            getODataValue(typeInfo == null
+                    ? null
+                    : typeInfo.getFullQualifiedName(),
+                    resource, null, null));
+    odataAnnotations(resource, property);
+
+    return property;
+  }
+
+  @Override
+  protected ODataValue getODataValue(final FullQualifiedName type,
+          final Valuable valuable, final ContextURL contextURL, final String metadataETag) {
+
+    // fixes enum values treated as primitive when no type information is available
+    if (client instanceof EdmEnabledODataClient && type != null) {
+      final EdmEnumType edmType = ((EdmEnabledODataClient) client).getEdm(metadataETag).getEnumType(type);
+      if (valuable.getValue().isPrimitive() && edmType != null) {
+        valuable.setValue(new EnumValueImpl(valuable.getValue().asPrimitive().get()));
+      }
+    }
+
+    ODataValue value;
+    if (valuable.getValue().isEnum()) {
+      value = ((ODataClient) client).getObjectFactory().newEnumValue(type == null ? null : type.toString(),
+              valuable.getValue().asEnum().get());
+    } else if (valuable.getValue().isLinkedComplex()) {
+      final ODataLinkedComplexValue lcValue =
+              ((ODataClient) client).getObjectFactory().newLinkedComplexValue(type == null ? null : type.toString());
+
+      for (Property property : valuable.getValue().asLinkedComplex().get()) {
+        lcValue.add(getODataProperty(new ResWrap<Property>(contextURL, metadataETag, property)));
+      }
+
+      EdmComplexType edmType = null;
+      if (client instanceof EdmEnabledODataClient && type != null) {
+        edmType = ((EdmEnabledODataClient) client).getEdm(metadataETag).getComplexType(type);
+      }
+
+      odataNavigationLinks(edmType, valuable.getValue().asLinkedComplex(), lcValue, metadataETag,
+              contextURL == null ? null : contextURL.getURI());
+      odataAnnotations(valuable.getValue().asLinkedComplex(), lcValue);
+
+      value = lcValue;
+    } else {
+      value = super.getODataValue(type, valuable, contextURL, metadataETag);
+    }
+
+    return value;
+  }
+
+  @Override
+  public ODataDelta getODataDelta(final ResWrap<Delta> resource) {
+    final URI base = resource.getContextURL() == null
+            ? resource.getPayload().getBaseURI() : resource.getContextURL().getServiceRoot();
+
+    final URI next = resource.getPayload().getNext();
+
+    final ODataDelta delta = next == null
+            ? ((ODataClient) client).getObjectFactory().newDelta()
+            : ((ODataClient) client).getObjectFactory().newDelta(URIUtils.getURI(base, next.toASCIIString()));
+
+    if (resource.getPayload().getCount() != null) {
+      delta.setCount(resource.getPayload().getCount());
+    }
+
+    if (resource.getPayload().getDeltaLink() != null) {
+      delta.setDeltaLink(URIUtils.getURI(base, resource.getPayload().getDeltaLink()));
+    }
+
+    for (Entity entityResource : resource.getPayload().getEntities()) {
+      add(delta, getODataEntity(
+              new ResWrap<Entity>(resource.getContextURL(), resource.getMetadataETag(), entityResource)));
+    }
+    for (DeletedEntity deletedEntity : resource.getPayload().getDeletedEntities()) {
+      final ODataDeletedEntityImpl impl = new ODataDeletedEntityImpl();
+      impl.setId(URIUtils.getURI(base, deletedEntity.getId()));
+      impl.setReason(Reason.valueOf(deletedEntity.getReason().name()));
+
+      delta.getDeletedEntities().add(impl);
+    }
+
+    odataAnnotations(resource.getPayload(), delta);
+
+    for (DeltaLink link : resource.getPayload().getAddedLinks()) {
+      final ODataDeltaLink impl = new ODataDeltaLinkImpl();
+      impl.setRelationship(link.getRelationship());
+      impl.setSource(URIUtils.getURI(base, link.getSource()));
+      impl.setTarget(URIUtils.getURI(base, link.getTarget()));
+
+      odataAnnotations(link, impl);
+
+      delta.getAddedLinks().add(impl);
+    }
+    for (DeltaLink link : resource.getPayload().getDeletedLinks()) {
+      final ODataDeltaLink impl = new ODataDeltaLinkImpl();
+      impl.setRelationship(link.getRelationship());
+      impl.setSource(URIUtils.getURI(base, link.getSource()));
+      impl.setTarget(URIUtils.getURI(base, link.getTarget()));
+
+      odataAnnotations(link, impl);
+
+      delta.getDeletedLinks().add(impl);
+    }
+
+    return delta;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataDeserializerImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataDeserializerImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataDeserializerImpl.java
new file mode 100644
index 0000000..f0d4149
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataDeserializerImpl.java
@@ -0,0 +1,78 @@
+/*
+ * 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.client.core.serialization.v4;
+
+import java.io.InputStream;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.olingo.client.api.data.ServiceDocument;
+import org.apache.olingo.client.api.edm.xml.v4.XMLMetadata;
+import org.apache.olingo.client.api.serialization.v4.ODataDeserializer;
+import org.apache.olingo.client.core.data.JSONServiceDocumentDeserializer;
+import org.apache.olingo.client.core.data.XMLServiceDocumentDeserializer;
+import org.apache.olingo.client.core.edm.xml.v4.EdmxImpl;
+import org.apache.olingo.client.core.edm.xml.v4.XMLMetadataImpl;
+import org.apache.olingo.client.core.serialization.AbstractODataDeserializer;
+import org.apache.olingo.commons.api.data.Delta;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.api.format.Format;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+import org.apache.olingo.commons.core.serialization.AtomDeserializer;
+import org.apache.olingo.commons.core.serialization.JsonDeltaDeserializer;
+
+public class ODataDeserializerImpl extends AbstractODataDeserializer implements ODataDeserializer {
+
+  private final Format format;
+
+  public ODataDeserializerImpl(final ODataServiceVersion version, final boolean serverMode, final Format format) {
+    super(version, serverMode, format);
+    this.format = format;
+  }
+
+  @Override
+  public XMLMetadata toMetadata(final InputStream input) {
+    try {
+      return new XMLMetadataImpl(getXmlMapper().readValue(input, EdmxImpl.class));
+    } catch (Exception e) {
+      throw new IllegalArgumentException("Could not parse as Edmx document", e);
+    }
+  }
+
+  @Override
+  public ResWrap<ServiceDocument> toServiceDocument(final InputStream input) throws ODataDeserializerException {
+    return format == ODataFormat.XML ?
+        new XMLServiceDocumentDeserializer(version, false).toServiceDocument(input) :
+        new JSONServiceDocumentDeserializer(version, false).toServiceDocument(input);
+  }
+
+  @Override
+  public ResWrap<Delta> toDelta(final InputStream input) throws ODataDeserializerException {
+    try {
+      return format == ODataPubFormat.ATOM ?
+          new AtomDeserializer(version).delta(input) :
+          new JsonDeltaDeserializer(version, false).toDelta(input);
+    } catch (XMLStreamException e) {
+      throw new ODataDeserializerException(e);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataReaderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataReaderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataReaderImpl.java
new file mode 100644
index 0000000..c6528f8
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataReaderImpl.java
@@ -0,0 +1,56 @@
+/*
+ * 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.client.core.serialization.v4;
+
+import java.io.InputStream;
+
+import org.apache.olingo.client.api.serialization.v4.ODataReader;
+import org.apache.olingo.client.api.v4.ODataClient;
+import org.apache.olingo.client.core.serialization.AbstractODataReader;
+import org.apache.olingo.commons.api.domain.v4.ODataEntity;
+import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
+import org.apache.olingo.commons.api.domain.v4.ODataProperty;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+
+public class ODataReaderImpl extends AbstractODataReader implements ODataReader {
+
+  public ODataReaderImpl(final ODataClient client) {
+    super(client);
+  }
+
+  @Override
+  public ODataEntitySet readEntitySet(final InputStream input, final ODataPubFormat format)
+      throws ODataDeserializerException {
+    return ((ODataClient) client).getBinder().getODataEntitySet(client.getDeserializer(format).toEntitySet(input));
+  }
+
+  @Override
+  public ODataEntity readEntity(final InputStream input, final ODataPubFormat format)
+      throws ODataDeserializerException {
+    return ((ODataClient) client).getBinder().getODataEntity(client.getDeserializer(format).toEntity(input));
+  }
+
+  @Override
+  public ODataProperty readProperty(final InputStream input, final ODataFormat format)
+      throws ODataDeserializerException {
+    return ((ODataClient) client).getBinder().getODataProperty(client.getDeserializer(format).toProperty(input));
+  }
+}


[3/9] [OLINGO-317] Rename and move of some packages and classes

Posted by mi...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/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
new file mode 100644
index 0000000..cce71c8
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java
@@ -0,0 +1,897 @@
+/*
+ * 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.serialization;
+
+import java.io.InputStream;
+import java.net.URI;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Attribute;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.Annotation;
+import org.apache.olingo.commons.api.data.CollectionValue;
+import org.apache.olingo.commons.api.data.DeletedEntity.Reason;
+import org.apache.olingo.commons.api.data.Delta;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.data.Valuable;
+import org.apache.olingo.commons.api.data.Value;
+import org.apache.olingo.commons.api.data.v3.LinkCollection;
+import org.apache.olingo.commons.api.domain.ODataError;
+import org.apache.olingo.commons.api.domain.ODataOperation;
+import org.apache.olingo.commons.api.domain.ODataPropertyType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.commons.api.serialization.ODataDeserializer;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+import org.apache.olingo.commons.core.data.AbstractODataObject;
+import org.apache.olingo.commons.core.data.AnnotationImpl;
+import org.apache.olingo.commons.core.data.CollectionValueImpl;
+import org.apache.olingo.commons.core.data.ComplexValueImpl;
+import org.apache.olingo.commons.core.data.DeletedEntityImpl;
+import org.apache.olingo.commons.core.data.DeltaLinkImpl;
+import org.apache.olingo.commons.core.data.EntityImpl;
+import org.apache.olingo.commons.core.data.EntitySetImpl;
+import org.apache.olingo.commons.core.data.EnumValueImpl;
+import org.apache.olingo.commons.core.data.GeospatialValueImpl;
+import org.apache.olingo.commons.core.data.LinkImpl;
+import org.apache.olingo.commons.core.data.LinkedComplexValueImpl;
+import org.apache.olingo.commons.core.data.NullValueImpl;
+import org.apache.olingo.commons.core.data.ODataErrorImpl;
+import org.apache.olingo.commons.core.data.PrimitiveValueImpl;
+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;
+import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+
+import com.fasterxml.aalto.stax.InputFactoryImpl;
+
+public class AtomDeserializer extends AbstractAtomDealer implements ODataDeserializer {
+
+  protected static final XMLInputFactory FACTORY = new InputFactoryImpl();
+
+  private final AtomGeoValueDeserializer geoDeserializer;
+
+  protected XMLEventReader getReader(final InputStream input) throws XMLStreamException {
+    return FACTORY.createXMLEventReader(input);
+  }
+
+  public AtomDeserializer(final ODataServiceVersion version) {
+    super(version);
+    this.geoDeserializer = new AtomGeoValueDeserializer();
+  }
+
+  private Value fromPrimitive(final XMLEventReader reader, final StartElement start,
+      final EdmTypeInfo typeInfo) throws XMLStreamException {
+
+    Value value = null;
+
+    boolean foundEndProperty = false;
+    while (reader.hasNext() && !foundEndProperty) {
+      final XMLEvent event = reader.nextEvent();
+
+      if (event.isStartElement() && typeInfo != null && typeInfo.getPrimitiveTypeKind().isGeospatial()) {
+        final EdmPrimitiveTypeKind geoType = EdmPrimitiveTypeKind.valueOfFQN(
+            version, typeInfo.getFullQualifiedName().toString());
+        value = new GeospatialValueImpl(this.geoDeserializer.deserialize(reader, event.asStartElement(), geoType));
+      }
+
+      if (event.isCharacters() && !event.asCharacters().isWhiteSpace()
+          && (typeInfo == null || !typeInfo.getPrimitiveTypeKind().isGeospatial())) {
+
+        value = new PrimitiveValueImpl(event.asCharacters().getData());
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndProperty = true;
+      }
+    }
+
+    return value == null ? new PrimitiveValueImpl(StringUtils.EMPTY) : value;
+  }
+
+  private Value fromComplexOrEnum(final XMLEventReader reader, final StartElement start)
+      throws XMLStreamException {
+
+    Value value = null;
+
+    boolean foundEndProperty = false;
+    while (reader.hasNext() && !foundEndProperty) {
+      final XMLEvent event = reader.nextEvent();
+
+      if (event.isStartElement()) {
+        if (value == null) {
+          value = version.compareTo(ODataServiceVersion.V40) < 0
+              ? new ComplexValueImpl()
+              : new LinkedComplexValueImpl();
+        }
+
+        if (Constants.QNAME_ATOM_ELEM_LINK.equals(event.asStartElement().getName())) {
+          final LinkImpl link = new LinkImpl();
+          final Attribute rel = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REL));
+          if (rel != null) {
+            link.setRel(rel.getValue());
+          }
+          final Attribute title = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TITLE));
+          if (title != null) {
+            link.setTitle(title.getValue());
+          }
+          final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
+          if (href != null) {
+            link.setHref(href.getValue());
+          }
+          final Attribute type = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TYPE));
+          if (type != null) {
+            link.setType(type.getValue());
+          }
+
+          if (link.getRel().startsWith(
+              version.getNamespaceMap().get(ODataServiceVersion.NAVIGATION_LINK_REL))) {
+
+            value.asLinkedComplex().getNavigationLinks().add(link);
+            inline(reader, event.asStartElement(), link);
+          } else if (link.getRel().startsWith(
+              version.getNamespaceMap().get(ODataServiceVersion.ASSOCIATION_LINK_REL))) {
+
+            value.asLinkedComplex().getAssociationLinks().add(link);
+          }
+        } else {
+          value.asComplex().get().add(property(reader, event.asStartElement()));
+        }
+      }
+
+      if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
+        value = new EnumValueImpl(event.asCharacters().getData());
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndProperty = true;
+      }
+    }
+
+    return value;
+  }
+
+  private CollectionValue fromCollection(final XMLEventReader reader, final StartElement start,
+      final EdmTypeInfo typeInfo) throws XMLStreamException {
+
+    final CollectionValueImpl value = new CollectionValueImpl();
+
+    final EdmTypeInfo type = typeInfo == null
+        ? null
+        : new EdmTypeInfo.Builder().setTypeExpression(typeInfo.getFullQualifiedName().toString()).build();
+
+    boolean foundEndProperty = false;
+    while (reader.hasNext() && !foundEndProperty) {
+      final XMLEvent event = reader.nextEvent();
+
+      if (event.isStartElement()) {
+        switch (guessPropertyType(reader, typeInfo)) {
+        case COMPLEX:
+        case ENUM:
+          value.get().add(fromComplexOrEnum(reader, event.asStartElement()));
+          break;
+
+        case PRIMITIVE:
+          value.get().add(fromPrimitive(reader, event.asStartElement(), type));
+          break;
+
+        default:
+          // do not add null or empty values
+        }
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndProperty = true;
+      }
+    }
+
+    return value;
+  }
+
+  private ODataPropertyType guessPropertyType(final XMLEventReader reader, final EdmTypeInfo typeInfo)
+      throws XMLStreamException {
+
+    XMLEvent child = null;
+    while (reader.hasNext() && child == null) {
+      final XMLEvent event = reader.peek();
+      if (event.isCharacters() && event.asCharacters().isWhiteSpace()) {
+        reader.nextEvent();
+      } else {
+        child = event;
+      }
+    }
+
+    final ODataPropertyType type;
+    if (child == null) {
+      type = typeInfo == null || typeInfo.isPrimitiveType()
+          ? ODataPropertyType.PRIMITIVE
+          : ODataPropertyType.ENUM;
+    } else {
+      if (child.isStartElement()) {
+        if (Constants.NS_GML.equals(child.asStartElement().getName().getNamespaceURI())) {
+          type = ODataPropertyType.PRIMITIVE;
+        } else if (elementQName.equals(child.asStartElement().getName())) {
+          type = ODataPropertyType.COLLECTION;
+        } else {
+          type = ODataPropertyType.COMPLEX;
+        }
+      } else if (child.isCharacters()) {
+        type = typeInfo == null || typeInfo.isPrimitiveType()
+            ? ODataPropertyType.PRIMITIVE
+            : ODataPropertyType.ENUM;
+      } else {
+        type = ODataPropertyType.EMPTY;
+      }
+    }
+
+    return type;
+  }
+
+  private Property property(final XMLEventReader reader, final StartElement start)
+      throws XMLStreamException {
+
+    final PropertyImpl property = new PropertyImpl();
+
+    if (ODataServiceVersion.V40 == version && propertyValueQName.equals(start.getName())) {
+      // retrieve name from context
+      final Attribute context = start.getAttributeByName(contextQName);
+      if (context != null) {
+        property.setName(StringUtils.substringAfterLast(context.getValue(), "/"));
+      }
+    } else {
+      property.setName(start.getName().getLocalPart());
+    }
+
+    valuable(property, reader, start);
+
+    return property;
+  }
+
+  private void valuable(final Valuable valuable, final XMLEventReader reader, final StartElement start)
+      throws XMLStreamException {
+
+    final Attribute nullAttr = start.getAttributeByName(this.nullQName);
+
+    Value value;
+    if (nullAttr == null) {
+      final Attribute typeAttr = start.getAttributeByName(this.typeQName);
+      final String typeAttrValue = typeAttr == null ? null : typeAttr.getValue();
+
+      final EdmTypeInfo typeInfo = StringUtils.isBlank(typeAttrValue)
+          ? null
+          : new EdmTypeInfo.Builder().setTypeExpression(typeAttrValue).build();
+
+      if (typeInfo != null) {
+        valuable.setType(typeInfo.internal());
+      }
+
+      final ODataPropertyType propType = typeInfo == null
+          ? guessPropertyType(reader, typeInfo)
+          : typeInfo.isCollection()
+              ? ODataPropertyType.COLLECTION
+              : typeInfo.isPrimitiveType()
+                  ? ODataPropertyType.PRIMITIVE
+                  : ODataPropertyType.COMPLEX;
+
+      switch (propType) {
+      case COLLECTION:
+        value = fromCollection(reader, start, typeInfo);
+        break;
+
+      case COMPLEX:
+        value = fromComplexOrEnum(reader, start);
+        break;
+
+      case PRIMITIVE:
+        // No type specified? Defaults to Edm.String
+        if (typeInfo == null) {
+          valuable.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName().toString());
+        }
+        value = fromPrimitive(reader, start, typeInfo);
+        break;
+
+      case EMPTY:
+      default:
+        value = new PrimitiveValueImpl(StringUtils.EMPTY);
+      }
+    } else {
+      value = new NullValueImpl();
+    }
+
+    valuable.setValue(value);
+  }
+
+  @Override
+  public ResWrap<Property> toProperty(final InputStream input) throws ODataDeserializerException {
+    try {
+      final XMLEventReader reader = getReader(input);
+      final StartElement start = skipBeforeFirstStartElement(reader);
+      return getContainer(start, property(reader, start));
+    } catch (XMLStreamException e) {
+      throw new ODataDeserializerException(e);
+    }
+  }
+
+  private StartElement skipBeforeFirstStartElement(final XMLEventReader reader) throws XMLStreamException {
+    StartElement startEvent = null;
+    while (reader.hasNext() && startEvent == null) {
+      final XMLEvent event = reader.nextEvent();
+      if (event.isStartElement()) {
+        startEvent = event.asStartElement();
+      }
+    }
+    if (startEvent == null) {
+      throw new IllegalArgumentException("Cannot find any XML start element");
+    }
+
+    return startEvent;
+  }
+
+  private void common(final XMLEventReader reader, final StartElement start,
+      final AbstractODataObject object, final String key) throws XMLStreamException {
+
+    boolean foundEndElement = false;
+    while (reader.hasNext() && !foundEndElement) {
+      final XMLEvent event = reader.nextEvent();
+
+      if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
+        try {
+          object.setCommonProperty(key, event.asCharacters().getData());
+        } catch (ParseException e) {
+          throw new XMLStreamException("While parsing Atom entry or feed common elements", e);
+        }
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndElement = true;
+      }
+    }
+  }
+
+  private void inline(final XMLEventReader reader, final StartElement start, final LinkImpl link)
+      throws XMLStreamException {
+
+    boolean foundEndElement = false;
+    while (reader.hasNext() && !foundEndElement) {
+      final XMLEvent event = reader.nextEvent();
+
+      if (event.isStartElement()) {
+        if (inlineQName.equals(event.asStartElement().getName())) {
+          StartElement inline = null;
+          while (reader.hasNext() && inline == null) {
+            final XMLEvent innerEvent = reader.peek();
+            if (innerEvent.isCharacters() && innerEvent.asCharacters().isWhiteSpace()) {
+              reader.nextEvent();
+            } else if (innerEvent.isStartElement()) {
+              inline = innerEvent.asStartElement();
+            }
+          }
+          if (inline != null) {
+            if (Constants.QNAME_ATOM_ELEM_ENTRY.equals(inline.getName())) {
+              link.setInlineEntity(entity(reader, inline));
+            }
+            if (Constants.QNAME_ATOM_ELEM_FEED.equals(inline.getName())) {
+              link.setInlineEntitySet(entitySet(reader, inline));
+            }
+          }
+        } else if (annotationQName.equals(event.asStartElement().getName())) {
+          link.getAnnotations().add(annotation(reader, event.asStartElement()));
+        }
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndElement = true;
+      }
+    }
+  }
+
+  public ResWrap<Delta> delta(final InputStream input) throws XMLStreamException {
+    final XMLEventReader reader = getReader(input);
+    final StartElement start = skipBeforeFirstStartElement(reader);
+    return getContainer(start, delta(reader, start));
+  }
+
+  private Delta delta(final XMLEventReader reader, final StartElement start) throws XMLStreamException {
+    if (!Constants.QNAME_ATOM_ELEM_FEED.equals(start.getName())) {
+      return null;
+    }
+    final DeltaImpl delta = new DeltaImpl();
+    final Attribute xmlBase = start.getAttributeByName(Constants.QNAME_ATTR_XML_BASE);
+    if (xmlBase != null) {
+      delta.setBaseURI(xmlBase.getValue());
+    }
+
+    boolean foundEndFeed = false;
+    while (reader.hasNext() && !foundEndFeed) {
+      final XMLEvent event = reader.nextEvent();
+      if (event.isStartElement()) {
+        if (countQName.equals(event.asStartElement().getName())) {
+          count(reader, event.asStartElement(), delta);
+        } else if (Constants.QNAME_ATOM_ELEM_ID.equals(event.asStartElement().getName())) {
+          common(reader, event.asStartElement(), delta, "id");
+        } else if (Constants.QNAME_ATOM_ELEM_TITLE.equals(event.asStartElement().getName())) {
+          common(reader, event.asStartElement(), delta, "title");
+        } else if (Constants.QNAME_ATOM_ELEM_SUMMARY.equals(event.asStartElement().getName())) {
+          common(reader, event.asStartElement(), delta, "summary");
+        } else if (Constants.QNAME_ATOM_ELEM_UPDATED.equals(event.asStartElement().getName())) {
+          common(reader, event.asStartElement(), delta, "updated");
+        } else if (Constants.QNAME_ATOM_ELEM_LINK.equals(event.asStartElement().getName())) {
+          final Attribute rel = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REL));
+          if (rel != null) {
+            if (Constants.NEXT_LINK_REL.equals(rel.getValue())) {
+              final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
+              if (href != null) {
+                delta.setNext(URI.create(href.getValue()));
+              }
+            }
+            if (Constants.DELTA_LINK_REL.equals(rel.getValue())) {
+              final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
+              if (href != null) {
+                delta.setDeltaLink(URI.create(href.getValue()));
+              }
+            }
+          }
+        } else if (Constants.QNAME_ATOM_ELEM_ENTRY.equals(event.asStartElement().getName())) {
+          delta.getEntities().add(entity(reader, event.asStartElement()));
+        } else if (deletedEntryQName.equals(event.asStartElement().getName())) {
+          final DeletedEntityImpl deletedEntity = new DeletedEntityImpl();
+
+          final Attribute ref = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REF));
+          if (ref != null) {
+            deletedEntity.setId(URI.create(ref.getValue()));
+          }
+          final Attribute reason = event.asStartElement().getAttributeByName(reasonQName);
+          if (reason != null) {
+            deletedEntity.setReason(Reason.valueOf(reason.getValue()));
+          }
+
+          delta.getDeletedEntities().add(deletedEntity);
+        } else if (linkQName.equals(event.asStartElement().getName())
+            || deletedLinkQName.equals(event.asStartElement().getName())) {
+
+          final DeltaLinkImpl link = new DeltaLinkImpl();
+
+          final Attribute source = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_SOURCE));
+          if (source != null) {
+            link.setSource(URI.create(source.getValue()));
+          }
+          final Attribute relationship =
+              event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_RELATIONSHIP));
+          if (relationship != null) {
+            link.setRelationship(relationship.getValue());
+          }
+          final Attribute target = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TARGET));
+          if (target != null) {
+            link.setTarget(URI.create(target.getValue()));
+          }
+
+          if (linkQName.equals(event.asStartElement().getName())) {
+            delta.getAddedLinks().add(link);
+          } else {
+            delta.getDeletedLinks().add(link);
+          }
+        }
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndFeed = true;
+      }
+    }
+
+    return delta;
+  }
+
+  public ResWrap<LinkCollection> linkCollection(final InputStream input) throws XMLStreamException {
+    final XMLEventReader reader = getReader(input);
+    final StartElement start = skipBeforeFirstStartElement(reader);
+    return getContainer(start, linkCollection(reader));
+  }
+
+  private LinkCollection linkCollection(final XMLEventReader reader) throws XMLStreamException {
+
+    final LinkCollectionImpl linkCollection = new LinkCollectionImpl();
+
+    boolean isURI = false;
+    boolean isNext = false;
+    while (reader.hasNext()) {
+      final XMLEvent event = reader.nextEvent();
+      if (event.isStartElement()) {
+        isURI = uriQName.equals(event.asStartElement().getName());
+        isNext = nextQName.equals(event.asStartElement().getName());
+      }
+
+      if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
+        if (isURI) {
+          linkCollection.getLinks().add(URI.create(event.asCharacters().getData()));
+          isURI = false;
+        } else if (isNext) {
+          linkCollection.setNext(URI.create(event.asCharacters().getData()));
+          isNext = false;
+        }
+      }
+    }
+
+    return linkCollection;
+  }
+
+  private void properties(final XMLEventReader reader, final StartElement start, final EntityImpl entity)
+      throws XMLStreamException {
+
+    final Map<String, List<Annotation>> annotations = new HashMap<String, List<Annotation>>();
+
+    boolean foundEndProperties = false;
+    while (reader.hasNext() && !foundEndProperties) {
+      final XMLEvent event = reader.nextEvent();
+
+      if (event.isStartElement()) {
+        if (annotationQName.equals(event.asStartElement().getName())) {
+          final String target = event.asStartElement().
+              getAttributeByName(QName.valueOf(Constants.ATTR_TARGET)).getValue();
+          if (!annotations.containsKey(target)) {
+            annotations.put(target, new ArrayList<Annotation>());
+          }
+          annotations.get(target).add(annotation(reader, event.asStartElement()));
+        } else {
+          entity.getProperties().add(property(reader, event.asStartElement()));
+        }
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndProperties = true;
+      }
+    }
+
+    for (Property property : entity.getProperties()) {
+      if (annotations.containsKey(property.getName())) {
+        property.getAnnotations().addAll(annotations.get(property.getName()));
+      }
+    }
+  }
+
+  private Annotation annotation(final XMLEventReader reader, final StartElement start)
+      throws XMLStreamException {
+
+    final Annotation annotation = new AnnotationImpl();
+
+    annotation.setTerm(start.getAttributeByName(QName.valueOf(Constants.ATOM_ATTR_TERM)).getValue());
+    valuable(annotation, reader, start);
+
+    return annotation;
+  }
+
+  private EntityImpl entityRef(final StartElement start) throws XMLStreamException {
+    final EntityImpl entity = new EntityImpl();
+
+    final Attribute entityRefId = start.getAttributeByName(Constants.QNAME_ATOM_ATTR_ID);
+    if (entityRefId != null) {
+      entity.setId(URI.create(entityRefId.getValue()));
+    }
+
+    return entity;
+  }
+
+  private Entity entity(final XMLEventReader reader, final StartElement start) throws XMLStreamException {
+    final EntityImpl entity;
+    if (entryRefQName.equals(start.getName())) {
+      entity = entityRef(start);
+    } else if (Constants.QNAME_ATOM_ELEM_ENTRY.equals(start.getName())) {
+      entity = new EntityImpl();
+      final Attribute xmlBase = start.getAttributeByName(Constants.QNAME_ATTR_XML_BASE);
+      if (xmlBase != null) {
+        entity.setBaseURI(xmlBase.getValue());
+      }
+
+      final Attribute etag = start.getAttributeByName(etagQName);
+      if (etag != null) {
+        entity.setETag(etag.getValue());
+      }
+
+      boolean foundEndEntry = false;
+      while (reader.hasNext() && !foundEndEntry) {
+        final XMLEvent event = reader.nextEvent();
+
+        if (event.isStartElement()) {
+          if (Constants.QNAME_ATOM_ELEM_ID.equals(event.asStartElement().getName())) {
+            common(reader, event.asStartElement(), entity, "id");
+          } else if (Constants.QNAME_ATOM_ELEM_TITLE.equals(event.asStartElement().getName())) {
+            common(reader, event.asStartElement(), entity, "title");
+          } else if (Constants.QNAME_ATOM_ELEM_SUMMARY.equals(event.asStartElement().getName())) {
+            common(reader, event.asStartElement(), entity, "summary");
+          } else if (Constants.QNAME_ATOM_ELEM_UPDATED.equals(event.asStartElement().getName())) {
+            common(reader, event.asStartElement(), entity, "updated");
+          } else if (Constants.QNAME_ATOM_ELEM_CATEGORY.equals(event.asStartElement().getName())) {
+            final Attribute term = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATOM_ATTR_TERM));
+            if (term != null) {
+              entity.setType(new EdmTypeInfo.Builder().setTypeExpression(term.getValue()).build().internal());
+            }
+          } else if (Constants.QNAME_ATOM_ELEM_LINK.equals(event.asStartElement().getName())) {
+            final LinkImpl link = new LinkImpl();
+            final Attribute rel = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REL));
+            if (rel != null) {
+              link.setRel(rel.getValue());
+            }
+            final Attribute title = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TITLE));
+            if (title != null) {
+              link.setTitle(title.getValue());
+            }
+            final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
+            if (href != null) {
+              link.setHref(href.getValue());
+            }
+            final Attribute type = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TYPE));
+            if (type != null) {
+              link.setType(type.getValue());
+            }
+
+            if (Constants.SELF_LINK_REL.equals(link.getRel())) {
+              entity.setSelfLink(link);
+            } else if (Constants.EDIT_LINK_REL.equals(link.getRel())) {
+              entity.setEditLink(link);
+            } else if (Constants.EDITMEDIA_LINK_REL.equals(link.getRel())) {
+              final Attribute mediaETag = event.asStartElement().getAttributeByName(etagQName);
+              if (mediaETag != null) {
+                entity.setMediaETag(mediaETag.getValue());
+              }
+            } else if (link.getRel().startsWith(
+                version.getNamespaceMap().get(ODataServiceVersion.NAVIGATION_LINK_REL))) {
+
+              entity.getNavigationLinks().add(link);
+              inline(reader, event.asStartElement(), link);
+            } else if (link.getRel().startsWith(
+                version.getNamespaceMap().get(ODataServiceVersion.ASSOCIATION_LINK_REL))) {
+
+              entity.getAssociationLinks().add(link);
+            } else if (link.getRel().startsWith(
+                version.getNamespaceMap().get(ODataServiceVersion.MEDIA_EDIT_LINK_REL))) {
+
+              final Attribute metag = event.asStartElement().getAttributeByName(etagQName);
+              if (metag != null) {
+                link.setMediaETag(metag.getValue());
+              }
+              entity.getMediaEditLinks().add(link);
+            }
+          } else if (actionQName.equals(event.asStartElement().getName())) {
+            final ODataOperation operation = new ODataOperation();
+            final Attribute metadata =
+                event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_METADATA));
+            if (metadata != null) {
+              operation.setMetadataAnchor(metadata.getValue());
+            }
+            final Attribute title = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TITLE));
+            if (title != null) {
+              operation.setTitle(title.getValue());
+            }
+            final Attribute target = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TARGET));
+            if (target != null) {
+              operation.setTarget(URI.create(target.getValue()));
+            }
+
+            entity.getOperations().add(operation);
+          } else if (Constants.QNAME_ATOM_ELEM_CONTENT.equals(event.asStartElement().getName())) {
+            final Attribute type = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TYPE));
+            if (type == null || ContentType.APPLICATION_XML.equals(type.getValue())) {
+              properties(reader, skipBeforeFirstStartElement(reader), entity);
+            } else {
+              entity.setMediaContentType(type.getValue());
+              final Attribute src = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATOM_ATTR_SRC));
+              if (src != null) {
+                entity.setMediaContentSource(URI.create(src.getValue()));
+              }
+            }
+          } else if (propertiesQName.equals(event.asStartElement().getName())) {
+            properties(reader, event.asStartElement(), entity);
+          } else if (annotationQName.equals(event.asStartElement().getName())) {
+            entity.getAnnotations().add(annotation(reader, event.asStartElement()));
+          }
+        }
+
+        if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+          foundEndEntry = true;
+        }
+      }
+    } else {
+      entity = null;
+    }
+
+    return entity;
+  }
+
+  @Override
+  public ResWrap<Entity> toEntity(final InputStream input) throws ODataDeserializerException {
+    try {
+      final XMLEventReader reader = getReader(input);
+      final StartElement start = skipBeforeFirstStartElement(reader);
+      return getContainer(start, entity(reader, start));
+    } catch (XMLStreamException e) {
+      throw new ODataDeserializerException(e);
+    }
+  }
+
+  private void count(final XMLEventReader reader, final StartElement start, final EntitySet entitySet)
+      throws XMLStreamException {
+
+    boolean foundEndElement = false;
+    while (reader.hasNext() && !foundEndElement) {
+      final XMLEvent event = reader.nextEvent();
+
+      if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
+        entitySet.setCount(Integer.valueOf(event.asCharacters().getData()));
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndElement = true;
+      }
+    }
+  }
+
+  private EntitySet entitySet(final XMLEventReader reader, final StartElement start) throws XMLStreamException {
+    if (!Constants.QNAME_ATOM_ELEM_FEED.equals(start.getName())) {
+      return null;
+    }
+    final EntitySetImpl entitySet = new EntitySetImpl();
+    final Attribute xmlBase = start.getAttributeByName(Constants.QNAME_ATTR_XML_BASE);
+    if (xmlBase != null) {
+      entitySet.setBaseURI(xmlBase.getValue());
+    }
+
+    boolean foundEndFeed = false;
+    while (reader.hasNext() && !foundEndFeed) {
+      final XMLEvent event = reader.nextEvent();
+      if (event.isStartElement()) {
+        if (countQName.equals(event.asStartElement().getName())) {
+          count(reader, event.asStartElement(), entitySet);
+        } else if (Constants.QNAME_ATOM_ELEM_ID.equals(event.asStartElement().getName())) {
+          common(reader, event.asStartElement(), entitySet, "id");
+        } else if (Constants.QNAME_ATOM_ELEM_TITLE.equals(event.asStartElement().getName())) {
+          common(reader, event.asStartElement(), entitySet, "title");
+        } else if (Constants.QNAME_ATOM_ELEM_SUMMARY.equals(event.asStartElement().getName())) {
+          common(reader, event.asStartElement(), entitySet, "summary");
+        } else if (Constants.QNAME_ATOM_ELEM_UPDATED.equals(event.asStartElement().getName())) {
+          common(reader, event.asStartElement(), entitySet, "updated");
+        } else if (Constants.QNAME_ATOM_ELEM_LINK.equals(event.asStartElement().getName())) {
+          final Attribute rel = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REL));
+          if (rel != null) {
+            if (Constants.NEXT_LINK_REL.equals(rel.getValue())) {
+              final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
+              if (href != null) {
+                entitySet.setNext(URI.create(href.getValue()));
+              }
+            }
+            if (Constants.DELTA_LINK_REL.equals(rel.getValue())) {
+              final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
+              if (href != null) {
+                entitySet.setDeltaLink(URI.create(href.getValue()));
+              }
+            }
+          }
+        } else if (Constants.QNAME_ATOM_ELEM_ENTRY.equals(event.asStartElement().getName())) {
+          entitySet.getEntities().add(entity(reader, event.asStartElement()));
+        } else if (entryRefQName.equals(event.asStartElement().getName())) {
+          entitySet.getEntities().add(entityRef(event.asStartElement()));
+        } else if (annotationQName.equals(event.asStartElement().getName())) {
+          entitySet.getAnnotations().add(annotation(reader, event.asStartElement()));
+        }
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndFeed = true;
+      }
+    }
+
+    return entitySet;
+  }
+
+  @Override
+  public ResWrap<EntitySet> toEntitySet(final InputStream input) throws ODataDeserializerException {
+    try {
+      final XMLEventReader reader = getReader(input);
+      final StartElement start = skipBeforeFirstStartElement(reader);
+      return getContainer(start, entitySet(reader, start));
+    } catch (XMLStreamException e) {
+      throw new ODataDeserializerException(e);
+    }
+  }
+
+  private ODataError error(final XMLEventReader reader, final StartElement start) throws XMLStreamException {
+    final ODataErrorImpl error = new ODataErrorImpl();
+
+    boolean setCode = false;
+    boolean codeSet = false;
+    boolean setMessage = false;
+    boolean messageSet = false;
+    boolean setTarget = false;
+    boolean targetSet = false;
+
+    boolean foundEndElement = false;
+    while (reader.hasNext() && !foundEndElement) {
+      final XMLEvent event = reader.nextEvent();
+
+      if (event.isStartElement()) {
+        if (errorCodeQName.equals(event.asStartElement().getName())) {
+          setCode = true;
+        } else if (errorMessageQName.equals(event.asStartElement().getName())) {
+          setMessage = true;
+        } else if (errorTargetQName.equals(event.asStartElement().getName())) {
+          setTarget = true;
+        }
+      }
+
+      if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
+        if (setCode && !codeSet) {
+          error.setCode(event.asCharacters().getData());
+          setCode = false;
+          codeSet = true;
+        }
+        if (setMessage && !messageSet) {
+          error.setMessage(event.asCharacters().getData());
+          setMessage = false;
+          messageSet = true;
+        }
+        if (setTarget && !targetSet) {
+          error.setTarget(event.asCharacters().getData());
+          setTarget = false;
+          targetSet = true;
+        }
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndElement = true;
+      }
+    }
+
+    return error;
+  }
+
+  @Override
+  public ODataError toError(final InputStream input) throws ODataDeserializerException {
+    try {
+      final XMLEventReader reader = getReader(input);
+      final StartElement start = skipBeforeFirstStartElement(reader);
+      return error(reader, start);
+    } catch (XMLStreamException e) {
+      throw new ODataDeserializerException(e);
+    }
+  }
+
+  private <T> ResWrap<T> getContainer(final StartElement start, final T object) {
+    final Attribute context = start.getAttributeByName(contextQName);
+    final Attribute metadataETag = start.getAttributeByName(metadataEtagQName);
+
+    return new ResWrap<T>(
+        context == null ? null : URI.create(context.getValue()),
+        metadataETag == null ? null : metadataETag.getValue(),
+        object);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomGeoValueDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomGeoValueDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomGeoValueDeserializer.java
new file mode 100644
index 0000000..0136406
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomGeoValueDeserializer.java
@@ -0,0 +1,267 @@
+/*
+ * 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.serialization;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Attribute;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.GeoUtils;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.geo.Geospatial;
+import org.apache.olingo.commons.api.edm.geo.GeospatialCollection;
+import org.apache.olingo.commons.api.edm.geo.LineString;
+import org.apache.olingo.commons.api.edm.geo.MultiLineString;
+import org.apache.olingo.commons.api.edm.geo.MultiPoint;
+import org.apache.olingo.commons.api.edm.geo.MultiPolygon;
+import org.apache.olingo.commons.api.edm.geo.Point;
+import org.apache.olingo.commons.api.edm.geo.Polygon;
+import org.apache.olingo.commons.api.edm.geo.SRID;
+import org.apache.olingo.commons.core.edm.primitivetype.EdmDouble;
+
+class AtomGeoValueDeserializer {
+
+  private List<Point> points(final XMLEventReader reader, final StartElement start,
+          final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
+
+    final List<Point> result = new ArrayList<Point>();
+
+    boolean foundEndProperty = false;
+    while (reader.hasNext() && !foundEndProperty) {
+      final XMLEvent event = reader.nextEvent();
+
+      if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
+        final String[] pointInfo = event.asCharacters().getData().split(" ");
+
+        final Point point = new Point(GeoUtils.getDimension(type), srid);
+        try {
+          point.setX(EdmDouble.getInstance().valueOfString(pointInfo[0], null, null,
+                  Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, Double.class));
+          point.setY(EdmDouble.getInstance().valueOfString(pointInfo[1], null, null,
+                  Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, Double.class));
+        } catch (EdmPrimitiveTypeException e) {
+          throw new XMLStreamException("While deserializing point coordinates as double", e);
+        }
+        result.add(point);
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndProperty = true;
+      }
+    }
+
+    // handles bad input, e.g. things like <gml:pos/>
+    if (result.isEmpty()) {
+      result.add(new Point(GeoUtils.getDimension(type), srid));
+    }
+
+    return result;
+  }
+
+  private MultiPoint multipoint(final XMLEventReader reader, final StartElement start,
+          final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
+
+    List<Point> points = Collections.<Point>emptyList();
+
+    boolean foundEndProperty = false;
+    while (reader.hasNext() && !foundEndProperty) {
+      final XMLEvent event = reader.nextEvent();
+
+      if (event.isStartElement() && event.asStartElement().getName().equals(Constants.QNAME_POINTMEMBERS)) {
+        points = points(reader, event.asStartElement(), type, null);
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndProperty = true;
+      }
+    }
+
+    return new MultiPoint(GeoUtils.getDimension(type), srid, points);
+  }
+
+  private LineString lineString(final XMLEventReader reader, final StartElement start,
+          final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
+
+    return new LineString(GeoUtils.getDimension(type), srid, points(reader, start, type, null));
+  }
+
+  private Polygon polygon(final XMLEventReader reader, final StartElement start,
+          final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
+
+    List<Point> extPoints = null;
+    List<Point> intPoints = null;
+
+    boolean foundEndProperty = false;
+    while (reader.hasNext() && !foundEndProperty) {
+      final XMLEvent event = reader.nextEvent();
+
+      if (event.isStartElement()) {
+        if (event.asStartElement().getName().equals(Constants.QNAME_POLYGON_EXTERIOR)) {
+          extPoints = points(reader, event.asStartElement(), type, null);
+        }
+        if (event.asStartElement().getName().equals(Constants.QNAME_POLYGON_INTERIOR)) {
+          intPoints = points(reader, event.asStartElement(), type, null);
+        }
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndProperty = true;
+      }
+    }
+
+    return new Polygon(GeoUtils.getDimension(type), srid, intPoints, extPoints);
+  }
+
+  private MultiLineString multiLineString(final XMLEventReader reader, final StartElement start,
+          final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
+
+    final List<LineString> lineStrings = new ArrayList<LineString>();
+
+    boolean foundEndProperty = false;
+    while (reader.hasNext() && !foundEndProperty) {
+      final XMLEvent event = reader.nextEvent();
+
+      if (event.isStartElement() && event.asStartElement().getName().equals(Constants.QNAME_LINESTRING)) {
+        lineStrings.add(lineString(reader, event.asStartElement(), type, null));
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndProperty = true;
+      }
+    }
+
+    return new MultiLineString(GeoUtils.getDimension(type), srid, lineStrings);
+  }
+
+  private MultiPolygon multiPolygon(final XMLEventReader reader, final StartElement start,
+          final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
+
+    final List<Polygon> polygons = new ArrayList<Polygon>();
+
+    boolean foundEndProperty = false;
+    while (reader.hasNext() && !foundEndProperty) {
+      final XMLEvent event = reader.nextEvent();
+
+      if (event.isStartElement() && event.asStartElement().getName().equals(Constants.QNAME_POLYGON)) {
+        polygons.add(polygon(reader, event.asStartElement(), type, null));
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndProperty = true;
+      }
+    }
+
+    return new MultiPolygon(GeoUtils.getDimension(type), srid, polygons);
+  }
+
+  private GeospatialCollection collection(final XMLEventReader reader, final StartElement start,
+          final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
+
+    final List<Geospatial> geospatials = new ArrayList<Geospatial>();
+
+    boolean foundEndCollection = false;
+    while (reader.hasNext() && !foundEndCollection) {
+      final XMLEvent event = reader.nextEvent();
+
+      if (event.isStartElement() && event.asStartElement().getName().equals(Constants.QNAME_GEOMEMBERS)) {
+        boolean foundEndMembers = false;
+        while (reader.hasNext() && !foundEndMembers) {
+          final XMLEvent subevent = reader.nextEvent();
+
+          if (subevent.isStartElement()) {
+            geospatials.add(deserialize(reader, subevent.asStartElement(),
+                    GeoUtils.getType(GeoUtils.getDimension(type), subevent.asStartElement().getName().getLocalPart())));
+          }
+
+          if (subevent.isEndElement() && Constants.QNAME_GEOMEMBERS.equals(subevent.asEndElement().getName())) {
+            foundEndMembers = true;
+          }
+        }
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndCollection = true;
+      }
+    }
+
+    return new GeospatialCollection(GeoUtils.getDimension(type), srid, geospatials);
+  }
+
+  public Geospatial deserialize(final XMLEventReader reader, final StartElement start,
+          final EdmPrimitiveTypeKind type) throws XMLStreamException {
+
+    SRID srid = null;
+    final Attribute srsName = start.getAttributeByName(Constants.QNAME_ATTR_SRSNAME);
+    if (srsName != null) {
+      srid = SRID.valueOf(StringUtils.substringAfterLast(srsName.getValue(), "/"));
+    }
+
+    Geospatial value;
+
+    switch (type) {
+      case GeographyPoint:
+      case GeometryPoint:
+        value = points(reader, start, type, srid).get(0);
+        break;
+
+      case GeographyMultiPoint:
+      case GeometryMultiPoint:
+        value = multipoint(reader, start, type, srid);
+        break;
+
+      case GeographyLineString:
+      case GeometryLineString:
+        value = lineString(reader, start, type, srid);
+        break;
+
+      case GeographyMultiLineString:
+      case GeometryMultiLineString:
+        value = multiLineString(reader, start, type, srid);
+        break;
+
+      case GeographyPolygon:
+      case GeometryPolygon:
+        value = polygon(reader, start, type, srid);
+        break;
+
+      case GeographyMultiPolygon:
+      case GeometryMultiPolygon:
+        value = multiPolygon(reader, start, type, srid);
+        break;
+
+      case GeographyCollection:
+      case GeometryCollection:
+        value = collection(reader, start, type, srid);
+        break;
+
+      default:
+        value = null;
+    }
+
+    return value;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomGeoValueSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomGeoValueSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomGeoValueSerializer.java
new file mode 100644
index 0000000..8f913a0
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomGeoValueSerializer.java
@@ -0,0 +1,221 @@
+/*
+ * 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.serialization;
+
+import java.util.Collections;
+import java.util.Iterator;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.edm.geo.Geospatial;
+import org.apache.olingo.commons.api.edm.geo.GeospatialCollection;
+import org.apache.olingo.commons.api.edm.geo.LineString;
+import org.apache.olingo.commons.api.edm.geo.MultiLineString;
+import org.apache.olingo.commons.api.edm.geo.MultiPoint;
+import org.apache.olingo.commons.api.edm.geo.MultiPolygon;
+import org.apache.olingo.commons.api.edm.geo.Point;
+import org.apache.olingo.commons.api.edm.geo.Polygon;
+import org.apache.olingo.commons.core.edm.primitivetype.EdmDouble;
+
+class AtomGeoValueSerializer {
+
+  private void points(final XMLStreamWriter writer, final Iterator<Point> itor, final boolean wrap)
+          throws XMLStreamException {
+
+    while (itor.hasNext()) {
+      final Point point = itor.next();
+
+      if (wrap) {
+        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POINT, Constants.NS_GML);
+      }
+
+      writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POS, Constants.NS_GML);
+      try {
+        writer.writeCharacters(EdmDouble.getInstance().valueToString(point.getX(), null, null,
+                Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null)
+                + " "
+                + EdmDouble.getInstance().valueToString(point.getY(), null, null,
+                        Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null));
+      } catch (EdmPrimitiveTypeException e) {
+        throw new XMLStreamException("While serializing point coordinates as double", e);
+      }
+      writer.writeEndElement();
+
+      if (wrap) {
+        writer.writeEndElement();
+      }
+    }
+  }
+
+  private void lineStrings(final XMLStreamWriter writer, final Iterator<LineString> itor, final boolean wrap)
+          throws XMLStreamException {
+
+    while (itor.hasNext()) {
+      final LineString lineString = itor.next();
+
+      if (wrap) {
+        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_LINESTRING, Constants.NS_GML);
+      }
+
+      points(writer, lineString.iterator(), false);
+
+      if (wrap) {
+        writer.writeEndElement();
+      }
+    }
+  }
+
+  private void polygons(final XMLStreamWriter writer, final Iterator<Polygon> itor, final boolean wrap)
+          throws XMLStreamException {
+
+    while (itor.hasNext()) {
+      final Polygon polygon = itor.next();
+
+      if (wrap) {
+        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POLYGON, Constants.NS_GML);
+      }
+
+      if (!polygon.getExterior().isEmpty()) {
+        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POLYGON_EXTERIOR, Constants.NS_GML);
+        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POLYGON_LINEARRING, Constants.NS_GML);
+
+        points(writer, polygon.getExterior().iterator(), false);
+
+        writer.writeEndElement();
+        writer.writeEndElement();
+      }
+      if (!polygon.getInterior().isEmpty()) {
+        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POLYGON_INTERIOR, Constants.NS_GML);
+        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POLYGON_LINEARRING, Constants.NS_GML);
+
+        points(writer, polygon.getInterior().iterator(), false);
+
+        writer.writeEndElement();
+        writer.writeEndElement();
+      }
+
+      if (wrap) {
+        writer.writeEndElement();
+      }
+    }
+  }
+
+  private void writeSrsName(final XMLStreamWriter writer, final Geospatial value) throws XMLStreamException {
+    if (value.getSrid() != null && value.getSrid().isNotDefault()) {
+      writer.writeAttribute(Constants.PREFIX_GML, Constants.NS_GML, Constants.ATTR_SRSNAME,
+              Constants.SRS_URLPREFIX + value.getSrid().toString());
+    }
+  }
+
+  public void serialize(final XMLStreamWriter writer, final Geospatial value) throws XMLStreamException {
+    switch (value.getEdmPrimitiveTypeKind()) {
+      case GeographyPoint:
+      case GeometryPoint:
+        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POINT, Constants.NS_GML);
+        writeSrsName(writer, value);
+
+        points(writer, Collections.singleton((Point) value).iterator(), false);
+
+        writer.writeEndElement();
+        break;
+
+      case GeometryMultiPoint:
+      case GeographyMultiPoint:
+        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_MULTIPOINT, Constants.NS_GML);
+        writeSrsName(writer, value);
+
+        if (!((MultiPoint) value).isEmpty()) {
+          writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POINTMEMBERS, Constants.NS_GML);
+          points(writer, ((MultiPoint) value).iterator(), true);
+          writer.writeEndElement();
+        }
+
+        writer.writeEndElement();
+        break;
+
+      case GeometryLineString:
+      case GeographyLineString:
+        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_LINESTRING, Constants.NS_GML);
+        writeSrsName(writer, value);
+
+        lineStrings(writer, Collections.singleton((LineString) value).iterator(), false);
+
+        writer.writeEndElement();
+        break;
+
+      case GeometryMultiLineString:
+      case GeographyMultiLineString:
+        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_MULTILINESTRING, Constants.NS_GML);
+        writeSrsName(writer, value);
+
+        if (!((MultiLineString) value).isEmpty()) {
+          writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_LINESTRINGMEMBERS, Constants.NS_GML);
+          lineStrings(writer, ((MultiLineString) value).iterator(), true);
+          writer.writeEndElement();
+        }
+
+        writer.writeEndElement();
+        break;
+
+      case GeographyPolygon:
+      case GeometryPolygon:
+        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POLYGON, Constants.NS_GML);
+        writeSrsName(writer, value);
+
+        polygons(writer, Collections.singleton(((Polygon) value)).iterator(), false);
+
+        writer.writeEndElement();
+        break;
+
+      case GeographyMultiPolygon:
+      case GeometryMultiPolygon:
+        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_MULTIPOLYGON, Constants.NS_GML);
+        writeSrsName(writer, value);
+
+        if (!((MultiPolygon) value).isEmpty()) {
+          writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_SURFACEMEMBERS, Constants.NS_GML);
+          polygons(writer, ((MultiPolygon) value).iterator(), true);
+          writer.writeEndElement();
+        }
+
+        writer.writeEndElement();
+        break;
+
+      case GeographyCollection:
+      case GeometryCollection:
+        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_GEOCOLLECTION, Constants.NS_GML);
+        writeSrsName(writer, value);
+
+        if (!((GeospatialCollection) value).isEmpty()) {
+          writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_GEOMEMBERS, Constants.NS_GML);
+          for (final Iterator<Geospatial> itor = ((GeospatialCollection) value).iterator(); itor.hasNext();) {
+            serialize(writer, itor.next());
+          }
+          writer.writeEndElement();
+        }
+
+        writer.writeEndElement();
+        break;
+
+      default:
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java
new file mode 100644
index 0000000..fb2a041
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java
@@ -0,0 +1,544 @@
+/*
+ * 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.serialization;
+
+import java.io.Writer;
+import java.util.Collections;
+import java.util.List;
+
+import javax.xml.XMLConstants;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.Annotation;
+import org.apache.olingo.commons.api.data.CollectionValue;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.Link;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.data.Value;
+import org.apache.olingo.commons.api.domain.ODataOperation;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.commons.api.serialization.ODataSerializer;
+import org.apache.olingo.commons.api.serialization.ODataSerializerException;
+import org.apache.olingo.commons.core.data.AbstractODataObject;
+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.edm.EdmTypeInfo;
+
+import com.fasterxml.aalto.stax.OutputFactoryImpl;
+
+public class AtomSerializer extends AbstractAtomDealer implements ODataSerializer {
+
+  private static final XMLOutputFactory FACTORY = new OutputFactoryImpl();
+
+  private final AtomGeoValueSerializer geoSerializer;
+
+  private final boolean serverMode;
+
+  public AtomSerializer(final ODataServiceVersion version) {
+    this(version, false);
+  }
+
+  public AtomSerializer(final ODataServiceVersion version, final boolean serverMode) {
+    super(version);
+    this.geoSerializer = new AtomGeoValueSerializer();
+    this.serverMode = serverMode;
+  }
+
+  private void collection(final XMLStreamWriter writer, final CollectionValue value) throws XMLStreamException {
+    for (Value item : value.get()) {
+      if (version.compareTo(ODataServiceVersion.V40) < 0) {
+        writer.writeStartElement(Constants.PREFIX_DATASERVICES, Constants.ELEM_ELEMENT,
+            version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES));
+      } else {
+        writer.writeStartElement(Constants.PREFIX_METADATA, Constants.ELEM_ELEMENT,
+            version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA));
+      }
+      value(writer, item);
+      writer.writeEndElement();
+    }
+  }
+
+  private void value(final XMLStreamWriter writer, final Value value) throws XMLStreamException {
+    if (value.isPrimitive()) {
+      writer.writeCharacters(value.asPrimitive().get());
+    } else if (value.isEnum()) {
+      writer.writeCharacters(value.asEnum().get());
+    } else if (value.isGeospatial()) {
+      this.geoSerializer.serialize(writer, value.asGeospatial().get());
+    } else if (value.isCollection()) {
+      collection(writer, value.asCollection());
+    } else if (value.isComplex()) {
+      for (Property property : value.asComplex().get()) {
+        property(writer, property, false);
+      }
+    }
+  }
+
+  public void property(final XMLStreamWriter writer, final Property property, final boolean standalone)
+      throws XMLStreamException {
+
+    if (version.compareTo(ODataServiceVersion.V40) >= 0 && standalone) {
+      writer.writeStartElement(Constants.PREFIX_METADATA, Constants.VALUE,
+          version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES));
+    } else {
+      writer.writeStartElement(Constants.PREFIX_DATASERVICES, property.getName(),
+          version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES));
+    }
+
+    if (standalone) {
+      namespaces(writer);
+    }
+
+    if (StringUtils.isNotBlank(property.getType())) {
+      final EdmTypeInfo typeInfo = new EdmTypeInfo.Builder().setTypeExpression(property.getType()).build();
+      if (!EdmPrimitiveTypeKind.String.getFullQualifiedName().toString().equals(typeInfo.internal())) {
+        writer.writeAttribute(Constants.PREFIX_METADATA, version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA),
+            Constants.ATTR_TYPE, typeInfo.external(version));
+      }
+    }
+
+    if (property.getValue().isNull()) {
+      writer.writeAttribute(Constants.PREFIX_METADATA, version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA),
+          Constants.ATTR_NULL, Boolean.TRUE.toString());
+    } else {
+      value(writer, property.getValue());
+      if (property.getValue().isLinkedComplex()) {
+        links(writer, property.getValue().asLinkedComplex().getAssociationLinks());
+        links(writer, property.getValue().asLinkedComplex().getNavigationLinks());
+      }
+    }
+
+    writer.writeEndElement();
+
+    for (Annotation annotation : property.getAnnotations()) {
+      annotation(writer, annotation, property.getName());
+    }
+  }
+
+  private void property(final XMLStreamWriter writer, final Property property) throws XMLStreamException {
+    property(writer, property, true);
+  }
+
+  private void startDocument(final XMLStreamWriter writer, final String rootElement) throws XMLStreamException {
+    writer.writeStartDocument();
+    writer.setDefaultNamespace(Constants.NS_ATOM);
+
+    writer.writeStartElement(rootElement);
+
+    namespaces(writer);
+  }
+
+  private void property(final Writer outWriter, final Property property) throws XMLStreamException {
+    final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
+
+    writer.writeStartDocument();
+
+    property(writer, property);
+
+    writer.writeEndDocument();
+    writer.flush();
+  }
+
+  private void links(final XMLStreamWriter writer, final List<Link> links) throws XMLStreamException {
+    for (Link link : links) {
+      writer.writeStartElement(Constants.ATOM_ELEM_LINK);
+
+      if (StringUtils.isNotBlank(link.getRel())) {
+        writer.writeAttribute(Constants.ATTR_REL, link.getRel());
+      }
+      if (StringUtils.isNotBlank(link.getTitle())) {
+        writer.writeAttribute(Constants.ATTR_TITLE, link.getTitle());
+      }
+      if (StringUtils.isNotBlank(link.getHref())) {
+        writer.writeAttribute(Constants.ATTR_HREF, link.getHref());
+      }
+      if (StringUtils.isNotBlank(link.getType())) {
+        writer.writeAttribute(Constants.ATTR_TYPE, link.getType());
+      }
+
+      if (link.getInlineEntity() != null || link.getInlineEntitySet() != null) {
+        writer.writeStartElement(Constants.PREFIX_METADATA, Constants.ATOM_ELEM_INLINE,
+            version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA));
+
+        if (link.getInlineEntity() != null) {
+          writer.writeStartElement(Constants.ATOM_ELEM_ENTRY);
+          entity(writer, link.getInlineEntity());
+          writer.writeEndElement();
+        }
+        if (link.getInlineEntitySet() != null) {
+          writer.writeStartElement(Constants.ATOM_ELEM_FEED);
+          entitySet(writer, link.getInlineEntitySet());
+          writer.writeEndElement();
+        }
+
+        writer.writeEndElement();
+      }
+
+      for (Annotation annotation : link.getAnnotations()) {
+        annotation(writer, annotation, null);
+      }
+
+      writer.writeEndElement();
+    }
+  }
+
+  private void common(final XMLStreamWriter writer, final AbstractODataObject object) throws XMLStreamException {
+    if (StringUtils.isNotBlank(object.getTitle())) {
+      writer.writeStartElement(Constants.ATOM_ELEM_TITLE);
+      writer.writeAttribute(Constants.ATTR_TYPE, TYPE_TEXT);
+      writer.writeCharacters(object.getTitle());
+      writer.writeEndElement();
+    }
+  }
+
+  private void properties(final XMLStreamWriter writer, final List<Property> properties) throws XMLStreamException {
+    for (Property property : properties) {
+      property(writer, property, false);
+    }
+  }
+
+  private void annotation(final XMLStreamWriter writer, final Annotation annotation, final String target)
+      throws XMLStreamException {
+
+    writer.writeStartElement(Constants.PREFIX_METADATA, Constants.ANNOTATION,
+        version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA));
+
+    writer.writeAttribute(Constants.ATOM_ATTR_TERM, annotation.getTerm());
+
+    if (target != null) {
+      writer.writeAttribute(Constants.ATTR_TARGET, target);
+    }
+
+    if (StringUtils.isNotBlank(annotation.getType())) {
+      final EdmTypeInfo typeInfo = new EdmTypeInfo.Builder().setTypeExpression(annotation.getType()).build();
+      if (!EdmPrimitiveTypeKind.String.getFullQualifiedName().toString().equals(typeInfo.internal())) {
+        writer.writeAttribute(Constants.PREFIX_METADATA, version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA),
+            Constants.ATTR_TYPE, typeInfo.external(version));
+      }
+    }
+
+    if (annotation.getValue().isNull()) {
+      writer.writeAttribute(Constants.PREFIX_METADATA, version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA),
+          Constants.ATTR_NULL, Boolean.TRUE.toString());
+    } else {
+      value(writer, annotation.getValue());
+    }
+
+    writer.writeEndElement();
+  }
+
+  private void entity(final XMLStreamWriter writer, final Entity entity) throws XMLStreamException {
+    if (entity.getBaseURI() != null) {
+      writer.writeAttribute(XMLConstants.XML_NS_URI, Constants.ATTR_XML_BASE, entity.getBaseURI().toASCIIString());
+    }
+
+    if (serverMode && StringUtils.isNotBlank(entity.getETag())) {
+      writer.writeAttribute(
+          version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA),
+          Constants.ATOM_ATTR_ETAG, entity.getETag());
+    }
+
+    if (entity.getId() != null) {
+      writer.writeStartElement(Constants.ATOM_ELEM_ID);
+      writer.writeCharacters(entity.getId().toASCIIString());
+      writer.writeEndElement();
+    }
+
+    writer.writeStartElement(Constants.ATOM_ELEM_CATEGORY);
+    writer.writeAttribute(Constants.ATOM_ATTR_SCHEME, version.getNamespaceMap().get(ODataServiceVersion.NS_SCHEME));
+    if (StringUtils.isNotBlank(entity.getType())) {
+      writer.writeAttribute(Constants.ATOM_ATTR_TERM,
+          new EdmTypeInfo.Builder().setTypeExpression(entity.getType()).build().external(version));
+    }
+    writer.writeEndElement();
+
+    if (entity instanceof AbstractODataObject) {
+      common(writer, (AbstractODataObject) entity);
+    }
+
+    if (serverMode) {
+      if (entity.getEditLink() != null) {
+        links(writer, Collections.singletonList(entity.getEditLink()));
+      }
+
+      if (entity.getSelfLink() != null) {
+        links(writer, Collections.singletonList(entity.getSelfLink()));
+      }
+    }
+
+    links(writer, entity.getAssociationLinks());
+    links(writer, entity.getNavigationLinks());
+    links(writer, entity.getMediaEditLinks());
+
+    if (serverMode) {
+      for (ODataOperation operation : entity.getOperations()) {
+        writer.writeStartElement(
+            version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ELEM_ACTION);
+        writer.writeAttribute(Constants.ATTR_METADATA, operation.getMetadataAnchor());
+        writer.writeAttribute(Constants.ATTR_TITLE, operation.getTitle());
+        writer.writeAttribute(Constants.ATTR_TARGET, operation.getTarget().toASCIIString());
+        writer.writeEndElement();
+      }
+    }
+
+    writer.writeStartElement(Constants.ATOM_ELEM_CONTENT);
+    if (entity.isMediaEntity()) {
+      if (StringUtils.isNotBlank(entity.getMediaContentType())) {
+        writer.writeAttribute(Constants.ATTR_TYPE, entity.getMediaContentType());
+      }
+      if (entity.getMediaContentSource() != null) {
+        writer.writeAttribute(Constants.ATOM_ATTR_SRC, entity.getMediaContentSource().toASCIIString());
+      }
+      writer.writeEndElement();
+
+      writer.writeStartElement(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.PROPERTIES);
+      properties(writer, entity.getProperties());
+    } else {
+      writer.writeAttribute(Constants.ATTR_TYPE, ContentType.APPLICATION_XML);
+      writer.writeStartElement(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.PROPERTIES);
+      properties(writer, entity.getProperties());
+      writer.writeEndElement();
+    }
+    writer.writeEndElement();
+
+    for (Annotation annotation : entity.getAnnotations()) {
+      annotation(writer, annotation, null);
+    }
+  }
+
+  private void entityRef(final XMLStreamWriter writer, final Entity entity) throws XMLStreamException {
+    writer.writeStartElement(Constants.ATOM_ELEM_ENTRY_REF);
+    writer.writeNamespace(StringUtils.EMPTY, version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA));
+    writer.writeAttribute(Constants.ATOM_ATTR_ID, entity.getId().toASCIIString());
+  }
+
+  private void entityRef(final XMLStreamWriter writer, final ResWrap<Entity> container) throws XMLStreamException {
+    writer.writeStartElement(Constants.ATOM_ELEM_ENTRY_REF);
+    writer.writeNamespace(StringUtils.EMPTY, version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA));
+    addContextInfo(writer, container);
+    writer.writeAttribute(Constants.ATOM_ATTR_ID, container.getPayload().getId().toASCIIString());
+  }
+
+  private void entity(final Writer outWriter, final Entity entity) throws XMLStreamException {
+    final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
+
+    if (entity.getType() == null && entity.getProperties().isEmpty()) {
+      writer.writeStartDocument();
+      writer.setDefaultNamespace(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA));
+
+      entityRef(writer, entity);
+    } else {
+      startDocument(writer, Constants.ATOM_ELEM_ENTRY);
+
+      entity(writer, entity);
+    }
+
+    writer.writeEndElement();
+    writer.writeEndDocument();
+    writer.flush();
+  }
+
+  private void entity(final Writer outWriter, final ResWrap<Entity> container) throws XMLStreamException {
+    final Entity entity = container.getPayload();
+
+    final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
+
+    if (entity.getType() == null && entity.getProperties().isEmpty()) {
+      writer.writeStartDocument();
+      writer.setDefaultNamespace(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA));
+
+      entityRef(writer, container);
+    } else {
+      startDocument(writer, Constants.ATOM_ELEM_ENTRY);
+
+      addContextInfo(writer, container);
+
+      entity(writer, entity);
+    }
+
+    writer.writeEndElement();
+    writer.writeEndDocument();
+    writer.flush();
+  }
+
+  private void entitySet(final XMLStreamWriter writer, final EntitySet entitySet) throws XMLStreamException {
+    if (entitySet.getBaseURI() != null) {
+      writer.writeAttribute(XMLConstants.XML_NS_URI, Constants.ATTR_XML_BASE, entitySet.getBaseURI().toASCIIString());
+    }
+
+    if (entitySet.getCount() != null) {
+      writer.writeStartElement(
+          version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ELEM_COUNT);
+      writer.writeCharacters(Integer.toString(entitySet.getCount()));
+      writer.writeEndElement();
+    }
+
+    if (entitySet.getId() != null) {
+      writer.writeStartElement(Constants.ATOM_ELEM_ID);
+      writer.writeCharacters(entitySet.getId().toASCIIString());
+      writer.writeEndElement();
+    }
+
+    if (entitySet instanceof AbstractODataObject) {
+      common(writer, (AbstractODataObject) entitySet);
+    }
+
+    for (Entity entity : entitySet.getEntities()) {
+      if (entity.getType() == null && entity.getProperties().isEmpty()) {
+        entityRef(writer, entity);
+        writer.writeEndElement();
+      } else {
+        writer.writeStartElement(Constants.ATOM_ELEM_ENTRY);
+        entity(writer, entity);
+        writer.writeEndElement();
+      }
+    }
+
+    if (serverMode) {
+      if (entitySet.getNext() != null) {
+        final LinkImpl next = new LinkImpl();
+        next.setRel(Constants.NEXT_LINK_REL);
+        next.setHref(entitySet.getNext().toASCIIString());
+
+        links(writer, Collections.<Link> singletonList(next));
+      }
+      if (entitySet.getDeltaLink() != null) {
+        final LinkImpl next = new LinkImpl();
+        next.setRel(Constants.DELTA_LINK_REL);
+        next.setHref(entitySet.getDeltaLink().toASCIIString());
+
+        links(writer, Collections.<Link> singletonList(next));
+      }
+    }
+  }
+
+  private void entitySet(final Writer outWriter, final EntitySet entitySet) throws XMLStreamException {
+    final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
+
+    startDocument(writer, Constants.ATOM_ELEM_FEED);
+
+    entitySet(writer, entitySet);
+
+    writer.writeEndElement();
+    writer.writeEndDocument();
+    writer.flush();
+  }
+
+  private void entitySet(final Writer outWriter, final ResWrap<EntitySet> entitySet) throws XMLStreamException {
+    final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
+
+    startDocument(writer, Constants.ATOM_ELEM_FEED);
+
+    addContextInfo(writer, entitySet);
+
+    entitySet(writer, entitySet.getPayload());
+
+    writer.writeEndElement();
+    writer.writeEndDocument();
+    writer.flush();
+  }
+
+  private void link(final Writer outWriter, final Link link) throws XMLStreamException {
+    final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
+
+    writer.writeStartDocument();
+
+    writer.writeStartElement(Constants.ELEM_LINKS);
+    writer.writeDefaultNamespace(version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES));
+
+    writer.writeStartElement(Constants.ELEM_URI);
+    writer.writeCharacters(link.getHref());
+    writer.writeEndElement();
+
+    writer.writeEndElement();
+
+    writer.writeEndDocument();
+    writer.flush();
+  }
+
+  public <T> void write(final Writer writer, final T obj) throws ODataSerializerException {
+    try {
+      if (obj instanceof EntitySet) {
+        entitySet(writer, (EntitySet) obj);
+      } else if (obj instanceof Entity) {
+        entity(writer, (Entity) obj);
+      } else if (obj instanceof Property) {
+        property(writer, (Property) obj);
+      } else if (obj instanceof Link) {
+        link(writer, (Link) obj);
+      }
+    } catch (final XMLStreamException e) {
+      throw new ODataSerializerException(e);
+    }
+  }
+
+  @SuppressWarnings("unchecked")
+  public <T> void write(final Writer writer, final ResWrap<T> container) throws ODataSerializerException {
+    final T obj = container == null ? null : container.getPayload();
+
+    try {
+      if (obj instanceof EntitySet) {
+        this.entitySet(writer, (ResWrap<EntitySet>) container);
+      } else if (obj instanceof Entity) {
+        entity(writer, (ResWrap<Entity>) container);
+      } else if (obj instanceof Property) {
+        property(writer, (Property) obj);
+      } else if (obj instanceof Link) {
+        link(writer, (Link) obj);
+      }
+    } catch (final XMLStreamException e) {
+      throw new ODataSerializerException(e);
+    }
+  }
+
+  private <T> void addContextInfo(
+      final XMLStreamWriter writer, final ResWrap<T> container) throws XMLStreamException {
+
+    if (container.getContextURL() != null) {
+      String base = container.getContextURL().getServiceRoot().toASCIIString();
+      if (container.getPayload() instanceof EntitySet) {
+        ((EntitySetImpl) container.getPayload()).setBaseURI(base);
+      }
+      if (container.getPayload() instanceof Entity) {
+        ((EntityImpl) container.getPayload()).setBaseURI(base);
+      }
+
+      writer.writeAttribute(
+          version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA),
+          Constants.CONTEXT,
+          container.getContextURL().getURI().toASCIIString());
+    }
+
+    if (StringUtils.isNotBlank(container.getMetadataETag())) {
+      writer.writeAttribute(
+          version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA),
+          Constants.ATOM_ATTR_METADATAETAG,
+          container.getMetadataETag());
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeltaDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeltaDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeltaDeserializer.java
new file mode 100644
index 0000000..c6df8f3
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeltaDeserializer.java
@@ -0,0 +1,102 @@
+/*
+ * 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.serialization;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.util.Iterator;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.ContextURL;
+import org.apache.olingo.commons.api.data.Delta;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+import org.apache.olingo.commons.core.data.DeletedEntityImpl;
+import org.apache.olingo.commons.core.data.DeltaLinkImpl;
+import org.apache.olingo.commons.core.data.v4.DeltaImpl;
+
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+public class JsonDeltaDeserializer extends JsonDeserializer {
+
+  public JsonDeltaDeserializer(final ODataServiceVersion version, final boolean serverMode) {
+    super(version, serverMode);
+  }
+
+  protected ResWrap<Delta> doDeserialize(final JsonParser parser) throws IOException {
+
+    final ObjectNode tree = parser.getCodec().readTree(parser);
+
+    final DeltaImpl delta = new DeltaImpl();
+
+    final URI contextURL = tree.hasNonNull(Constants.JSON_CONTEXT) ?
+        URI.create(tree.get(Constants.JSON_CONTEXT).textValue()) : null;
+    if (contextURL != null) {
+      delta.setBaseURI(StringUtils.substringBefore(contextURL.toASCIIString(), Constants.METADATA));
+    }
+
+    if (tree.hasNonNull(jsonCount)) {
+      delta.setCount(tree.get(jsonCount).asInt());
+    }
+    if (tree.hasNonNull(jsonNextLink)) {
+      delta.setNext(URI.create(tree.get(jsonNextLink).textValue()));
+    }
+    if (tree.hasNonNull(jsonDeltaLink)) {
+      delta.setDeltaLink(URI.create(tree.get(jsonDeltaLink).textValue()));
+    }
+
+    if (tree.hasNonNull(Constants.VALUE)) {
+      JsonEntityDeserializer entityDeserializer = new JsonEntityDeserializer(version, serverMode);
+      for (final Iterator<JsonNode> itor = tree.get(Constants.VALUE).iterator(); itor.hasNext();) {
+        final ObjectNode item = (ObjectNode) itor.next();
+        final ContextURL itemContextURL = item.hasNonNull(Constants.JSON_CONTEXT)
+            ? ContextURL.getInstance(URI.create(item.get(Constants.JSON_CONTEXT).textValue())) : null;
+        item.remove(Constants.JSON_CONTEXT);
+
+        if (itemContextURL == null || itemContextURL.isEntity()) {
+          delta.getEntities().add(entityDeserializer.doDeserialize(item.traverse(parser.getCodec())).getPayload());
+        } else if (itemContextURL.isDeltaDeletedEntity()) {
+          delta.getDeletedEntities().add(parser.getCodec().treeToValue(item, DeletedEntityImpl.class));
+        } else if (itemContextURL.isDeltaLink()) {
+          delta.getAddedLinks().add(parser.getCodec().treeToValue(item, DeltaLinkImpl.class));
+        } else if (itemContextURL.isDeltaDeletedLink()) {
+          delta.getDeletedLinks().add(parser.getCodec().treeToValue(item, DeltaLinkImpl.class));
+        }
+      }
+    }
+
+    return new ResWrap<Delta>(contextURL, null, delta);
+  }
+
+  public ResWrap<Delta> toDelta(InputStream input) throws ODataDeserializerException {
+    try {
+      JsonParser parser = new JsonFactory(new ObjectMapper()).createParser(input);
+      return doDeserialize(parser);
+    } catch (final IOException e) {
+      throw new ODataDeserializerException(e);
+    }
+  }
+}


[5/9] [OLINGO-317] Rename and move of some packages and classes

Posted by mi...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomGeoValueSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomGeoValueSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomGeoValueSerializer.java
deleted file mode 100644
index 7b83e8a..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomGeoValueSerializer.java
+++ /dev/null
@@ -1,221 +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.Collections;
-import java.util.Iterator;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.edm.geo.Geospatial;
-import org.apache.olingo.commons.api.edm.geo.GeospatialCollection;
-import org.apache.olingo.commons.api.edm.geo.LineString;
-import org.apache.olingo.commons.api.edm.geo.MultiLineString;
-import org.apache.olingo.commons.api.edm.geo.MultiPoint;
-import org.apache.olingo.commons.api.edm.geo.MultiPolygon;
-import org.apache.olingo.commons.api.edm.geo.Point;
-import org.apache.olingo.commons.api.edm.geo.Polygon;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmDouble;
-
-class AtomGeoValueSerializer {
-
-  private void points(final XMLStreamWriter writer, final Iterator<Point> itor, final boolean wrap)
-          throws XMLStreamException {
-
-    while (itor.hasNext()) {
-      final Point point = itor.next();
-
-      if (wrap) {
-        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POINT, Constants.NS_GML);
-      }
-
-      writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POS, Constants.NS_GML);
-      try {
-        writer.writeCharacters(EdmDouble.getInstance().valueToString(point.getX(), null, null,
-                Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null)
-                + " "
-                + EdmDouble.getInstance().valueToString(point.getY(), null, null,
-                        Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null));
-      } catch (EdmPrimitiveTypeException e) {
-        throw new XMLStreamException("While serializing point coordinates as double", e);
-      }
-      writer.writeEndElement();
-
-      if (wrap) {
-        writer.writeEndElement();
-      }
-    }
-  }
-
-  private void lineStrings(final XMLStreamWriter writer, final Iterator<LineString> itor, final boolean wrap)
-          throws XMLStreamException {
-
-    while (itor.hasNext()) {
-      final LineString lineString = itor.next();
-
-      if (wrap) {
-        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_LINESTRING, Constants.NS_GML);
-      }
-
-      points(writer, lineString.iterator(), false);
-
-      if (wrap) {
-        writer.writeEndElement();
-      }
-    }
-  }
-
-  private void polygons(final XMLStreamWriter writer, final Iterator<Polygon> itor, final boolean wrap)
-          throws XMLStreamException {
-
-    while (itor.hasNext()) {
-      final Polygon polygon = itor.next();
-
-      if (wrap) {
-        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POLYGON, Constants.NS_GML);
-      }
-
-      if (!polygon.getExterior().isEmpty()) {
-        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POLYGON_EXTERIOR, Constants.NS_GML);
-        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POLYGON_LINEARRING, Constants.NS_GML);
-
-        points(writer, polygon.getExterior().iterator(), false);
-
-        writer.writeEndElement();
-        writer.writeEndElement();
-      }
-      if (!polygon.getInterior().isEmpty()) {
-        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POLYGON_INTERIOR, Constants.NS_GML);
-        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POLYGON_LINEARRING, Constants.NS_GML);
-
-        points(writer, polygon.getInterior().iterator(), false);
-
-        writer.writeEndElement();
-        writer.writeEndElement();
-      }
-
-      if (wrap) {
-        writer.writeEndElement();
-      }
-    }
-  }
-
-  private void writeSrsName(final XMLStreamWriter writer, final Geospatial value) throws XMLStreamException {
-    if (value.getSrid() != null && value.getSrid().isNotDefault()) {
-      writer.writeAttribute(Constants.PREFIX_GML, Constants.NS_GML, Constants.ATTR_SRSNAME,
-              Constants.SRS_URLPREFIX + value.getSrid().toString());
-    }
-  }
-
-  public void serialize(final XMLStreamWriter writer, final Geospatial value) throws XMLStreamException {
-    switch (value.getEdmPrimitiveTypeKind()) {
-      case GeographyPoint:
-      case GeometryPoint:
-        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POINT, Constants.NS_GML);
-        writeSrsName(writer, value);
-
-        points(writer, Collections.singleton((Point) value).iterator(), false);
-
-        writer.writeEndElement();
-        break;
-
-      case GeometryMultiPoint:
-      case GeographyMultiPoint:
-        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_MULTIPOINT, Constants.NS_GML);
-        writeSrsName(writer, value);
-
-        if (!((MultiPoint) value).isEmpty()) {
-          writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POINTMEMBERS, Constants.NS_GML);
-          points(writer, ((MultiPoint) value).iterator(), true);
-          writer.writeEndElement();
-        }
-
-        writer.writeEndElement();
-        break;
-
-      case GeometryLineString:
-      case GeographyLineString:
-        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_LINESTRING, Constants.NS_GML);
-        writeSrsName(writer, value);
-
-        lineStrings(writer, Collections.singleton((LineString) value).iterator(), false);
-
-        writer.writeEndElement();
-        break;
-
-      case GeometryMultiLineString:
-      case GeographyMultiLineString:
-        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_MULTILINESTRING, Constants.NS_GML);
-        writeSrsName(writer, value);
-
-        if (!((MultiLineString) value).isEmpty()) {
-          writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_LINESTRINGMEMBERS, Constants.NS_GML);
-          lineStrings(writer, ((MultiLineString) value).iterator(), true);
-          writer.writeEndElement();
-        }
-
-        writer.writeEndElement();
-        break;
-
-      case GeographyPolygon:
-      case GeometryPolygon:
-        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POLYGON, Constants.NS_GML);
-        writeSrsName(writer, value);
-
-        polygons(writer, Collections.singleton(((Polygon) value)).iterator(), false);
-
-        writer.writeEndElement();
-        break;
-
-      case GeographyMultiPolygon:
-      case GeometryMultiPolygon:
-        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_MULTIPOLYGON, Constants.NS_GML);
-        writeSrsName(writer, value);
-
-        if (!((MultiPolygon) value).isEmpty()) {
-          writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_SURFACEMEMBERS, Constants.NS_GML);
-          polygons(writer, ((MultiPolygon) value).iterator(), true);
-          writer.writeEndElement();
-        }
-
-        writer.writeEndElement();
-        break;
-
-      case GeographyCollection:
-      case GeometryCollection:
-        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_GEOCOLLECTION, Constants.NS_GML);
-        writeSrsName(writer, value);
-
-        if (!((GeospatialCollection) value).isEmpty()) {
-          writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_GEOMEMBERS, Constants.NS_GML);
-          for (final Iterator<Geospatial> itor = ((GeospatialCollection) value).iterator(); itor.hasNext();) {
-            serialize(writer, itor.next());
-          }
-          writer.writeEndElement();
-        }
-
-        writer.writeEndElement();
-        break;
-
-      default:
-    }
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomSerializer.java
deleted file mode 100644
index 3d4eae6..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomSerializer.java
+++ /dev/null
@@ -1,540 +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.io.Writer;
-import java.util.Collections;
-import java.util.List;
-
-import javax.xml.XMLConstants;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.Annotation;
-import org.apache.olingo.commons.api.data.CollectionValue;
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
-import org.apache.olingo.commons.api.data.Link;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.data.Value;
-import org.apache.olingo.commons.api.domain.ODataOperation;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.commons.api.op.ODataSerializer;
-import org.apache.olingo.commons.api.op.ODataSerializerException;
-import org.apache.olingo.commons.core.edm.EdmTypeInfo;
-
-import com.fasterxml.aalto.stax.OutputFactoryImpl;
-
-public class AtomSerializer extends AbstractAtomDealer implements ODataSerializer {
-
-  private static final XMLOutputFactory FACTORY = new OutputFactoryImpl();
-
-  private final AtomGeoValueSerializer geoSerializer;
-
-  private final boolean serverMode;
-
-  public AtomSerializer(final ODataServiceVersion version) {
-    this(version, false);
-  }
-
-  public AtomSerializer(final ODataServiceVersion version, final boolean serverMode) {
-    super(version);
-    this.geoSerializer = new AtomGeoValueSerializer();
-    this.serverMode = serverMode;
-  }
-
-  private void collection(final XMLStreamWriter writer, final CollectionValue value) throws XMLStreamException {
-    for (Value item : value.get()) {
-      if (version.compareTo(ODataServiceVersion.V40) < 0) {
-        writer.writeStartElement(Constants.PREFIX_DATASERVICES, Constants.ELEM_ELEMENT,
-            version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES));
-      } else {
-        writer.writeStartElement(Constants.PREFIX_METADATA, Constants.ELEM_ELEMENT,
-            version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA));
-      }
-      value(writer, item);
-      writer.writeEndElement();
-    }
-  }
-
-  private void value(final XMLStreamWriter writer, final Value value) throws XMLStreamException {
-    if (value.isPrimitive()) {
-      writer.writeCharacters(value.asPrimitive().get());
-    } else if (value.isEnum()) {
-      writer.writeCharacters(value.asEnum().get());
-    } else if (value.isGeospatial()) {
-      this.geoSerializer.serialize(writer, value.asGeospatial().get());
-    } else if (value.isCollection()) {
-      collection(writer, value.asCollection());
-    } else if (value.isComplex()) {
-      for (Property property : value.asComplex().get()) {
-        property(writer, property, false);
-      }
-    }
-  }
-
-  public void property(final XMLStreamWriter writer, final Property property, final boolean standalone)
-      throws XMLStreamException {
-
-    if (version.compareTo(ODataServiceVersion.V40) >= 0 && standalone) {
-      writer.writeStartElement(Constants.PREFIX_METADATA, Constants.VALUE,
-          version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES));
-    } else {
-      writer.writeStartElement(Constants.PREFIX_DATASERVICES, property.getName(),
-          version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES));
-    }
-
-    if (standalone) {
-      namespaces(writer);
-    }
-
-    if (StringUtils.isNotBlank(property.getType())) {
-      final EdmTypeInfo typeInfo = new EdmTypeInfo.Builder().setTypeExpression(property.getType()).build();
-      if (!EdmPrimitiveTypeKind.String.getFullQualifiedName().toString().equals(typeInfo.internal())) {
-        writer.writeAttribute(Constants.PREFIX_METADATA, version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA),
-            Constants.ATTR_TYPE, typeInfo.external(version));
-      }
-    }
-
-    if (property.getValue().isNull()) {
-      writer.writeAttribute(Constants.PREFIX_METADATA, version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA),
-          Constants.ATTR_NULL, Boolean.TRUE.toString());
-    } else {
-      value(writer, property.getValue());
-      if (property.getValue().isLinkedComplex()) {
-        links(writer, property.getValue().asLinkedComplex().getAssociationLinks());
-        links(writer, property.getValue().asLinkedComplex().getNavigationLinks());
-      }
-    }
-
-    writer.writeEndElement();
-
-    for (Annotation annotation : property.getAnnotations()) {
-      annotation(writer, annotation, property.getName());
-    }
-  }
-
-  private void property(final XMLStreamWriter writer, final Property property) throws XMLStreamException {
-    property(writer, property, true);
-  }
-
-  private void startDocument(final XMLStreamWriter writer, final String rootElement) throws XMLStreamException {
-    writer.writeStartDocument();
-    writer.setDefaultNamespace(Constants.NS_ATOM);
-
-    writer.writeStartElement(rootElement);
-
-    namespaces(writer);
-  }
-
-  private void property(final Writer outWriter, final Property property) throws XMLStreamException {
-    final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
-
-    writer.writeStartDocument();
-
-    property(writer, property);
-
-    writer.writeEndDocument();
-    writer.flush();
-  }
-
-  private void links(final XMLStreamWriter writer, final List<Link> links) throws XMLStreamException {
-    for (Link link : links) {
-      writer.writeStartElement(Constants.ATOM_ELEM_LINK);
-
-      if (StringUtils.isNotBlank(link.getRel())) {
-        writer.writeAttribute(Constants.ATTR_REL, link.getRel());
-      }
-      if (StringUtils.isNotBlank(link.getTitle())) {
-        writer.writeAttribute(Constants.ATTR_TITLE, link.getTitle());
-      }
-      if (StringUtils.isNotBlank(link.getHref())) {
-        writer.writeAttribute(Constants.ATTR_HREF, link.getHref());
-      }
-      if (StringUtils.isNotBlank(link.getType())) {
-        writer.writeAttribute(Constants.ATTR_TYPE, link.getType());
-      }
-
-      if (link.getInlineEntity() != null || link.getInlineEntitySet() != null) {
-        writer.writeStartElement(Constants.PREFIX_METADATA, Constants.ATOM_ELEM_INLINE,
-            version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA));
-
-        if (link.getInlineEntity() != null) {
-          writer.writeStartElement(Constants.ATOM_ELEM_ENTRY);
-          entity(writer, link.getInlineEntity());
-          writer.writeEndElement();
-        }
-        if (link.getInlineEntitySet() != null) {
-          writer.writeStartElement(Constants.ATOM_ELEM_FEED);
-          entitySet(writer, link.getInlineEntitySet());
-          writer.writeEndElement();
-        }
-
-        writer.writeEndElement();
-      }
-
-      for (Annotation annotation : link.getAnnotations()) {
-        annotation(writer, annotation, null);
-      }
-
-      writer.writeEndElement();
-    }
-  }
-
-  private void common(final XMLStreamWriter writer, final AbstractODataObject object) throws XMLStreamException {
-    if (StringUtils.isNotBlank(object.getTitle())) {
-      writer.writeStartElement(Constants.ATOM_ELEM_TITLE);
-      writer.writeAttribute(Constants.ATTR_TYPE, TYPE_TEXT);
-      writer.writeCharacters(object.getTitle());
-      writer.writeEndElement();
-    }
-  }
-
-  private void properties(final XMLStreamWriter writer, final List<Property> properties) throws XMLStreamException {
-    for (Property property : properties) {
-      property(writer, property, false);
-    }
-  }
-
-  private void annotation(final XMLStreamWriter writer, final Annotation annotation, final String target)
-      throws XMLStreamException {
-
-    writer.writeStartElement(Constants.PREFIX_METADATA, Constants.ANNOTATION,
-        version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA));
-
-    writer.writeAttribute(Constants.ATOM_ATTR_TERM, annotation.getTerm());
-
-    if (target != null) {
-      writer.writeAttribute(Constants.ATTR_TARGET, target);
-    }
-
-    if (StringUtils.isNotBlank(annotation.getType())) {
-      final EdmTypeInfo typeInfo = new EdmTypeInfo.Builder().setTypeExpression(annotation.getType()).build();
-      if (!EdmPrimitiveTypeKind.String.getFullQualifiedName().toString().equals(typeInfo.internal())) {
-        writer.writeAttribute(Constants.PREFIX_METADATA, version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA),
-            Constants.ATTR_TYPE, typeInfo.external(version));
-      }
-    }
-
-    if (annotation.getValue().isNull()) {
-      writer.writeAttribute(Constants.PREFIX_METADATA, version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA),
-          Constants.ATTR_NULL, Boolean.TRUE.toString());
-    } else {
-      value(writer, annotation.getValue());
-    }
-
-    writer.writeEndElement();
-  }
-
-  private void entity(final XMLStreamWriter writer, final Entity entity) throws XMLStreamException {
-    if (entity.getBaseURI() != null) {
-      writer.writeAttribute(XMLConstants.XML_NS_URI, Constants.ATTR_XML_BASE, entity.getBaseURI().toASCIIString());
-    }
-
-    if (serverMode && StringUtils.isNotBlank(entity.getETag())) {
-      writer.writeAttribute(
-          version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA),
-          Constants.ATOM_ATTR_ETAG, entity.getETag());
-    }
-
-    if (entity.getId() != null) {
-      writer.writeStartElement(Constants.ATOM_ELEM_ID);
-      writer.writeCharacters(entity.getId().toASCIIString());
-      writer.writeEndElement();
-    }
-
-    writer.writeStartElement(Constants.ATOM_ELEM_CATEGORY);
-    writer.writeAttribute(Constants.ATOM_ATTR_SCHEME, version.getNamespaceMap().get(ODataServiceVersion.NS_SCHEME));
-    if (StringUtils.isNotBlank(entity.getType())) {
-      writer.writeAttribute(Constants.ATOM_ATTR_TERM,
-          new EdmTypeInfo.Builder().setTypeExpression(entity.getType()).build().external(version));
-    }
-    writer.writeEndElement();
-
-    if (entity instanceof AbstractODataObject) {
-      common(writer, (AbstractODataObject) entity);
-    }
-
-    if (serverMode) {
-      if (entity.getEditLink() != null) {
-        links(writer, Collections.singletonList(entity.getEditLink()));
-      }
-
-      if (entity.getSelfLink() != null) {
-        links(writer, Collections.singletonList(entity.getSelfLink()));
-      }
-    }
-
-    links(writer, entity.getAssociationLinks());
-    links(writer, entity.getNavigationLinks());
-    links(writer, entity.getMediaEditLinks());
-
-    if (serverMode) {
-      for (ODataOperation operation : entity.getOperations()) {
-        writer.writeStartElement(
-            version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ELEM_ACTION);
-        writer.writeAttribute(Constants.ATTR_METADATA, operation.getMetadataAnchor());
-        writer.writeAttribute(Constants.ATTR_TITLE, operation.getTitle());
-        writer.writeAttribute(Constants.ATTR_TARGET, operation.getTarget().toASCIIString());
-        writer.writeEndElement();
-      }
-    }
-
-    writer.writeStartElement(Constants.ATOM_ELEM_CONTENT);
-    if (entity.isMediaEntity()) {
-      if (StringUtils.isNotBlank(entity.getMediaContentType())) {
-        writer.writeAttribute(Constants.ATTR_TYPE, entity.getMediaContentType());
-      }
-      if (entity.getMediaContentSource() != null) {
-        writer.writeAttribute(Constants.ATOM_ATTR_SRC, entity.getMediaContentSource().toASCIIString());
-      }
-      writer.writeEndElement();
-
-      writer.writeStartElement(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.PROPERTIES);
-      properties(writer, entity.getProperties());
-    } else {
-      writer.writeAttribute(Constants.ATTR_TYPE, ContentType.APPLICATION_XML);
-      writer.writeStartElement(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.PROPERTIES);
-      properties(writer, entity.getProperties());
-      writer.writeEndElement();
-    }
-    writer.writeEndElement();
-
-    for (Annotation annotation : entity.getAnnotations()) {
-      annotation(writer, annotation, null);
-    }
-  }
-
-  private void entityRef(final XMLStreamWriter writer, final Entity entity) throws XMLStreamException {
-    writer.writeStartElement(Constants.ATOM_ELEM_ENTRY_REF);
-    writer.writeNamespace(StringUtils.EMPTY, version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA));
-    writer.writeAttribute(Constants.ATOM_ATTR_ID, entity.getId().toASCIIString());
-  }
-
-  private void entityRef(final XMLStreamWriter writer, final ResWrap<Entity> container) throws XMLStreamException {
-    writer.writeStartElement(Constants.ATOM_ELEM_ENTRY_REF);
-    writer.writeNamespace(StringUtils.EMPTY, version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA));
-    addContextInfo(writer, container);
-    writer.writeAttribute(Constants.ATOM_ATTR_ID, container.getPayload().getId().toASCIIString());
-  }
-
-  private void entity(final Writer outWriter, final Entity entity) throws XMLStreamException {
-    final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
-
-    if (entity.getType() == null && entity.getProperties().isEmpty()) {
-      writer.writeStartDocument();
-      writer.setDefaultNamespace(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA));
-
-      entityRef(writer, entity);
-    } else {
-      startDocument(writer, Constants.ATOM_ELEM_ENTRY);
-
-      entity(writer, entity);
-    }
-
-    writer.writeEndElement();
-    writer.writeEndDocument();
-    writer.flush();
-  }
-
-  private void entity(final Writer outWriter, final ResWrap<Entity> container) throws XMLStreamException {
-    final Entity entity = container.getPayload();
-
-    final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
-
-    if (entity.getType() == null && entity.getProperties().isEmpty()) {
-      writer.writeStartDocument();
-      writer.setDefaultNamespace(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA));
-
-      entityRef(writer, container);
-    } else {
-      startDocument(writer, Constants.ATOM_ELEM_ENTRY);
-
-      addContextInfo(writer, container);
-
-      entity(writer, entity);
-    }
-
-    writer.writeEndElement();
-    writer.writeEndDocument();
-    writer.flush();
-  }
-
-  private void entitySet(final XMLStreamWriter writer, final EntitySet entitySet) throws XMLStreamException {
-    if (entitySet.getBaseURI() != null) {
-      writer.writeAttribute(XMLConstants.XML_NS_URI, Constants.ATTR_XML_BASE, entitySet.getBaseURI().toASCIIString());
-    }
-
-    if (entitySet.getCount() != null) {
-      writer.writeStartElement(
-          version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ELEM_COUNT);
-      writer.writeCharacters(Integer.toString(entitySet.getCount()));
-      writer.writeEndElement();
-    }
-
-    if (entitySet.getId() != null) {
-      writer.writeStartElement(Constants.ATOM_ELEM_ID);
-      writer.writeCharacters(entitySet.getId().toASCIIString());
-      writer.writeEndElement();
-    }
-
-    if (entitySet instanceof AbstractODataObject) {
-      common(writer, (AbstractODataObject) entitySet);
-    }
-
-    for (Entity entity : entitySet.getEntities()) {
-      if (entity.getType() == null && entity.getProperties().isEmpty()) {
-        entityRef(writer, entity);
-        writer.writeEndElement();
-      } else {
-        writer.writeStartElement(Constants.ATOM_ELEM_ENTRY);
-        entity(writer, entity);
-        writer.writeEndElement();
-      }
-    }
-
-    if (serverMode) {
-      if (entitySet.getNext() != null) {
-        final LinkImpl next = new LinkImpl();
-        next.setRel(Constants.NEXT_LINK_REL);
-        next.setHref(entitySet.getNext().toASCIIString());
-
-        links(writer, Collections.<Link> singletonList(next));
-      }
-      if (entitySet.getDeltaLink() != null) {
-        final LinkImpl next = new LinkImpl();
-        next.setRel(Constants.DELTA_LINK_REL);
-        next.setHref(entitySet.getDeltaLink().toASCIIString());
-
-        links(writer, Collections.<Link> singletonList(next));
-      }
-    }
-  }
-
-  private void entitySet(final Writer outWriter, final EntitySet entitySet) throws XMLStreamException {
-    final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
-
-    startDocument(writer, Constants.ATOM_ELEM_FEED);
-
-    entitySet(writer, entitySet);
-
-    writer.writeEndElement();
-    writer.writeEndDocument();
-    writer.flush();
-  }
-
-  private void entitySet(final Writer outWriter, final ResWrap<EntitySet> entitySet) throws XMLStreamException {
-    final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
-
-    startDocument(writer, Constants.ATOM_ELEM_FEED);
-
-    addContextInfo(writer, entitySet);
-
-    entitySet(writer, entitySet.getPayload());
-
-    writer.writeEndElement();
-    writer.writeEndDocument();
-    writer.flush();
-  }
-
-  private void link(final Writer outWriter, final Link link) throws XMLStreamException {
-    final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
-
-    writer.writeStartDocument();
-
-    writer.writeStartElement(Constants.ELEM_LINKS);
-    writer.writeDefaultNamespace(version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES));
-
-    writer.writeStartElement(Constants.ELEM_URI);
-    writer.writeCharacters(link.getHref());
-    writer.writeEndElement();
-
-    writer.writeEndElement();
-
-    writer.writeEndDocument();
-    writer.flush();
-  }
-
-  public <T> void write(final Writer writer, final T obj) throws ODataSerializerException {
-    try {
-      if (obj instanceof EntitySet) {
-        entitySet(writer, (EntitySet) obj);
-      } else if (obj instanceof Entity) {
-        entity(writer, (Entity) obj);
-      } else if (obj instanceof Property) {
-        property(writer, (Property) obj);
-      } else if (obj instanceof Link) {
-        link(writer, (Link) obj);
-      }
-    } catch (final XMLStreamException e) {
-      throw new ODataSerializerException(e);
-    }
-  }
-
-  @SuppressWarnings("unchecked")
-  public <T> void write(final Writer writer, final ResWrap<T> container) throws ODataSerializerException {
-    final T obj = container == null ? null : container.getPayload();
-
-    try {
-      if (obj instanceof EntitySet) {
-        this.entitySet(writer, (ResWrap<EntitySet>) container);
-      } else if (obj instanceof Entity) {
-        entity(writer, (ResWrap<Entity>) container);
-      } else if (obj instanceof Property) {
-        property(writer, (Property) obj);
-      } else if (obj instanceof Link) {
-        link(writer, (Link) obj);
-      }
-    } catch (final XMLStreamException e) {
-      throw new ODataSerializerException(e);
-    }
-  }
-
-  private <T> void addContextInfo(
-      final XMLStreamWriter writer, final ResWrap<T> container) throws XMLStreamException {
-
-    if (container.getContextURL() != null) {
-      String base = container.getContextURL().getServiceRoot().toASCIIString();
-      if (container.getPayload() instanceof EntitySet) {
-        ((EntitySetImpl) container.getPayload()).setBaseURI(base);
-      }
-      if (container.getPayload() instanceof Entity) {
-        ((EntityImpl) container.getPayload()).setBaseURI(base);
-      }
-
-      writer.writeAttribute(
-          version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA),
-          Constants.CONTEXT,
-          container.getContextURL().getURI().toASCIIString());
-    }
-
-    if (StringUtils.isNotBlank(container.getMetadataETag())) {
-      writer.writeAttribute(
-          version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA),
-          Constants.ATOM_ATTR_METADATAETAG,
-          container.getMetadataETag());
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONDeltaDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONDeltaDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONDeltaDeserializer.java
deleted file mode 100644
index 9ca82f1..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONDeltaDeserializer.java
+++ /dev/null
@@ -1,100 +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.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.util.Iterator;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.ContextURL;
-import org.apache.olingo.commons.api.data.Delta;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
-import org.apache.olingo.commons.core.data.v4.DeltaImpl;
-
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-public class JSONDeltaDeserializer extends JsonDeserializer {
-
-  public JSONDeltaDeserializer(final ODataServiceVersion version, final boolean serverMode) {
-    super(version, serverMode);
-  }
-
-  protected ResWrap<Delta> doDeserialize(final JsonParser parser) throws IOException {
-
-    final ObjectNode tree = parser.getCodec().readTree(parser);
-
-    final DeltaImpl delta = new DeltaImpl();
-
-    final URI contextURL = tree.hasNonNull(Constants.JSON_CONTEXT) ?
-        URI.create(tree.get(Constants.JSON_CONTEXT).textValue()) : null;
-    if (contextURL != null) {
-      delta.setBaseURI(StringUtils.substringBefore(contextURL.toASCIIString(), Constants.METADATA));
-    }
-
-    if (tree.hasNonNull(jsonCount)) {
-      delta.setCount(tree.get(jsonCount).asInt());
-    }
-    if (tree.hasNonNull(jsonNextLink)) {
-      delta.setNext(URI.create(tree.get(jsonNextLink).textValue()));
-    }
-    if (tree.hasNonNull(jsonDeltaLink)) {
-      delta.setDeltaLink(URI.create(tree.get(jsonDeltaLink).textValue()));
-    }
-
-    if (tree.hasNonNull(Constants.VALUE)) {
-      JSONEntityDeserializer entityDeserializer = new JSONEntityDeserializer(version, serverMode);
-      for (final Iterator<JsonNode> itor = tree.get(Constants.VALUE).iterator(); itor.hasNext();) {
-        final ObjectNode item = (ObjectNode) itor.next();
-        final ContextURL itemContextURL = item.hasNonNull(Constants.JSON_CONTEXT)
-            ? ContextURL.getInstance(URI.create(item.get(Constants.JSON_CONTEXT).textValue())) : null;
-        item.remove(Constants.JSON_CONTEXT);
-
-        if (itemContextURL == null || itemContextURL.isEntity()) {
-          delta.getEntities().add(entityDeserializer.doDeserialize(item.traverse(parser.getCodec())).getPayload());
-        } else if (itemContextURL.isDeltaDeletedEntity()) {
-          delta.getDeletedEntities().add(parser.getCodec().treeToValue(item, DeletedEntityImpl.class));
-        } else if (itemContextURL.isDeltaLink()) {
-          delta.getAddedLinks().add(parser.getCodec().treeToValue(item, DeltaLinkImpl.class));
-        } else if (itemContextURL.isDeltaDeletedLink()) {
-          delta.getDeletedLinks().add(parser.getCodec().treeToValue(item, DeltaLinkImpl.class));
-        }
-      }
-    }
-
-    return new ResWrap<Delta>(contextURL, null, delta);
-  }
-
-  public ResWrap<Delta> toDelta(InputStream input) throws ODataDeserializerException {
-    try {
-      JsonParser parser = new JsonFactory(new ObjectMapper()).createParser(input);
-      return doDeserialize(parser);
-    } catch (final IOException e) {
-      throw new ODataDeserializerException(e);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntityDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntityDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntityDeserializer.java
deleted file mode 100644
index 00f0d3f..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntityDeserializer.java
+++ /dev/null
@@ -1,220 +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.io.IOException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Matcher;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.Annotation;
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.Link;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.domain.ODataLinkType;
-import org.apache.olingo.commons.api.domain.ODataOperation;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.core.edm.EdmTypeInfo;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Reads JSON string into an entity.
- * <br/>
- * If metadata information is available, the corresponding entity fields and content will be populated.
- */
-public class JSONEntityDeserializer extends JsonDeserializer {
-
-  public JSONEntityDeserializer(final ODataServiceVersion version, final boolean serverMode) {
-    super(version, serverMode);
-  }
-
-  protected ResWrap<Entity> doDeserialize(final JsonParser parser) throws IOException {
-
-    final ObjectNode tree = parser.getCodec().readTree(parser);
-
-    if (tree.has(Constants.VALUE) && tree.get(Constants.VALUE).isArray()) {
-      throw new JsonParseException("Expected OData Entity, found EntitySet", parser.getCurrentLocation());
-    }
-
-    final EntityImpl entity = new EntityImpl();
-
-    final URI contextURL;
-    if (tree.hasNonNull(Constants.JSON_CONTEXT)) {
-      contextURL = URI.create(tree.get(Constants.JSON_CONTEXT).textValue());
-      tree.remove(Constants.JSON_CONTEXT);
-    } else if (tree.hasNonNull(Constants.JSON_METADATA)) {
-      contextURL = URI.create(tree.get(Constants.JSON_METADATA).textValue());
-      tree.remove(Constants.JSON_METADATA);
-    } else {
-      contextURL = null;
-    }
-    if (contextURL != null) {
-      entity.setBaseURI(StringUtils.substringBefore(contextURL.toASCIIString(), Constants.METADATA));
-    }
-
-    final String metadataETag;
-    if (tree.hasNonNull(Constants.JSON_METADATA_ETAG)) {
-      metadataETag = tree.get(Constants.JSON_METADATA_ETAG).textValue();
-      tree.remove(Constants.JSON_METADATA_ETAG);
-    } else {
-      metadataETag = null;
-    }
-
-    if (tree.hasNonNull(jsonETag)) {
-      entity.setETag(tree.get(jsonETag).textValue());
-      tree.remove(jsonETag);
-    }
-
-    if (tree.hasNonNull(jsonType)) {
-      entity.setType(new EdmTypeInfo.Builder().setTypeExpression(tree.get(jsonType).textValue()).build().internal());
-      tree.remove(jsonType);
-    }
-
-    if (tree.hasNonNull(jsonId)) {
-      entity.setId(URI.create(tree.get(jsonId).textValue()));
-      tree.remove(jsonId);
-    }
-
-    if (tree.hasNonNull(jsonReadLink)) {
-      final LinkImpl link = new LinkImpl();
-      link.setRel(Constants.SELF_LINK_REL);
-      link.setHref(tree.get(jsonReadLink).textValue());
-      entity.setSelfLink(link);
-
-      tree.remove(jsonReadLink);
-    }
-
-    if (tree.hasNonNull(jsonEditLink)) {
-      final LinkImpl link = new LinkImpl();
-      if (serverMode) {
-        link.setRel(Constants.EDIT_LINK_REL);
-      }
-      link.setHref(tree.get(jsonEditLink).textValue());
-      entity.setEditLink(link);
-
-      tree.remove(jsonEditLink);
-    }
-
-    if (tree.hasNonNull(jsonMediaReadLink)) {
-      entity.setMediaContentSource(URI.create(tree.get(jsonMediaReadLink).textValue()));
-      tree.remove(jsonMediaReadLink);
-    }
-    if (tree.hasNonNull(jsonMediaEditLink)) {
-      entity.setMediaContentSource(URI.create(tree.get(jsonMediaEditLink).textValue()));
-      tree.remove(jsonMediaEditLink);
-    }
-    if (tree.hasNonNull(jsonMediaContentType)) {
-      entity.setMediaContentType(tree.get(jsonMediaContentType).textValue());
-      tree.remove(jsonMediaContentType);
-    }
-    if (tree.hasNonNull(jsonMediaETag)) {
-      entity.setMediaETag(tree.get(jsonMediaETag).textValue());
-      tree.remove(jsonMediaETag);
-    }
-
-    final Set<String> toRemove = new HashSet<String>();
-
-    final Map<String, List<Annotation>> annotations = new HashMap<String, List<Annotation>>();
-    for (final Iterator<Map.Entry<String, JsonNode>> itor = tree.fields(); itor.hasNext();) {
-      final Map.Entry<String, JsonNode> field = itor.next();
-      final Matcher customAnnotation = CUSTOM_ANNOTATION.matcher(field.getKey());
-
-      links(field, entity, toRemove, tree, parser.getCodec());
-      if (field.getKey().endsWith(getJSONAnnotation(jsonMediaEditLink))) {
-        final LinkImpl link = new LinkImpl();
-        link.setTitle(getTitle(field));
-        link.setRel(version.getNamespaceMap().get(ODataServiceVersion.MEDIA_EDIT_LINK_REL) + getTitle(field));
-        link.setHref(field.getValue().textValue());
-        link.setType(ODataLinkType.MEDIA_EDIT.toString());
-        entity.getMediaEditLinks().add(link);
-
-        if (tree.has(link.getTitle() + getJSONAnnotation(jsonMediaETag))) {
-          link.setMediaETag(tree.get(link.getTitle() + getJSONAnnotation(jsonMediaETag)).asText());
-          toRemove.add(link.getTitle() + getJSONAnnotation(jsonMediaETag));
-        }
-
-        toRemove.add(field.getKey());
-        toRemove.add(setInline(field.getKey(), getJSONAnnotation(jsonMediaEditLink), tree, parser.getCodec(), link));
-      } else if (field.getKey().endsWith(getJSONAnnotation(jsonMediaContentType))) {
-        final String linkTitle = getTitle(field);
-        for (Link link : entity.getMediaEditLinks()) {
-          if (linkTitle.equals(link.getTitle())) {
-            ((LinkImpl) link).setType(field.getValue().asText());
-          }
-        }
-        toRemove.add(field.getKey());
-      } else if (field.getKey().charAt(0) == '#') {
-        final ODataOperation operation = new ODataOperation();
-        operation.setMetadataAnchor(field.getKey());
-
-        final ObjectNode opNode = (ObjectNode) tree.get(field.getKey());
-        operation.setTitle(opNode.get(Constants.ATTR_TITLE).asText());
-        operation.setTarget(URI.create(opNode.get(Constants.ATTR_TARGET).asText()));
-
-        entity.getOperations().add(operation);
-
-        toRemove.add(field.getKey());
-      } else if (customAnnotation.matches() && !"odata".equals(customAnnotation.group(2))) {
-        final Annotation annotation = new AnnotationImpl();
-        annotation.setTerm(customAnnotation.group(2) + "." + customAnnotation.group(3));
-        value(annotation, field.getValue(), parser.getCodec());
-
-        if (!annotations.containsKey(customAnnotation.group(1))) {
-          annotations.put(customAnnotation.group(1), new ArrayList<Annotation>());
-        }
-        annotations.get(customAnnotation.group(1)).add(annotation);
-      }
-    }
-
-    for (Link link : entity.getNavigationLinks()) {
-      if (annotations.containsKey(link.getTitle())) {
-        link.getAnnotations().addAll(annotations.get(link.getTitle()));
-        for (Annotation annotation : annotations.get(link.getTitle())) {
-          toRemove.add(link.getTitle() + "@" + annotation.getTerm());
-        }
-      }
-    }
-    for (Link link : entity.getMediaEditLinks()) {
-      if (annotations.containsKey(link.getTitle())) {
-        link.getAnnotations().addAll(annotations.get(link.getTitle()));
-        for (Annotation annotation : annotations.get(link.getTitle())) {
-          toRemove.add(link.getTitle() + "@" + annotation.getTerm());
-        }
-      }
-    }
-
-    tree.remove(toRemove);
-
-    populate(entity, entity.getProperties(), tree, parser.getCodec());
-
-    return new ResWrap<Entity>(contextURL, metadataETag, entity);
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySerializer.java
deleted file mode 100644
index 36e7ae1..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySerializer.java
+++ /dev/null
@@ -1,129 +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.io.IOException;
-import java.net.URI;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.Annotation;
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.Link;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.domain.ODataOperation;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.core.edm.EdmTypeInfo;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-
-/**
- * Writes out JSON string from an entity.
- */
-public class JSONEntitySerializer extends JsonSerializer {
-
-  public JSONEntitySerializer(final ODataServiceVersion version, final boolean serverMode) {
-    super(version, serverMode);
-  }
-
-  protected void doSerialize(final Entity entity, final JsonGenerator jgen) throws IOException {
-    doContainerSerialize(new ResWrap<Entity>((URI) null, null, entity), jgen);
-  }
-
-  protected void doContainerSerialize(final ResWrap<Entity> container, final JsonGenerator jgen)
-      throws IOException {
-
-    final Entity entity = container.getPayload();
-
-    jgen.writeStartObject();
-
-    if (serverMode) {
-      if (container.getContextURL() != null) {
-        jgen.writeStringField(version.compareTo(ODataServiceVersion.V40) >= 0
-            ? Constants.JSON_CONTEXT : Constants.JSON_METADATA,
-            container.getContextURL().getURI().toASCIIString());
-      }
-      if (version.compareTo(ODataServiceVersion.V40) >= 0 && StringUtils.isNotBlank(container.getMetadataETag())) {
-        jgen.writeStringField(Constants.JSON_METADATA_ETAG, container.getMetadataETag());
-      }
-
-      if (StringUtils.isNotBlank(entity.getETag())) {
-        jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_ETAG), entity.getETag());
-      }
-    }
-
-    if (StringUtils.isNotBlank(entity.getType())) {
-      jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_TYPE),
-          new EdmTypeInfo.Builder().setTypeExpression(entity.getType()).build().external(version));
-    }
-
-    if (entity.getId() != null) {
-      jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_ID), entity.getId().toASCIIString());
-    }
-
-    for (Annotation annotation : entity.getAnnotations()) {
-      valuable(jgen, annotation, "@" + annotation.getTerm());
-    }
-
-    for (Property property : entity.getProperties()) {
-      valuable(jgen, property, property.getName());
-    }
-
-    if (serverMode && entity.getEditLink() != null && StringUtils.isNotBlank(entity.getEditLink().getHref())) {
-      jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_EDIT_LINK),
-          entity.getEditLink().getHref());
-
-      if (entity.isMediaEntity()) {
-        jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_MEDIAREAD_LINK),
-            entity.getEditLink().getHref() + "/$value");
-      }
-    }
-
-    links(entity, jgen);
-
-    for (Link link : entity.getMediaEditLinks()) {
-      if (link.getTitle() == null) {
-        jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK), link.getHref());
-      }
-
-      if (link.getInlineEntity() != null) {
-        jgen.writeObjectField(link.getTitle(), link.getInlineEntity());
-      }
-      if (link.getInlineEntitySet() != null) {
-        jgen.writeArrayFieldStart(link.getTitle());
-        for (Entity subEntry : link.getInlineEntitySet().getEntities()) {
-          jgen.writeObject(subEntry);
-        }
-        jgen.writeEndArray();
-      }
-    }
-
-    if (serverMode) {
-      for (ODataOperation operation : entity.getOperations()) {
-        jgen.writeObjectFieldStart("#" + StringUtils.substringAfterLast(operation.getMetadataAnchor(), "#"));
-        jgen.writeStringField(Constants.ATTR_TITLE, operation.getTitle());
-        jgen.writeStringField(Constants.ATTR_TARGET, operation.getTarget().toASCIIString());
-        jgen.writeEndObject();
-      }
-    }
-
-    jgen.writeEndObject();
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetDeserializer.java
deleted file mode 100644
index e4cd3ab..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetDeserializer.java
+++ /dev/null
@@ -1,116 +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.io.IOException;
-import java.net.URI;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.Annotation;
-import org.apache.olingo.commons.api.data.EntitySet;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Reads JSON string into an entity set.
- * <br/>
- * If metadata information is available, the corresponding entity fields and content will be populated.
- */
-public class JSONEntitySetDeserializer extends JsonDeserializer {
-
-  public JSONEntitySetDeserializer(final ODataServiceVersion version, final boolean serverMode) {
-    super(version, serverMode);
-  }
-
-  protected ResWrap<EntitySet> doDeserialize(final JsonParser parser) throws IOException {
-
-    final ObjectNode tree = (ObjectNode) parser.getCodec().readTree(parser);
-
-    if (!tree.has(Constants.VALUE)) {
-      return null;
-    }
-
-    final EntitySetImpl entitySet = new EntitySetImpl();
-
-    URI contextURL;
-    if (tree.hasNonNull(Constants.JSON_CONTEXT)) {
-      contextURL = URI.create(tree.get(Constants.JSON_CONTEXT).textValue());
-      tree.remove(Constants.JSON_CONTEXT);
-    } else if (tree.hasNonNull(Constants.JSON_METADATA)) {
-      contextURL = URI.create(tree.get(Constants.JSON_METADATA).textValue());
-      tree.remove(Constants.JSON_METADATA);
-    } else {
-      contextURL = null;
-    }
-    if (contextURL != null) {
-      entitySet.setBaseURI(StringUtils.substringBefore(contextURL.toASCIIString(), Constants.METADATA));
-    }
-
-    final String metadataETag;
-    if (tree.hasNonNull(Constants.JSON_METADATA_ETAG)) {
-      metadataETag = tree.get(Constants.JSON_METADATA_ETAG).textValue();
-      tree.remove(Constants.JSON_METADATA_ETAG);
-    } else {
-      metadataETag = null;
-    }
-
-    if (tree.hasNonNull(jsonCount)) {
-      entitySet.setCount(tree.get(jsonCount).asInt());
-      tree.remove(jsonCount);
-    }
-    if (tree.hasNonNull(jsonNextLink)) {
-      entitySet.setNext(URI.create(tree.get(jsonNextLink).textValue()));
-      tree.remove(jsonNextLink);
-    }
-    if (tree.hasNonNull(jsonDeltaLink)) {
-      entitySet.setDeltaLink(URI.create(tree.get(jsonDeltaLink).textValue()));
-      tree.remove(jsonDeltaLink);
-    }
-
-    if (tree.hasNonNull(Constants.VALUE)) {
-      final JSONEntityDeserializer entityDeserializer = new JSONEntityDeserializer(version, serverMode);
-      for (final Iterator<JsonNode> itor = tree.get(Constants.VALUE).iterator(); itor.hasNext();) {
-        entitySet.getEntities().add(
-            entityDeserializer.doDeserialize(itor.next().traverse(parser.getCodec())).getPayload());
-      }
-      tree.remove(Constants.VALUE);
-    }
-
-    // any remaining entry is supposed to be an annotation or is ignored
-    for (final Iterator<Map.Entry<String, JsonNode>> itor = tree.fields(); itor.hasNext();) {
-      final Map.Entry<String, JsonNode> field = itor.next();
-      if (field.getKey().charAt(0) == '@') {
-        final Annotation annotation = new AnnotationImpl();
-        annotation.setTerm(field.getKey().substring(1));
-
-        value(annotation, field.getValue(), parser.getCodec());
-        entitySet.getAnnotations().add(annotation);
-      }
-    }
-
-    return new ResWrap<EntitySet>(contextURL, metadataETag, entitySet);
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetSerializer.java
deleted file mode 100644
index 1670259..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetSerializer.java
+++ /dev/null
@@ -1,94 +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.io.IOException;
-import java.net.URI;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.Annotation;
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-
-public class JSONEntitySetSerializer extends JsonSerializer {
-
-  public JSONEntitySetSerializer(final ODataServiceVersion version, final boolean serverMode) {
-    super(version, serverMode);
-  }
-
-  protected void doSerialize(final EntitySet entitySet, final JsonGenerator jgen) throws IOException {
-    doContainerSerialize(new ResWrap<EntitySet>((URI) null, null, entitySet), jgen);
-  }
-
-  protected void doContainerSerialize(final ResWrap<EntitySet> container, final JsonGenerator jgen)
-      throws IOException {
-
-    final EntitySet entitySet = container.getPayload();
-
-    jgen.writeStartObject();
-
-    if (serverMode) {
-      if (container.getContextURL() != null) {
-        jgen.writeStringField(version.compareTo(ODataServiceVersion.V40) >= 0
-            ? Constants.JSON_CONTEXT : Constants.JSON_METADATA,
-            container.getContextURL().getURI().toASCIIString());
-      }
-
-      if (version.compareTo(ODataServiceVersion.V40) >= 0 && StringUtils.isNotBlank(container.getMetadataETag())) {
-        jgen.writeStringField(
-            Constants.JSON_METADATA_ETAG,
-            container.getMetadataETag());
-      }
-    }
-
-    if (entitySet.getId() != null) {
-      jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_ID), entitySet.getId().toASCIIString());
-    }
-    jgen.writeNumberField(version.getJSONMap().get(ODataServiceVersion.JSON_COUNT),
-        entitySet.getCount() == null ? entitySet.getEntities().size() : entitySet.getCount());
-    if (serverMode) {
-      if (entitySet.getNext() != null) {
-        jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_NEXT_LINK),
-            entitySet.getNext().toASCIIString());
-      }
-      if (entitySet.getDeltaLink() != null) {
-        jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_DELTA_LINK),
-            entitySet.getDeltaLink().toASCIIString());
-      }
-    }
-
-    for (Annotation annotation : entitySet.getAnnotations()) {
-      valuable(jgen, annotation, "@" + annotation.getTerm());
-    }
-
-    jgen.writeArrayFieldStart(Constants.VALUE);
-    final JSONEntitySerializer entitySerializer = new JSONEntitySerializer(version, serverMode);
-    for (Entity entity : entitySet.getEntities()) {
-      entitySerializer.doSerialize(entity, jgen);
-    }
-    jgen.writeEndArray();
-
-    jgen.writeEndObject();
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONGeoValueDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONGeoValueDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONGeoValueDeserializer.java
deleted file mode 100644
index d645587..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONGeoValueDeserializer.java
+++ /dev/null
@@ -1,267 +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 com.fasterxml.jackson.databind.JsonNode;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.GeoUtils;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.api.edm.geo.Geospatial;
-import org.apache.olingo.commons.api.edm.geo.GeospatialCollection;
-import org.apache.olingo.commons.api.edm.geo.LineString;
-import org.apache.olingo.commons.api.edm.geo.MultiLineString;
-import org.apache.olingo.commons.api.edm.geo.MultiPoint;
-import org.apache.olingo.commons.api.edm.geo.MultiPolygon;
-import org.apache.olingo.commons.api.edm.geo.Point;
-import org.apache.olingo.commons.api.edm.geo.Polygon;
-import org.apache.olingo.commons.api.edm.geo.SRID;
-import org.apache.olingo.commons.core.edm.EdmTypeInfo;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmDouble;
-
-class JSONGeoValueDeserializer {
-
-  private final ODataServiceVersion version;
-
-  public JSONGeoValueDeserializer(final ODataServiceVersion version) {
-    this.version = version;
-  }
-
-  private Point point(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type, final SRID srid) {
-    Point point = null;
-
-    if (itor.hasNext()) {
-      point = new Point(GeoUtils.getDimension(type), srid);
-      try {
-        point.setX(EdmDouble.getInstance().valueOfString(itor.next().asText(), null, null,
-                Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, Double.class));
-        point.setY(EdmDouble.getInstance().valueOfString(itor.next().asText(), null, null,
-                Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, Double.class));
-      } catch (EdmPrimitiveTypeException e) {
-        throw new IllegalArgumentException("While deserializing point coordinates as double", e);
-      }
-    }
-
-    return point;
-  }
-
-  private MultiPoint multipoint(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type, final SRID srid) {
-    final MultiPoint multiPoint;
-
-    if (itor.hasNext()) {
-      final List<Point> points = new ArrayList<Point>();
-      while (itor.hasNext()) {
-        final Iterator<JsonNode> mpItor = itor.next().elements();
-        points.add(point(mpItor, type, srid));
-      }
-      multiPoint = new MultiPoint(GeoUtils.getDimension(type), srid, points);
-    } else {
-      multiPoint = new MultiPoint(GeoUtils.getDimension(type), srid, Collections.<Point>emptyList());
-    }
-
-    return multiPoint;
-  }
-
-  private LineString lineString(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type, final SRID srid) {
-    final LineString lineString;
-
-    if (itor.hasNext()) {
-      final List<Point> points = new ArrayList<Point>();
-      while (itor.hasNext()) {
-        final Iterator<JsonNode> mpItor = itor.next().elements();
-        points.add(point(mpItor, type, srid));
-      }
-      lineString = new LineString(GeoUtils.getDimension(type), srid, points);
-    } else {
-      lineString = new LineString(GeoUtils.getDimension(type), srid, Collections.<Point>emptyList());
-    }
-
-    return lineString;
-  }
-
-  private MultiLineString multiLineString(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type,
-          final SRID srid) {
-
-    final MultiLineString multiLineString;
-
-    if (itor.hasNext()) {
-      final List<LineString> lineStrings = new ArrayList<LineString>();
-      while (itor.hasNext()) {
-        final Iterator<JsonNode> mlsItor = itor.next().elements();
-        lineStrings.add(lineString(mlsItor, type, srid));
-      }
-      multiLineString = new MultiLineString(GeoUtils.getDimension(type), srid, lineStrings);
-    } else {
-      multiLineString = new MultiLineString(GeoUtils.getDimension(type), srid, Collections.<LineString>emptyList());
-    }
-
-    return multiLineString;
-  }
-
-  private Polygon polygon(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type, final SRID srid) {
-    List<Point> extPoints = null;
-    if (itor.hasNext()) {
-      final Iterator<JsonNode> extItor = itor.next().elements();
-      if (extItor.hasNext()) {
-        extPoints = new ArrayList<Point>();
-        while (extItor.hasNext()) {
-          final Iterator<JsonNode> mpItor = extItor.next().elements();
-          extPoints.add(point(mpItor, type, srid));
-        }
-      }
-    }
-
-    List<Point> intPoints = null;
-    if (itor.hasNext()) {
-      final Iterator<JsonNode> intItor = itor.next().elements();
-      if (intItor.hasNext()) {
-        intPoints = new ArrayList<Point>();
-        while (intItor.hasNext()) {
-          final Iterator<JsonNode> mpItor = intItor.next().elements();
-          intPoints.add(point(mpItor, type, srid));
-        }
-      }
-    }
-
-    return new Polygon(GeoUtils.getDimension(type), srid, intPoints, extPoints);
-  }
-
-  private MultiPolygon multiPolygon(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type, final SRID srid) {
-    final MultiPolygon multiPolygon;
-
-    if (itor.hasNext()) {
-      final List<Polygon> polygons = new ArrayList<Polygon>();
-      while (itor.hasNext()) {
-        final Iterator<JsonNode> mpItor = itor.next().elements();
-        polygons.add(polygon(mpItor, type, srid));
-      }
-      multiPolygon = new MultiPolygon(GeoUtils.getDimension(type), srid, polygons);
-    } else {
-      multiPolygon = new MultiPolygon(GeoUtils.getDimension(type), srid, Collections.<Polygon>emptyList());
-    }
-
-    return multiPolygon;
-  }
-
-  private GeospatialCollection collection(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type,
-          final SRID srid) {
-
-    final GeospatialCollection collection;
-
-    if (itor.hasNext()) {
-      final List<Geospatial> geospatials = new ArrayList<Geospatial>();
-
-      while (itor.hasNext()) {
-        final JsonNode geo = itor.next();
-        final String collItemType = geo.get(Constants.ATTR_TYPE).asText();
-        final String callAsType;
-        if (EdmPrimitiveTypeKind.GeographyCollection.name().equals(collItemType)
-                || EdmPrimitiveTypeKind.GeometryCollection.name().equals(collItemType)) {
-
-          callAsType = collItemType;
-        } else {
-          callAsType = (type == EdmPrimitiveTypeKind.GeographyCollection ? "Geography" : "Geometry")
-                  + collItemType;
-        }
-
-        geospatials.add(deserialize(geo, new EdmTypeInfo.Builder().setTypeExpression(callAsType).build()));
-      }
-
-      collection = new GeospatialCollection(GeoUtils.getDimension(type), srid, geospatials);
-    } else {
-      collection = new GeospatialCollection(GeoUtils.getDimension(type), srid, Collections.<Geospatial>emptyList());
-    }
-
-    return collection;
-  }
-
-  public Geospatial deserialize(final JsonNode node, final EdmTypeInfo typeInfo) {
-    final EdmPrimitiveTypeKind actualType;
-    if ((typeInfo.getPrimitiveTypeKind() == EdmPrimitiveTypeKind.Geography
-            || typeInfo.getPrimitiveTypeKind() == EdmPrimitiveTypeKind.Geometry)
-            && node.has(Constants.ATTR_TYPE)) {
-
-      String nodeType = node.get(Constants.ATTR_TYPE).asText();
-      if (nodeType.startsWith("Geo")) {
-        final int yIdx = nodeType.indexOf('y');
-        nodeType = nodeType.substring(yIdx + 1);
-      }
-      actualType = EdmPrimitiveTypeKind.valueOfFQN(version, typeInfo.getFullQualifiedName().toString() + nodeType);
-    } else {
-      actualType = typeInfo.getPrimitiveTypeKind();
-    }
-
-    final Iterator<JsonNode> cooItor = node.has(Constants.JSON_COORDINATES)
-            ? node.get(Constants.JSON_COORDINATES).elements()
-            : Collections.<JsonNode>emptyList().iterator();
-
-    SRID srid = null;
-    if (node.has(Constants.JSON_CRS)) {
-      srid = SRID.valueOf(
-              node.get(Constants.JSON_CRS).get(Constants.PROPERTIES).get(Constants.JSON_NAME).asText().split(":")[1]);
-    }
-
-    Geospatial value = null;
-    switch (actualType) {
-      case GeographyPoint:
-      case GeometryPoint:
-        value = point(cooItor, actualType, srid);
-        break;
-
-      case GeographyMultiPoint:
-      case GeometryMultiPoint:
-        value = multipoint(cooItor, actualType, srid);
-        break;
-
-      case GeographyLineString:
-      case GeometryLineString:
-        value = lineString(cooItor, actualType, srid);
-        break;
-
-      case GeographyMultiLineString:
-      case GeometryMultiLineString:
-        value = multiLineString(cooItor, actualType, srid);
-        break;
-
-      case GeographyPolygon:
-      case GeometryPolygon:
-        value = polygon(cooItor, actualType, srid);
-        break;
-
-      case GeographyMultiPolygon:
-      case GeometryMultiPolygon:
-        value = multiPolygon(cooItor, actualType, srid);
-        break;
-
-      case GeographyCollection:
-      case GeometryCollection:
-        value = collection(node.get(Constants.JSON_GEOMETRIES).elements(), actualType, srid);
-        break;
-
-      default:
-    }
-
-    return value;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONGeoValueSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONGeoValueSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONGeoValueSerializer.java
deleted file mode 100644
index 4578e52..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONGeoValueSerializer.java
+++ /dev/null
@@ -1,184 +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 com.fasterxml.jackson.core.JsonGenerator;
-import java.io.IOException;
-import java.util.Iterator;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.geo.ComposedGeospatial;
-import org.apache.olingo.commons.api.edm.geo.Geospatial;
-import org.apache.olingo.commons.api.edm.geo.GeospatialCollection;
-import org.apache.olingo.commons.api.edm.geo.LineString;
-import org.apache.olingo.commons.api.edm.geo.MultiLineString;
-import org.apache.olingo.commons.api.edm.geo.MultiPoint;
-import org.apache.olingo.commons.api.edm.geo.MultiPolygon;
-import org.apache.olingo.commons.api.edm.geo.Point;
-import org.apache.olingo.commons.api.edm.geo.Polygon;
-import org.apache.olingo.commons.api.edm.geo.SRID;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmDouble;
-
-class JSONGeoValueSerializer {
-
-  private void srid(final JsonGenerator jgen, final SRID srid) throws IOException {
-    jgen.writeObjectFieldStart(Constants.JSON_CRS);
-    jgen.writeStringField(Constants.ATTR_TYPE, Constants.JSON_NAME);
-    jgen.writeObjectFieldStart(Constants.PROPERTIES);
-    jgen.writeStringField(Constants.JSON_NAME, "EPSG:" + srid.toString());
-    jgen.writeEndObject();
-    jgen.writeEndObject();
-  }
-
-  private void point(final JsonGenerator jgen, final Point point) throws IOException {
-    try {
-      jgen.writeNumber(EdmDouble.getInstance().valueToString(point.getX(), null, null,
-              Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null));
-      jgen.writeNumber(EdmDouble.getInstance().valueToString(point.getY(), null, null,
-              Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null));
-    } catch (EdmPrimitiveTypeException e) {
-      throw new IllegalArgumentException("While serializing point coordinates as double", e);
-    }
-  }
-
-  private void multipoint(final JsonGenerator jgen, final MultiPoint multiPoint) throws IOException {
-    for (final Iterator<Point> itor = multiPoint.iterator(); itor.hasNext();) {
-      jgen.writeStartArray();
-      point(jgen, itor.next());
-      jgen.writeEndArray();
-    }
-  }
-
-  private void lineString(final JsonGenerator jgen, final ComposedGeospatial<Point> lineString) throws IOException {
-    for (final Iterator<Point> itor = lineString.iterator(); itor.hasNext();) {
-      jgen.writeStartArray();
-      point(jgen, itor.next());
-      jgen.writeEndArray();
-    }
-  }
-
-  private void multiLineString(final JsonGenerator jgen, final MultiLineString multiLineString) throws IOException {
-    for (final Iterator<LineString> itor = multiLineString.iterator(); itor.hasNext();) {
-      jgen.writeStartArray();
-      lineString(jgen, itor.next());
-      jgen.writeEndArray();
-    }
-  }
-
-  private void polygon(final JsonGenerator jgen, final Polygon polygon) throws IOException {
-    if (!polygon.getExterior().isEmpty()) {
-      jgen.writeStartArray();
-      lineString(jgen, polygon.getExterior());
-      jgen.writeEndArray();
-    }
-    if (!polygon.getInterior().isEmpty()) {
-      jgen.writeStartArray();
-      lineString(jgen, polygon.getInterior());
-      jgen.writeEndArray();
-    }
-  }
-
-  private void multiPolygon(final JsonGenerator jgen, final MultiPolygon multiPolygon) throws IOException {
-    for (final Iterator<Polygon> itor = multiPolygon.iterator(); itor.hasNext();) {
-      final Polygon polygon = itor.next();
-      jgen.writeStartArray();
-      polygon(jgen, polygon);
-      jgen.writeEndArray();
-    }
-  }
-
-  private void collection(final JsonGenerator jgen, final GeospatialCollection collection) throws IOException {
-    jgen.writeArrayFieldStart(Constants.JSON_GEOMETRIES);
-    for (final Iterator<Geospatial> itor = collection.iterator(); itor.hasNext();) {
-      jgen.writeStartObject();
-      serialize(jgen, itor.next());
-      jgen.writeEndObject();
-    }
-    jgen.writeEndArray();
-  }
-
-  public void serialize(final JsonGenerator jgen, final Geospatial value) throws IOException {
-    if (value.getEdmPrimitiveTypeKind().equals(EdmPrimitiveTypeKind.GeographyCollection)
-            || value.getEdmPrimitiveTypeKind().equals(EdmPrimitiveTypeKind.GeometryCollection)) {
-
-      jgen.writeStringField(Constants.ATTR_TYPE, EdmPrimitiveTypeKind.GeometryCollection.name());
-    } else {
-      final int yIdx = value.getEdmPrimitiveTypeKind().name().indexOf('y');
-      final String itemType = value.getEdmPrimitiveTypeKind().name().substring(yIdx + 1);
-      jgen.writeStringField(Constants.ATTR_TYPE, itemType);
-    }
-
-    switch (value.getEdmPrimitiveTypeKind()) {
-      case GeographyPoint:
-      case GeometryPoint:
-        jgen.writeArrayFieldStart(Constants.JSON_COORDINATES);
-        point(jgen, (Point) value);
-        jgen.writeEndArray();
-        break;
-
-      case GeographyMultiPoint:
-      case GeometryMultiPoint:
-        jgen.writeArrayFieldStart(Constants.JSON_COORDINATES);
-        multipoint(jgen, (MultiPoint) value);
-        jgen.writeEndArray();
-        break;
-
-      case GeographyLineString:
-      case GeometryLineString:
-        jgen.writeArrayFieldStart(Constants.JSON_COORDINATES);
-        lineString(jgen, (LineString) value);
-        jgen.writeEndArray();
-        break;
-
-      case GeographyMultiLineString:
-      case GeometryMultiLineString:
-        jgen.writeArrayFieldStart(Constants.JSON_COORDINATES);
-        multiLineString(jgen, (MultiLineString) value);
-        jgen.writeEndArray();
-        break;
-
-      case GeographyPolygon:
-      case GeometryPolygon:
-        jgen.writeArrayFieldStart(Constants.JSON_COORDINATES);
-        polygon(jgen, (Polygon) value);
-        jgen.writeEndArray();
-        break;
-
-      case GeographyMultiPolygon:
-      case GeometryMultiPolygon:
-        jgen.writeArrayFieldStart(Constants.JSON_COORDINATES);
-        multiPolygon(jgen, (MultiPolygon) value);
-        jgen.writeEndArray();
-        break;
-
-      case GeographyCollection:
-      case GeometryCollection:
-        collection(jgen, (GeospatialCollection) value);
-        break;
-
-      default:
-    }
-
-    if (value.getSrid() != null && value.getSrid().isNotDefault()) {
-      srid(jgen, value.getSrid());
-    }
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONLinkCollectionDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONLinkCollectionDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONLinkCollectionDeserializer.java
deleted file mode 100755
index 1876b9c..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONLinkCollectionDeserializer.java
+++ /dev/null
@@ -1,80 +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.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.data.v3.LinkCollection;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
-import org.apache.olingo.commons.core.data.v3.LinkCollectionImpl;
-
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-public class JSONLinkCollectionDeserializer extends JsonDeserializer {
-
-  public JSONLinkCollectionDeserializer(final ODataServiceVersion version, final boolean serverMode) {
-    super(version, serverMode);
-  }
-
-  protected ResWrap<LinkCollection> doDeserialize(final JsonParser parser) throws IOException {
-
-    final ObjectNode tree = parser.getCodec().readTree(parser);
-
-    final LinkCollectionImpl links = new LinkCollectionImpl();
-
-    if (tree.hasNonNull("odata.metadata")) {
-      links.setMetadata(URI.create(tree.get("odata.metadata").textValue()));
-    }
-
-    if (tree.hasNonNull(Constants.JSON_URL)) {
-      links.getLinks().add(URI.create(tree.get(Constants.JSON_URL).textValue()));
-    }
-
-    if (tree.hasNonNull(Constants.VALUE)) {
-      for (final JsonNode item : tree.get(Constants.VALUE)) {
-        final URI uri = URI.create(item.get(Constants.JSON_URL).textValue());
-        links.getLinks().add(uri);
-      }
-    }
-
-    if (tree.hasNonNull(jsonNextLink)) {
-      links.setNext(URI.create(tree.get(jsonNextLink).textValue()));
-    }
-
-    return new ResWrap<LinkCollection>((URI) null, null, links);
-  }
-
-  public ResWrap<LinkCollection> toLinkCollection(InputStream input) throws ODataDeserializerException {
-    try {
-      JsonParser parser = new JsonFactory(new ObjectMapper()).createParser(input);
-      return doDeserialize(parser);
-    } catch (final IOException e) {
-      throw new ODataDeserializerException(e);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDeserializer.java
deleted file mode 100644
index 1803c10..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDeserializer.java
+++ /dev/null
@@ -1,86 +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.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-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 com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-public class JSONODataErrorDeserializer extends JsonDeserializer {
-
-  public JSONODataErrorDeserializer(final ODataServiceVersion version, final boolean serverMode) {
-    super(version, serverMode);
-  }
-
-  protected ODataError doDeserialize(final JsonParser parser) throws IOException {
-
-    final ODataErrorImpl error = new ODataErrorImpl();
-
-    final ObjectNode tree = parser.getCodec().readTree(parser);
-    if (tree.has(jsonError)) {
-      final JsonNode errorNode = tree.get(jsonError);
-
-      if (errorNode.has(Constants.ERROR_CODE)) {
-        error.setCode(errorNode.get(Constants.ERROR_CODE).textValue());
-      }
-      if (errorNode.has(Constants.ERROR_MESSAGE)) {
-        final JsonNode message = errorNode.get(Constants.ERROR_MESSAGE);
-        if (message.isValueNode()) {
-          error.setMessage(message.textValue());
-        } else if (message.isObject()) {
-          error.setMessage(message.get(Constants.VALUE).asText());
-        }
-      }
-      if (errorNode.has(Constants.ERROR_TARGET)) {
-        error.setTarget(errorNode.get(Constants.ERROR_TARGET).textValue());
-      }
-      if (errorNode.hasNonNull(Constants.ERROR_DETAILS)) {
-        List<ODataErrorDetail> details = new ArrayList<ODataErrorDetail>();
-        JSONODataErrorDetailDeserializer detailDeserializer =
-            new JSONODataErrorDetailDeserializer(version, serverMode);
-        for (Iterator<JsonNode> itor = errorNode.get(Constants.ERROR_DETAILS).iterator(); itor.hasNext();) {
-          details.add(detailDeserializer.doDeserialize(itor.next().traverse(parser.getCodec()))
-              .getPayload());
-        }
-
-        error.setDetails(details);
-      }
-      if (errorNode.hasNonNull(Constants.ERROR_INNERERROR)) {
-        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);
-        }
-      }
-    }
-
-    return error;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDetailDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDetailDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDetailDeserializer.java
deleted file mode 100644
index 6fe51ce..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDetailDeserializer.java
+++ /dev/null
@@ -1,59 +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.io.IOException;
-import java.net.URI;
-
-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 com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.JsonNode;
-
-public class JSONODataErrorDetailDeserializer extends JsonDeserializer {
-
-  public JSONODataErrorDetailDeserializer(final ODataServiceVersion version, final boolean serverMode) {
-    super(version, serverMode);
-  }
-
-  protected ResWrap<ODataErrorDetail> doDeserialize(final JsonParser parser) throws IOException {
-
-    final ODataErrorDetailImpl error = new ODataErrorDetailImpl();
-    final JsonNode errorNode = parser.getCodec().readTree(parser);
-    if (errorNode.has(Constants.ERROR_CODE)) {
-      error.setCode(errorNode.get(Constants.ERROR_CODE).textValue());
-    }
-    if (errorNode.has(Constants.ERROR_MESSAGE)) {
-      final JsonNode message = errorNode.get(Constants.ERROR_MESSAGE);
-      if (message.isValueNode()) {
-        error.setMessage(message.textValue());
-      } else if (message.isObject()) {
-        error.setMessage(message.get(Constants.VALUE).asText());
-      }
-    }
-    if (errorNode.has(Constants.ERROR_TARGET)) {
-      error.setTarget(errorNode.get(Constants.ERROR_TARGET).textValue());
-    }
-
-    return new ResWrap<ODataErrorDetail>((URI) null, null, error);
-  }
-}


[8/9] [OLINGO-317] Rename and move of some packages and classes

Posted by mi...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityUpdateRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityUpdateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityUpdateRequestImpl.java
index 1165042..7ce5788 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityUpdateRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityUpdateRequestImpl.java
@@ -36,8 +36,8 @@ import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.domain.CommonODataEntity;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
-import org.apache.olingo.commons.api.op.ODataSerializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataSerializerException;
 
 /**
  * This class implements an OData update request.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataPropertyUpdateRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataPropertyUpdateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataPropertyUpdateRequestImpl.java
index 5f9014d..d23c642 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataPropertyUpdateRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataPropertyUpdateRequestImpl.java
@@ -36,8 +36,8 @@ import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.domain.CommonODataProperty;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
-import org.apache.olingo.commons.api.op.ODataSerializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataSerializerException;
 
 /**
  * This class implements an OData update entity property request.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/ODataLinkCreateRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/ODataLinkCreateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/ODataLinkCreateRequestImpl.java
index 293908a..2f43812 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/ODataLinkCreateRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/ODataLinkCreateRequestImpl.java
@@ -34,7 +34,7 @@ import org.apache.olingo.client.core.communication.response.AbstractODataRespons
 import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.commons.api.domain.ODataLink;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.op.ODataSerializerException;
+import org.apache.olingo.commons.api.serialization.ODataSerializerException;
 
 /**
  * This class implements an insert link OData request.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/ODataLinkUpdateRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/ODataLinkUpdateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/ODataLinkUpdateRequestImpl.java
index 5392ac6..59172ec 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/ODataLinkUpdateRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/ODataLinkUpdateRequestImpl.java
@@ -34,7 +34,7 @@ import org.apache.olingo.client.core.communication.response.AbstractODataRespons
 import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.commons.api.domain.ODataLink;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.op.ODataSerializerException;
+import org.apache.olingo.commons.api.serialization.ODataSerializerException;
 
 /**
  * This class implements an update link OData request.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
index 7fcaa65..b6b476e 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
@@ -47,8 +47,8 @@ import org.apache.olingo.commons.api.domain.ODataInvokeResult;
 import org.apache.olingo.commons.api.domain.ODataValue;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
-import org.apache.olingo.commons.api.op.ODataSerializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataSerializerException;
 
 /**
  * This class implements an OData invoke operation request.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntityRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntityRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntityRequestImpl.java
index cecbcd1..f75333e 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntityRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntityRequestImpl.java
@@ -29,7 +29,7 @@ import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.domain.CommonODataEntity;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 
 /**
  * This class implements an OData retrieve query request returning a single entity.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java
index 6e7df50..8013cfd 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java
@@ -29,7 +29,7 @@ import org.apache.olingo.commons.api.data.EntitySet;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 
 /**
  * This class implements an OData EntitySet query request.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataPropertyRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataPropertyRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataPropertyRequestImpl.java
index c409d99..3d0b64f 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataPropertyRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataPropertyRequestImpl.java
@@ -28,7 +28,7 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataProperty
 import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
 import org.apache.olingo.commons.api.domain.CommonODataProperty;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 import org.apache.olingo.client.api.http.HttpClientException;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.data.Property;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataRawRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataRawRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataRawRequestImpl.java
index b2632b7..070f59f 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataRawRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataRawRequestImpl.java
@@ -33,7 +33,7 @@ import org.apache.olingo.client.core.communication.request.AbstractODataRequest;
 import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 
 /**
  * This class implements a generic OData request.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataServiceDocumentRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataServiceDocumentRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataServiceDocumentRequestImpl.java
index cd11e91..6014b5b 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataServiceDocumentRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataServiceDocumentRequestImpl.java
@@ -29,7 +29,7 @@ import org.apache.olingo.client.api.data.ServiceDocument;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.domain.ODataServiceDocument;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 
 /**
  * This class implements an OData service document request.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/ODataLinkCollectionRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/ODataLinkCollectionRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/ODataLinkCollectionRequestImpl.java
index 8c5ef8c..0761aff 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/ODataLinkCollectionRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/ODataLinkCollectionRequestImpl.java
@@ -28,7 +28,7 @@ import org.apache.olingo.client.api.communication.request.retrieve.v3.ODataLinkC
 import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
 import org.apache.olingo.client.api.domain.v3.ODataLinkCollection;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 import org.apache.olingo.client.api.http.HttpClientException;
 import org.apache.olingo.client.core.communication.request.retrieve.AbstractODataRetrieveRequest;
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/ODataDeltaRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/ODataDeltaRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/ODataDeltaRequestImpl.java
index 41708b9..d817dc4 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/ODataDeltaRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/ODataDeltaRequestImpl.java
@@ -33,7 +33,7 @@ import org.apache.olingo.commons.api.data.Delta;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.domain.v4.ODataDelta;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 
 public class ODataDeltaRequestImpl extends AbstractODataRetrieveRequest<ODataDelta, ODataPubFormat>
     implements ODataDeltaRequest {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityCreateRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityCreateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityCreateRequestImpl.java
index d669129..7089a7e 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityCreateRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityCreateRequestImpl.java
@@ -34,7 +34,7 @@ import org.apache.olingo.client.core.communication.response.AbstractODataRespons
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.domain.CommonODataEntity;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 
 /**
  * This class implements an OData Media Entity create request. Get instance by using ODataStreamedRequestFactory.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityUpdateRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityUpdateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityUpdateRequestImpl.java
index 87a6fdb..154d699 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityUpdateRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityUpdateRequestImpl.java
@@ -34,7 +34,7 @@ import org.apache.olingo.client.core.communication.response.AbstractODataRespons
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.domain.CommonODataEntity;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 
 /**
  * This class implements an OData Media Entity create request. Get instance by using ODataStreamedRequestFactory.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/data/JSONServiceDocumentDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/JSONServiceDocumentDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/JSONServiceDocumentDeserializer.java
index 1bf5c4d..fc9b27e 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/JSONServiceDocumentDeserializer.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/JSONServiceDocumentDeserializer.java
@@ -28,8 +28,8 @@ import org.apache.olingo.client.api.data.ServiceDocument;
 import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
-import org.apache.olingo.commons.core.data.JsonDeserializer;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+import org.apache.olingo.commons.core.serialization.JsonDeserializer;
 
 import com.fasterxml.jackson.core.JsonFactory;
 import com.fasterxml.jackson.core.JsonParser;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/data/XMLServiceDocumentDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/XMLServiceDocumentDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/XMLServiceDocumentDeserializer.java
index 22d5dc8..ee67b5e 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/XMLServiceDocumentDeserializer.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/XMLServiceDocumentDeserializer.java
@@ -26,8 +26,8 @@ import org.apache.olingo.client.api.data.ServiceDocument;
 import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
-import org.apache.olingo.commons.core.data.JsonDeserializer;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+import org.apache.olingo.commons.core.serialization.JsonDeserializer;
 
 import com.fasterxml.jackson.core.JsonParser;
 import com.fasterxml.jackson.core.JsonToken;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
deleted file mode 100644
index 1327e43..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
+++ /dev/null
@@ -1,528 +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.client.core.op;
-
-import java.io.StringWriter;
-import java.net.URI;
-import java.util.Iterator;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.client.api.CommonODataClient;
-import org.apache.olingo.client.api.data.ServiceDocument;
-import org.apache.olingo.client.api.data.ServiceDocumentItem;
-import org.apache.olingo.client.api.op.CommonODataBinder;
-import org.apache.olingo.client.api.v4.EdmEnabledODataClient;
-import org.apache.olingo.client.core.uri.URIUtils;
-import org.apache.olingo.commons.api.Constants;
-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.Link;
-import org.apache.olingo.commons.api.data.Linked;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.data.Valuable;
-import org.apache.olingo.commons.api.data.Value;
-import org.apache.olingo.commons.api.domain.CommonODataEntity;
-import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
-import org.apache.olingo.commons.api.domain.CommonODataProperty;
-import org.apache.olingo.commons.api.domain.ODataCollectionValue;
-import org.apache.olingo.commons.api.domain.ODataComplexValue;
-import org.apache.olingo.commons.api.domain.ODataInlineEntity;
-import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
-import org.apache.olingo.commons.api.domain.ODataLink;
-import org.apache.olingo.commons.api.domain.ODataLinkType;
-import org.apache.olingo.commons.api.domain.ODataLinked;
-import org.apache.olingo.commons.api.domain.ODataOperation;
-import org.apache.olingo.commons.api.domain.ODataServiceDocument;
-import org.apache.olingo.commons.api.domain.ODataValue;
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.EdmBindingTarget;
-import org.apache.olingo.commons.api.edm.EdmElement;
-import org.apache.olingo.commons.api.edm.EdmEntityContainer;
-import org.apache.olingo.commons.api.edm.EdmEntityType;
-import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.EdmProperty;
-import org.apache.olingo.commons.api.edm.EdmSchema;
-import org.apache.olingo.commons.api.edm.EdmStructuredType;
-import org.apache.olingo.commons.api.edm.EdmType;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.edm.geo.Geospatial;
-import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.op.ODataSerializerException;
-import org.apache.olingo.commons.core.data.CollectionValueImpl;
-import org.apache.olingo.commons.core.data.ComplexValueImpl;
-import org.apache.olingo.commons.core.data.EntityImpl;
-import org.apache.olingo.commons.core.data.EntitySetImpl;
-import org.apache.olingo.commons.core.data.GeospatialValueImpl;
-import org.apache.olingo.commons.core.data.LinkImpl;
-import org.apache.olingo.commons.core.data.NullValueImpl;
-import org.apache.olingo.commons.core.data.PrimitiveValueImpl;
-import org.apache.olingo.commons.core.data.PropertyImpl;
-import org.apache.olingo.commons.core.edm.EdmTypeInfo;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public abstract class AbstractODataBinder implements CommonODataBinder {
-
-  /**
-   * Logger.
-   */
-  protected final Logger LOG = LoggerFactory.getLogger(AbstractODataBinder.class);
-
-  protected final CommonODataClient<?> client;
-
-  protected AbstractODataBinder(final CommonODataClient<?> client) {
-    this.client = client;
-  }
-
-  @Override
-  public ODataServiceDocument getODataServiceDocument(final ServiceDocument resource) {
-    final ODataServiceDocument serviceDocument = new ODataServiceDocument();
-
-    for (ServiceDocumentItem entitySet : resource.getEntitySets()) {
-      serviceDocument.getEntitySets().
-          put(entitySet.getName(), URIUtils.getURI(resource.getBaseURI(), entitySet.getUrl()));
-    }
-
-    return serviceDocument;
-  }
-
-  @Override
-  public EntitySet getEntitySet(final CommonODataEntitySet odataEntitySet) {
-    final EntitySet entitySet = new EntitySetImpl();
-
-    entitySet.setCount(odataEntitySet.getCount());
-
-    final URI next = odataEntitySet.getNext();
-    if (next != null) {
-      entitySet.setNext(next);
-    }
-
-    for (CommonODataEntity entity : odataEntitySet.getEntities()) {
-      entitySet.getEntities().add(getEntity(entity));
-    }
-
-    return entitySet;
-  }
-
-  protected void links(final ODataLinked odataLinked, final Linked linked) {
-    // -------------------------------------------------------------
-    // Append navigation links (handling inline entity / entity set as well)
-    // -------------------------------------------------------------
-    // handle navigation links
-    for (ODataLink link : odataLinked.getNavigationLinks()) {
-      // append link 
-      LOG.debug("Append navigation link\n{}", link);
-      linked.getNavigationLinks().add(getLink(link));
-    }
-    // -------------------------------------------------------------
-
-    // -------------------------------------------------------------
-    // Append association links
-    // -------------------------------------------------------------
-    for (ODataLink link : odataLinked.getAssociationLinks()) {
-      LOG.debug("Append association link\n{}", link);
-      linked.getAssociationLinks().add(getLink(link));
-    }
-    // -------------------------------------------------------------
-  }
-
-  @Override
-  public Entity getEntity(final CommonODataEntity odataEntity) {
-    final Entity entity = new EntityImpl();
-
-    entity.setType(odataEntity.getTypeName() == null ? null : odataEntity.getTypeName().toString());
-
-    // -------------------------------------------------------------
-    // Add edit and self link
-    // -------------------------------------------------------------
-    final URI odataEditLink = odataEntity.getEditLink();
-    if (odataEditLink != null) {
-      final LinkImpl editLink = new LinkImpl();
-      editLink.setTitle(entity.getType());
-      editLink.setHref(odataEditLink.toASCIIString());
-      editLink.setRel(Constants.EDIT_LINK_REL);
-      entity.setEditLink(editLink);
-    }
-
-    if (odataEntity.isReadOnly()) {
-      final LinkImpl selfLink = new LinkImpl();
-      selfLink.setTitle(entity.getType());
-      selfLink.setHref(odataEntity.getLink().toASCIIString());
-      selfLink.setRel(Constants.SELF_LINK_REL);
-      entity.setSelfLink(selfLink);
-    }
-    // -------------------------------------------------------------
-
-    links(odataEntity, entity);
-
-    // -------------------------------------------------------------
-    // Append edit-media links
-    // -------------------------------------------------------------
-    for (ODataLink link : odataEntity.getMediaEditLinks()) {
-      LOG.debug("Append edit-media link\n{}", link);
-      entity.getMediaEditLinks().add(getLink(link));
-    }
-    // -------------------------------------------------------------
-
-    if (odataEntity.isMediaEntity()) {
-      entity.setMediaContentSource(odataEntity.getMediaContentSource());
-      entity.setMediaContentType(odataEntity.getMediaContentType());
-      entity.setMediaETag(odataEntity.getMediaETag());
-    }
-
-    for (CommonODataProperty property : odataEntity.getProperties()) {
-      entity.getProperties().add(getProperty(property));
-    }
-
-    return entity;
-  }
-
-  @Override
-  public Link getLink(final ODataLink link) {
-    final Link linkResource = new LinkImpl();
-    linkResource.setRel(link.getRel());
-    linkResource.setTitle(link.getName());
-    linkResource.setHref(link.getLink() == null ? null : link.getLink().toASCIIString());
-    linkResource.setType(link.getType().toString());
-    linkResource.setMediaETag(link.getMediaETag());
-
-    if (link instanceof ODataInlineEntity) {
-      // append inline entity
-      final CommonODataEntity inlineEntity = ((ODataInlineEntity) link).getEntity();
-      LOG.debug("Append in-line entity\n{}", inlineEntity);
-
-      linkResource.setInlineEntity(getEntity(inlineEntity));
-    } else if (link instanceof ODataInlineEntitySet) {
-      // append inline entity set
-      final CommonODataEntitySet InlineEntitySet = ((ODataInlineEntitySet) link).getEntitySet();
-      LOG.debug("Append in-line entity set\n{}", InlineEntitySet);
-
-      linkResource.setInlineEntitySet(getEntitySet(InlineEntitySet));
-    }
-
-    return linkResource;
-  }
-
-  protected Value getValue(final ODataValue value) {
-    Value valueResource = null;
-
-    if (value == null) {
-      valueResource = new NullValueImpl();
-    } else if (value.isPrimitive()) {
-      valueResource = value.asPrimitive().getTypeKind().isGeospatial()
-          ? new GeospatialValueImpl((Geospatial) value.asPrimitive().toValue())
-          : new PrimitiveValueImpl(value.asPrimitive().toString());
-    } else if (value.isComplex()) {
-      final ODataComplexValue<? extends CommonODataProperty> _value = value.asComplex();
-      valueResource = new ComplexValueImpl();
-
-      for (final Iterator<? extends CommonODataProperty> itor = _value.iterator(); itor.hasNext();) {
-        valueResource.asComplex().get().add(getProperty(itor.next()));
-      }
-    } else if (value.isCollection()) {
-      final ODataCollectionValue<? extends ODataValue> _value = value.asCollection();
-      valueResource = new CollectionValueImpl();
-
-      for (final Iterator<? extends ODataValue> itor = _value.iterator(); itor.hasNext();) {
-        valueResource.asCollection().get().add(getValue(itor.next()));
-      }
-    }
-
-    return valueResource;
-  }
-
-  protected abstract boolean add(CommonODataEntitySet entitySet, CommonODataEntity entity);
-
-  @Override
-  public CommonODataEntitySet getODataEntitySet(final ResWrap<EntitySet> resource) {
-    if (LOG.isDebugEnabled()) {
-      final StringWriter writer = new StringWriter();
-      try {
-        client.getSerializer(ODataFormat.JSON).write(writer, resource.getPayload());
-      } catch (final ODataSerializerException e) {}
-      writer.flush();
-      LOG.debug("EntitySet -> ODataEntitySet:\n{}", writer.toString());
-    }
-
-    final URI base = resource.getContextURL() == null
-        ? resource.getPayload().getBaseURI() : resource.getContextURL().getServiceRoot();
-
-    final URI next = resource.getPayload().getNext();
-
-    final CommonODataEntitySet entitySet = next == null
-        ? client.getObjectFactory().newEntitySet()
-        : client.getObjectFactory().newEntitySet(URIUtils.getURI(base, next.toASCIIString()));
-
-    if (resource.getPayload().getCount() != null) {
-      entitySet.setCount(resource.getPayload().getCount());
-    }
-
-    for (Entity entityResource : resource.getPayload().getEntities()) {
-      add(entitySet, getODataEntity(
-          new ResWrap<Entity>(resource.getContextURL(), resource.getMetadataETag(), entityResource)));
-    }
-
-    return entitySet;
-  }
-
-  protected void odataNavigationLinks(final EdmType edmType,
-      final Linked linked, final ODataLinked odataLinked, final String metadataETag, final URI base) {
-
-    for (Link link : linked.getNavigationLinks()) {
-      final Entity inlineEntity = link.getInlineEntity();
-      final EntitySet inlineEntitySet = link.getInlineEntitySet();
-
-      if (inlineEntity == null && inlineEntitySet == null) {
-        ODataLinkType linkType = null;
-        if (edmType instanceof EdmStructuredType) {
-          final EdmNavigationProperty navProp = ((EdmStructuredType) edmType).getNavigationProperty(link.getTitle());
-          if (navProp != null) {
-            linkType = navProp.isCollection()
-                ? ODataLinkType.ENTITY_SET_NAVIGATION
-                : ODataLinkType.ENTITY_NAVIGATION;
-          }
-        }
-        if (linkType == null) {
-          linkType = link.getType() == null
-              ? ODataLinkType.ENTITY_NAVIGATION
-              : ODataLinkType.fromString(client.getServiceVersion(), link.getRel(), link.getType());
-        }
-
-        odataLinked.addLink(linkType == ODataLinkType.ENTITY_NAVIGATION
-            ? client.getObjectFactory().
-                newEntityNavigationLink(link.getTitle(), URIUtils.getURI(base, link.getHref()))
-            : client.getObjectFactory().
-                newEntitySetNavigationLink(link.getTitle(), URIUtils.getURI(base, link.getHref())));
-      } else if (inlineEntity != null) {
-        odataLinked.addLink(new ODataInlineEntity(client.getServiceVersion(),
-            URIUtils.getURI(base, link.getHref()), ODataLinkType.ENTITY_NAVIGATION, link.getTitle(),
-            getODataEntity(new ResWrap<Entity>(
-                inlineEntity.getBaseURI() == null ? base : inlineEntity.getBaseURI(),
-                metadataETag,
-                inlineEntity))));
-      } else {
-        odataLinked.addLink(new ODataInlineEntitySet(client.getServiceVersion(),
-            URIUtils.getURI(base, link.getHref()), ODataLinkType.ENTITY_SET_NAVIGATION, link.getTitle(),
-            getODataEntitySet(new ResWrap<EntitySet>(
-                inlineEntitySet.getBaseURI() == null ? base : inlineEntitySet.getBaseURI(),
-                metadataETag,
-                inlineEntitySet))));
-      }
-    }
-  }
-
-  /**
-   * Infer type name from various sources of information including Edm and context URL, if available.
-   *
-   * @param contextURL context URL
-   * @param metadataETag metadata ETag
-   * @return Edm type information
-   */
-  private EdmType findType(final ContextURL contextURL, final String metadataETag) {
-    EdmType type = null;
-
-    if (client instanceof EdmEnabledODataClient && contextURL != null) {
-      final Edm edm = ((EdmEnabledODataClient) client).getEdm(metadataETag);
-
-      if (contextURL.getDerivedEntity() == null) {
-        for (EdmSchema schema : edm.getSchemas()) {
-          final EdmEntityContainer container = schema.getEntityContainer();
-          if (container != null) {
-            EdmBindingTarget bindingTarget = container.getEntitySet(contextURL.getEntitySetOrSingletonOrType());
-            if (bindingTarget == null) {
-              bindingTarget = container.getSingleton(contextURL.getEntitySetOrSingletonOrType());
-            }
-            if (bindingTarget != null) {
-              if (contextURL.getNavOrPropertyPath() == null) {
-                type = bindingTarget.getEntityType();
-              } else {
-                final EdmNavigationProperty navProp = bindingTarget.getEntityType().
-                    getNavigationProperty(contextURL.getNavOrPropertyPath());
-
-                type = navProp == null
-                    ? bindingTarget.getEntityType()
-                    : navProp.getType();
-              }
-            }
-          }
-        }
-        if (type == null) {
-          type = new EdmTypeInfo.Builder().setEdm(edm).
-              setTypeExpression(contextURL.getEntitySetOrSingletonOrType()).build().getType();
-        }
-      } else {
-        type = edm.getEntityType(new FullQualifiedName(contextURL.getDerivedEntity()));
-      }
-    }
-
-    return type;
-  }
-
-  @Override
-  public CommonODataEntity getODataEntity(final ResWrap<Entity> resource) {
-    if (LOG.isDebugEnabled()) {
-      final StringWriter writer = new StringWriter();
-      try {
-        client.getSerializer(ODataFormat.JSON).write(writer, resource.getPayload());
-      } catch (final ODataSerializerException e) {}
-      writer.flush();
-      LOG.debug("EntityResource -> ODataEntity:\n{}", writer.toString());
-    }
-
-    final URI base = resource.getContextURL() == null
-        ? resource.getPayload().getBaseURI() : resource.getContextURL().getServiceRoot();
-
-    final EdmType edmType = findType(resource.getContextURL(), resource.getMetadataETag());
-    FullQualifiedName typeName = null;
-    if (resource.getPayload().getType() == null) {
-      if (edmType != null) {
-        typeName = edmType.getFullQualifiedName();
-      }
-    } else {
-      typeName = new FullQualifiedName(resource.getPayload().getType());
-    }
-
-    final CommonODataEntity entity = resource.getPayload().getSelfLink() == null
-        ? client.getObjectFactory().newEntity(typeName)
-        : client.getObjectFactory().newEntity(typeName,
-            URIUtils.getURI(base, resource.getPayload().getSelfLink().getHref()));
-
-    if (StringUtils.isNotBlank(resource.getPayload().getETag())) {
-      entity.setETag(resource.getPayload().getETag());
-    }
-
-    if (resource.getPayload().getEditLink() != null) {
-      entity.setEditLink(URIUtils.getURI(base, resource.getPayload().getEditLink().getHref()));
-    }
-
-    for (Link link : resource.getPayload().getAssociationLinks()) {
-      entity.addLink(client.getObjectFactory().
-          newAssociationLink(link.getTitle(), URIUtils.getURI(base, link.getHref())));
-    }
-
-    odataNavigationLinks(edmType, resource.getPayload(), entity, resource.getMetadataETag(), base);
-
-    for (Link link : resource.getPayload().getMediaEditLinks()) {
-      entity.addLink(client.getObjectFactory().
-          newMediaEditLink(link.getTitle(), URIUtils.getURI(base, link.getHref())));
-    }
-
-    for (ODataOperation operation : resource.getPayload().getOperations()) {
-      operation.setTarget(URIUtils.getURI(base, operation.getTarget()));
-      entity.getOperations().add(operation);
-    }
-
-    if (resource.getPayload().isMediaEntity()) {
-      entity.setMediaEntity(true);
-      entity.setMediaContentSource(URIUtils.getURI(base, resource.getPayload().getMediaContentSource()));
-      entity.setMediaContentType(resource.getPayload().getMediaContentType());
-      entity.setMediaETag(resource.getPayload().getMediaETag());
-    }
-
-    for (Property property : resource.getPayload().getProperties()) {
-      EdmType propertyType = null;
-      if (edmType instanceof EdmEntityType) {
-        final EdmElement edmProperty = ((EdmEntityType) edmType).getProperty(property.getName());
-        if (edmProperty != null) {
-          propertyType = edmProperty.getType();
-        }
-      }
-      add(entity, getODataProperty(propertyType, property));
-    }
-
-    return entity;
-  }
-
-  protected EdmTypeInfo buildTypeInfo(final ContextURL contextURL, final String metadataETag,
-      final String propertyName, final String propertyType) {
-
-    FullQualifiedName typeName = null;
-    final EdmType type = findType(contextURL, metadataETag);
-    if (type instanceof EdmStructuredType) {
-      final EdmProperty edmProperty = ((EdmStructuredType) type).getStructuralProperty(propertyName);
-      if (edmProperty != null) {
-        typeName = edmProperty.getType().getFullQualifiedName();
-      }
-    }
-    if (typeName == null && type != null) {
-      typeName = type.getFullQualifiedName();
-    }
-
-    return buildTypeInfo(typeName, propertyType);
-  }
-
-  protected EdmTypeInfo buildTypeInfo(final FullQualifiedName typeName, final String propertyType) {
-    EdmTypeInfo typeInfo = null;
-    if (typeName == null) {
-      if (propertyType != null) {
-        typeInfo = new EdmTypeInfo.Builder().setTypeExpression(propertyType).build();
-      }
-    } else {
-      if (propertyType == null || propertyType.equals(EdmPrimitiveTypeKind.String.getFullQualifiedName().toString())) {
-        typeInfo = new EdmTypeInfo.Builder().setTypeExpression(typeName.toString()).build();
-      } else {
-        typeInfo = new EdmTypeInfo.Builder().setTypeExpression(propertyType).build();
-      }
-    }
-    return typeInfo;
-  }
-
-  protected abstract CommonODataProperty getODataProperty(EdmType type, Property resource);
-
-  protected ODataValue getODataValue(final FullQualifiedName type,
-      final Valuable valuable, final ContextURL contextURL, final String metadataETag) {
-
-    ODataValue value = null;
-    if (valuable.getValue().isGeospatial()) {
-      value = client.getObjectFactory().newPrimitiveValueBuilder().
-          setValue(valuable.getValue().asGeospatial().get()).
-          setType(type == null
-              || EdmPrimitiveTypeKind.Geography.getFullQualifiedName().equals(type)
-              || EdmPrimitiveTypeKind.Geometry.getFullQualifiedName().equals(type)
-              ? valuable.getValue().asGeospatial().get().getEdmPrimitiveTypeKind()
-              : EdmPrimitiveTypeKind.valueOfFQN(client.getServiceVersion(), type.toString())).build();
-    } else if (valuable.getValue().isPrimitive()) {
-      value = client.getObjectFactory().newPrimitiveValueBuilder().
-          setText(valuable.getValue().asPrimitive().get()).
-          setType(type == null || !EdmPrimitiveType.EDM_NAMESPACE.equals(type.getNamespace())
-              ? null
-              : EdmPrimitiveTypeKind.valueOfFQN(client.getServiceVersion(), type.toString())).build();
-    } else if (valuable.getValue().isComplex()) {
-      value = client.getObjectFactory().newComplexValue(type == null ? null : type.toString());
-
-      for (Property property : valuable.getValue().asComplex().get()) {
-        value.asComplex().add(getODataProperty(new ResWrap<Property>(contextURL, metadataETag, property)));
-      }
-    } else if (valuable.getValue().isCollection()) {
-      value = client.getObjectFactory().newCollectionValue(type == null ? null : "Collection(" + type.toString() + ")");
-
-      for (Value _value : valuable.getValue().asCollection().get()) {
-        final Property fake = new PropertyImpl();
-        fake.setValue(_value);
-        value.asCollection().add(getODataValue(type, fake, contextURL, metadataETag));
-      }
-    }
-
-    return value;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataReader.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataReader.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataReader.java
deleted file mode 100644
index 1b60736..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataReader.java
+++ /dev/null
@@ -1,159 +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.client.core.op;
-
-import java.io.InputStream;
-import java.net.URI;
-import java.util.Map;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.olingo.client.api.CommonODataClient;
-import org.apache.olingo.client.api.data.ServiceDocument;
-import org.apache.olingo.commons.api.domain.ODataError;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.domain.CommonODataEntity;
-import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
-import org.apache.olingo.client.api.domain.ODataEntitySetIterator;
-import org.apache.olingo.client.api.edm.xml.Schema;
-import org.apache.olingo.commons.api.domain.CommonODataProperty;
-import org.apache.olingo.commons.api.domain.ODataServiceDocument;
-import org.apache.olingo.commons.api.domain.ODataValue;
-import org.apache.olingo.client.api.edm.xml.XMLMetadata;
-import org.apache.olingo.client.api.op.CommonODataReader;
-import org.apache.olingo.client.core.edm.EdmClientImpl;
-import org.apache.olingo.commons.api.data.ResWrap;
-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.format.ODataFormat;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.format.ODataValueFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public abstract class AbstractODataReader implements CommonODataReader {
-
-  /**
-   * Logger.
-   */
-  protected static final Logger LOG = LoggerFactory.getLogger(AbstractODataReader.class);
-
-  protected final CommonODataClient<?> client;
-
-  protected AbstractODataReader(final CommonODataClient<?> client) {
-    this.client = client;
-  }
-
-  @Override
-  public Edm readMetadata(final InputStream input) {
-    return readMetadata(client.getDeserializer(ODataFormat.XML).toMetadata(input).getSchemaByNsOrAlias());
-  }
-
-  @Override
-  public Edm readMetadata(final Map<String, Schema> xmlSchemas) {
-    return new EdmClientImpl(client.getServiceVersion(), xmlSchemas);
-  }
-
-  @Override
-  public ODataServiceDocument readServiceDocument(final InputStream input, final ODataFormat format)
-      throws ODataDeserializerException {
-    return client.getBinder().getODataServiceDocument(
-            client.getDeserializer(format).toServiceDocument(input).getPayload());
-  }
-
-  @Override
-  public ODataError readError(final InputStream inputStream, final ODataFormat format )
-      throws ODataDeserializerException {
-    return client.getDeserializer(format).toError(inputStream);
-  }
-
-  @Override
-  public <T> ResWrap<T> read(final InputStream src, final String format, final Class<T> reference)
-      throws ODataDeserializerException {
-    ResWrap<T> res;
-
-    try {
-      if (ODataEntitySetIterator.class.isAssignableFrom(reference)) {
-        res = new ResWrap<T>(
-                (URI) null,
-                null,
-                reference.cast(new ODataEntitySetIterator<CommonODataEntitySet, CommonODataEntity>(
-                                client, src, ODataPubFormat.fromString(format))));
-      } else if (CommonODataEntitySet.class.isAssignableFrom(reference)) {
-        final ResWrap<EntitySet> resource = client.getDeserializer(ODataPubFormat.fromString(format))
-            .toEntitySet(src);
-        res = new ResWrap<T>(
-                resource.getContextURL(),
-                resource.getMetadataETag(),
-                reference.cast(client.getBinder().getODataEntitySet(resource)));
-      } else if (CommonODataEntity.class.isAssignableFrom(reference)) {
-        final ResWrap<Entity> container = client.getDeserializer(ODataPubFormat.fromString(format)).toEntity(src);
-        res = new ResWrap<T>(
-                container.getContextURL(),
-                container.getMetadataETag(),
-                reference.cast(client.getBinder().getODataEntity(container)));
-      } else if (CommonODataProperty.class.isAssignableFrom(reference)) {
-        final ResWrap<Property> container = client.getDeserializer(ODataFormat.fromString(format)).toProperty(src);
-        res = new ResWrap<T>(
-                container.getContextURL(),
-                container.getMetadataETag(),
-                reference.cast(client.getBinder().getODataProperty(container)));
-      } else if (ODataValue.class.isAssignableFrom(reference)) {
-        res = new ResWrap<T>(
-                (URI) null,
-                null,
-                reference.cast(client.getObjectFactory().newPrimitiveValueBuilder().
-                        setType(ODataValueFormat.fromString(format) == ODataValueFormat.TEXT
-                                ? EdmPrimitiveTypeKind.String : EdmPrimitiveTypeKind.Stream).
-                        setText(IOUtils.toString(src)).
-                        build()));
-      } else if (XMLMetadata.class.isAssignableFrom(reference)) {
-        res = new ResWrap<T>(
-                (URI) null,
-                null,
-                reference.cast(readMetadata(src)));
-      } else if (ODataServiceDocument.class.isAssignableFrom(reference)) {
-        final ResWrap<ServiceDocument> resource =
-                client.getDeserializer(ODataFormat.fromString(format)).toServiceDocument(src);
-        res = new ResWrap<T>(
-                resource.getContextURL(),
-                resource.getMetadataETag(),
-                reference.cast(client.getBinder().getODataServiceDocument(resource.getPayload())));
-      } else if (ODataError.class.isAssignableFrom(reference)) {
-        res = new ResWrap<T>(
-                (URI) null,
-                null,
-                reference.cast(readError(src, ODataFormat.fromString(format))));
-      } else {
-        throw new IllegalArgumentException("Invalid reference type " + reference);
-      }
-    } catch (Exception e) {
-      LOG.warn("Cast error", e);
-      res = null;
-    } finally {
-      if (!ODataEntitySetIterator.class.isAssignableFrom(reference)) {
-        IOUtils.closeQuietly(src);
-      }
-    }
-
-    return res;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/op/ODataWriterImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/ODataWriterImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/ODataWriterImpl.java
deleted file mode 100644
index 71fe85d..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/ODataWriterImpl.java
+++ /dev/null
@@ -1,111 +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.client.core.op;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-import java.util.Collection;
-import java.util.Collections;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.olingo.client.api.CommonODataClient;
-import org.apache.olingo.client.api.op.ODataWriter;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.domain.CommonODataEntity;
-import org.apache.olingo.commons.api.domain.CommonODataProperty;
-import org.apache.olingo.commons.api.domain.ODataLink;
-import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataSerializerException;
-
-public class ODataWriterImpl implements ODataWriter {
-
-  protected final CommonODataClient<?> client;
-
-  public ODataWriterImpl(final CommonODataClient<?> client) {
-    this.client = client;
-  }
-
-  @Override
-  public InputStream writeEntities(final Collection<CommonODataEntity> entities, final ODataPubFormat format)
-      throws ODataSerializerException {
-    ByteArrayOutputStream output = new ByteArrayOutputStream();
-    OutputStreamWriter writer;
-    try {
-      writer = new OutputStreamWriter(output, Constants.UTF8);
-    } catch (final UnsupportedEncodingException e) {
-      writer = null;
-    }
-    try {
-      for (CommonODataEntity entity : entities) {
-        client.getSerializer(format).write(writer, client.getBinder().getEntity(entity));
-      }
-
-      return new ByteArrayInputStream(output.toByteArray());
-    } finally {
-      IOUtils.closeQuietly(output);
-    }
-  }
-
-  @Override
-  public InputStream writeEntity(final CommonODataEntity entity, final ODataPubFormat format)
-      throws ODataSerializerException {
-    return writeEntities(Collections.<CommonODataEntity>singleton(entity), format);
-  }
-
-  @Override
-  public InputStream writeProperty(final CommonODataProperty property, final ODataFormat format)
-      throws ODataSerializerException {
-    final ByteArrayOutputStream output = new ByteArrayOutputStream();
-    OutputStreamWriter writer;
-    try {
-      writer = new OutputStreamWriter(output, Constants.UTF8);
-    } catch (final UnsupportedEncodingException e) {
-      writer = null;
-    }
-    try {
-      client.getSerializer(format).write(writer, client.getBinder().getProperty(property));
-
-      return new ByteArrayInputStream(output.toByteArray());
-    } finally {
-      IOUtils.closeQuietly(output);
-    }
-  }
-
-  @Override
-  public InputStream writeLink(final ODataLink link, final ODataFormat format) throws ODataSerializerException {
-    final ByteArrayOutputStream output = new ByteArrayOutputStream();
-    OutputStreamWriter writer;
-    try {
-      writer = new OutputStreamWriter(output, Constants.UTF8);
-    } catch (final UnsupportedEncodingException e) {
-      writer = null;
-    }
-    try {
-      client.getSerializer(format).write(writer, client.getBinder().getLink(link));
-
-      return new ByteArrayInputStream(output.toByteArray());
-    } finally {
-      IOUtils.closeQuietly(output);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java
deleted file mode 100644
index 932a766..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java
+++ /dev/null
@@ -1,117 +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.client.core.op.impl.v3;
-
-import org.apache.olingo.client.api.domain.v3.ODataLinkCollection;
-import org.apache.olingo.client.api.op.v3.ODataBinder;
-import org.apache.olingo.client.core.op.AbstractODataBinder;
-import org.apache.olingo.client.core.v3.ODataClientImpl;
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.data.v3.LinkCollection;
-import org.apache.olingo.commons.api.domain.CommonODataEntity;
-import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
-import org.apache.olingo.commons.api.domain.CommonODataProperty;
-import org.apache.olingo.commons.api.domain.ODataComplexValue;
-import org.apache.olingo.commons.api.domain.v3.ODataEntity;
-import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
-import org.apache.olingo.commons.api.domain.v3.ODataProperty;
-import org.apache.olingo.commons.api.edm.EdmType;
-import org.apache.olingo.commons.core.data.PropertyImpl;
-import org.apache.olingo.commons.core.domain.v3.ODataPropertyImpl;
-import org.apache.olingo.commons.core.edm.EdmTypeInfo;
-
-public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder {
-
-  public ODataBinderImpl(final ODataClientImpl client) {
-    super(client);
-  }
-
-  @Override
-  public void add(final ODataComplexValue<CommonODataProperty> complex, final CommonODataProperty property) {
-    complex.add(property);
-  }
-
-  @Override
-  public boolean add(final CommonODataEntity entity, final CommonODataProperty property) {
-    return ((ODataEntity) entity).getProperties().add((ODataProperty) property);
-  }
-
-  @Override
-  protected boolean add(final CommonODataEntitySet entitySet, final CommonODataEntity entity) {
-    return ((ODataEntitySet) entitySet).getEntities().add((ODataEntity) entity);
-  }
-
-  @Override
-  public Property getProperty(final CommonODataProperty property) {
-    final Property propertyResource = new PropertyImpl();
-    propertyResource.setName(property.getName());
-    propertyResource.setValue(getValue(property.getValue()));
-
-    if (property.hasPrimitiveValue()) {
-      propertyResource.setType(property.getPrimitiveValue().getTypeName());
-    } else if (property.hasComplexValue()) {
-      propertyResource.setType(((ODataProperty) property).getComplexValue().getTypeName());
-    } else if (property.hasCollectionValue()) {
-      propertyResource.setType(((ODataProperty) property).getCollectionValue().getTypeName());
-    }
-
-    return propertyResource;
-  }
-
-  @Override
-  public ODataEntitySet getODataEntitySet(final ResWrap<EntitySet> resource) {
-    return (ODataEntitySet) super.getODataEntitySet(resource);
-  }
-
-  @Override
-  public ODataEntity getODataEntity(final ResWrap<Entity> resource) {
-    return (ODataEntity) super.getODataEntity(resource);
-  }
-
-  @Override
-  public ODataProperty getODataProperty(final ResWrap<Property> property) {
-    final EdmTypeInfo typeInfo = buildTypeInfo(property.getContextURL(), property.getMetadataETag(),
-            property.getPayload().getName(), property.getPayload().getType());
-
-    return new ODataPropertyImpl(property.getPayload().getName(),
-            getODataValue(typeInfo == null ? null : typeInfo.getFullQualifiedName(),
-                    property.getPayload(), property.getContextURL(), property.getMetadataETag()));
-  }
-
-  @Override
-  protected ODataProperty getODataProperty(final EdmType type, final Property resource) {
-    final EdmTypeInfo typeInfo = buildTypeInfo(type == null ? null : type.getFullQualifiedName(), resource.getType());
-
-    return new ODataPropertyImpl(resource.getName(),
-            getODataValue(typeInfo == null
-                    ? null
-                    : typeInfo.getFullQualifiedName(),
-                    resource, null, null));
-  }
-
-  @Override
-  public ODataLinkCollection getLinkCollection(final LinkCollection linkCollection) {
-    final ODataLinkCollection collection = new ODataLinkCollection(linkCollection.getNext());
-    collection.setLinks(linkCollection.getLinks());
-    return collection;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataDeserializerImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataDeserializerImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataDeserializerImpl.java
deleted file mode 100644
index 348d524..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataDeserializerImpl.java
+++ /dev/null
@@ -1,77 +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.client.core.op.impl.v3;
-
-import java.io.InputStream;
-
-import javax.xml.stream.XMLStreamException;
-
-import org.apache.olingo.client.api.data.ServiceDocument;
-import org.apache.olingo.client.api.edm.xml.XMLMetadata;
-import org.apache.olingo.client.api.op.v3.ODataDeserializer;
-import org.apache.olingo.client.core.data.JSONServiceDocumentDeserializer;
-import org.apache.olingo.client.core.data.XMLServiceDocumentDeserializer;
-import org.apache.olingo.client.core.edm.xml.v3.EdmxImpl;
-import org.apache.olingo.client.core.edm.xml.v3.XMLMetadataImpl;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.data.v3.LinkCollection;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.api.format.Format;
-import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
-import org.apache.olingo.commons.core.data.AtomDeserializer;
-import org.apache.olingo.commons.core.data.JSONLinkCollectionDeserializer;
-import org.apache.olingo.commons.core.op.AbstractODataDeserializer;
-
-public class ODataDeserializerImpl extends AbstractODataDeserializer implements ODataDeserializer {
-
-  private final Format format;
-
-  public ODataDeserializerImpl(final ODataServiceVersion version, final boolean serverMode, final Format format) {
-    super(version, serverMode, format);
-    this.format = format;
-  }
-
-  @Override
-  public XMLMetadata toMetadata(final InputStream input) {
-    try {
-      return new XMLMetadataImpl(getXmlMapper().readValue(input, EdmxImpl.class));
-    } catch (Exception e) {
-      throw new IllegalArgumentException("Could not parse as Edmx document", e);
-    }
-  }
-
-  @Override
-  public ResWrap<ServiceDocument> toServiceDocument(final InputStream input) throws ODataDeserializerException {
-    return format == ODataFormat.XML ?
-        new XMLServiceDocumentDeserializer(version, false).toServiceDocument(input) :
-        new JSONServiceDocumentDeserializer(version, false).toServiceDocument(input);
-  }
-
-  @Override
-  public ResWrap<LinkCollection> toLinkCollection(final InputStream input) throws ODataDeserializerException {
-    try {
-      return format == ODataFormat.XML ?
-          new AtomDeserializer(version).linkCollection(input) :
-          new JSONLinkCollectionDeserializer(version, false).toLinkCollection(input);
-    } catch (final XMLStreamException e) {
-      throw new ODataDeserializerException(e);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataReaderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataReaderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataReaderImpl.java
deleted file mode 100644
index 16a897d..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataReaderImpl.java
+++ /dev/null
@@ -1,83 +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.client.core.op.impl.v3;
-
-import java.io.InputStream;
-
-import org.apache.olingo.client.api.domain.v3.ODataLinkCollection;
-import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.client.api.op.v3.ODataReader;
-import org.apache.olingo.client.api.v3.ODataClient;
-import org.apache.olingo.client.core.op.AbstractODataReader;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.data.v3.LinkCollection;
-import org.apache.olingo.commons.api.domain.v3.ODataEntity;
-import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
-import org.apache.olingo.commons.api.domain.v3.ODataProperty;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
-
-public class ODataReaderImpl extends AbstractODataReader implements ODataReader {
-
-  public ODataReaderImpl(final ODataClient client) {
-    super(client);
-  }
-
-  @Override
-  public ODataEntitySet readEntitySet(final InputStream input, final ODataPubFormat format)
-      throws ODataDeserializerException {
-    return ((ODataClient) client).getBinder().getODataEntitySet(client.getDeserializer(format).toEntitySet(input));
-  }
-
-  @Override
-  public ODataEntity readEntity(final InputStream input, final ODataPubFormat format)
-      throws ODataDeserializerException {
-    return ((ODataClient) client).getBinder().getODataEntity(client.getDeserializer(format).toEntity(input));
-  }
-
-  @Override
-  public ODataProperty readProperty(final InputStream input, final ODataFormat format)
-      throws ODataDeserializerException {
-    return ((ODataClient) client).getBinder().getODataProperty(client.getDeserializer(format).toProperty(input));
-  }
-
-  @Override
-  public ODataLinkCollection readLinks(final InputStream input, final ODataFormat format)
-      throws ODataDeserializerException {
-    return ((ODataClient) client).getBinder().getLinkCollection(
-            ((ODataClient) client).getDeserializer(format).toLinkCollection(input).getPayload());
-  }
-
-  @Override
-  @SuppressWarnings("unchecked")
-  public <T> ResWrap<T> read(final InputStream src, final String format, final Class<T> reference)
-      throws ODataDeserializerException {
-    if (ODataLinkCollection.class.isAssignableFrom(reference)) {
-      final ResWrap<LinkCollection> container =
-              ((ODataClient) client).getDeserializer(ODataFormat.fromString(format)).toLinkCollection(src);
-
-      return new ResWrap<T>(
-              container.getContextURL(),
-              container.getMetadataETag(),
-              (T) ((ODataClient) client).getBinder().getLinkCollection(container.getPayload()));
-    } else {
-      return super.read(src, format, reference);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java
deleted file mode 100644
index 9151b74..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java
+++ /dev/null
@@ -1,405 +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.client.core.op.impl.v4;
-
-import java.net.URI;
-
-import org.apache.olingo.client.api.data.ServiceDocument;
-import org.apache.olingo.client.api.data.ServiceDocumentItem;
-import org.apache.olingo.client.api.op.v4.ODataBinder;
-import org.apache.olingo.client.api.v4.EdmEnabledODataClient;
-import org.apache.olingo.client.api.v4.ODataClient;
-import org.apache.olingo.client.core.op.AbstractODataBinder;
-import org.apache.olingo.client.core.uri.URIUtils;
-import org.apache.olingo.commons.api.data.Annotatable;
-import org.apache.olingo.commons.api.data.Annotation;
-import org.apache.olingo.commons.api.data.ContextURL;
-import org.apache.olingo.commons.api.data.DeletedEntity;
-import org.apache.olingo.commons.api.data.Delta;
-import org.apache.olingo.commons.api.data.DeltaLink;
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
-import org.apache.olingo.commons.api.data.Link;
-import org.apache.olingo.commons.api.data.Linked;
-import org.apache.olingo.commons.api.data.LinkedComplexValue;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.data.Valuable;
-import org.apache.olingo.commons.api.data.Value;
-import org.apache.olingo.commons.api.domain.CommonODataEntity;
-import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
-import org.apache.olingo.commons.api.domain.CommonODataProperty;
-import org.apache.olingo.commons.api.domain.ODataComplexValue;
-import org.apache.olingo.commons.api.domain.ODataInlineEntity;
-import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
-import org.apache.olingo.commons.api.domain.ODataLinked;
-import org.apache.olingo.commons.api.domain.ODataServiceDocument;
-import org.apache.olingo.commons.api.domain.ODataValue;
-import org.apache.olingo.commons.api.domain.v4.ODataAnnotatable;
-import org.apache.olingo.commons.api.domain.v4.ODataAnnotation;
-import org.apache.olingo.commons.api.domain.v4.ODataDeletedEntity.Reason;
-import org.apache.olingo.commons.api.domain.v4.ODataDelta;
-import org.apache.olingo.commons.api.domain.v4.ODataDeltaLink;
-import org.apache.olingo.commons.api.domain.v4.ODataEntity;
-import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
-import org.apache.olingo.commons.api.domain.v4.ODataLink;
-import org.apache.olingo.commons.api.domain.v4.ODataLinkedComplexValue;
-import org.apache.olingo.commons.api.domain.v4.ODataProperty;
-import org.apache.olingo.commons.api.domain.v4.ODataValuable;
-import org.apache.olingo.commons.api.edm.EdmComplexType;
-import org.apache.olingo.commons.api.edm.EdmEnumType;
-import org.apache.olingo.commons.api.edm.EdmTerm;
-import org.apache.olingo.commons.api.edm.EdmType;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.core.data.AnnotationImpl;
-import org.apache.olingo.commons.core.data.EnumValueImpl;
-import org.apache.olingo.commons.core.data.LinkedComplexValueImpl;
-import org.apache.olingo.commons.core.data.PropertyImpl;
-import org.apache.olingo.commons.core.domain.v4.ODataAnnotationImpl;
-import org.apache.olingo.commons.core.domain.v4.ODataDeletedEntityImpl;
-import org.apache.olingo.commons.core.domain.v4.ODataDeltaLinkImpl;
-import org.apache.olingo.commons.core.domain.v4.ODataPropertyImpl;
-import org.apache.olingo.commons.core.edm.EdmTypeInfo;
-
-public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder {
-
-  public ODataBinderImpl(final ODataClient client) {
-    super(client);
-  }
-
-  @Override
-  public void add(final ODataComplexValue<CommonODataProperty> complex, final CommonODataProperty property) {
-    complex.add(property);
-  }
-
-  @Override
-  public boolean add(final CommonODataEntity entity, final CommonODataProperty property) {
-    return ((ODataEntity) entity).getProperties().add((ODataProperty) property);
-  }
-
-  @Override
-  protected boolean add(final CommonODataEntitySet entitySet, final CommonODataEntity entity) {
-    return ((ODataEntitySet) entitySet).getEntities().add((ODataEntity) entity);
-  }
-
-  @Override
-  public ODataServiceDocument getODataServiceDocument(final ServiceDocument resource) {
-    final ODataServiceDocument serviceDocument = super.getODataServiceDocument(resource);
-
-    for (ServiceDocumentItem functionImport : resource.getFunctionImports()) {
-      serviceDocument.getFunctionImports().put(
-              functionImport.getName() == null ? functionImport.getUrl() : functionImport.getName(),
-              URIUtils.getURI(resource.getBaseURI(), functionImport.getUrl()));
-    }
-    for (ServiceDocumentItem singleton : resource.getSingletons()) {
-      serviceDocument.getSingletons().put(
-              singleton.getName() == null ? singleton.getUrl() : singleton.getName(),
-              URIUtils.getURI(resource.getBaseURI(), singleton.getUrl()));
-    }
-    for (ServiceDocumentItem sdoc : resource.getRelatedServiceDocuments()) {
-      serviceDocument.getRelatedServiceDocuments().put(
-              sdoc.getName() == null ? sdoc.getUrl() : sdoc.getName(),
-              URIUtils.getURI(resource.getBaseURI(), sdoc.getUrl()));
-    }
-
-    return serviceDocument;
-  }
-
-  private void updateValuable(final Valuable propertyResource, final ODataValuable odataValuable) {
-
-    propertyResource.setValue(getValue(odataValuable.getValue()));
-
-    if (odataValuable.hasPrimitiveValue()) {
-      propertyResource.setType(odataValuable.getPrimitiveValue().getTypeName());
-    } else if (odataValuable.hasEnumValue()) {
-      propertyResource.setType(odataValuable.getEnumValue().getTypeName());
-    } else if (odataValuable.hasComplexValue()) {
-      propertyResource.setType(odataValuable.getComplexValue().getTypeName());
-    } else if (odataValuable.hasCollectionValue()) {
-      propertyResource.setType(odataValuable.getCollectionValue().getTypeName());
-    }
-  }
-
-  private void annotations(final ODataAnnotatable odataAnnotatable, final Annotatable annotatable) {
-
-    for (ODataAnnotation odataAnnotation : odataAnnotatable.getAnnotations()) {
-      final Annotation annotation = new AnnotationImpl();
-
-      annotation.setTerm(odataAnnotation.getTerm());
-      annotation.setType(odataAnnotation.getValue().getTypeName());
-      updateValuable(annotation, odataAnnotation);
-
-      annotatable.getAnnotations().add(annotation);
-    }
-  }
-
-  @Override
-  public EntitySet getEntitySet(final CommonODataEntitySet odataEntitySet) {
-    final EntitySet entitySet = super.getEntitySet(odataEntitySet);
-    entitySet.setDeltaLink(((ODataEntitySet) odataEntitySet).getDeltaLink());
-    annotations((ODataEntitySet) odataEntitySet, entitySet);
-    return entitySet;
-  }
-
-  @Override
-  protected void links(final ODataLinked odataLinked, final Linked linked) {
-    super.links(odataLinked, linked);
-
-    for (Link link : linked.getNavigationLinks()) {
-      final org.apache.olingo.commons.api.domain.ODataLink odataLink = odataLinked.getNavigationLink(link.getTitle());
-      if (!(odataLink instanceof ODataInlineEntity) && !(odataLink instanceof ODataInlineEntitySet)) {
-        annotations((ODataLink) odataLink, link);
-      }
-    }
-  }
-
-  @Override
-  public Entity getEntity(final CommonODataEntity odataEntity) {
-    final Entity entity = super.getEntity(odataEntity);
-    entity.setId(((ODataEntity) odataEntity).getId());
-    annotations((ODataEntity) odataEntity, entity);
-    return entity;
-  }
-
-  @Override
-  public Property getProperty(final CommonODataProperty property) {
-    final ODataProperty _property = (ODataProperty) property;
-
-    final Property propertyResource = new PropertyImpl();
-    propertyResource.setName(_property.getName());
-    updateValuable(propertyResource, _property);
-    annotations(_property, propertyResource);
-
-    return propertyResource;
-  }
-
-  @Override
-  protected Value getValue(final ODataValue value) {
-    Value valueResource;
-    if (value instanceof org.apache.olingo.commons.api.domain.v4.ODataValue
-            && ((org.apache.olingo.commons.api.domain.v4.ODataValue) value).isEnum()) {
-
-      valueResource = new EnumValueImpl(
-              ((org.apache.olingo.commons.api.domain.v4.ODataValue) value).asEnum().getValue());
-    } else {
-      valueResource = super.getValue(value);
-
-      if (value instanceof org.apache.olingo.commons.api.domain.v4.ODataValue
-              && ((org.apache.olingo.commons.api.domain.v4.ODataValue) value).isLinkedComplex()) {
-
-        final LinkedComplexValue lcValueResource = new LinkedComplexValueImpl();
-        lcValueResource.get().addAll(valueResource.asComplex().get());
-
-        final ODataLinkedComplexValue linked =
-                ((org.apache.olingo.commons.api.domain.v4.ODataValue) value).asLinkedComplex();
-        annotations(linked, lcValueResource);
-        links(linked, lcValueResource);
-
-        valueResource = lcValueResource;
-      }
-    }
-    return valueResource;
-  }
-
-  private void odataAnnotations(final Annotatable annotatable, final ODataAnnotatable odataAnnotatable) {
-    for (Annotation annotation : annotatable.getAnnotations()) {
-      FullQualifiedName fqn = null;
-      if (client instanceof EdmEnabledODataClient) {
-        final EdmTerm term = ((EdmEnabledODataClient) client).getEdm(null).
-                getTerm(new FullQualifiedName(annotation.getTerm()));
-        if (term != null) {
-          fqn = term.getType().getFullQualifiedName();
-        }
-      }
-
-      if (fqn == null && annotation.getType() != null) {
-        final EdmTypeInfo typeInfo = new EdmTypeInfo.Builder().setTypeExpression(annotation.getType()).build();
-        if (typeInfo.isPrimitiveType()) {
-          fqn = typeInfo.getPrimitiveTypeKind().getFullQualifiedName();
-        }
-      }
-
-      final ODataAnnotation odataAnnotation = new ODataAnnotationImpl(annotation.getTerm(),
-              (org.apache.olingo.commons.api.domain.v4.ODataValue) getODataValue(fqn, annotation, null, null));
-      odataAnnotatable.getAnnotations().add(odataAnnotation);
-    }
-  }
-
-  @Override
-  public ODataEntitySet getODataEntitySet(final ResWrap<EntitySet> resource) {
-    final ODataEntitySet entitySet = (ODataEntitySet) super.getODataEntitySet(resource);
-
-    if (resource.getPayload().getDeltaLink() != null) {
-      final URI base = resource.getContextURL() == null
-              ? resource.getPayload().getBaseURI() : resource.getContextURL().getServiceRoot();
-      entitySet.setDeltaLink(URIUtils.getURI(base, resource.getPayload().getDeltaLink()));
-    }
-    odataAnnotations(resource.getPayload(), entitySet);
-
-    return entitySet;
-  }
-
-  @Override
-  protected void odataNavigationLinks(final EdmType edmType,
-          final Linked linked, final ODataLinked odataLinked, final String metadataETag, final URI base) {
-
-    super.odataNavigationLinks(edmType, linked, odataLinked, metadataETag, base);
-    for (org.apache.olingo.commons.api.domain.ODataLink link : odataLinked.getNavigationLinks()) {
-      if (!(link instanceof ODataInlineEntity) && !(link instanceof ODataInlineEntitySet)) {
-        odataAnnotations(linked.getNavigationLink(link.getName()), (ODataAnnotatable) link);
-      }
-    }
-  }
-
-  @Override
-  public ODataEntity getODataEntity(final ResWrap<Entity> resource) {
-    final ODataEntity entity = (ODataEntity) super.getODataEntity(resource);
-
-    entity.setId(resource.getPayload().getId());
-    odataAnnotations(resource.getPayload(), entity);
-
-    return entity;
-  }
-
-  @Override
-  public ODataProperty getODataProperty(final ResWrap<Property> resource) {
-    final Property payload = resource.getPayload();
-    final EdmTypeInfo typeInfo = buildTypeInfo(resource.getContextURL(), resource.getMetadataETag(),
-        payload.getName(), payload.getType());
-
-    final ODataProperty property = new ODataPropertyImpl(payload.getName(),
-        getODataValue(typeInfo == null ? null : typeInfo.getFullQualifiedName(),
-            payload, resource.getContextURL(), resource.getMetadataETag()));
-    odataAnnotations(payload, property);
-
-    return property;
-  }
-
-  @Override
-  protected ODataProperty getODataProperty(final EdmType type, final Property resource) {
-    final EdmTypeInfo typeInfo = buildTypeInfo(type == null ? null : type.getFullQualifiedName(), resource.getType());
-
-    final ODataProperty property = new ODataPropertyImpl(resource.getName(),
-            getODataValue(typeInfo == null
-                    ? null
-                    : typeInfo.getFullQualifiedName(),
-                    resource, null, null));
-    odataAnnotations(resource, property);
-
-    return property;
-  }
-
-  @Override
-  protected ODataValue getODataValue(final FullQualifiedName type,
-          final Valuable valuable, final ContextURL contextURL, final String metadataETag) {
-
-    // fixes enum values treated as primitive when no type information is available
-    if (client instanceof EdmEnabledODataClient && type != null) {
-      final EdmEnumType edmType = ((EdmEnabledODataClient) client).getEdm(metadataETag).getEnumType(type);
-      if (valuable.getValue().isPrimitive() && edmType != null) {
-        valuable.setValue(new EnumValueImpl(valuable.getValue().asPrimitive().get()));
-      }
-    }
-
-    ODataValue value;
-    if (valuable.getValue().isEnum()) {
-      value = ((ODataClient) client).getObjectFactory().newEnumValue(type == null ? null : type.toString(),
-              valuable.getValue().asEnum().get());
-    } else if (valuable.getValue().isLinkedComplex()) {
-      final ODataLinkedComplexValue lcValue =
-              ((ODataClient) client).getObjectFactory().newLinkedComplexValue(type == null ? null : type.toString());
-
-      for (Property property : valuable.getValue().asLinkedComplex().get()) {
-        lcValue.add(getODataProperty(new ResWrap<Property>(contextURL, metadataETag, property)));
-      }
-
-      EdmComplexType edmType = null;
-      if (client instanceof EdmEnabledODataClient && type != null) {
-        edmType = ((EdmEnabledODataClient) client).getEdm(metadataETag).getComplexType(type);
-      }
-
-      odataNavigationLinks(edmType, valuable.getValue().asLinkedComplex(), lcValue, metadataETag,
-              contextURL == null ? null : contextURL.getURI());
-      odataAnnotations(valuable.getValue().asLinkedComplex(), lcValue);
-
-      value = lcValue;
-    } else {
-      value = super.getODataValue(type, valuable, contextURL, metadataETag);
-    }
-
-    return value;
-  }
-
-  @Override
-  public ODataDelta getODataDelta(final ResWrap<Delta> resource) {
-    final URI base = resource.getContextURL() == null
-            ? resource.getPayload().getBaseURI() : resource.getContextURL().getServiceRoot();
-
-    final URI next = resource.getPayload().getNext();
-
-    final ODataDelta delta = next == null
-            ? ((ODataClient) client).getObjectFactory().newDelta()
-            : ((ODataClient) client).getObjectFactory().newDelta(URIUtils.getURI(base, next.toASCIIString()));
-
-    if (resource.getPayload().getCount() != null) {
-      delta.setCount(resource.getPayload().getCount());
-    }
-
-    if (resource.getPayload().getDeltaLink() != null) {
-      delta.setDeltaLink(URIUtils.getURI(base, resource.getPayload().getDeltaLink()));
-    }
-
-    for (Entity entityResource : resource.getPayload().getEntities()) {
-      add(delta, getODataEntity(
-              new ResWrap<Entity>(resource.getContextURL(), resource.getMetadataETag(), entityResource)));
-    }
-    for (DeletedEntity deletedEntity : resource.getPayload().getDeletedEntities()) {
-      final ODataDeletedEntityImpl impl = new ODataDeletedEntityImpl();
-      impl.setId(URIUtils.getURI(base, deletedEntity.getId()));
-      impl.setReason(Reason.valueOf(deletedEntity.getReason().name()));
-
-      delta.getDeletedEntities().add(impl);
-    }
-
-    odataAnnotations(resource.getPayload(), delta);
-
-    for (DeltaLink link : resource.getPayload().getAddedLinks()) {
-      final ODataDeltaLink impl = new ODataDeltaLinkImpl();
-      impl.setRelationship(link.getRelationship());
-      impl.setSource(URIUtils.getURI(base, link.getSource()));
-      impl.setTarget(URIUtils.getURI(base, link.getTarget()));
-
-      odataAnnotations(link, impl);
-
-      delta.getAddedLinks().add(impl);
-    }
-    for (DeltaLink link : resource.getPayload().getDeletedLinks()) {
-      final ODataDeltaLink impl = new ODataDeltaLinkImpl();
-      impl.setRelationship(link.getRelationship());
-      impl.setSource(URIUtils.getURI(base, link.getSource()));
-      impl.setTarget(URIUtils.getURI(base, link.getTarget()));
-
-      odataAnnotations(link, impl);
-
-      delta.getDeletedLinks().add(impl);
-    }
-
-    return delta;
-  }
-}


[2/9] [OLINGO-317] Rename and move of some packages and classes

Posted by mi...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java
new file mode 100755
index 0000000..bb2e0d2
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java
@@ -0,0 +1,474 @@
+/*
+ * 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.serialization;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.AbstractMap.SimpleEntry;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.Annotatable;
+import org.apache.olingo.commons.api.data.Annotation;
+import org.apache.olingo.commons.api.data.CollectionValue;
+import org.apache.olingo.commons.api.data.ComplexValue;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.Linked;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.data.Valuable;
+import org.apache.olingo.commons.api.data.Value;
+import org.apache.olingo.commons.api.domain.ODataError;
+import org.apache.olingo.commons.api.domain.ODataLinkType;
+import org.apache.olingo.commons.api.domain.ODataPropertyType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.api.serialization.ODataDeserializer;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+import org.apache.olingo.commons.core.data.AnnotationImpl;
+import org.apache.olingo.commons.core.data.CollectionValueImpl;
+import org.apache.olingo.commons.core.data.ComplexValueImpl;
+import org.apache.olingo.commons.core.data.EntitySetImpl;
+import org.apache.olingo.commons.core.data.EnumValueImpl;
+import org.apache.olingo.commons.core.data.GeospatialValueImpl;
+import org.apache.olingo.commons.core.data.LinkImpl;
+import org.apache.olingo.commons.core.data.LinkedComplexValueImpl;
+import org.apache.olingo.commons.core.data.NullValueImpl;
+import org.apache.olingo.commons.core.data.PrimitiveValueImpl;
+import org.apache.olingo.commons.core.data.PropertyImpl;
+import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.ObjectCodec;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+public class JsonDeserializer implements ODataDeserializer {
+
+  protected final Pattern CUSTOM_ANNOTATION = Pattern.compile("(.+)@(.+)\\.(.+)");
+  protected final ODataServiceVersion version;
+  protected final boolean serverMode;
+
+  protected String jsonType;
+  protected String jsonId;
+  protected String jsonETag;
+  protected String jsonReadLink;
+  protected String jsonEditLink;
+  protected String jsonMediaEditLink;
+  protected String jsonMediaReadLink;
+  protected String jsonMediaContentType;
+  protected String jsonMediaETag;
+  protected String jsonAssociationLink;
+  protected String jsonNavigationLink;
+  protected String jsonCount;
+  protected String jsonNextLink;
+  protected String jsonDeltaLink;
+  protected String jsonError;
+
+  private JsonGeoValueDeserializer geoDeserializer;
+
+  private JsonParser parser;
+
+  public JsonDeserializer(final ODataServiceVersion version, final boolean serverMode) {
+    this.version = version;
+    this.serverMode = serverMode;
+
+    jsonType = version.getJSONMap().get(ODataServiceVersion.JSON_TYPE);
+    jsonId = version.getJSONMap().get(ODataServiceVersion.JSON_ID);
+    jsonETag = version.getJSONMap().get(ODataServiceVersion.JSON_ETAG);
+    jsonReadLink = version.getJSONMap().get(ODataServiceVersion.JSON_READ_LINK);
+    jsonEditLink = version.getJSONMap().get(ODataServiceVersion.JSON_EDIT_LINK);
+    jsonMediaReadLink = version.getJSONMap().get(ODataServiceVersion.JSON_MEDIAREAD_LINK);
+    jsonMediaEditLink = version.getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK);
+    jsonMediaContentType = version.getJSONMap().get(ODataServiceVersion.JSON_MEDIA_CONTENT_TYPE);
+    jsonMediaETag = version.getJSONMap().get(ODataServiceVersion.JSON_MEDIA_ETAG);
+    jsonAssociationLink = version.getJSONMap().get(ODataServiceVersion.JSON_ASSOCIATION_LINK);
+    jsonNavigationLink = version.getJSONMap().get(ODataServiceVersion.JSON_NAVIGATION_LINK);
+    jsonCount = version.getJSONMap().get(ODataServiceVersion.JSON_COUNT);
+    jsonNextLink = version.getJSONMap().get(ODataServiceVersion.JSON_NEXT_LINK);
+    jsonDeltaLink = version.getJSONMap().get(ODataServiceVersion.JSON_DELTA_LINK);
+    jsonError = version.getJSONMap().get(ODataServiceVersion.JSON_ERROR);
+}
+
+  private JsonGeoValueDeserializer getGeoDeserializer() {
+    if (geoDeserializer == null) {
+      geoDeserializer = new JsonGeoValueDeserializer(version);
+    }
+    return geoDeserializer;
+  }
+
+  protected String getJSONAnnotation(final String string) {
+    return StringUtils.prependIfMissing(string, "@");
+  }
+
+  protected String getTitle(final Map.Entry<String, JsonNode> entry) {
+    return entry.getKey().substring(0, entry.getKey().indexOf('@'));
+  }
+
+  protected String setInline(final String name, final String suffix, final JsonNode tree,
+      final ObjectCodec codec, final LinkImpl link) throws IOException {
+
+    final String entityNamePrefix = name.substring(0, name.indexOf(suffix));
+    if (tree.has(entityNamePrefix)) {
+      final JsonNode inline = tree.path(entityNamePrefix);
+      JsonEntityDeserializer entityDeserializer = new JsonEntityDeserializer(version, serverMode);
+
+      if (inline instanceof ObjectNode) {
+        link.setType(ODataLinkType.ENTITY_NAVIGATION.toString());
+        link.setInlineEntity(entityDeserializer.doDeserialize(inline.traverse(codec)).getPayload());
+
+      } else if (inline instanceof ArrayNode) {
+        link.setType(ODataLinkType.ENTITY_SET_NAVIGATION.toString());
+
+        EntitySet entitySet = new EntitySetImpl();
+        Iterator<JsonNode> entries = ((ArrayNode) inline).elements();
+        while (entries.hasNext()) {
+          entitySet.getEntities().add(
+              entityDeserializer.doDeserialize(entries.next().traverse(codec)).getPayload());
+        }
+
+        link.setInlineEntitySet(entitySet);
+      }
+    }
+    return entityNamePrefix;
+  }
+
+  protected void links(final Map.Entry<String, JsonNode> field, final Linked linked, final Set<String> toRemove,
+      final JsonNode tree, final ObjectCodec codec) throws IOException {
+    if (serverMode) {
+      serverLinks(field, linked, toRemove, tree, codec);
+    } else {
+      clientLinks(field, linked, toRemove, tree, codec);
+    }
+  }
+
+  private void clientLinks(final Map.Entry<String, JsonNode> field, final Linked linked, final Set<String> toRemove,
+      final JsonNode tree, final ObjectCodec codec) throws IOException {
+
+    if (field.getKey().endsWith(jsonNavigationLink)) {
+      final LinkImpl link = new LinkImpl();
+      link.setTitle(getTitle(field));
+      link.setRel(version.getNamespaceMap().get(ODataServiceVersion.NAVIGATION_LINK_REL) + getTitle(field));
+
+      if (field.getValue().isValueNode()) {
+        link.setHref(field.getValue().textValue());
+        link.setType(ODataLinkType.ENTITY_NAVIGATION.toString());
+      }
+
+      linked.getNavigationLinks().add(link);
+
+      toRemove.add(field.getKey());
+      toRemove.add(setInline(field.getKey(), jsonNavigationLink, tree, codec, link));
+    } else if (field.getKey().endsWith(jsonAssociationLink)) {
+      final LinkImpl link = new LinkImpl();
+      link.setTitle(getTitle(field));
+      link.setRel(version.getNamespaceMap().get(ODataServiceVersion.ASSOCIATION_LINK_REL) + getTitle(field));
+      link.setHref(field.getValue().textValue());
+      link.setType(ODataLinkType.ASSOCIATION.toString());
+      linked.getAssociationLinks().add(link);
+
+      toRemove.add(field.getKey());
+    }
+  }
+
+  private void serverLinks(final Map.Entry<String, JsonNode> field, final Linked linked, final Set<String> toRemove,
+      final JsonNode tree, final ObjectCodec codec) throws IOException {
+
+    if (field.getKey().endsWith(Constants.JSON_BIND_LINK_SUFFIX)
+        || field.getKey().endsWith(jsonNavigationLink)) {
+
+      if (field.getValue().isValueNode()) {
+        final String suffix = field.getKey().replaceAll("^.*@", "@");
+
+        final LinkImpl link = new LinkImpl();
+        link.setTitle(getTitle(field));
+        link.setRel(version.getNamespaceMap().get(ODataServiceVersion.NAVIGATION_LINK_REL) + getTitle(field));
+        link.setHref(field.getValue().textValue());
+        link.setType(ODataLinkType.ENTITY_NAVIGATION.toString());
+        linked.getNavigationLinks().add(link);
+
+        toRemove.add(setInline(field.getKey(), suffix, tree, codec, link));
+      } else if (field.getValue().isArray()) {
+        for (final Iterator<JsonNode> itor = field.getValue().elements(); itor.hasNext();) {
+          final JsonNode node = itor.next();
+
+          final LinkImpl link = new LinkImpl();
+          link.setTitle(getTitle(field));
+          link.setRel(version.getNamespaceMap().get(ODataServiceVersion.NAVIGATION_LINK_REL) + getTitle(field));
+          link.setHref(node.asText());
+          link.setType(ODataLinkType.ENTITY_SET_NAVIGATION.toString());
+          linked.getNavigationLinks().add(link);
+          toRemove.add(setInline(field.getKey(), Constants.JSON_BIND_LINK_SUFFIX, tree, codec, link));
+        }
+      }
+      toRemove.add(field.getKey());
+    }
+  }
+
+  private Map.Entry<ODataPropertyType, EdmTypeInfo> guessPropertyType(final JsonNode node) {
+    ODataPropertyType type;
+    EdmTypeInfo typeInfo = null;
+
+    if (node.isValueNode() || node.isNull()) {
+      type = ODataPropertyType.PRIMITIVE;
+
+      EdmPrimitiveTypeKind kind = EdmPrimitiveTypeKind.String;
+      if (node.isShort()) {
+        kind = EdmPrimitiveTypeKind.Int16;
+      } else if (node.isInt()) {
+        kind = EdmPrimitiveTypeKind.Int32;
+      } else if (node.isLong()) {
+        kind = EdmPrimitiveTypeKind.Int64;
+      } else if (node.isBoolean()) {
+        kind = EdmPrimitiveTypeKind.Boolean;
+      } else if (node.isFloat()) {
+        kind = EdmPrimitiveTypeKind.Single;
+      } else if (node.isDouble()) {
+        kind = EdmPrimitiveTypeKind.Double;
+      } else if (node.isBigDecimal()) {
+        kind = EdmPrimitiveTypeKind.Decimal;
+      }
+      typeInfo = new EdmTypeInfo.Builder().setTypeExpression(kind.getFullQualifiedName().toString()).build();
+    } else if (node.isArray()) {
+      type = ODataPropertyType.COLLECTION;
+    } else if (node.isObject()) {
+      if (node.has(Constants.ATTR_TYPE)) {
+        type = ODataPropertyType.PRIMITIVE;
+        typeInfo = new EdmTypeInfo.Builder().
+            setTypeExpression("Edm.Geography" + node.get(Constants.ATTR_TYPE).asText()).build();
+      } else {
+        type = ODataPropertyType.COMPLEX;
+      }
+    } else {
+      type = ODataPropertyType.EMPTY;
+    }
+
+    return new SimpleEntry<ODataPropertyType, EdmTypeInfo>(type, typeInfo);
+  }
+
+  protected void populate(final Annotatable annotatable, final List<Property> properties,
+      final ObjectNode tree, final ObjectCodec codec) throws IOException {
+
+    String type = null;
+    Annotation annotation = null;
+    for (final Iterator<Map.Entry<String, JsonNode>> itor = tree.fields(); itor.hasNext();) {
+      final Map.Entry<String, JsonNode> field = itor.next();
+      final Matcher customAnnotation = CUSTOM_ANNOTATION.matcher(field.getKey());
+
+      if (field.getKey().charAt(0) == '@') {
+        final Annotation entityAnnot = new AnnotationImpl();
+        entityAnnot.setTerm(field.getKey().substring(1));
+
+        value(entityAnnot, field.getValue(), codec);
+        if (annotatable != null) {
+          annotatable.getAnnotations().add(entityAnnot);
+        }
+      } else if (type == null && field.getKey().endsWith(getJSONAnnotation(jsonType))) {
+        type = field.getValue().asText();
+      } else if (annotation == null && customAnnotation.matches() && !"odata".equals(customAnnotation.group(2))) {
+        annotation = new AnnotationImpl();
+        annotation.setTerm(customAnnotation.group(2) + "." + customAnnotation.group(3));
+        value(annotation, field.getValue(), codec);
+      } else {
+        final PropertyImpl property = new PropertyImpl();
+        property.setName(field.getKey());
+        property.setType(type == null
+            ? null
+            : new EdmTypeInfo.Builder().setTypeExpression(type).build().internal());
+        type = null;
+
+        value(property, field.getValue(), codec);
+        properties.add(property);
+
+        if (annotation != null) {
+          property.getAnnotations().add(annotation);
+          annotation = null;
+        }
+      }
+    }
+  }
+
+  private Value fromPrimitive(final JsonNode node, final EdmTypeInfo typeInfo) {
+    final Value value;
+
+    if (node.isNull()) {
+      value = new NullValueImpl();
+    } else {
+      if (typeInfo != null && typeInfo.getPrimitiveTypeKind().isGeospatial()) {
+        value = new GeospatialValueImpl(getGeoDeserializer().deserialize(node, typeInfo));
+      } else {
+        value = new PrimitiveValueImpl(node.asText());
+      }
+    }
+
+    return value;
+  }
+
+  private ComplexValue fromComplex(final ObjectNode node, final ObjectCodec codec) throws IOException {
+    final ComplexValue value = version.compareTo(ODataServiceVersion.V40) < 0
+        ? new ComplexValueImpl()
+        : new LinkedComplexValueImpl();
+
+    if (value.isLinkedComplex()) {
+      final Set<String> toRemove = new HashSet<String>();
+      for (final Iterator<Map.Entry<String, JsonNode>> itor = node.fields(); itor.hasNext();) {
+        final Map.Entry<String, JsonNode> field = itor.next();
+
+        links(field, value.asLinkedComplex(), toRemove, node, codec);
+      }
+      node.remove(toRemove);
+    }
+
+    populate(value.asLinkedComplex(), value.get(), node, codec);
+
+    return value;
+  }
+
+  private CollectionValue fromCollection(final Iterator<JsonNode> nodeItor, final EdmTypeInfo typeInfo,
+      final ObjectCodec codec) throws IOException {
+
+    final CollectionValueImpl value = new CollectionValueImpl();
+
+    final EdmTypeInfo type = typeInfo == null
+        ? null
+        : new EdmTypeInfo.Builder().setTypeExpression(typeInfo.getFullQualifiedName().toString()).build();
+
+    while (nodeItor.hasNext()) {
+      final JsonNode child = nodeItor.next();
+
+      if (child.isValueNode()) {
+        if (typeInfo == null || typeInfo.isPrimitiveType()) {
+          value.get().add(fromPrimitive(child, type));
+        } else {
+          value.get().add(new EnumValueImpl(child.asText()));
+        }
+      } else if (child.isContainerNode()) {
+        if (child.has(jsonType)) {
+          ((ObjectNode) child).remove(jsonType);
+        }
+        value.get().add(fromComplex((ObjectNode) child, codec));
+      }
+    }
+
+    return value;
+  }
+
+  protected void value(final Valuable valuable, final JsonNode node, final ObjectCodec codec)
+      throws IOException {
+
+    EdmTypeInfo typeInfo = StringUtils.isBlank(valuable.getType())
+        ? null
+        : new EdmTypeInfo.Builder().setTypeExpression(valuable.getType()).build();
+
+    final Map.Entry<ODataPropertyType, EdmTypeInfo> guessed = guessPropertyType(node);
+    if (typeInfo == null) {
+      typeInfo = guessed.getValue();
+    }
+
+    final ODataPropertyType propType = typeInfo == null
+        ? guessed.getKey()
+        : typeInfo.isCollection()
+            ? ODataPropertyType.COLLECTION
+            : typeInfo.isPrimitiveType()
+                ? ODataPropertyType.PRIMITIVE
+                : node.isValueNode()
+                    ? ODataPropertyType.ENUM
+                    : ODataPropertyType.COMPLEX;
+
+    switch (propType) {
+    case COLLECTION:
+      valuable.setValue(fromCollection(node.elements(), typeInfo, codec));
+      break;
+
+    case COMPLEX:
+      if (node.has(jsonType)) {
+        valuable.setType(node.get(jsonType).asText());
+        ((ObjectNode) node).remove(jsonType);
+      }
+      valuable.setValue(fromComplex((ObjectNode) node, codec));
+      break;
+
+    case ENUM:
+      valuable.setValue(new EnumValueImpl(node.asText()));
+      break;
+
+    case PRIMITIVE:
+      if (valuable.getType() == null && typeInfo != null) {
+        valuable.setType(typeInfo.getFullQualifiedName().toString());
+      }
+      valuable.setValue(fromPrimitive(node, typeInfo));
+      break;
+
+    case EMPTY:
+    default:
+      valuable.setValue(new PrimitiveValueImpl(StringUtils.EMPTY));
+    }
+  }
+
+  @Override
+  public ResWrap<EntitySet> toEntitySet(InputStream input) throws ODataDeserializerException {
+    try {
+      parser = new JsonFactory(new ObjectMapper()).createParser(input);
+      return new JsonEntitySetDeserializer(version, serverMode).doDeserialize(parser);
+    } catch (final IOException e) {
+      throw new ODataDeserializerException(e);
+    }
+  }
+
+  @Override
+  public ResWrap<Entity> toEntity(InputStream input) throws ODataDeserializerException {
+    try {
+      parser = new JsonFactory(new ObjectMapper()).createParser(input);
+      return new JsonEntityDeserializer(version, serverMode).doDeserialize(parser);
+    } catch (final IOException e) {
+      throw new ODataDeserializerException(e);
+    }
+  }
+
+  @Override
+  public ResWrap<Property> toProperty(InputStream input) throws ODataDeserializerException {
+    try {
+      parser = new JsonFactory(new ObjectMapper()).createParser(input);
+      return new JsonPropertyDeserializer(version, serverMode).doDeserialize(parser);
+    } catch (final IOException e) {
+      throw new ODataDeserializerException(e);
+    }
+  }
+
+  @Override
+  public ODataError toError(InputStream input) throws ODataDeserializerException {
+    try {
+      parser = new JsonFactory(new ObjectMapper()).createParser(input);
+      return new JsonODataErrorDeserializer(version, serverMode).doDeserialize(parser);
+    } catch (final IOException e) {
+      throw new ODataDeserializerException(e);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntityDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntityDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntityDeserializer.java
new file mode 100644
index 0000000..af5d42f
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntityDeserializer.java
@@ -0,0 +1,223 @@
+/*
+ * 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.serialization;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.Annotation;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.Link;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.domain.ODataLinkType;
+import org.apache.olingo.commons.api.domain.ODataOperation;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.core.data.AnnotationImpl;
+import org.apache.olingo.commons.core.data.EntityImpl;
+import org.apache.olingo.commons.core.data.LinkImpl;
+import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * Reads JSON string into an entity.
+ * <br/>
+ * If metadata information is available, the corresponding entity fields and content will be populated.
+ */
+public class JsonEntityDeserializer extends JsonDeserializer {
+
+  public JsonEntityDeserializer(final ODataServiceVersion version, final boolean serverMode) {
+    super(version, serverMode);
+  }
+
+  protected ResWrap<Entity> doDeserialize(final JsonParser parser) throws IOException {
+
+    final ObjectNode tree = parser.getCodec().readTree(parser);
+
+    if (tree.has(Constants.VALUE) && tree.get(Constants.VALUE).isArray()) {
+      throw new JsonParseException("Expected OData Entity, found EntitySet", parser.getCurrentLocation());
+    }
+
+    final EntityImpl entity = new EntityImpl();
+
+    final URI contextURL;
+    if (tree.hasNonNull(Constants.JSON_CONTEXT)) {
+      contextURL = URI.create(tree.get(Constants.JSON_CONTEXT).textValue());
+      tree.remove(Constants.JSON_CONTEXT);
+    } else if (tree.hasNonNull(Constants.JSON_METADATA)) {
+      contextURL = URI.create(tree.get(Constants.JSON_METADATA).textValue());
+      tree.remove(Constants.JSON_METADATA);
+    } else {
+      contextURL = null;
+    }
+    if (contextURL != null) {
+      entity.setBaseURI(StringUtils.substringBefore(contextURL.toASCIIString(), Constants.METADATA));
+    }
+
+    final String metadataETag;
+    if (tree.hasNonNull(Constants.JSON_METADATA_ETAG)) {
+      metadataETag = tree.get(Constants.JSON_METADATA_ETAG).textValue();
+      tree.remove(Constants.JSON_METADATA_ETAG);
+    } else {
+      metadataETag = null;
+    }
+
+    if (tree.hasNonNull(jsonETag)) {
+      entity.setETag(tree.get(jsonETag).textValue());
+      tree.remove(jsonETag);
+    }
+
+    if (tree.hasNonNull(jsonType)) {
+      entity.setType(new EdmTypeInfo.Builder().setTypeExpression(tree.get(jsonType).textValue()).build().internal());
+      tree.remove(jsonType);
+    }
+
+    if (tree.hasNonNull(jsonId)) {
+      entity.setId(URI.create(tree.get(jsonId).textValue()));
+      tree.remove(jsonId);
+    }
+
+    if (tree.hasNonNull(jsonReadLink)) {
+      final LinkImpl link = new LinkImpl();
+      link.setRel(Constants.SELF_LINK_REL);
+      link.setHref(tree.get(jsonReadLink).textValue());
+      entity.setSelfLink(link);
+
+      tree.remove(jsonReadLink);
+    }
+
+    if (tree.hasNonNull(jsonEditLink)) {
+      final LinkImpl link = new LinkImpl();
+      if (serverMode) {
+        link.setRel(Constants.EDIT_LINK_REL);
+      }
+      link.setHref(tree.get(jsonEditLink).textValue());
+      entity.setEditLink(link);
+
+      tree.remove(jsonEditLink);
+    }
+
+    if (tree.hasNonNull(jsonMediaReadLink)) {
+      entity.setMediaContentSource(URI.create(tree.get(jsonMediaReadLink).textValue()));
+      tree.remove(jsonMediaReadLink);
+    }
+    if (tree.hasNonNull(jsonMediaEditLink)) {
+      entity.setMediaContentSource(URI.create(tree.get(jsonMediaEditLink).textValue()));
+      tree.remove(jsonMediaEditLink);
+    }
+    if (tree.hasNonNull(jsonMediaContentType)) {
+      entity.setMediaContentType(tree.get(jsonMediaContentType).textValue());
+      tree.remove(jsonMediaContentType);
+    }
+    if (tree.hasNonNull(jsonMediaETag)) {
+      entity.setMediaETag(tree.get(jsonMediaETag).textValue());
+      tree.remove(jsonMediaETag);
+    }
+
+    final Set<String> toRemove = new HashSet<String>();
+
+    final Map<String, List<Annotation>> annotations = new HashMap<String, List<Annotation>>();
+    for (final Iterator<Map.Entry<String, JsonNode>> itor = tree.fields(); itor.hasNext();) {
+      final Map.Entry<String, JsonNode> field = itor.next();
+      final Matcher customAnnotation = CUSTOM_ANNOTATION.matcher(field.getKey());
+
+      links(field, entity, toRemove, tree, parser.getCodec());
+      if (field.getKey().endsWith(getJSONAnnotation(jsonMediaEditLink))) {
+        final LinkImpl link = new LinkImpl();
+        link.setTitle(getTitle(field));
+        link.setRel(version.getNamespaceMap().get(ODataServiceVersion.MEDIA_EDIT_LINK_REL) + getTitle(field));
+        link.setHref(field.getValue().textValue());
+        link.setType(ODataLinkType.MEDIA_EDIT.toString());
+        entity.getMediaEditLinks().add(link);
+
+        if (tree.has(link.getTitle() + getJSONAnnotation(jsonMediaETag))) {
+          link.setMediaETag(tree.get(link.getTitle() + getJSONAnnotation(jsonMediaETag)).asText());
+          toRemove.add(link.getTitle() + getJSONAnnotation(jsonMediaETag));
+        }
+
+        toRemove.add(field.getKey());
+        toRemove.add(setInline(field.getKey(), getJSONAnnotation(jsonMediaEditLink), tree, parser.getCodec(), link));
+      } else if (field.getKey().endsWith(getJSONAnnotation(jsonMediaContentType))) {
+        final String linkTitle = getTitle(field);
+        for (Link link : entity.getMediaEditLinks()) {
+          if (linkTitle.equals(link.getTitle())) {
+            ((LinkImpl) link).setType(field.getValue().asText());
+          }
+        }
+        toRemove.add(field.getKey());
+      } else if (field.getKey().charAt(0) == '#') {
+        final ODataOperation operation = new ODataOperation();
+        operation.setMetadataAnchor(field.getKey());
+
+        final ObjectNode opNode = (ObjectNode) tree.get(field.getKey());
+        operation.setTitle(opNode.get(Constants.ATTR_TITLE).asText());
+        operation.setTarget(URI.create(opNode.get(Constants.ATTR_TARGET).asText()));
+
+        entity.getOperations().add(operation);
+
+        toRemove.add(field.getKey());
+      } else if (customAnnotation.matches() && !"odata".equals(customAnnotation.group(2))) {
+        final Annotation annotation = new AnnotationImpl();
+        annotation.setTerm(customAnnotation.group(2) + "." + customAnnotation.group(3));
+        value(annotation, field.getValue(), parser.getCodec());
+
+        if (!annotations.containsKey(customAnnotation.group(1))) {
+          annotations.put(customAnnotation.group(1), new ArrayList<Annotation>());
+        }
+        annotations.get(customAnnotation.group(1)).add(annotation);
+      }
+    }
+
+    for (Link link : entity.getNavigationLinks()) {
+      if (annotations.containsKey(link.getTitle())) {
+        link.getAnnotations().addAll(annotations.get(link.getTitle()));
+        for (Annotation annotation : annotations.get(link.getTitle())) {
+          toRemove.add(link.getTitle() + "@" + annotation.getTerm());
+        }
+      }
+    }
+    for (Link link : entity.getMediaEditLinks()) {
+      if (annotations.containsKey(link.getTitle())) {
+        link.getAnnotations().addAll(annotations.get(link.getTitle()));
+        for (Annotation annotation : annotations.get(link.getTitle())) {
+          toRemove.add(link.getTitle() + "@" + annotation.getTerm());
+        }
+      }
+    }
+
+    tree.remove(toRemove);
+
+    populate(entity, entity.getProperties(), tree, parser.getCodec());
+
+    return new ResWrap<Entity>(contextURL, metadataETag, entity);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySerializer.java
new file mode 100644
index 0000000..22d6a92
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySerializer.java
@@ -0,0 +1,129 @@
+/*
+ * 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.serialization;
+
+import java.io.IOException;
+import java.net.URI;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.Annotation;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.Link;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.domain.ODataOperation;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+
+/**
+ * Writes out JSON string from an entity.
+ */
+public class JsonEntitySerializer extends JsonSerializer {
+
+  public JsonEntitySerializer(final ODataServiceVersion version, final boolean serverMode) {
+    super(version, serverMode);
+  }
+
+  protected void doSerialize(final Entity entity, final JsonGenerator jgen) throws IOException {
+    doContainerSerialize(new ResWrap<Entity>((URI) null, null, entity), jgen);
+  }
+
+  protected void doContainerSerialize(final ResWrap<Entity> container, final JsonGenerator jgen)
+      throws IOException {
+
+    final Entity entity = container.getPayload();
+
+    jgen.writeStartObject();
+
+    if (serverMode) {
+      if (container.getContextURL() != null) {
+        jgen.writeStringField(version.compareTo(ODataServiceVersion.V40) >= 0
+            ? Constants.JSON_CONTEXT : Constants.JSON_METADATA,
+            container.getContextURL().getURI().toASCIIString());
+      }
+      if (version.compareTo(ODataServiceVersion.V40) >= 0 && StringUtils.isNotBlank(container.getMetadataETag())) {
+        jgen.writeStringField(Constants.JSON_METADATA_ETAG, container.getMetadataETag());
+      }
+
+      if (StringUtils.isNotBlank(entity.getETag())) {
+        jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_ETAG), entity.getETag());
+      }
+    }
+
+    if (StringUtils.isNotBlank(entity.getType())) {
+      jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_TYPE),
+          new EdmTypeInfo.Builder().setTypeExpression(entity.getType()).build().external(version));
+    }
+
+    if (entity.getId() != null) {
+      jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_ID), entity.getId().toASCIIString());
+    }
+
+    for (Annotation annotation : entity.getAnnotations()) {
+      valuable(jgen, annotation, "@" + annotation.getTerm());
+    }
+
+    for (Property property : entity.getProperties()) {
+      valuable(jgen, property, property.getName());
+    }
+
+    if (serverMode && entity.getEditLink() != null && StringUtils.isNotBlank(entity.getEditLink().getHref())) {
+      jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_EDIT_LINK),
+          entity.getEditLink().getHref());
+
+      if (entity.isMediaEntity()) {
+        jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_MEDIAREAD_LINK),
+            entity.getEditLink().getHref() + "/$value");
+      }
+    }
+
+    links(entity, jgen);
+
+    for (Link link : entity.getMediaEditLinks()) {
+      if (link.getTitle() == null) {
+        jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK), link.getHref());
+      }
+
+      if (link.getInlineEntity() != null) {
+        jgen.writeObjectField(link.getTitle(), link.getInlineEntity());
+      }
+      if (link.getInlineEntitySet() != null) {
+        jgen.writeArrayFieldStart(link.getTitle());
+        for (Entity subEntry : link.getInlineEntitySet().getEntities()) {
+          jgen.writeObject(subEntry);
+        }
+        jgen.writeEndArray();
+      }
+    }
+
+    if (serverMode) {
+      for (ODataOperation operation : entity.getOperations()) {
+        jgen.writeObjectFieldStart("#" + StringUtils.substringAfterLast(operation.getMetadataAnchor(), "#"));
+        jgen.writeStringField(Constants.ATTR_TITLE, operation.getTitle());
+        jgen.writeStringField(Constants.ATTR_TARGET, operation.getTarget().toASCIIString());
+        jgen.writeEndObject();
+      }
+    }
+
+    jgen.writeEndObject();
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetDeserializer.java
new file mode 100644
index 0000000..d7f86fb
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetDeserializer.java
@@ -0,0 +1,118 @@
+/*
+ * 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.serialization;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.Annotation;
+import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.core.data.AnnotationImpl;
+import org.apache.olingo.commons.core.data.EntitySetImpl;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * Reads JSON string into an entity set.
+ * <br/>
+ * If metadata information is available, the corresponding entity fields and content will be populated.
+ */
+public class JsonEntitySetDeserializer extends JsonDeserializer {
+
+  public JsonEntitySetDeserializer(final ODataServiceVersion version, final boolean serverMode) {
+    super(version, serverMode);
+  }
+
+  protected ResWrap<EntitySet> doDeserialize(final JsonParser parser) throws IOException {
+
+    final ObjectNode tree = (ObjectNode) parser.getCodec().readTree(parser);
+
+    if (!tree.has(Constants.VALUE)) {
+      return null;
+    }
+
+    final EntitySetImpl entitySet = new EntitySetImpl();
+
+    URI contextURL;
+    if (tree.hasNonNull(Constants.JSON_CONTEXT)) {
+      contextURL = URI.create(tree.get(Constants.JSON_CONTEXT).textValue());
+      tree.remove(Constants.JSON_CONTEXT);
+    } else if (tree.hasNonNull(Constants.JSON_METADATA)) {
+      contextURL = URI.create(tree.get(Constants.JSON_METADATA).textValue());
+      tree.remove(Constants.JSON_METADATA);
+    } else {
+      contextURL = null;
+    }
+    if (contextURL != null) {
+      entitySet.setBaseURI(StringUtils.substringBefore(contextURL.toASCIIString(), Constants.METADATA));
+    }
+
+    final String metadataETag;
+    if (tree.hasNonNull(Constants.JSON_METADATA_ETAG)) {
+      metadataETag = tree.get(Constants.JSON_METADATA_ETAG).textValue();
+      tree.remove(Constants.JSON_METADATA_ETAG);
+    } else {
+      metadataETag = null;
+    }
+
+    if (tree.hasNonNull(jsonCount)) {
+      entitySet.setCount(tree.get(jsonCount).asInt());
+      tree.remove(jsonCount);
+    }
+    if (tree.hasNonNull(jsonNextLink)) {
+      entitySet.setNext(URI.create(tree.get(jsonNextLink).textValue()));
+      tree.remove(jsonNextLink);
+    }
+    if (tree.hasNonNull(jsonDeltaLink)) {
+      entitySet.setDeltaLink(URI.create(tree.get(jsonDeltaLink).textValue()));
+      tree.remove(jsonDeltaLink);
+    }
+
+    if (tree.hasNonNull(Constants.VALUE)) {
+      final JsonEntityDeserializer entityDeserializer = new JsonEntityDeserializer(version, serverMode);
+      for (final Iterator<JsonNode> itor = tree.get(Constants.VALUE).iterator(); itor.hasNext();) {
+        entitySet.getEntities().add(
+            entityDeserializer.doDeserialize(itor.next().traverse(parser.getCodec())).getPayload());
+      }
+      tree.remove(Constants.VALUE);
+    }
+
+    // any remaining entry is supposed to be an annotation or is ignored
+    for (final Iterator<Map.Entry<String, JsonNode>> itor = tree.fields(); itor.hasNext();) {
+      final Map.Entry<String, JsonNode> field = itor.next();
+      if (field.getKey().charAt(0) == '@') {
+        final Annotation annotation = new AnnotationImpl();
+        annotation.setTerm(field.getKey().substring(1));
+
+        value(annotation, field.getValue(), parser.getCodec());
+        entitySet.getAnnotations().add(annotation);
+      }
+    }
+
+    return new ResWrap<EntitySet>(contextURL, metadataETag, entitySet);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetSerializer.java
new file mode 100644
index 0000000..e1cc38b
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetSerializer.java
@@ -0,0 +1,94 @@
+/*
+ * 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.serialization;
+
+import java.io.IOException;
+import java.net.URI;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.Annotation;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+
+public class JsonEntitySetSerializer extends JsonSerializer {
+
+  public JsonEntitySetSerializer(final ODataServiceVersion version, final boolean serverMode) {
+    super(version, serverMode);
+  }
+
+  protected void doSerialize(final EntitySet entitySet, final JsonGenerator jgen) throws IOException {
+    doContainerSerialize(new ResWrap<EntitySet>((URI) null, null, entitySet), jgen);
+  }
+
+  protected void doContainerSerialize(final ResWrap<EntitySet> container, final JsonGenerator jgen)
+      throws IOException {
+
+    final EntitySet entitySet = container.getPayload();
+
+    jgen.writeStartObject();
+
+    if (serverMode) {
+      if (container.getContextURL() != null) {
+        jgen.writeStringField(version.compareTo(ODataServiceVersion.V40) >= 0
+            ? Constants.JSON_CONTEXT : Constants.JSON_METADATA,
+            container.getContextURL().getURI().toASCIIString());
+      }
+
+      if (version.compareTo(ODataServiceVersion.V40) >= 0 && StringUtils.isNotBlank(container.getMetadataETag())) {
+        jgen.writeStringField(
+            Constants.JSON_METADATA_ETAG,
+            container.getMetadataETag());
+      }
+    }
+
+    if (entitySet.getId() != null) {
+      jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_ID), entitySet.getId().toASCIIString());
+    }
+    jgen.writeNumberField(version.getJSONMap().get(ODataServiceVersion.JSON_COUNT),
+        entitySet.getCount() == null ? entitySet.getEntities().size() : entitySet.getCount());
+    if (serverMode) {
+      if (entitySet.getNext() != null) {
+        jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_NEXT_LINK),
+            entitySet.getNext().toASCIIString());
+      }
+      if (entitySet.getDeltaLink() != null) {
+        jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_DELTA_LINK),
+            entitySet.getDeltaLink().toASCIIString());
+      }
+    }
+
+    for (Annotation annotation : entitySet.getAnnotations()) {
+      valuable(jgen, annotation, "@" + annotation.getTerm());
+    }
+
+    jgen.writeArrayFieldStart(Constants.VALUE);
+    final JsonEntitySerializer entitySerializer = new JsonEntitySerializer(version, serverMode);
+    for (Entity entity : entitySet.getEntities()) {
+      entitySerializer.doSerialize(entity, jgen);
+    }
+    jgen.writeEndArray();
+
+    jgen.writeEndObject();
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonGeoValueDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonGeoValueDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonGeoValueDeserializer.java
new file mode 100644
index 0000000..8d2db37
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonGeoValueDeserializer.java
@@ -0,0 +1,267 @@
+/*
+ * 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.serialization;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.GeoUtils;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.api.edm.geo.Geospatial;
+import org.apache.olingo.commons.api.edm.geo.GeospatialCollection;
+import org.apache.olingo.commons.api.edm.geo.LineString;
+import org.apache.olingo.commons.api.edm.geo.MultiLineString;
+import org.apache.olingo.commons.api.edm.geo.MultiPoint;
+import org.apache.olingo.commons.api.edm.geo.MultiPolygon;
+import org.apache.olingo.commons.api.edm.geo.Point;
+import org.apache.olingo.commons.api.edm.geo.Polygon;
+import org.apache.olingo.commons.api.edm.geo.SRID;
+import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+import org.apache.olingo.commons.core.edm.primitivetype.EdmDouble;
+
+class JsonGeoValueDeserializer {
+
+  private final ODataServiceVersion version;
+
+  public JsonGeoValueDeserializer(final ODataServiceVersion version) {
+    this.version = version;
+  }
+
+  private Point point(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type, final SRID srid) {
+    Point point = null;
+
+    if (itor.hasNext()) {
+      point = new Point(GeoUtils.getDimension(type), srid);
+      try {
+        point.setX(EdmDouble.getInstance().valueOfString(itor.next().asText(), null, null,
+                Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, Double.class));
+        point.setY(EdmDouble.getInstance().valueOfString(itor.next().asText(), null, null,
+                Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, Double.class));
+      } catch (EdmPrimitiveTypeException e) {
+        throw new IllegalArgumentException("While deserializing point coordinates as double", e);
+      }
+    }
+
+    return point;
+  }
+
+  private MultiPoint multipoint(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type, final SRID srid) {
+    final MultiPoint multiPoint;
+
+    if (itor.hasNext()) {
+      final List<Point> points = new ArrayList<Point>();
+      while (itor.hasNext()) {
+        final Iterator<JsonNode> mpItor = itor.next().elements();
+        points.add(point(mpItor, type, srid));
+      }
+      multiPoint = new MultiPoint(GeoUtils.getDimension(type), srid, points);
+    } else {
+      multiPoint = new MultiPoint(GeoUtils.getDimension(type), srid, Collections.<Point>emptyList());
+    }
+
+    return multiPoint;
+  }
+
+  private LineString lineString(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type, final SRID srid) {
+    final LineString lineString;
+
+    if (itor.hasNext()) {
+      final List<Point> points = new ArrayList<Point>();
+      while (itor.hasNext()) {
+        final Iterator<JsonNode> mpItor = itor.next().elements();
+        points.add(point(mpItor, type, srid));
+      }
+      lineString = new LineString(GeoUtils.getDimension(type), srid, points);
+    } else {
+      lineString = new LineString(GeoUtils.getDimension(type), srid, Collections.<Point>emptyList());
+    }
+
+    return lineString;
+  }
+
+  private MultiLineString multiLineString(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type,
+          final SRID srid) {
+
+    final MultiLineString multiLineString;
+
+    if (itor.hasNext()) {
+      final List<LineString> lineStrings = new ArrayList<LineString>();
+      while (itor.hasNext()) {
+        final Iterator<JsonNode> mlsItor = itor.next().elements();
+        lineStrings.add(lineString(mlsItor, type, srid));
+      }
+      multiLineString = new MultiLineString(GeoUtils.getDimension(type), srid, lineStrings);
+    } else {
+      multiLineString = new MultiLineString(GeoUtils.getDimension(type), srid, Collections.<LineString>emptyList());
+    }
+
+    return multiLineString;
+  }
+
+  private Polygon polygon(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type, final SRID srid) {
+    List<Point> extPoints = null;
+    if (itor.hasNext()) {
+      final Iterator<JsonNode> extItor = itor.next().elements();
+      if (extItor.hasNext()) {
+        extPoints = new ArrayList<Point>();
+        while (extItor.hasNext()) {
+          final Iterator<JsonNode> mpItor = extItor.next().elements();
+          extPoints.add(point(mpItor, type, srid));
+        }
+      }
+    }
+
+    List<Point> intPoints = null;
+    if (itor.hasNext()) {
+      final Iterator<JsonNode> intItor = itor.next().elements();
+      if (intItor.hasNext()) {
+        intPoints = new ArrayList<Point>();
+        while (intItor.hasNext()) {
+          final Iterator<JsonNode> mpItor = intItor.next().elements();
+          intPoints.add(point(mpItor, type, srid));
+        }
+      }
+    }
+
+    return new Polygon(GeoUtils.getDimension(type), srid, intPoints, extPoints);
+  }
+
+  private MultiPolygon multiPolygon(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type, final SRID srid) {
+    final MultiPolygon multiPolygon;
+
+    if (itor.hasNext()) {
+      final List<Polygon> polygons = new ArrayList<Polygon>();
+      while (itor.hasNext()) {
+        final Iterator<JsonNode> mpItor = itor.next().elements();
+        polygons.add(polygon(mpItor, type, srid));
+      }
+      multiPolygon = new MultiPolygon(GeoUtils.getDimension(type), srid, polygons);
+    } else {
+      multiPolygon = new MultiPolygon(GeoUtils.getDimension(type), srid, Collections.<Polygon>emptyList());
+    }
+
+    return multiPolygon;
+  }
+
+  private GeospatialCollection collection(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type,
+          final SRID srid) {
+
+    final GeospatialCollection collection;
+
+    if (itor.hasNext()) {
+      final List<Geospatial> geospatials = new ArrayList<Geospatial>();
+
+      while (itor.hasNext()) {
+        final JsonNode geo = itor.next();
+        final String collItemType = geo.get(Constants.ATTR_TYPE).asText();
+        final String callAsType;
+        if (EdmPrimitiveTypeKind.GeographyCollection.name().equals(collItemType)
+                || EdmPrimitiveTypeKind.GeometryCollection.name().equals(collItemType)) {
+
+          callAsType = collItemType;
+        } else {
+          callAsType = (type == EdmPrimitiveTypeKind.GeographyCollection ? "Geography" : "Geometry")
+                  + collItemType;
+        }
+
+        geospatials.add(deserialize(geo, new EdmTypeInfo.Builder().setTypeExpression(callAsType).build()));
+      }
+
+      collection = new GeospatialCollection(GeoUtils.getDimension(type), srid, geospatials);
+    } else {
+      collection = new GeospatialCollection(GeoUtils.getDimension(type), srid, Collections.<Geospatial>emptyList());
+    }
+
+    return collection;
+  }
+
+  public Geospatial deserialize(final JsonNode node, final EdmTypeInfo typeInfo) {
+    final EdmPrimitiveTypeKind actualType;
+    if ((typeInfo.getPrimitiveTypeKind() == EdmPrimitiveTypeKind.Geography
+            || typeInfo.getPrimitiveTypeKind() == EdmPrimitiveTypeKind.Geometry)
+            && node.has(Constants.ATTR_TYPE)) {
+
+      String nodeType = node.get(Constants.ATTR_TYPE).asText();
+      if (nodeType.startsWith("Geo")) {
+        final int yIdx = nodeType.indexOf('y');
+        nodeType = nodeType.substring(yIdx + 1);
+      }
+      actualType = EdmPrimitiveTypeKind.valueOfFQN(version, typeInfo.getFullQualifiedName().toString() + nodeType);
+    } else {
+      actualType = typeInfo.getPrimitiveTypeKind();
+    }
+
+    final Iterator<JsonNode> cooItor = node.has(Constants.JSON_COORDINATES)
+            ? node.get(Constants.JSON_COORDINATES).elements()
+            : Collections.<JsonNode>emptyList().iterator();
+
+    SRID srid = null;
+    if (node.has(Constants.JSON_CRS)) {
+      srid = SRID.valueOf(
+              node.get(Constants.JSON_CRS).get(Constants.PROPERTIES).get(Constants.JSON_NAME).asText().split(":")[1]);
+    }
+
+    Geospatial value = null;
+    switch (actualType) {
+      case GeographyPoint:
+      case GeometryPoint:
+        value = point(cooItor, actualType, srid);
+        break;
+
+      case GeographyMultiPoint:
+      case GeometryMultiPoint:
+        value = multipoint(cooItor, actualType, srid);
+        break;
+
+      case GeographyLineString:
+      case GeometryLineString:
+        value = lineString(cooItor, actualType, srid);
+        break;
+
+      case GeographyMultiLineString:
+      case GeometryMultiLineString:
+        value = multiLineString(cooItor, actualType, srid);
+        break;
+
+      case GeographyPolygon:
+      case GeometryPolygon:
+        value = polygon(cooItor, actualType, srid);
+        break;
+
+      case GeographyMultiPolygon:
+      case GeometryMultiPolygon:
+        value = multiPolygon(cooItor, actualType, srid);
+        break;
+
+      case GeographyCollection:
+      case GeometryCollection:
+        value = collection(node.get(Constants.JSON_GEOMETRIES).elements(), actualType, srid);
+        break;
+
+      default:
+    }
+
+    return value;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonGeoValueSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonGeoValueSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonGeoValueSerializer.java
new file mode 100644
index 0000000..cfc026c
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonGeoValueSerializer.java
@@ -0,0 +1,184 @@
+/*
+ * 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.serialization;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import java.io.IOException;
+import java.util.Iterator;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.geo.ComposedGeospatial;
+import org.apache.olingo.commons.api.edm.geo.Geospatial;
+import org.apache.olingo.commons.api.edm.geo.GeospatialCollection;
+import org.apache.olingo.commons.api.edm.geo.LineString;
+import org.apache.olingo.commons.api.edm.geo.MultiLineString;
+import org.apache.olingo.commons.api.edm.geo.MultiPoint;
+import org.apache.olingo.commons.api.edm.geo.MultiPolygon;
+import org.apache.olingo.commons.api.edm.geo.Point;
+import org.apache.olingo.commons.api.edm.geo.Polygon;
+import org.apache.olingo.commons.api.edm.geo.SRID;
+import org.apache.olingo.commons.core.edm.primitivetype.EdmDouble;
+
+class JsonGeoValueSerializer {
+
+  private void srid(final JsonGenerator jgen, final SRID srid) throws IOException {
+    jgen.writeObjectFieldStart(Constants.JSON_CRS);
+    jgen.writeStringField(Constants.ATTR_TYPE, Constants.JSON_NAME);
+    jgen.writeObjectFieldStart(Constants.PROPERTIES);
+    jgen.writeStringField(Constants.JSON_NAME, "EPSG:" + srid.toString());
+    jgen.writeEndObject();
+    jgen.writeEndObject();
+  }
+
+  private void point(final JsonGenerator jgen, final Point point) throws IOException {
+    try {
+      jgen.writeNumber(EdmDouble.getInstance().valueToString(point.getX(), null, null,
+              Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null));
+      jgen.writeNumber(EdmDouble.getInstance().valueToString(point.getY(), null, null,
+              Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null));
+    } catch (EdmPrimitiveTypeException e) {
+      throw new IllegalArgumentException("While serializing point coordinates as double", e);
+    }
+  }
+
+  private void multipoint(final JsonGenerator jgen, final MultiPoint multiPoint) throws IOException {
+    for (final Iterator<Point> itor = multiPoint.iterator(); itor.hasNext();) {
+      jgen.writeStartArray();
+      point(jgen, itor.next());
+      jgen.writeEndArray();
+    }
+  }
+
+  private void lineString(final JsonGenerator jgen, final ComposedGeospatial<Point> lineString) throws IOException {
+    for (final Iterator<Point> itor = lineString.iterator(); itor.hasNext();) {
+      jgen.writeStartArray();
+      point(jgen, itor.next());
+      jgen.writeEndArray();
+    }
+  }
+
+  private void multiLineString(final JsonGenerator jgen, final MultiLineString multiLineString) throws IOException {
+    for (final Iterator<LineString> itor = multiLineString.iterator(); itor.hasNext();) {
+      jgen.writeStartArray();
+      lineString(jgen, itor.next());
+      jgen.writeEndArray();
+    }
+  }
+
+  private void polygon(final JsonGenerator jgen, final Polygon polygon) throws IOException {
+    if (!polygon.getExterior().isEmpty()) {
+      jgen.writeStartArray();
+      lineString(jgen, polygon.getExterior());
+      jgen.writeEndArray();
+    }
+    if (!polygon.getInterior().isEmpty()) {
+      jgen.writeStartArray();
+      lineString(jgen, polygon.getInterior());
+      jgen.writeEndArray();
+    }
+  }
+
+  private void multiPolygon(final JsonGenerator jgen, final MultiPolygon multiPolygon) throws IOException {
+    for (final Iterator<Polygon> itor = multiPolygon.iterator(); itor.hasNext();) {
+      final Polygon polygon = itor.next();
+      jgen.writeStartArray();
+      polygon(jgen, polygon);
+      jgen.writeEndArray();
+    }
+  }
+
+  private void collection(final JsonGenerator jgen, final GeospatialCollection collection) throws IOException {
+    jgen.writeArrayFieldStart(Constants.JSON_GEOMETRIES);
+    for (final Iterator<Geospatial> itor = collection.iterator(); itor.hasNext();) {
+      jgen.writeStartObject();
+      serialize(jgen, itor.next());
+      jgen.writeEndObject();
+    }
+    jgen.writeEndArray();
+  }
+
+  public void serialize(final JsonGenerator jgen, final Geospatial value) throws IOException {
+    if (value.getEdmPrimitiveTypeKind().equals(EdmPrimitiveTypeKind.GeographyCollection)
+            || value.getEdmPrimitiveTypeKind().equals(EdmPrimitiveTypeKind.GeometryCollection)) {
+
+      jgen.writeStringField(Constants.ATTR_TYPE, EdmPrimitiveTypeKind.GeometryCollection.name());
+    } else {
+      final int yIdx = value.getEdmPrimitiveTypeKind().name().indexOf('y');
+      final String itemType = value.getEdmPrimitiveTypeKind().name().substring(yIdx + 1);
+      jgen.writeStringField(Constants.ATTR_TYPE, itemType);
+    }
+
+    switch (value.getEdmPrimitiveTypeKind()) {
+      case GeographyPoint:
+      case GeometryPoint:
+        jgen.writeArrayFieldStart(Constants.JSON_COORDINATES);
+        point(jgen, (Point) value);
+        jgen.writeEndArray();
+        break;
+
+      case GeographyMultiPoint:
+      case GeometryMultiPoint:
+        jgen.writeArrayFieldStart(Constants.JSON_COORDINATES);
+        multipoint(jgen, (MultiPoint) value);
+        jgen.writeEndArray();
+        break;
+
+      case GeographyLineString:
+      case GeometryLineString:
+        jgen.writeArrayFieldStart(Constants.JSON_COORDINATES);
+        lineString(jgen, (LineString) value);
+        jgen.writeEndArray();
+        break;
+
+      case GeographyMultiLineString:
+      case GeometryMultiLineString:
+        jgen.writeArrayFieldStart(Constants.JSON_COORDINATES);
+        multiLineString(jgen, (MultiLineString) value);
+        jgen.writeEndArray();
+        break;
+
+      case GeographyPolygon:
+      case GeometryPolygon:
+        jgen.writeArrayFieldStart(Constants.JSON_COORDINATES);
+        polygon(jgen, (Polygon) value);
+        jgen.writeEndArray();
+        break;
+
+      case GeographyMultiPolygon:
+      case GeometryMultiPolygon:
+        jgen.writeArrayFieldStart(Constants.JSON_COORDINATES);
+        multiPolygon(jgen, (MultiPolygon) value);
+        jgen.writeEndArray();
+        break;
+
+      case GeographyCollection:
+      case GeometryCollection:
+        collection(jgen, (GeospatialCollection) value);
+        break;
+
+      default:
+    }
+
+    if (value.getSrid() != null && value.getSrid().isNotDefault()) {
+      srid(jgen, value.getSrid());
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonLinkCollectionDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonLinkCollectionDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonLinkCollectionDeserializer.java
new file mode 100755
index 0000000..feeeb43
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonLinkCollectionDeserializer.java
@@ -0,0 +1,80 @@
+/*
+ * 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.serialization;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.data.v3.LinkCollection;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+import org.apache.olingo.commons.core.data.v3.LinkCollectionImpl;
+
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+public class JsonLinkCollectionDeserializer extends JsonDeserializer {
+
+  public JsonLinkCollectionDeserializer(final ODataServiceVersion version, final boolean serverMode) {
+    super(version, serverMode);
+  }
+
+  protected ResWrap<LinkCollection> doDeserialize(final JsonParser parser) throws IOException {
+
+    final ObjectNode tree = parser.getCodec().readTree(parser);
+
+    final LinkCollectionImpl links = new LinkCollectionImpl();
+
+    if (tree.hasNonNull("odata.metadata")) {
+      links.setMetadata(URI.create(tree.get("odata.metadata").textValue()));
+    }
+
+    if (tree.hasNonNull(Constants.JSON_URL)) {
+      links.getLinks().add(URI.create(tree.get(Constants.JSON_URL).textValue()));
+    }
+
+    if (tree.hasNonNull(Constants.VALUE)) {
+      for (final JsonNode item : tree.get(Constants.VALUE)) {
+        final URI uri = URI.create(item.get(Constants.JSON_URL).textValue());
+        links.getLinks().add(uri);
+      }
+    }
+
+    if (tree.hasNonNull(jsonNextLink)) {
+      links.setNext(URI.create(tree.get(jsonNextLink).textValue()));
+    }
+
+    return new ResWrap<LinkCollection>((URI) null, null, links);
+  }
+
+  public ResWrap<LinkCollection> toLinkCollection(InputStream input) throws ODataDeserializerException {
+    try {
+      JsonParser parser = new JsonFactory(new ObjectMapper()).createParser(input);
+      return doDeserialize(parser);
+    } catch (final IOException e) {
+      throw new ODataDeserializerException(e);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/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
new file mode 100644
index 0000000..3d44e5a
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonODataErrorDeserializer.java
@@ -0,0 +1,87 @@
+/*
+ * 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.serialization;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+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;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+public class JsonODataErrorDeserializer extends JsonDeserializer {
+
+  public JsonODataErrorDeserializer(final ODataServiceVersion version, final boolean serverMode) {
+    super(version, serverMode);
+  }
+
+  protected ODataError doDeserialize(final JsonParser parser) throws IOException {
+
+    final ODataErrorImpl error = new ODataErrorImpl();
+
+    final ObjectNode tree = parser.getCodec().readTree(parser);
+    if (tree.has(jsonError)) {
+      final JsonNode errorNode = tree.get(jsonError);
+
+      if (errorNode.has(Constants.ERROR_CODE)) {
+        error.setCode(errorNode.get(Constants.ERROR_CODE).textValue());
+      }
+      if (errorNode.has(Constants.ERROR_MESSAGE)) {
+        final JsonNode message = errorNode.get(Constants.ERROR_MESSAGE);
+        if (message.isValueNode()) {
+          error.setMessage(message.textValue());
+        } else if (message.isObject()) {
+          error.setMessage(message.get(Constants.VALUE).asText());
+        }
+      }
+      if (errorNode.has(Constants.ERROR_TARGET)) {
+        error.setTarget(errorNode.get(Constants.ERROR_TARGET).textValue());
+      }
+      if (errorNode.hasNonNull(Constants.ERROR_DETAILS)) {
+        List<ODataErrorDetail> details = new ArrayList<ODataErrorDetail>();
+        JsonODataErrorDetailDeserializer detailDeserializer =
+            new JsonODataErrorDetailDeserializer(version, serverMode);
+        for (Iterator<JsonNode> itor = errorNode.get(Constants.ERROR_DETAILS).iterator(); itor.hasNext();) {
+          details.add(detailDeserializer.doDeserialize(itor.next().traverse(parser.getCodec()))
+              .getPayload());
+        }
+
+        error.setDetails(details);
+      }
+      if (errorNode.hasNonNull(Constants.ERROR_INNERERROR)) {
+        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);
+        }
+      }
+    }
+
+    return error;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/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
new file mode 100644
index 0000000..613e687
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonODataErrorDetailDeserializer.java
@@ -0,0 +1,60 @@
+/*
+ * 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.serialization;
+
+import java.io.IOException;
+import java.net.URI;
+
+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;
+
+public class JsonODataErrorDetailDeserializer extends JsonDeserializer {
+
+  public JsonODataErrorDetailDeserializer(final ODataServiceVersion version, final boolean serverMode) {
+    super(version, serverMode);
+  }
+
+  protected ResWrap<ODataErrorDetail> doDeserialize(final JsonParser parser) throws IOException {
+
+    final ODataErrorDetailImpl error = new ODataErrorDetailImpl();
+    final JsonNode errorNode = parser.getCodec().readTree(parser);
+    if (errorNode.has(Constants.ERROR_CODE)) {
+      error.setCode(errorNode.get(Constants.ERROR_CODE).textValue());
+    }
+    if (errorNode.has(Constants.ERROR_MESSAGE)) {
+      final JsonNode message = errorNode.get(Constants.ERROR_MESSAGE);
+      if (message.isValueNode()) {
+        error.setMessage(message.textValue());
+      } else if (message.isObject()) {
+        error.setMessage(message.get(Constants.VALUE).asText());
+      }
+    }
+    if (errorNode.has(Constants.ERROR_TARGET)) {
+      error.setTarget(errorNode.get(Constants.ERROR_TARGET).textValue());
+    }
+
+    return new ResWrap<ODataErrorDetail>((URI) null, null, error);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertyDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertyDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertyDeserializer.java
new file mode 100644
index 0000000..380d245
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertyDeserializer.java
@@ -0,0 +1,107 @@
+/*
+ * 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.serialization;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.Annotation;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.core.data.AnnotationImpl;
+import org.apache.olingo.commons.core.data.NullValueImpl;
+import org.apache.olingo.commons.core.data.PropertyImpl;
+import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * Parse JSON string into <tt>Property</tt>.
+ */
+public class JsonPropertyDeserializer extends JsonDeserializer {
+
+  public JsonPropertyDeserializer(final ODataServiceVersion version, final boolean serverMode) {
+    super(version, serverMode);
+  }
+
+  protected ResWrap<Property> doDeserialize(final JsonParser parser) throws IOException {
+
+    final ObjectNode tree = (ObjectNode) parser.getCodec().readTree(parser);
+
+    final String metadataETag;
+    final URI contextURL;
+    final PropertyImpl property = new PropertyImpl();
+
+    if (tree.hasNonNull(Constants.JSON_METADATA_ETAG)) {
+      metadataETag = tree.get(Constants.JSON_METADATA_ETAG).textValue();
+      tree.remove(Constants.JSON_METADATA_ETAG);
+    } else {
+      metadataETag = null;
+    }
+
+    if (tree.hasNonNull(Constants.JSON_CONTEXT)) {
+      contextURL = URI.create(tree.get(Constants.JSON_CONTEXT).textValue());
+      property.setName(StringUtils.substringAfterLast(contextURL.toASCIIString(), "/"));
+      tree.remove(Constants.JSON_CONTEXT);
+    } else if (tree.hasNonNull(Constants.JSON_METADATA)) {
+      contextURL = URI.create(tree.get(Constants.JSON_METADATA).textValue());
+      property.setType(new EdmTypeInfo.Builder().
+              setTypeExpression(StringUtils.substringAfterLast(contextURL.toASCIIString(), "#")).build().internal());
+      tree.remove(Constants.JSON_METADATA);
+    } else {
+      contextURL = null;
+    }
+
+    if (tree.has(jsonType)) {
+      property.setType(new EdmTypeInfo.Builder().setTypeExpression(tree.get(jsonType).textValue()).build().internal());
+      tree.remove(jsonType);
+    }
+
+    if (tree.has(Constants.JSON_NULL) && tree.get(Constants.JSON_NULL).asBoolean()) {
+      property.setValue(new NullValueImpl());
+      tree.remove(Constants.JSON_NULL);
+    }
+
+    if (property.getValue() == null) {
+      value(property, tree.has(Constants.VALUE) ? tree.get(Constants.VALUE) : tree, parser.getCodec());
+      tree.remove(Constants.VALUE);
+    }
+
+    // any remaining entry is supposed to be an annotation or is ignored
+    for (final Iterator<Map.Entry<String, JsonNode>> itor = tree.fields(); itor.hasNext();) {
+      final Map.Entry<String, JsonNode> field = itor.next();
+      if (field.getKey().charAt(0) == '@') {
+        final Annotation annotation = new AnnotationImpl();
+        annotation.setTerm(field.getKey().substring(1));
+
+        value(annotation, field.getValue(), parser.getCodec());
+        property.getAnnotations().add(annotation);
+      }
+    }
+
+    return new ResWrap<Property>(contextURL, metadataETag, property);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertySerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertySerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertySerializer.java
new file mode 100644
index 0000000..9576007
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertySerializer.java
@@ -0,0 +1,90 @@
+/*
+ * 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.serialization;
+
+import java.io.IOException;
+import java.net.URI;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.Annotation;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+
+/**
+ * Writes out JSON string from <tt>PropertyImpl</tt>.
+ */
+public class JsonPropertySerializer extends JsonSerializer {
+
+  public JsonPropertySerializer(final ODataServiceVersion version, final boolean serverMode) {
+    super(version, serverMode);
+  }
+
+  protected void doSerialize(final Property property, final JsonGenerator jgen) throws IOException {
+    doContainerSerialize(new ResWrap<Property>((URI) null, null, property), jgen);
+  }
+
+  protected void doContainerSerialize(final ResWrap<Property> container, final JsonGenerator jgen)
+          throws IOException {
+
+    final Property property = container.getPayload();
+
+    jgen.writeStartObject();
+
+    if (serverMode && container.getContextURL() != null) {
+      jgen.writeStringField(version.compareTo(ODataServiceVersion.V40) >= 0
+              ? Constants.JSON_CONTEXT : Constants.JSON_METADATA,
+              container.getContextURL().getURI().toASCIIString());
+    }
+
+    if (StringUtils.isNotBlank(property.getType())) {
+      jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_TYPE),
+              new EdmTypeInfo.Builder().setTypeExpression(property.getType()).build().external(version));
+    }
+
+    for (Annotation annotation : property.getAnnotations()) {
+      valuable(jgen, annotation, "@" + annotation.getTerm());
+    }
+
+    if (property.getValue().isNull()) {
+      jgen.writeBooleanField(Constants.JSON_NULL, true);
+    } else if (property.getValue().isPrimitive()) {
+      final EdmTypeInfo typeInfo = property.getType() == null
+              ? null
+              : new EdmTypeInfo.Builder().setTypeExpression(property.getType()).build();
+
+      jgen.writeFieldName(Constants.VALUE);
+      primitiveValue(jgen, typeInfo, property.getValue().asPrimitive());
+    } else if (property.getValue().isEnum()) {
+      jgen.writeStringField(Constants.VALUE, property.getValue().asEnum().get());
+    } else if (property.getValue().isGeospatial() || property.getValue().isCollection()) {
+      valuable(jgen, property, Constants.VALUE);
+    } else if (property.getValue().isComplex()) {
+      for (Property cproperty : property.getValue().asComplex().get()) {
+        valuable(jgen, cproperty, cproperty.getName());
+      }
+    }
+
+    jgen.writeEndObject();
+  }
+}


[9/9] git commit: [OLINGO-317] Rename and move of some packages and classes

Posted by mi...@apache.org.
[OLINGO-317] Rename and move of some packages and classes


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

Branch: refs/heads/Olingo-317_DeSerializerRefactoring
Commit: b15439ffc4c5bc1dee11bea65439f905c6d1b165
Parents: 634d75b
Author: Michael Bolz <mi...@sap.com>
Authored: Thu Jun 12 10:49:57 2014 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Thu Jun 12 10:59:18 2014 +0200

----------------------------------------------------------------------
 .../org/apache/olingo/fit/AbstractServices.java |  10 +-
 .../fit/serializer/FITAtomDeserializer.java     |   4 +-
 .../olingo/fit/utils/AbstractUtilities.java     |  14 +-
 .../org/apache/olingo/fit/utils/FSManager.java  |   6 +-
 .../fit/utils/InjectableSerializerProvider.java |  42 +
 .../apache/olingo/fit/utils/JSONUtilities.java  |   1 -
 .../olingo/fit/AbstractBaseTestITCase.java      |   2 +-
 .../olingo/client/api/CommonODataClient.java    |  10 +-
 .../api/domain/ODataEntitySetIterator.java      |   2 +-
 .../client/api/op/ClientODataDeserializer.java  |  41 -
 .../olingo/client/api/op/CommonODataBinder.java | 116 ---
 .../olingo/client/api/op/CommonODataReader.java | 123 ---
 .../olingo/client/api/op/ODataWriter.java       |  83 --
 .../olingo/client/api/op/v3/ODataBinder.java    |  51 --
 .../client/api/op/v3/ODataDeserializer.java     |  38 -
 .../olingo/client/api/op/v3/ODataReader.java    |  51 --
 .../olingo/client/api/op/v4/ODataBinder.java    |  44 -
 .../client/api/op/v4/ODataDeserializer.java     |  42 -
 .../olingo/client/api/op/v4/ODataReader.java    |  41 -
 .../serialization/ClientODataDeserializer.java  |  41 +
 .../api/serialization/CommonODataBinder.java    | 116 +++
 .../api/serialization/CommonODataReader.java    | 123 +++
 .../client/api/serialization/ODataWriter.java   |  83 ++
 .../api/serialization/v3/ODataBinder.java       |  51 ++
 .../api/serialization/v3/ODataDeserializer.java |  38 +
 .../api/serialization/v3/ODataReader.java       |  51 ++
 .../api/serialization/v4/ODataBinder.java       |  44 +
 .../api/serialization/v4/ODataDeserializer.java |  42 +
 .../api/serialization/v4/ODataReader.java       |  41 +
 .../olingo/client/api/v3/ODataClient.java       |   6 +-
 .../olingo/client/api/v4/ODataClient.java       |   6 +-
 .../olingo/client/core/AbstractODataClient.java |   4 +-
 .../communication/request/AbstractRequest.java  |   2 +-
 .../cud/ODataEntityCreateRequestImpl.java       |   4 +-
 .../cud/ODataEntityUpdateRequestImpl.java       |   4 +-
 .../cud/ODataPropertyUpdateRequestImpl.java     |   4 +-
 .../cud/v3/ODataLinkCreateRequestImpl.java      |   2 +-
 .../cud/v3/ODataLinkUpdateRequestImpl.java      |   2 +-
 .../invoke/AbstractODataInvokeRequest.java      |   4 +-
 .../retrieve/ODataEntityRequestImpl.java        |   2 +-
 .../retrieve/ODataEntitySetRequestImpl.java     |   2 +-
 .../retrieve/ODataPropertyRequestImpl.java      |   2 +-
 .../request/retrieve/ODataRawRequestImpl.java   |   2 +-
 .../ODataServiceDocumentRequestImpl.java        |   2 +-
 .../v3/ODataLinkCollectionRequestImpl.java      |   2 +-
 .../retrieve/v4/ODataDeltaRequestImpl.java      |   2 +-
 .../ODataMediaEntityCreateRequestImpl.java      |   2 +-
 .../ODataMediaEntityUpdateRequestImpl.java      |   2 +-
 .../data/JSONServiceDocumentDeserializer.java   |   4 +-
 .../data/XMLServiceDocumentDeserializer.java    |   4 +-
 .../client/core/op/AbstractODataBinder.java     | 528 -----------
 .../client/core/op/AbstractODataReader.java     | 159 ----
 .../olingo/client/core/op/ODataWriterImpl.java  | 111 ---
 .../client/core/op/impl/v3/ODataBinderImpl.java | 117 ---
 .../core/op/impl/v3/ODataDeserializerImpl.java  |  77 --
 .../client/core/op/impl/v3/ODataReaderImpl.java |  83 --
 .../client/core/op/impl/v4/ODataBinderImpl.java | 405 ---------
 .../core/op/impl/v4/ODataDeserializerImpl.java  |  78 --
 .../client/core/op/impl/v4/ODataReaderImpl.java |  56 --
 .../core/serialization/AbstractODataBinder.java | 528 +++++++++++
 .../AbstractODataDeserializer.java              | 101 +++
 .../core/serialization/AbstractODataReader.java | 159 ++++
 .../core/serialization/ODataWriterImpl.java     | 111 +++
 .../core/serialization/v3/ODataBinderImpl.java  | 117 +++
 .../serialization/v3/ODataDeserializerImpl.java |  77 ++
 .../core/serialization/v3/ODataReaderImpl.java  |  83 ++
 .../core/serialization/v4/ODataBinderImpl.java  | 405 +++++++++
 .../serialization/v4/ODataDeserializerImpl.java |  78 ++
 .../core/serialization/v4/ODataReaderImpl.java  |  56 ++
 .../olingo/client/core/v3/ODataClientImpl.java  |  18 +-
 .../olingo/client/core/v4/ODataClientImpl.java  |  18 +-
 .../olingo/client/core/v3/EntitySetTest.java    |   2 +-
 .../olingo/client/core/v3/EntityTest.java       |   2 +-
 .../apache/olingo/client/core/v3/ErrorTest.java |   2 +-
 .../olingo/client/core/v3/PropertyTest.java     |   4 +-
 .../client/core/v3/ServiceDocumentTest.java     |   2 +-
 .../olingo/client/core/v4/EntitySetTest.java    |   2 +-
 .../olingo/client/core/v4/EntityTest.java       |   2 +-
 .../apache/olingo/client/core/v4/ErrorTest.java |   2 +-
 .../olingo/client/core/v4/PropertyTest.java     |   4 +-
 .../client/core/v4/ServiceDocumentTest.java     |   2 +-
 .../commons/api/op/ODataDeserializer.java       |  65 --
 .../api/op/ODataDeserializerException.java      |  38 -
 .../olingo/commons/api/op/ODataSerializer.java  |  33 -
 .../api/op/ODataSerializerException.java        |  38 -
 .../api/serialization/ODataDeserializer.java    |  65 ++
 .../ODataDeserializerException.java             |  38 +
 .../api/serialization/ODataSerializer.java      |  33 +
 .../serialization/ODataSerializerException.java |  38 +
 .../commons/core/data/AbstractAtomDealer.java   | 137 ---
 .../commons/core/data/AtomDeserializer.java     | 882 ------------------
 .../core/data/AtomGeoValueDeserializer.java     | 267 ------
 .../core/data/AtomGeoValueSerializer.java       | 221 -----
 .../commons/core/data/AtomSerializer.java       | 540 -----------
 .../core/data/JSONDeltaDeserializer.java        | 100 ---
 .../core/data/JSONEntityDeserializer.java       | 220 -----
 .../commons/core/data/JSONEntitySerializer.java | 129 ---
 .../core/data/JSONEntitySetDeserializer.java    | 116 ---
 .../core/data/JSONEntitySetSerializer.java      |  94 --
 .../core/data/JSONGeoValueDeserializer.java     | 267 ------
 .../core/data/JSONGeoValueSerializer.java       | 184 ----
 .../data/JSONLinkCollectionDeserializer.java    |  80 --
 .../core/data/JSONODataErrorDeserializer.java   |  86 --
 .../data/JSONODataErrorDetailDeserializer.java  |  59 --
 .../core/data/JSONPropertyDeserializer.java     | 104 ---
 .../core/data/JSONPropertySerializer.java       |  90 --
 .../commons/core/data/JsonDeserializer.java     | 463 ----------
 .../commons/core/data/JsonSerializer.java       | 315 -------
 .../core/op/AbstractODataDeserializer.java      | 101 ---
 .../core/op/InjectableSerializerProvider.java   |  42 -
 .../core/serialization/AbstractAtomDealer.java  | 137 +++
 .../core/serialization/AtomDeserializer.java    | 897 +++++++++++++++++++
 .../serialization/AtomGeoValueDeserializer.java | 267 ++++++
 .../serialization/AtomGeoValueSerializer.java   | 221 +++++
 .../core/serialization/AtomSerializer.java      | 544 +++++++++++
 .../serialization/JsonDeltaDeserializer.java    | 102 +++
 .../core/serialization/JsonDeserializer.java    | 474 ++++++++++
 .../serialization/JsonEntityDeserializer.java   | 223 +++++
 .../serialization/JsonEntitySerializer.java     | 129 +++
 .../JsonEntitySetDeserializer.java              | 118 +++
 .../serialization/JsonEntitySetSerializer.java  |  94 ++
 .../serialization/JsonGeoValueDeserializer.java | 267 ++++++
 .../serialization/JsonGeoValueSerializer.java   | 184 ++++
 .../JsonLinkCollectionDeserializer.java         |  80 ++
 .../JsonODataErrorDeserializer.java             |  87 ++
 .../JsonODataErrorDetailDeserializer.java       |  60 ++
 .../serialization/JsonPropertyDeserializer.java | 107 +++
 .../serialization/JsonPropertySerializer.java   |  90 ++
 .../core/serialization/JsonSerializer.java      | 314 +++++++
 129 files changed, 7043 insertions(+), 7001 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
index ad931b9..f701b2a 100644
--- a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
+++ b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
@@ -77,17 +77,17 @@ import org.apache.olingo.commons.api.data.Value;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.commons.api.op.ODataDeserializer;
-import org.apache.olingo.commons.api.op.ODataSerializer;
-import org.apache.olingo.commons.core.data.AtomSerializer;
+import org.apache.olingo.commons.api.serialization.ODataDeserializer;
+import org.apache.olingo.commons.api.serialization.ODataSerializer;
 import org.apache.olingo.commons.core.data.EntityImpl;
 import org.apache.olingo.commons.core.data.EntitySetImpl;
-import org.apache.olingo.commons.core.data.JsonDeserializer;
-import org.apache.olingo.commons.core.data.JsonSerializer;
 import org.apache.olingo.commons.core.data.LinkImpl;
 import org.apache.olingo.commons.core.data.NullValueImpl;
 import org.apache.olingo.commons.core.data.PrimitiveValueImpl;
 import org.apache.olingo.commons.core.data.PropertyImpl;
+import org.apache.olingo.commons.core.serialization.AtomSerializer;
+import org.apache.olingo.commons.core.serialization.JsonDeserializer;
+import org.apache.olingo.commons.core.serialization.JsonSerializer;
 import org.apache.olingo.fit.metadata.EntityType;
 import org.apache.olingo.fit.metadata.Metadata;
 import org.apache.olingo.fit.metadata.NavigationProperty;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/fit/src/main/java/org/apache/olingo/fit/serializer/FITAtomDeserializer.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/serializer/FITAtomDeserializer.java b/fit/src/main/java/org/apache/olingo/fit/serializer/FITAtomDeserializer.java
index 515fd06..901cc3c 100644
--- a/fit/src/main/java/org/apache/olingo/fit/serializer/FITAtomDeserializer.java
+++ b/fit/src/main/java/org/apache/olingo/fit/serializer/FITAtomDeserializer.java
@@ -23,11 +23,13 @@ import java.io.InputStreamReader;
 import java.nio.charset.Charset;
 import java.nio.charset.CharsetDecoder;
 import java.nio.charset.CodingErrorAction;
+
 import javax.xml.stream.XMLEventReader;
 import javax.xml.stream.XMLStreamException;
+
 import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.core.data.AtomDeserializer;
+import org.apache.olingo.commons.core.serialization.AtomDeserializer;
 
 public class FITAtomDeserializer extends AtomDeserializer {
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java b/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java
index 4706aa4..e293a78 100644
--- a/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java
@@ -48,13 +48,13 @@ import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.api.op.ODataDeserializer;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
-import org.apache.olingo.commons.api.op.ODataSerializer;
-import org.apache.olingo.commons.api.op.ODataSerializerException;
-import org.apache.olingo.commons.core.data.AtomSerializer;
-import org.apache.olingo.commons.core.data.JsonDeserializer;
-import org.apache.olingo.commons.core.data.JsonSerializer;
+import org.apache.olingo.commons.api.serialization.ODataDeserializer;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataSerializer;
+import org.apache.olingo.commons.api.serialization.ODataSerializerException;
+import org.apache.olingo.commons.core.serialization.AtomSerializer;
+import org.apache.olingo.commons.core.serialization.JsonDeserializer;
+import org.apache.olingo.commons.core.serialization.JsonSerializer;
 import org.apache.olingo.fit.UnsupportedMediaTypeException;
 import org.apache.olingo.fit.metadata.Metadata;
 import org.apache.olingo.fit.metadata.NavigationProperty;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java b/fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java
index 650a98f..2b63501 100644
--- a/fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java
@@ -41,9 +41,9 @@ import org.apache.commons.vfs2.VFS;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.api.op.ODataSerializerException;
-import org.apache.olingo.commons.core.data.AtomSerializer;
-import org.apache.olingo.commons.core.data.JsonSerializer;
+import org.apache.olingo.commons.api.serialization.ODataSerializerException;
+import org.apache.olingo.commons.core.serialization.AtomSerializer;
+import org.apache.olingo.commons.core.serialization.JsonSerializer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/fit/src/main/java/org/apache/olingo/fit/utils/InjectableSerializerProvider.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/InjectableSerializerProvider.java b/fit/src/main/java/org/apache/olingo/fit/utils/InjectableSerializerProvider.java
new file mode 100644
index 0000000..69b3bb1
--- /dev/null
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/InjectableSerializerProvider.java
@@ -0,0 +1,42 @@
+/*
+ * 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.fit.utils;
+
+import com.fasterxml.jackson.databind.SerializationConfig;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.ser.DefaultSerializerProvider;
+import com.fasterxml.jackson.databind.ser.SerializerFactory;
+
+public class InjectableSerializerProvider extends DefaultSerializerProvider {
+
+  private static final long serialVersionUID = 3432260063063739646L;
+
+  public InjectableSerializerProvider(
+          final SerializerProvider src, final SerializationConfig config, final SerializerFactory factory) {
+
+    super(src, config, factory);
+  }
+
+  @Override
+  public InjectableSerializerProvider createInstance(
+          final SerializationConfig config, final SerializerFactory factory) {
+
+    return this;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/fit/src/main/java/org/apache/olingo/fit/utils/JSONUtilities.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/JSONUtilities.java b/fit/src/main/java/org/apache/olingo/fit/utils/JSONUtilities.java
index 23a95cd..fcfa552 100644
--- a/fit/src/main/java/org/apache/olingo/fit/utils/JSONUtilities.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/JSONUtilities.java
@@ -36,7 +36,6 @@ import javax.ws.rs.NotFoundException;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.core.op.InjectableSerializerProvider;
 import org.apache.olingo.fit.metadata.Metadata;
 import org.apache.olingo.fit.metadata.NavigationProperty;
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
index d292232..cef8d11 100644
--- a/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
@@ -31,7 +31,7 @@ import org.apache.olingo.commons.api.domain.CommonODataProperty;
 import org.apache.olingo.commons.api.domain.ODataValue;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataSerializerException;
+import org.apache.olingo.commons.api.serialization.ODataSerializerException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java
index 8c398ca..d3c929a 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java
@@ -25,16 +25,16 @@ import org.apache.olingo.client.api.communication.request.cud.CommonCUDRequestFa
 import org.apache.olingo.client.api.communication.request.cud.CommonUpdateType;
 import org.apache.olingo.client.api.communication.request.invoke.InvokeRequestFactory;
 import org.apache.olingo.client.api.communication.request.retrieve.CommonRetrieveRequestFactory;
-import org.apache.olingo.client.api.op.ClientODataDeserializer;
-import org.apache.olingo.client.api.op.CommonODataBinder;
-import org.apache.olingo.client.api.op.CommonODataReader;
-import org.apache.olingo.client.api.op.ODataWriter;
+import org.apache.olingo.client.api.serialization.ClientODataDeserializer;
+import org.apache.olingo.client.api.serialization.CommonODataBinder;
+import org.apache.olingo.client.api.serialization.CommonODataReader;
+import org.apache.olingo.client.api.serialization.ODataWriter;
 import org.apache.olingo.client.api.uri.CommonFilterFactory;
 import org.apache.olingo.client.api.uri.CommonURIBuilder;
 import org.apache.olingo.commons.api.domain.CommonODataObjectFactory;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.api.format.Format;
-import org.apache.olingo.commons.api.op.ODataSerializer;
+import org.apache.olingo.commons.api.serialization.ODataSerializer;
 
 /**
  * Generic client interface (common to all supported OData protocol versions).

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataEntitySetIterator.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataEntitySetIterator.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataEntitySetIterator.java
index 87cc970..3525518 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataEntitySetIterator.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataEntitySetIterator.java
@@ -36,7 +36,7 @@ import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.domain.CommonODataEntity;
 import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-api/src/main/java/org/apache/olingo/client/api/op/ClientODataDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/ClientODataDeserializer.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/ClientODataDeserializer.java
deleted file mode 100644
index f7586bc..0000000
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/ClientODataDeserializer.java
+++ /dev/null
@@ -1,41 +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.client.api.op;
-
-import java.io.InputStream;
-
-import org.apache.olingo.client.api.data.ServiceDocument;
-import org.apache.olingo.client.api.edm.xml.XMLMetadata;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.op.ODataDeserializer;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
-
-public interface ClientODataDeserializer extends ODataDeserializer {
-
-  XMLMetadata toMetadata(InputStream input);
-
-  /**
-   * Gets the ServiceDocument object represented by the given InputStream.
-   *
-   * @param input stream to be de-serialized.
-   * @return <tt>ServiceDocument</tt> object.
-   * @throws ODataDeserializerException 
-   */
-  ResWrap<ServiceDocument> toServiceDocument(InputStream input) throws ODataDeserializerException;
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataBinder.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataBinder.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataBinder.java
deleted file mode 100644
index 530177c..0000000
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataBinder.java
+++ /dev/null
@@ -1,116 +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.client.api.op;
-
-import org.apache.olingo.client.api.data.ServiceDocument;
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
-import org.apache.olingo.commons.api.data.Link;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.domain.CommonODataEntity;
-import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
-import org.apache.olingo.commons.api.domain.CommonODataProperty;
-import org.apache.olingo.commons.api.domain.ODataComplexValue;
-import org.apache.olingo.commons.api.domain.ODataLink;
-import org.apache.olingo.commons.api.domain.ODataServiceDocument;
-
-public interface CommonODataBinder {
-
-  /**
-   * Gets a <tt>EntitySet</tt> from the given OData entity set.
-   *
-   * @param entitySet OData entity set.
-   * @return {@link EntitySet} object.
-   */
-  EntitySet getEntitySet(CommonODataEntitySet entitySet);
-
-  /**
-   * Gets an <tt>Entity</tt> from the given OData entity.
-   *
-   * @param entity OData entity.
-   * @return {@link Entity} object.
-   */
-  Entity getEntity(CommonODataEntity entity);
-
-  /**
-   * Gets a <tt>Link</tt> from the given OData link.
-   *
-   * @param link OData link.
-   * @return <tt>Link</tt> object.
-   */
-  Link getLink(ODataLink link);
-
-  /**
-   * Gets a <tt>Property</tt> from the given OData property.
-   *
-   * @param property OData property.
-   * @return <tt>Property</tt> object.
-   */
-  Property getProperty(CommonODataProperty property);
-
-  /**
-   * Adds the given property to the given complex value.
-   *
-   * @param complex OData complex value.
-   * @param property OData property.
-   */
-  void add(ODataComplexValue<CommonODataProperty> complex, CommonODataProperty property);
-
-  /**
-   * Adds the given property to the given entity.
-   *
-   * @param entity OData entity.
-   * @param property OData property.
-   * @return whether add was successful or not.
-   */
-  boolean add(CommonODataEntity entity, CommonODataProperty property);
-
-  /**
-   * Gets <tt>ODataServiceDocument</tt> from the given service document resource.
-   *
-   * @param resource service document resource.
-   * @return <tt>ODataServiceDocument</tt> object.
-   */
-  ODataServiceDocument getODataServiceDocument(ServiceDocument resource);
-
-  /**
-   * Gets <tt>ODataEntitySet</tt> from the given entity set resource.
-   *
-   * @param resource entity set resource.
-   * @return {@link CommonODataEntitySet} object.
-   */
-  CommonODataEntitySet getODataEntitySet(ResWrap<EntitySet> resource);
-
-  /**
-   * Gets <tt>ODataEntity</tt> from the given entity resource.
-   *
-   * @param resource entity resource.
-   * @return {@link CommonODataEntity} object.
-   */
-  CommonODataEntity getODataEntity(ResWrap<Entity> resource);
-
-  /**
-   * Gets an <tt>ODataProperty</tt> from the given property resource.
-   *
-   * @param resource property resource.
-   * @return {@link CommonODataProperty} object.
-   */
-  CommonODataProperty getODataProperty(ResWrap<Property> resource);
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataReader.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataReader.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataReader.java
deleted file mode 100644
index 056977f..0000000
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataReader.java
+++ /dev/null
@@ -1,123 +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.client.api.op;
-
-import java.io.InputStream;
-import java.util.Map;
-
-import org.apache.olingo.client.api.edm.xml.Schema;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.domain.CommonODataEntity;
-import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
-import org.apache.olingo.commons.api.domain.CommonODataProperty;
-import org.apache.olingo.commons.api.domain.ODataError;
-import org.apache.olingo.commons.api.domain.ODataServiceDocument;
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
-
-/**
- * OData reader.
- * <br/>
- * Use this class to de-serialize an OData response body.
- * <br/>
- * This class provides method helpers to de-serialize an entire entity set, a set of entities or a single entity.
- */
-public interface CommonODataReader {
-
-  /**
-   * Parses a stream into metadata representation.
-   *
-   * @param input stream to de-serialize.
-   * @return metadata representation.
-   */
-  Edm readMetadata(InputStream input);
-
-  /**
-   * Parses a stream into metadata representation, including referenced metadata documents.
-   *
-   * @param xmlSchemas XML representation of the requested metadata document + any other referenced (via
-   * <tt>&lt;edmx:Reference/&gt;</tt>) metadata document
-   * @return metadata representation.
-   */
-  Edm readMetadata(Map<String, Schema> xmlSchemas);
-
-  /**
-   * Parses an OData service document.
-   *
-   * @param input stream to de-serialize.
-   * @param format de-serialize as XML or JSON
-   * @return List of URIs.
-   * @throws ODataDeserializerException 
-   */
-  ODataServiceDocument readServiceDocument(InputStream input, ODataFormat format) throws ODataDeserializerException;
-
-  /**
-   * De-Serializes a stream into an OData entity set.
-   *
-   * @param input stream to de-serialize.
-   * @param format de-serialize format
-   * @return de-serialized entity set.
-   * @throws ODataDeserializerException 
-   */
-  CommonODataEntitySet readEntitySet(InputStream input, ODataPubFormat format) throws ODataDeserializerException;
-
-  /**
-   * Parses a stream taking care to de-serializes the first OData entity found.
-   *
-   * @param input stream to de-serialize.
-   * @param format de-serialize format
-   * @return entity de-serialized.
-   * @throws ODataDeserializerException 
-   */
-  CommonODataEntity readEntity(InputStream input, ODataPubFormat format) throws ODataDeserializerException;
-
-  /**
-   * Parses a stream taking care to de-serialize the first OData entity property found.
-   *
-   * @param input stream to de-serialize.
-   * @param format de-serialize as XML or JSON
-   * @return OData entity property de-serialized.
-   * @throws ODataDeserializerException 
-   */
-  CommonODataProperty readProperty(InputStream input, ODataFormat format) throws ODataDeserializerException;
-
-  /**
-   * Parses a stream into an OData error.
-   *
-   * @param inputStream stream to de-serialize.
-   * @param format format
-   * @return OData error.
-   * @throws ODataDeserializerException 
-   */
-  ODataError readError(InputStream inputStream, ODataFormat format) throws ODataDeserializerException;
-
-  /**
-   * Parses a stream into the object type specified by the given reference.
-   *
-   * @param <T> expected object type.
-   * @param src input stream.
-   * @param format format
-   * @param reference reference.
-   * @return read object.
-   * @throws ODataDeserializerException 
-   */
-  <T> ResWrap<T> read(InputStream src, String format, Class<T> reference) throws ODataDeserializerException;
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-api/src/main/java/org/apache/olingo/client/api/op/ODataWriter.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/ODataWriter.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/ODataWriter.java
deleted file mode 100644
index 6cd8b7a..0000000
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/ODataWriter.java
+++ /dev/null
@@ -1,83 +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.client.api.op;
-
-import java.io.InputStream;
-import java.util.Collection;
-
-import org.apache.olingo.commons.api.domain.CommonODataEntity;
-import org.apache.olingo.commons.api.domain.CommonODataProperty;
-import org.apache.olingo.commons.api.domain.ODataLink;
-import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataSerializerException;
-
-/**
- * OData writer.
- * <br/>
- * Use this interface to serialize an OData request body.
- * <br/>
- * This interface provides method helpers to serialize a set of entities and a single entity as well.
- */
-public interface ODataWriter {
-
-  /**
-   * Writes a collection of OData entities.
-   *
-   * @param entities entities to be serialized.
-   * @param format serialization format.
-   * @return stream of serialized objects.
-   * @throws ODataSerializerException 
-   */
-  InputStream writeEntities(Collection<CommonODataEntity> entities, ODataPubFormat format)
-      throws ODataSerializerException;
-
-  /**
-   * Serializes a single OData entity.
-   *
-   * @param entity entity to be serialized.
-   * @param format serialization format.
-   * @return stream of serialized object.
-   * @throws ODataSerializerException 
-   */
-  InputStream writeEntity(CommonODataEntity entity, ODataPubFormat format)
-      throws ODataSerializerException;
-
-  /**
-   * Writes a single OData entity property.
-   *
-   * @param property entity property to be serialized.
-   * @param format serialization format.
-   * @return stream of serialized object.
-   * @throws ODataSerializerException 
-   */
-  InputStream writeProperty(CommonODataProperty property, ODataFormat format)
-      throws ODataSerializerException;
-
-  /**
-   * Writes an OData link.
-   *
-   * @param link link to be serialized.
-   * @param format serialization format.
-   * @return stream of serialized object.
-   * @throws ODataSerializerException 
-   */
-  InputStream writeLink(ODataLink link, ODataFormat format)
-      throws ODataSerializerException;
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v3/ODataBinder.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v3/ODataBinder.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v3/ODataBinder.java
deleted file mode 100644
index 88e3224..0000000
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v3/ODataBinder.java
+++ /dev/null
@@ -1,51 +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.client.api.op.v3;
-
-import org.apache.olingo.commons.api.data.v3.LinkCollection;
-import org.apache.olingo.client.api.domain.v3.ODataLinkCollection;
-import org.apache.olingo.client.api.op.CommonODataBinder;
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.domain.v3.ODataEntity;
-import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
-import org.apache.olingo.commons.api.domain.v3.ODataProperty;
-
-public interface ODataBinder extends CommonODataBinder {
-
-  @Override
-  ODataEntitySet getODataEntitySet(ResWrap<EntitySet> resource);
-
-  @Override
-  ODataEntity getODataEntity(ResWrap<Entity> resource);
-
-  @Override
-  ODataProperty getODataProperty(ResWrap<Property> resource);
-
-  /**
-   * Gets <tt>ODataLinkCollection</tt> from the given link collection resource.
-   *
-   * @param resource link collection resource.
-   * @return <tt>ODataLinkCollection</tt> object.
-   */
-  ODataLinkCollection getLinkCollection(LinkCollection resource);
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v3/ODataDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v3/ODataDeserializer.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v3/ODataDeserializer.java
deleted file mode 100644
index e71ed05..0000000
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v3/ODataDeserializer.java
+++ /dev/null
@@ -1,38 +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.client.api.op.v3;
-
-import java.io.InputStream;
-
-import org.apache.olingo.client.api.op.ClientODataDeserializer;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.data.v3.LinkCollection;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
-
-public interface ODataDeserializer extends ClientODataDeserializer {
-
-  /**
-   * Gets a list of links from the given InputStream.
-   *
-   * @param input stream to be de-serialized.
-   * @return de-serialized links.
-   * @throws ODataDeserializerException 
-   */
-  ResWrap<LinkCollection> toLinkCollection(InputStream input) throws ODataDeserializerException;
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v3/ODataReader.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v3/ODataReader.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v3/ODataReader.java
deleted file mode 100644
index 4b91f16..0000000
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v3/ODataReader.java
+++ /dev/null
@@ -1,51 +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.client.api.op.v3;
-
-import java.io.InputStream;
-
-import org.apache.olingo.client.api.domain.v3.ODataLinkCollection;
-import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.client.api.op.CommonODataReader;
-import org.apache.olingo.commons.api.domain.v3.ODataEntity;
-import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
-import org.apache.olingo.commons.api.domain.v3.ODataProperty;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
-
-public interface ODataReader extends CommonODataReader {
-
-  @Override
-  ODataEntitySet readEntitySet(InputStream input, ODataPubFormat format) throws ODataDeserializerException;
-
-  @Override
-  ODataEntity readEntity(InputStream input, ODataPubFormat format) throws ODataDeserializerException;
-
-  @Override
-  ODataProperty readProperty(InputStream input, ODataFormat format) throws ODataDeserializerException;
-
-  /**
-   * Parses a $links request response.
-   *
-   * @param input stream to de-serialize.
-   * @param format de-serialize as XML or JSON
-   * @return List of URIs.
-   */
-  ODataLinkCollection readLinks(InputStream input, ODataFormat format) throws ODataDeserializerException;
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataBinder.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataBinder.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataBinder.java
deleted file mode 100644
index 0f5657f..0000000
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataBinder.java
+++ /dev/null
@@ -1,44 +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.client.api.op.v4;
-
-import org.apache.olingo.client.api.op.CommonODataBinder;
-import org.apache.olingo.commons.api.data.Delta;
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.domain.v4.ODataDelta;
-import org.apache.olingo.commons.api.domain.v4.ODataEntity;
-import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
-import org.apache.olingo.commons.api.domain.v4.ODataProperty;
-
-public interface ODataBinder extends CommonODataBinder {
-
-  @Override
-  ODataEntitySet getODataEntitySet(ResWrap<EntitySet> resource);
-
-  @Override
-  ODataEntity getODataEntity(ResWrap<Entity> resource);
-
-  @Override
-  ODataProperty getODataProperty(ResWrap<Property> resource);
-
-  ODataDelta getODataDelta(ResWrap<Delta> resource);
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataDeserializer.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataDeserializer.java
deleted file mode 100644
index e20c66e..0000000
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataDeserializer.java
+++ /dev/null
@@ -1,42 +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.client.api.op.v4;
-
-import java.io.InputStream;
-
-import org.apache.olingo.client.api.edm.xml.v4.XMLMetadata;
-import org.apache.olingo.client.api.op.ClientODataDeserializer;
-import org.apache.olingo.commons.api.data.Delta;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
-
-public interface ODataDeserializer extends ClientODataDeserializer {
-
-  @Override
-  XMLMetadata toMetadata(InputStream input);
-
-  /**
-   * Gets a delta object from the given InputStream.
-   *
-   * @param input stream to be de-serialized.
-   * @return {@link Delta} instance.
-   * @throws ODataDeserializerException 
-   */
-  ResWrap<Delta> toDelta(InputStream input) throws ODataDeserializerException;
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataReader.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataReader.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataReader.java
deleted file mode 100644
index 8877e7e..0000000
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataReader.java
+++ /dev/null
@@ -1,41 +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.client.api.op.v4;
-
-import java.io.InputStream;
-
-import org.apache.olingo.client.api.op.CommonODataReader;
-import org.apache.olingo.commons.api.domain.v4.ODataEntity;
-import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
-import org.apache.olingo.commons.api.domain.v4.ODataProperty;
-import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
-
-public interface ODataReader extends CommonODataReader {
-
-  @Override
-  ODataEntitySet readEntitySet(InputStream input, ODataPubFormat format) throws ODataDeserializerException;
-
-  @Override
-  ODataEntity readEntity(InputStream input, ODataPubFormat format) throws ODataDeserializerException;
-
-  @Override
-  ODataProperty readProperty(InputStream input, ODataFormat format) throws ODataDeserializerException;
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ClientODataDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ClientODataDeserializer.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ClientODataDeserializer.java
new file mode 100644
index 0000000..8d4149f
--- /dev/null
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ClientODataDeserializer.java
@@ -0,0 +1,41 @@
+/*
+ * 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.client.api.serialization;
+
+import java.io.InputStream;
+
+import org.apache.olingo.client.api.data.ServiceDocument;
+import org.apache.olingo.client.api.edm.xml.XMLMetadata;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.serialization.ODataDeserializer;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+
+public interface ClientODataDeserializer extends ODataDeserializer {
+
+  XMLMetadata toMetadata(InputStream input);
+
+  /**
+   * Gets the ServiceDocument object represented by the given InputStream.
+   *
+   * @param input stream to be de-serialized.
+   * @return <tt>ServiceDocument</tt> object.
+   * @throws ODataDeserializerException
+   */
+  ResWrap<ServiceDocument> toServiceDocument(InputStream input) throws ODataDeserializerException;
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/CommonODataBinder.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/CommonODataBinder.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/CommonODataBinder.java
new file mode 100644
index 0000000..04b6bfc
--- /dev/null
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/CommonODataBinder.java
@@ -0,0 +1,116 @@
+/*
+ * 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.client.api.serialization;
+
+import org.apache.olingo.client.api.data.ServiceDocument;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.Link;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.domain.CommonODataEntity;
+import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
+import org.apache.olingo.commons.api.domain.CommonODataProperty;
+import org.apache.olingo.commons.api.domain.ODataComplexValue;
+import org.apache.olingo.commons.api.domain.ODataLink;
+import org.apache.olingo.commons.api.domain.ODataServiceDocument;
+
+public interface CommonODataBinder {
+
+  /**
+   * Gets a <tt>EntitySet</tt> from the given OData entity set.
+   *
+   * @param entitySet OData entity set.
+   * @return {@link EntitySet} object.
+   */
+  EntitySet getEntitySet(CommonODataEntitySet entitySet);
+
+  /**
+   * Gets an <tt>Entity</tt> from the given OData entity.
+   *
+   * @param entity OData entity.
+   * @return {@link Entity} object.
+   */
+  Entity getEntity(CommonODataEntity entity);
+
+  /**
+   * Gets a <tt>Link</tt> from the given OData link.
+   *
+   * @param link OData link.
+   * @return <tt>Link</tt> object.
+   */
+  Link getLink(ODataLink link);
+
+  /**
+   * Gets a <tt>Property</tt> from the given OData property.
+   *
+   * @param property OData property.
+   * @return <tt>Property</tt> object.
+   */
+  Property getProperty(CommonODataProperty property);
+
+  /**
+   * Adds the given property to the given complex value.
+   *
+   * @param complex OData complex value.
+   * @param property OData property.
+   */
+  void add(ODataComplexValue<CommonODataProperty> complex, CommonODataProperty property);
+
+  /**
+   * Adds the given property to the given entity.
+   *
+   * @param entity OData entity.
+   * @param property OData property.
+   * @return whether add was successful or not.
+   */
+  boolean add(CommonODataEntity entity, CommonODataProperty property);
+
+  /**
+   * Gets <tt>ODataServiceDocument</tt> from the given service document resource.
+   *
+   * @param resource service document resource.
+   * @return <tt>ODataServiceDocument</tt> object.
+   */
+  ODataServiceDocument getODataServiceDocument(ServiceDocument resource);
+
+  /**
+   * Gets <tt>ODataEntitySet</tt> from the given entity set resource.
+   *
+   * @param resource entity set resource.
+   * @return {@link CommonODataEntitySet} object.
+   */
+  CommonODataEntitySet getODataEntitySet(ResWrap<EntitySet> resource);
+
+  /**
+   * Gets <tt>ODataEntity</tt> from the given entity resource.
+   *
+   * @param resource entity resource.
+   * @return {@link CommonODataEntity} object.
+   */
+  CommonODataEntity getODataEntity(ResWrap<Entity> resource);
+
+  /**
+   * Gets an <tt>ODataProperty</tt> from the given property resource.
+   *
+   * @param resource property resource.
+   * @return {@link CommonODataProperty} object.
+   */
+  CommonODataProperty getODataProperty(ResWrap<Property> resource);
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/CommonODataReader.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/CommonODataReader.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/CommonODataReader.java
new file mode 100644
index 0000000..e41d0bd
--- /dev/null
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/CommonODataReader.java
@@ -0,0 +1,123 @@
+/*
+ * 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.client.api.serialization;
+
+import java.io.InputStream;
+import java.util.Map;
+
+import org.apache.olingo.client.api.edm.xml.Schema;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.domain.CommonODataEntity;
+import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
+import org.apache.olingo.commons.api.domain.CommonODataProperty;
+import org.apache.olingo.commons.api.domain.ODataError;
+import org.apache.olingo.commons.api.domain.ODataServiceDocument;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+
+/**
+ * OData reader.
+ * <br/>
+ * Use this class to de-serialize an OData response body.
+ * <br/>
+ * This class provides method helpers to de-serialize an entire entity set, a set of entities or a single entity.
+ */
+public interface CommonODataReader {
+
+  /**
+   * Parses a stream into metadata representation.
+   *
+   * @param input stream to de-serialize.
+   * @return metadata representation.
+   */
+  Edm readMetadata(InputStream input);
+
+  /**
+   * Parses a stream into metadata representation, including referenced metadata documents.
+   *
+   * @param xmlSchemas XML representation of the requested metadata document + any other referenced (via
+   * <tt>&lt;edmx:Reference/&gt;</tt>) metadata document
+   * @return metadata representation.
+   */
+  Edm readMetadata(Map<String, Schema> xmlSchemas);
+
+  /**
+   * Parses an OData service document.
+   *
+   * @param input stream to de-serialize.
+   * @param format de-serialize as XML or JSON
+   * @return List of URIs.
+   * @throws ODataDeserializerException
+   */
+  ODataServiceDocument readServiceDocument(InputStream input, ODataFormat format) throws ODataDeserializerException;
+
+  /**
+   * De-Serializes a stream into an OData entity set.
+   *
+   * @param input stream to de-serialize.
+   * @param format de-serialize format
+   * @return de-serialized entity set.
+   * @throws ODataDeserializerException
+   */
+  CommonODataEntitySet readEntitySet(InputStream input, ODataPubFormat format) throws ODataDeserializerException;
+
+  /**
+   * Parses a stream taking care to de-serializes the first OData entity found.
+   *
+   * @param input stream to de-serialize.
+   * @param format de-serialize format
+   * @return entity de-serialized.
+   * @throws ODataDeserializerException
+   */
+  CommonODataEntity readEntity(InputStream input, ODataPubFormat format) throws ODataDeserializerException;
+
+  /**
+   * Parses a stream taking care to de-serialize the first OData entity property found.
+   *
+   * @param input stream to de-serialize.
+   * @param format de-serialize as XML or JSON
+   * @return OData entity property de-serialized.
+   * @throws ODataDeserializerException
+   */
+  CommonODataProperty readProperty(InputStream input, ODataFormat format) throws ODataDeserializerException;
+
+  /**
+   * Parses a stream into an OData error.
+   *
+   * @param inputStream stream to de-serialize.
+   * @param format format
+   * @return OData error.
+   * @throws ODataDeserializerException
+   */
+  ODataError readError(InputStream inputStream, ODataFormat format) throws ODataDeserializerException;
+
+  /**
+   * Parses a stream into the object type specified by the given reference.
+   *
+   * @param <T> expected object type.
+   * @param src input stream.
+   * @param format format
+   * @param reference reference.
+   * @return read object.
+   * @throws ODataDeserializerException
+   */
+  <T> ResWrap<T> read(InputStream src, String format, Class<T> reference) throws ODataDeserializerException;
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataWriter.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataWriter.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataWriter.java
new file mode 100644
index 0000000..07a2fcd
--- /dev/null
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataWriter.java
@@ -0,0 +1,83 @@
+/*
+ * 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.client.api.serialization;
+
+import java.io.InputStream;
+import java.util.Collection;
+
+import org.apache.olingo.commons.api.domain.CommonODataEntity;
+import org.apache.olingo.commons.api.domain.CommonODataProperty;
+import org.apache.olingo.commons.api.domain.ODataLink;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.serialization.ODataSerializerException;
+
+/**
+ * OData writer.
+ * <br/>
+ * Use this interface to serialize an OData request body.
+ * <br/>
+ * This interface provides method helpers to serialize a set of entities and a single entity as well.
+ */
+public interface ODataWriter {
+
+  /**
+   * Writes a collection of OData entities.
+   *
+   * @param entities entities to be serialized.
+   * @param format serialization format.
+   * @return stream of serialized objects.
+   * @throws ODataSerializerException
+   */
+  InputStream writeEntities(Collection<CommonODataEntity> entities, ODataPubFormat format)
+      throws ODataSerializerException;
+
+  /**
+   * Serializes a single OData entity.
+   *
+   * @param entity entity to be serialized.
+   * @param format serialization format.
+   * @return stream of serialized object.
+   * @throws ODataSerializerException
+   */
+  InputStream writeEntity(CommonODataEntity entity, ODataPubFormat format)
+      throws ODataSerializerException;
+
+  /**
+   * Writes a single OData entity property.
+   *
+   * @param property entity property to be serialized.
+   * @param format serialization format.
+   * @return stream of serialized object.
+   * @throws ODataSerializerException
+   */
+  InputStream writeProperty(CommonODataProperty property, ODataFormat format)
+      throws ODataSerializerException;
+
+  /**
+   * Writes an OData link.
+   *
+   * @param link link to be serialized.
+   * @param format serialization format.
+   * @return stream of serialized object.
+   * @throws ODataSerializerException
+   */
+  InputStream writeLink(ODataLink link, ODataFormat format)
+      throws ODataSerializerException;
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v3/ODataBinder.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v3/ODataBinder.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v3/ODataBinder.java
new file mode 100644
index 0000000..99c91d6
--- /dev/null
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v3/ODataBinder.java
@@ -0,0 +1,51 @@
+/*
+ * 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.client.api.serialization.v3;
+
+import org.apache.olingo.commons.api.data.v3.LinkCollection;
+import org.apache.olingo.client.api.domain.v3.ODataLinkCollection;
+import org.apache.olingo.client.api.serialization.CommonODataBinder;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.domain.v3.ODataEntity;
+import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
+import org.apache.olingo.commons.api.domain.v3.ODataProperty;
+
+public interface ODataBinder extends CommonODataBinder {
+
+  @Override
+  ODataEntitySet getODataEntitySet(ResWrap<EntitySet> resource);
+
+  @Override
+  ODataEntity getODataEntity(ResWrap<Entity> resource);
+
+  @Override
+  ODataProperty getODataProperty(ResWrap<Property> resource);
+
+  /**
+   * Gets <tt>ODataLinkCollection</tt> from the given link collection resource.
+   *
+   * @param resource link collection resource.
+   * @return <tt>ODataLinkCollection</tt> object.
+   */
+  ODataLinkCollection getLinkCollection(LinkCollection resource);
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v3/ODataDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v3/ODataDeserializer.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v3/ODataDeserializer.java
new file mode 100644
index 0000000..22cb305
--- /dev/null
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v3/ODataDeserializer.java
@@ -0,0 +1,38 @@
+/*
+ * 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.client.api.serialization.v3;
+
+import java.io.InputStream;
+
+import org.apache.olingo.client.api.serialization.ClientODataDeserializer;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.data.v3.LinkCollection;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+
+public interface ODataDeserializer extends ClientODataDeserializer {
+
+  /**
+   * Gets a list of links from the given InputStream.
+   *
+   * @param input stream to be de-serialized.
+   * @return de-serialized links.
+   * @throws ODataDeserializerException
+   */
+  ResWrap<LinkCollection> toLinkCollection(InputStream input) throws ODataDeserializerException;
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v3/ODataReader.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v3/ODataReader.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v3/ODataReader.java
new file mode 100644
index 0000000..082bf46
--- /dev/null
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v3/ODataReader.java
@@ -0,0 +1,51 @@
+/*
+ * 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.client.api.serialization.v3;
+
+import java.io.InputStream;
+
+import org.apache.olingo.client.api.domain.v3.ODataLinkCollection;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.client.api.serialization.CommonODataReader;
+import org.apache.olingo.commons.api.domain.v3.ODataEntity;
+import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
+import org.apache.olingo.commons.api.domain.v3.ODataProperty;
+import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+
+public interface ODataReader extends CommonODataReader {
+
+  @Override
+  ODataEntitySet readEntitySet(InputStream input, ODataPubFormat format) throws ODataDeserializerException;
+
+  @Override
+  ODataEntity readEntity(InputStream input, ODataPubFormat format) throws ODataDeserializerException;
+
+  @Override
+  ODataProperty readProperty(InputStream input, ODataFormat format) throws ODataDeserializerException;
+
+  /**
+   * Parses a $links request response.
+   *
+   * @param input stream to de-serialize.
+   * @param format de-serialize as XML or JSON
+   * @return List of URIs.
+   */
+  ODataLinkCollection readLinks(InputStream input, ODataFormat format) throws ODataDeserializerException;
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v4/ODataBinder.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v4/ODataBinder.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v4/ODataBinder.java
new file mode 100644
index 0000000..1a8565f
--- /dev/null
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v4/ODataBinder.java
@@ -0,0 +1,44 @@
+/*
+ * 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.client.api.serialization.v4;
+
+import org.apache.olingo.client.api.serialization.CommonODataBinder;
+import org.apache.olingo.commons.api.data.Delta;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.domain.v4.ODataDelta;
+import org.apache.olingo.commons.api.domain.v4.ODataEntity;
+import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
+import org.apache.olingo.commons.api.domain.v4.ODataProperty;
+
+public interface ODataBinder extends CommonODataBinder {
+
+  @Override
+  ODataEntitySet getODataEntitySet(ResWrap<EntitySet> resource);
+
+  @Override
+  ODataEntity getODataEntity(ResWrap<Entity> resource);
+
+  @Override
+  ODataProperty getODataProperty(ResWrap<Property> resource);
+
+  ODataDelta getODataDelta(ResWrap<Delta> resource);
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v4/ODataDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v4/ODataDeserializer.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v4/ODataDeserializer.java
new file mode 100644
index 0000000..9df40d9
--- /dev/null
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v4/ODataDeserializer.java
@@ -0,0 +1,42 @@
+/*
+ * 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.client.api.serialization.v4;
+
+import java.io.InputStream;
+
+import org.apache.olingo.client.api.edm.xml.v4.XMLMetadata;
+import org.apache.olingo.client.api.serialization.ClientODataDeserializer;
+import org.apache.olingo.commons.api.data.Delta;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+
+public interface ODataDeserializer extends ClientODataDeserializer {
+
+  @Override
+  XMLMetadata toMetadata(InputStream input);
+
+  /**
+   * Gets a delta object from the given InputStream.
+   *
+   * @param input stream to be de-serialized.
+   * @return {@link Delta} instance.
+   * @throws ODataDeserializerException
+   */
+  ResWrap<Delta> toDelta(InputStream input) throws ODataDeserializerException;
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v4/ODataReader.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v4/ODataReader.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v4/ODataReader.java
new file mode 100644
index 0000000..31d4969
--- /dev/null
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v4/ODataReader.java
@@ -0,0 +1,41 @@
+/*
+ * 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.client.api.serialization.v4;
+
+import java.io.InputStream;
+
+import org.apache.olingo.client.api.serialization.CommonODataReader;
+import org.apache.olingo.commons.api.domain.v4.ODataEntity;
+import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
+import org.apache.olingo.commons.api.domain.v4.ODataProperty;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+
+public interface ODataReader extends CommonODataReader {
+
+  @Override
+  ODataEntitySet readEntitySet(InputStream input, ODataPubFormat format) throws ODataDeserializerException;
+
+  @Override
+  ODataEntity readEntity(InputStream input, ODataPubFormat format) throws ODataDeserializerException;
+
+  @Override
+  ODataProperty readProperty(InputStream input, ODataFormat format) throws ODataDeserializerException;
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java
index 86e5b6d..6360f0a 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java
@@ -23,9 +23,9 @@ import org.apache.olingo.client.api.communication.request.batch.v3.BatchRequestF
 import org.apache.olingo.client.api.communication.request.cud.v3.CUDRequestFactory;
 import org.apache.olingo.client.api.communication.request.cud.v3.UpdateType;
 import org.apache.olingo.client.api.communication.request.retrieve.v3.RetrieveRequestFactory;
-import org.apache.olingo.client.api.op.v3.ODataBinder;
-import org.apache.olingo.client.api.op.v3.ODataDeserializer;
-import org.apache.olingo.client.api.op.v3.ODataReader;
+import org.apache.olingo.client.api.serialization.v3.ODataBinder;
+import org.apache.olingo.client.api.serialization.v3.ODataDeserializer;
+import org.apache.olingo.client.api.serialization.v3.ODataReader;
 import org.apache.olingo.client.api.uri.v3.URIBuilder;
 import org.apache.olingo.client.api.uri.v3.FilterFactory;
 import org.apache.olingo.commons.api.domain.v3.ODataObjectFactory;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java
index 383a488..fa923aa 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java
@@ -24,9 +24,9 @@ import org.apache.olingo.client.api.communication.request.cud.v4.CUDRequestFacto
 import org.apache.olingo.client.api.communication.request.cud.v4.UpdateType;
 import org.apache.olingo.client.api.communication.request.retrieve.v4.RetrieveRequestFactory;
 import org.apache.olingo.client.api.communication.request.v4.AsyncRequestFactory;
-import org.apache.olingo.client.api.op.v4.ODataBinder;
-import org.apache.olingo.client.api.op.v4.ODataDeserializer;
-import org.apache.olingo.client.api.op.v4.ODataReader;
+import org.apache.olingo.client.api.serialization.v4.ODataBinder;
+import org.apache.olingo.client.api.serialization.v4.ODataDeserializer;
+import org.apache.olingo.client.api.serialization.v4.ODataReader;
 import org.apache.olingo.client.api.uri.v4.URIBuilder;
 import org.apache.olingo.client.api.uri.v4.FilterFactory;
 import org.apache.olingo.client.api.uri.v4.SearchFactory;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractODataClient.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractODataClient.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractODataClient.java
index 203f624..71c60c4 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractODataClient.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractODataClient.java
@@ -21,8 +21,8 @@ package org.apache.olingo.client.core;
 import org.apache.olingo.client.api.CommonODataClient;
 import org.apache.olingo.client.api.communication.header.ODataPreferences;
 import org.apache.olingo.client.api.communication.request.cud.CommonUpdateType;
-import org.apache.olingo.client.api.op.ODataWriter;
-import org.apache.olingo.client.core.op.ODataWriterImpl;
+import org.apache.olingo.client.api.serialization.ODataWriter;
+import org.apache.olingo.client.core.serialization.ODataWriterImpl;
 
 public abstract class AbstractODataClient<UT extends CommonUpdateType> implements CommonODataClient<UT> {
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/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 d86f599..69fa29c 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
@@ -27,7 +27,7 @@ import org.apache.olingo.client.api.communication.ODataServerErrorException;
 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.op.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 import org.apache.olingo.commons.core.data.ODataErrorImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java
index 67a6950..fcaf9de 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java
@@ -36,8 +36,8 @@ import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.domain.CommonODataEntity;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
-import org.apache.olingo.commons.api.op.ODataSerializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataSerializerException;
 
 /**
  * This class implements an OData create request.


[4/9] [OLINGO-317] Rename and move of some packages and classes

Posted by mi...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertyDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertyDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertyDeserializer.java
deleted file mode 100644
index 465250a..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertyDeserializer.java
+++ /dev/null
@@ -1,104 +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.io.IOException;
-import java.net.URI;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.Annotation;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.core.edm.EdmTypeInfo;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Parse JSON string into <tt>Property</tt>.
- */
-public class JSONPropertyDeserializer extends JsonDeserializer {
-
-  public JSONPropertyDeserializer(final ODataServiceVersion version, final boolean serverMode) {
-    super(version, serverMode);
-  }
-
-  protected ResWrap<Property> doDeserialize(final JsonParser parser) throws IOException {
-
-    final ObjectNode tree = (ObjectNode) parser.getCodec().readTree(parser);
-
-    final String metadataETag;
-    final URI contextURL;
-    final PropertyImpl property = new PropertyImpl();
-
-    if (tree.hasNonNull(Constants.JSON_METADATA_ETAG)) {
-      metadataETag = tree.get(Constants.JSON_METADATA_ETAG).textValue();
-      tree.remove(Constants.JSON_METADATA_ETAG);
-    } else {
-      metadataETag = null;
-    }
-
-    if (tree.hasNonNull(Constants.JSON_CONTEXT)) {
-      contextURL = URI.create(tree.get(Constants.JSON_CONTEXT).textValue());
-      property.setName(StringUtils.substringAfterLast(contextURL.toASCIIString(), "/"));
-      tree.remove(Constants.JSON_CONTEXT);
-    } else if (tree.hasNonNull(Constants.JSON_METADATA)) {
-      contextURL = URI.create(tree.get(Constants.JSON_METADATA).textValue());
-      property.setType(new EdmTypeInfo.Builder().
-              setTypeExpression(StringUtils.substringAfterLast(contextURL.toASCIIString(), "#")).build().internal());
-      tree.remove(Constants.JSON_METADATA);
-    } else {
-      contextURL = null;
-    }
-
-    if (tree.has(jsonType)) {
-      property.setType(new EdmTypeInfo.Builder().setTypeExpression(tree.get(jsonType).textValue()).build().internal());
-      tree.remove(jsonType);
-    }
-
-    if (tree.has(Constants.JSON_NULL) && tree.get(Constants.JSON_NULL).asBoolean()) {
-      property.setValue(new NullValueImpl());
-      tree.remove(Constants.JSON_NULL);
-    }
-
-    if (property.getValue() == null) {
-      value(property, tree.has(Constants.VALUE) ? tree.get(Constants.VALUE) : tree, parser.getCodec());
-      tree.remove(Constants.VALUE);
-    }
-
-    // any remaining entry is supposed to be an annotation or is ignored
-    for (final Iterator<Map.Entry<String, JsonNode>> itor = tree.fields(); itor.hasNext();) {
-      final Map.Entry<String, JsonNode> field = itor.next();
-      if (field.getKey().charAt(0) == '@') {
-        final Annotation annotation = new AnnotationImpl();
-        annotation.setTerm(field.getKey().substring(1));
-
-        value(annotation, field.getValue(), parser.getCodec());
-        property.getAnnotations().add(annotation);
-      }
-    }
-
-    return new ResWrap<Property>(contextURL, metadataETag, property);
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertySerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertySerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertySerializer.java
deleted file mode 100644
index 1a82a3b..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertySerializer.java
+++ /dev/null
@@ -1,90 +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.io.IOException;
-import java.net.URI;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.Annotation;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.core.edm.EdmTypeInfo;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-
-/**
- * Writes out JSON string from <tt>PropertyImpl</tt>.
- */
-public class JSONPropertySerializer extends JsonSerializer {
-
-  public JSONPropertySerializer(final ODataServiceVersion version, final boolean serverMode) {
-    super(version, serverMode);
-  }
-
-  protected void doSerialize(final Property property, final JsonGenerator jgen) throws IOException {
-    doContainerSerialize(new ResWrap<Property>((URI) null, null, property), jgen);
-  }
-
-  protected void doContainerSerialize(final ResWrap<Property> container, final JsonGenerator jgen)
-          throws IOException {
-
-    final Property property = container.getPayload();
-
-    jgen.writeStartObject();
-
-    if (serverMode && container.getContextURL() != null) {
-      jgen.writeStringField(version.compareTo(ODataServiceVersion.V40) >= 0
-              ? Constants.JSON_CONTEXT : Constants.JSON_METADATA,
-              container.getContextURL().getURI().toASCIIString());
-    }
-
-    if (StringUtils.isNotBlank(property.getType())) {
-      jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_TYPE),
-              new EdmTypeInfo.Builder().setTypeExpression(property.getType()).build().external(version));
-    }
-
-    for (Annotation annotation : property.getAnnotations()) {
-      valuable(jgen, annotation, "@" + annotation.getTerm());
-    }
-
-    if (property.getValue().isNull()) {
-      jgen.writeBooleanField(Constants.JSON_NULL, true);
-    } else if (property.getValue().isPrimitive()) {
-      final EdmTypeInfo typeInfo = property.getType() == null
-              ? null
-              : new EdmTypeInfo.Builder().setTypeExpression(property.getType()).build();
-
-      jgen.writeFieldName(Constants.VALUE);
-      primitiveValue(jgen, typeInfo, property.getValue().asPrimitive());
-    } else if (property.getValue().isEnum()) {
-      jgen.writeStringField(Constants.VALUE, property.getValue().asEnum().get());
-    } else if (property.getValue().isGeospatial() || property.getValue().isCollection()) {
-      valuable(jgen, property, Constants.VALUE);
-    } else if (property.getValue().isComplex()) {
-      for (Property cproperty : property.getValue().asComplex().get()) {
-        valuable(jgen, cproperty, cproperty.getName());
-      }
-    }
-
-    jgen.writeEndObject();
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JsonDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JsonDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JsonDeserializer.java
deleted file mode 100755
index 0ecd7f3..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JsonDeserializer.java
+++ /dev/null
@@ -1,463 +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.io.IOException;
-import java.io.InputStream;
-import java.util.AbstractMap.SimpleEntry;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.Annotatable;
-import org.apache.olingo.commons.api.data.Annotation;
-import org.apache.olingo.commons.api.data.CollectionValue;
-import org.apache.olingo.commons.api.data.ComplexValue;
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
-import org.apache.olingo.commons.api.data.Linked;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.data.Valuable;
-import org.apache.olingo.commons.api.data.Value;
-import org.apache.olingo.commons.api.domain.ODataError;
-import org.apache.olingo.commons.api.domain.ODataLinkType;
-import org.apache.olingo.commons.api.domain.ODataPropertyType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.api.op.ODataDeserializer;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
-import org.apache.olingo.commons.core.edm.EdmTypeInfo;
-
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.ObjectCodec;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-public class JsonDeserializer implements ODataDeserializer {
-
-  protected final Pattern CUSTOM_ANNOTATION = Pattern.compile("(.+)@(.+)\\.(.+)");
-  protected final ODataServiceVersion version;
-  protected final boolean serverMode;
-
-  protected String jsonType;
-  protected String jsonId;
-  protected String jsonETag;
-  protected String jsonReadLink;
-  protected String jsonEditLink;
-  protected String jsonMediaEditLink;
-  protected String jsonMediaReadLink;
-  protected String jsonMediaContentType;
-  protected String jsonMediaETag;
-  protected String jsonAssociationLink;
-  protected String jsonNavigationLink;
-  protected String jsonCount;
-  protected String jsonNextLink;
-  protected String jsonDeltaLink;
-  protected String jsonError;
-
-  private JSONGeoValueDeserializer geoDeserializer;
-
-  private JsonParser parser;
-
-  public JsonDeserializer(final ODataServiceVersion version, final boolean serverMode) {
-    this.version = version;
-    this.serverMode = serverMode;
-
-    jsonType = version.getJSONMap().get(ODataServiceVersion.JSON_TYPE);
-    jsonId = version.getJSONMap().get(ODataServiceVersion.JSON_ID);
-    jsonETag = version.getJSONMap().get(ODataServiceVersion.JSON_ETAG);
-    jsonReadLink = version.getJSONMap().get(ODataServiceVersion.JSON_READ_LINK);
-    jsonEditLink = version.getJSONMap().get(ODataServiceVersion.JSON_EDIT_LINK);
-    jsonMediaReadLink = version.getJSONMap().get(ODataServiceVersion.JSON_MEDIAREAD_LINK);
-    jsonMediaEditLink = version.getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK);
-    jsonMediaContentType = version.getJSONMap().get(ODataServiceVersion.JSON_MEDIA_CONTENT_TYPE);
-    jsonMediaETag = version.getJSONMap().get(ODataServiceVersion.JSON_MEDIA_ETAG);
-    jsonAssociationLink = version.getJSONMap().get(ODataServiceVersion.JSON_ASSOCIATION_LINK);
-    jsonNavigationLink = version.getJSONMap().get(ODataServiceVersion.JSON_NAVIGATION_LINK);
-    jsonCount = version.getJSONMap().get(ODataServiceVersion.JSON_COUNT);
-    jsonNextLink = version.getJSONMap().get(ODataServiceVersion.JSON_NEXT_LINK);
-    jsonDeltaLink = version.getJSONMap().get(ODataServiceVersion.JSON_DELTA_LINK);
-    jsonError = version.getJSONMap().get(ODataServiceVersion.JSON_ERROR);
-}
-
-  private JSONGeoValueDeserializer getGeoDeserializer() {
-    if (geoDeserializer == null) {
-      geoDeserializer = new JSONGeoValueDeserializer(version);
-    }
-    return geoDeserializer;
-  }
-
-  protected String getJSONAnnotation(final String string) {
-    return StringUtils.prependIfMissing(string, "@");
-  }
-
-  protected String getTitle(final Map.Entry<String, JsonNode> entry) {
-    return entry.getKey().substring(0, entry.getKey().indexOf('@'));
-  }
-
-  protected String setInline(final String name, final String suffix, final JsonNode tree,
-      final ObjectCodec codec, final LinkImpl link) throws IOException {
-
-    final String entityNamePrefix = name.substring(0, name.indexOf(suffix));
-    if (tree.has(entityNamePrefix)) {
-      final JsonNode inline = tree.path(entityNamePrefix);
-      JSONEntityDeserializer entityDeserializer = new JSONEntityDeserializer(version, serverMode);
-
-      if (inline instanceof ObjectNode) {
-        link.setType(ODataLinkType.ENTITY_NAVIGATION.toString());
-        link.setInlineEntity(entityDeserializer.doDeserialize(inline.traverse(codec)).getPayload());
-
-      } else if (inline instanceof ArrayNode) {
-        link.setType(ODataLinkType.ENTITY_SET_NAVIGATION.toString());
-
-        EntitySet entitySet = new EntitySetImpl();
-        Iterator<JsonNode> entries = ((ArrayNode) inline).elements();
-        while (entries.hasNext()) {
-          entitySet.getEntities().add(
-              entityDeserializer.doDeserialize(entries.next().traverse(codec)).getPayload());
-        }
-
-        link.setInlineEntitySet(entitySet);
-      }
-    }
-    return entityNamePrefix;
-  }
-
-  protected void links(final Map.Entry<String, JsonNode> field, final Linked linked, final Set<String> toRemove,
-      final JsonNode tree, final ObjectCodec codec) throws IOException {
-    if (serverMode) {
-      serverLinks(field, linked, toRemove, tree, codec);
-    } else {
-      clientLinks(field, linked, toRemove, tree, codec);
-    }
-  }
-
-  private void clientLinks(final Map.Entry<String, JsonNode> field, final Linked linked, final Set<String> toRemove,
-      final JsonNode tree, final ObjectCodec codec) throws IOException {
-
-    if (field.getKey().endsWith(jsonNavigationLink)) {
-      final LinkImpl link = new LinkImpl();
-      link.setTitle(getTitle(field));
-      link.setRel(version.getNamespaceMap().get(ODataServiceVersion.NAVIGATION_LINK_REL) + getTitle(field));
-
-      if (field.getValue().isValueNode()) {
-        link.setHref(field.getValue().textValue());
-        link.setType(ODataLinkType.ENTITY_NAVIGATION.toString());
-      }
-
-      linked.getNavigationLinks().add(link);
-
-      toRemove.add(field.getKey());
-      toRemove.add(setInline(field.getKey(), jsonNavigationLink, tree, codec, link));
-    } else if (field.getKey().endsWith(jsonAssociationLink)) {
-      final LinkImpl link = new LinkImpl();
-      link.setTitle(getTitle(field));
-      link.setRel(version.getNamespaceMap().get(ODataServiceVersion.ASSOCIATION_LINK_REL) + getTitle(field));
-      link.setHref(field.getValue().textValue());
-      link.setType(ODataLinkType.ASSOCIATION.toString());
-      linked.getAssociationLinks().add(link);
-
-      toRemove.add(field.getKey());
-    }
-  }
-
-  private void serverLinks(final Map.Entry<String, JsonNode> field, final Linked linked, final Set<String> toRemove,
-      final JsonNode tree, final ObjectCodec codec) throws IOException {
-
-    if (field.getKey().endsWith(Constants.JSON_BIND_LINK_SUFFIX)
-        || field.getKey().endsWith(jsonNavigationLink)) {
-
-      if (field.getValue().isValueNode()) {
-        final String suffix = field.getKey().replaceAll("^.*@", "@");
-
-        final LinkImpl link = new LinkImpl();
-        link.setTitle(getTitle(field));
-        link.setRel(version.getNamespaceMap().get(ODataServiceVersion.NAVIGATION_LINK_REL) + getTitle(field));
-        link.setHref(field.getValue().textValue());
-        link.setType(ODataLinkType.ENTITY_NAVIGATION.toString());
-        linked.getNavigationLinks().add(link);
-
-        toRemove.add(setInline(field.getKey(), suffix, tree, codec, link));
-      } else if (field.getValue().isArray()) {
-        for (final Iterator<JsonNode> itor = field.getValue().elements(); itor.hasNext();) {
-          final JsonNode node = itor.next();
-
-          final LinkImpl link = new LinkImpl();
-          link.setTitle(getTitle(field));
-          link.setRel(version.getNamespaceMap().get(ODataServiceVersion.NAVIGATION_LINK_REL) + getTitle(field));
-          link.setHref(node.asText());
-          link.setType(ODataLinkType.ENTITY_SET_NAVIGATION.toString());
-          linked.getNavigationLinks().add(link);
-          toRemove.add(setInline(field.getKey(), Constants.JSON_BIND_LINK_SUFFIX, tree, codec, link));
-        }
-      }
-      toRemove.add(field.getKey());
-    }
-  }
-
-  private Map.Entry<ODataPropertyType, EdmTypeInfo> guessPropertyType(final JsonNode node) {
-    ODataPropertyType type;
-    EdmTypeInfo typeInfo = null;
-
-    if (node.isValueNode() || node.isNull()) {
-      type = ODataPropertyType.PRIMITIVE;
-
-      EdmPrimitiveTypeKind kind = EdmPrimitiveTypeKind.String;
-      if (node.isShort()) {
-        kind = EdmPrimitiveTypeKind.Int16;
-      } else if (node.isInt()) {
-        kind = EdmPrimitiveTypeKind.Int32;
-      } else if (node.isLong()) {
-        kind = EdmPrimitiveTypeKind.Int64;
-      } else if (node.isBoolean()) {
-        kind = EdmPrimitiveTypeKind.Boolean;
-      } else if (node.isFloat()) {
-        kind = EdmPrimitiveTypeKind.Single;
-      } else if (node.isDouble()) {
-        kind = EdmPrimitiveTypeKind.Double;
-      } else if (node.isBigDecimal()) {
-        kind = EdmPrimitiveTypeKind.Decimal;
-      }
-      typeInfo = new EdmTypeInfo.Builder().setTypeExpression(kind.getFullQualifiedName().toString()).build();
-    } else if (node.isArray()) {
-      type = ODataPropertyType.COLLECTION;
-    } else if (node.isObject()) {
-      if (node.has(Constants.ATTR_TYPE)) {
-        type = ODataPropertyType.PRIMITIVE;
-        typeInfo = new EdmTypeInfo.Builder().
-            setTypeExpression("Edm.Geography" + node.get(Constants.ATTR_TYPE).asText()).build();
-      } else {
-        type = ODataPropertyType.COMPLEX;
-      }
-    } else {
-      type = ODataPropertyType.EMPTY;
-    }
-
-    return new SimpleEntry<ODataPropertyType, EdmTypeInfo>(type, typeInfo);
-  }
-
-  protected void populate(final Annotatable annotatable, final List<Property> properties,
-      final ObjectNode tree, final ObjectCodec codec) throws IOException {
-
-    String type = null;
-    Annotation annotation = null;
-    for (final Iterator<Map.Entry<String, JsonNode>> itor = tree.fields(); itor.hasNext();) {
-      final Map.Entry<String, JsonNode> field = itor.next();
-      final Matcher customAnnotation = CUSTOM_ANNOTATION.matcher(field.getKey());
-
-      if (field.getKey().charAt(0) == '@') {
-        final Annotation entityAnnot = new AnnotationImpl();
-        entityAnnot.setTerm(field.getKey().substring(1));
-
-        value(entityAnnot, field.getValue(), codec);
-        if (annotatable != null) {
-          annotatable.getAnnotations().add(entityAnnot);
-        }
-      } else if (type == null && field.getKey().endsWith(getJSONAnnotation(jsonType))) {
-        type = field.getValue().asText();
-      } else if (annotation == null && customAnnotation.matches() && !"odata".equals(customAnnotation.group(2))) {
-        annotation = new AnnotationImpl();
-        annotation.setTerm(customAnnotation.group(2) + "." + customAnnotation.group(3));
-        value(annotation, field.getValue(), codec);
-      } else {
-        final PropertyImpl property = new PropertyImpl();
-        property.setName(field.getKey());
-        property.setType(type == null
-            ? null
-            : new EdmTypeInfo.Builder().setTypeExpression(type).build().internal());
-        type = null;
-
-        value(property, field.getValue(), codec);
-        properties.add(property);
-
-        if (annotation != null) {
-          property.getAnnotations().add(annotation);
-          annotation = null;
-        }
-      }
-    }
-  }
-
-  private Value fromPrimitive(final JsonNode node, final EdmTypeInfo typeInfo) {
-    final Value value;
-
-    if (node.isNull()) {
-      value = new NullValueImpl();
-    } else {
-      if (typeInfo != null && typeInfo.getPrimitiveTypeKind().isGeospatial()) {
-        value = new GeospatialValueImpl(getGeoDeserializer().deserialize(node, typeInfo));
-      } else {
-        value = new PrimitiveValueImpl(node.asText());
-      }
-    }
-
-    return value;
-  }
-
-  private ComplexValue fromComplex(final ObjectNode node, final ObjectCodec codec) throws IOException {
-    final ComplexValue value = version.compareTo(ODataServiceVersion.V40) < 0
-        ? new ComplexValueImpl()
-        : new LinkedComplexValueImpl();
-
-    if (value.isLinkedComplex()) {
-      final Set<String> toRemove = new HashSet<String>();
-      for (final Iterator<Map.Entry<String, JsonNode>> itor = node.fields(); itor.hasNext();) {
-        final Map.Entry<String, JsonNode> field = itor.next();
-
-        links(field, value.asLinkedComplex(), toRemove, node, codec);
-      }
-      node.remove(toRemove);
-    }
-
-    populate(value.asLinkedComplex(), value.get(), node, codec);
-
-    return value;
-  }
-
-  private CollectionValue fromCollection(final Iterator<JsonNode> nodeItor, final EdmTypeInfo typeInfo,
-      final ObjectCodec codec) throws IOException {
-
-    final CollectionValueImpl value = new CollectionValueImpl();
-
-    final EdmTypeInfo type = typeInfo == null
-        ? null
-        : new EdmTypeInfo.Builder().setTypeExpression(typeInfo.getFullQualifiedName().toString()).build();
-
-    while (nodeItor.hasNext()) {
-      final JsonNode child = nodeItor.next();
-
-      if (child.isValueNode()) {
-        if (typeInfo == null || typeInfo.isPrimitiveType()) {
-          value.get().add(fromPrimitive(child, type));
-        } else {
-          value.get().add(new EnumValueImpl(child.asText()));
-        }
-      } else if (child.isContainerNode()) {
-        if (child.has(jsonType)) {
-          ((ObjectNode) child).remove(jsonType);
-        }
-        value.get().add(fromComplex((ObjectNode) child, codec));
-      }
-    }
-
-    return value;
-  }
-
-  protected void value(final Valuable valuable, final JsonNode node, final ObjectCodec codec)
-      throws IOException {
-
-    EdmTypeInfo typeInfo = StringUtils.isBlank(valuable.getType())
-        ? null
-        : new EdmTypeInfo.Builder().setTypeExpression(valuable.getType()).build();
-
-    final Map.Entry<ODataPropertyType, EdmTypeInfo> guessed = guessPropertyType(node);
-    if (typeInfo == null) {
-      typeInfo = guessed.getValue();
-    }
-
-    final ODataPropertyType propType = typeInfo == null
-        ? guessed.getKey()
-        : typeInfo.isCollection()
-            ? ODataPropertyType.COLLECTION
-            : typeInfo.isPrimitiveType()
-                ? ODataPropertyType.PRIMITIVE
-                : node.isValueNode()
-                    ? ODataPropertyType.ENUM
-                    : ODataPropertyType.COMPLEX;
-
-    switch (propType) {
-    case COLLECTION:
-      valuable.setValue(fromCollection(node.elements(), typeInfo, codec));
-      break;
-
-    case COMPLEX:
-      if (node.has(jsonType)) {
-        valuable.setType(node.get(jsonType).asText());
-        ((ObjectNode) node).remove(jsonType);
-      }
-      valuable.setValue(fromComplex((ObjectNode) node, codec));
-      break;
-
-    case ENUM:
-      valuable.setValue(new EnumValueImpl(node.asText()));
-      break;
-
-    case PRIMITIVE:
-      if (valuable.getType() == null && typeInfo != null) {
-        valuable.setType(typeInfo.getFullQualifiedName().toString());
-      }
-      valuable.setValue(fromPrimitive(node, typeInfo));
-      break;
-
-    case EMPTY:
-    default:
-      valuable.setValue(new PrimitiveValueImpl(StringUtils.EMPTY));
-    }
-  }
-
-  @Override
-  public ResWrap<EntitySet> toEntitySet(InputStream input) throws ODataDeserializerException {
-    try {
-      parser = new JsonFactory(new ObjectMapper()).createParser(input);
-      return new JSONEntitySetDeserializer(version, serverMode).doDeserialize(parser);
-    } catch (final IOException e) {
-      throw new ODataDeserializerException(e);
-    }
-  }
-
-  @Override
-  public ResWrap<Entity> toEntity(InputStream input) throws ODataDeserializerException {
-    try {
-      parser = new JsonFactory(new ObjectMapper()).createParser(input);
-      return new JSONEntityDeserializer(version, serverMode).doDeserialize(parser);
-    } catch (final IOException e) {
-      throw new ODataDeserializerException(e);
-    }
-  }
-
-  @Override
-  public ResWrap<Property> toProperty(InputStream input) throws ODataDeserializerException {
-    try {
-      parser = new JsonFactory(new ObjectMapper()).createParser(input);
-      return new JSONPropertyDeserializer(version, serverMode).doDeserialize(parser);
-    } catch (final IOException e) {
-      throw new ODataDeserializerException(e);
-    }
-  }
-
-  @Override
-  public ODataError toError(InputStream input) throws ODataDeserializerException {
-    try {
-      parser = new JsonFactory(new ObjectMapper()).createParser(input);
-      return new JSONODataErrorDeserializer(version, serverMode).doDeserialize(parser);
-    } catch (final IOException e) {
-      throw new ODataDeserializerException(e);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JsonSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JsonSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JsonSerializer.java
deleted file mode 100755
index bf1c19e..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JsonSerializer.java
+++ /dev/null
@@ -1,315 +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.io.IOException;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.BooleanUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.math.NumberUtils;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.Annotatable;
-import org.apache.olingo.commons.api.data.Annotation;
-import org.apache.olingo.commons.api.data.CollectionValue;
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
-import org.apache.olingo.commons.api.data.Link;
-import org.apache.olingo.commons.api.data.Linked;
-import org.apache.olingo.commons.api.data.PrimitiveValue;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.data.Valuable;
-import org.apache.olingo.commons.api.data.Value;
-import org.apache.olingo.commons.api.domain.ODataLinkType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.api.op.ODataSerializer;
-import org.apache.olingo.commons.api.op.ODataSerializerException;
-import org.apache.olingo.commons.core.edm.EdmTypeInfo;
-
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonGenerator;
-
-public class JsonSerializer implements ODataSerializer {
-
-  protected ODataServiceVersion version;
-  protected boolean serverMode;
-
-  private static final EdmPrimitiveTypeKind[] NUMBER_TYPES = {
-    EdmPrimitiveTypeKind.Byte, EdmPrimitiveTypeKind.SByte,
-    EdmPrimitiveTypeKind.Single, EdmPrimitiveTypeKind.Double,
-    EdmPrimitiveTypeKind.Int16, EdmPrimitiveTypeKind.Int32, EdmPrimitiveTypeKind.Int64,
-    EdmPrimitiveTypeKind.Decimal
-  };
-
-  private final JSONGeoValueSerializer geoSerializer = new JSONGeoValueSerializer();
-
-  public JsonSerializer(final ODataServiceVersion version, final boolean serverMode) {
-    this.version = version;
-    this.serverMode = serverMode;
-  }
-
-  @Override
-  public <T> void write(Writer writer, T obj) throws ODataSerializerException {
-    try {
-      JsonGenerator json = new JsonFactory().createGenerator(writer);
-      if (obj instanceof EntitySet) {
-        new JSONEntitySetSerializer(version, serverMode).doSerialize((EntitySet) obj, json);
-      } else if (obj instanceof Entity) {
-        new JSONEntitySerializer(version, serverMode).doSerialize((Entity) obj, json);
-      } else if (obj instanceof Property) {
-        new JSONPropertySerializer(version, serverMode).doSerialize((Property) obj, json);
-      } else if (obj instanceof Link) {
-        link((Link) obj, json);
-      }
-      json.flush();
-    } catch (final IOException e) {
-      throw new ODataSerializerException(e);
-    }
-  }
-
-  @SuppressWarnings("unchecked")
-  @Override
-  public <T> void write(Writer writer, ResWrap<T> container) throws ODataSerializerException {
-    final T obj = container == null ? null : container.getPayload();
-
-    try {
-      JsonGenerator json = new JsonFactory().createGenerator(writer);
-      if (obj instanceof EntitySet) {
-        new JSONEntitySetSerializer(version, serverMode).doContainerSerialize((ResWrap<EntitySet>) container, json);
-      } else if (obj instanceof Entity) {
-        new JSONEntitySerializer(version, serverMode).doContainerSerialize((ResWrap<Entity>) container, json);
-      } else if (obj instanceof Property) {
-        new JSONPropertySerializer(version, serverMode).doContainerSerialize((ResWrap<Property>) container, json);
-      } else if (obj instanceof Link) {
-        link((Link) obj, json);
-      }
-      json.flush();
-    } catch (final IOException e) {
-      throw new ODataSerializerException(e);
-    }
-  }
-
-  protected void link(final Link link, JsonGenerator jgen) throws IOException {
-    jgen.writeStartObject();
-    jgen.writeStringField(Constants.JSON_URL, link.getHref());
-    jgen.writeEndObject();
-  }
-
-  protected void links(final Linked linked, final JsonGenerator jgen) throws IOException {
-    if (serverMode) {
-      serverLinks(linked, jgen);
-    } else {
-      clientLinks(linked, jgen);
-    }
-  }
-
-  protected void clientLinks(final Linked linked, final JsonGenerator jgen) throws IOException {
-    final Map<String, List<String>> entitySetLinks = new HashMap<String, List<String>>();
-    for (Link link : linked.getNavigationLinks()) {
-      for (Annotation annotation : link.getAnnotations()) {
-        valuable(jgen, annotation, link.getTitle() + "@" + annotation.getTerm());
-      }
-
-      ODataLinkType type = null;
-      try {
-        type = ODataLinkType.fromString(version, link.getRel(), link.getType());
-      } catch (IllegalArgumentException e) {
-        // ignore   
-      }
-
-      if (type == ODataLinkType.ENTITY_SET_NAVIGATION) {
-        final List<String> uris;
-        if (entitySetLinks.containsKey(link.getTitle())) {
-          uris = entitySetLinks.get(link.getTitle());
-        } else {
-          uris = new ArrayList<String>();
-          entitySetLinks.put(link.getTitle(), uris);
-        }
-        if (StringUtils.isNotBlank(link.getHref())) {
-          uris.add(link.getHref());
-        }
-      } else {
-        if (StringUtils.isNotBlank(link.getHref())) {
-          jgen.writeStringField(link.getTitle() + Constants.JSON_BIND_LINK_SUFFIX, link.getHref());
-        }
-      }
-
-      if (link.getInlineEntity() != null) {
-        jgen.writeFieldName(link.getTitle());
-        new JSONEntitySerializer(version, serverMode).doSerialize(link.getInlineEntity(), jgen);
-      } else if (link.getInlineEntitySet() != null) {
-        jgen.writeArrayFieldStart(link.getTitle());
-        JSONEntitySerializer entitySerializer = new JSONEntitySerializer(version, serverMode);
-        for (Entity subEntry : link.getInlineEntitySet().getEntities()) {
-          entitySerializer.doSerialize(subEntry, jgen);
-        }
-        jgen.writeEndArray();
-      }
-    }
-    for (Map.Entry<String, List<String>> entitySetLink : entitySetLinks.entrySet()) {
-      if (!entitySetLink.getValue().isEmpty()) {
-        jgen.writeArrayFieldStart(entitySetLink.getKey() + Constants.JSON_BIND_LINK_SUFFIX);
-        for (String uri : entitySetLink.getValue()) {
-          jgen.writeString(uri);
-        }
-        jgen.writeEndArray();
-      }
-    }
-  }
-
-  protected void serverLinks(final Linked linked, final JsonGenerator jgen) throws IOException {
-    if (linked instanceof Entity) {
-      for (Link link : ((Entity) linked).getMediaEditLinks()) {
-        if (StringUtils.isNotBlank(link.getHref())) {
-          jgen.writeStringField(
-                  link.getTitle() + StringUtils.prependIfMissing(
-                          version.getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK), "@"),
-                  link.getHref());
-        }
-      }
-    }
-
-    for (Link link : linked.getAssociationLinks()) {
-      if (StringUtils.isNotBlank(link.getHref())) {
-        jgen.writeStringField(
-                link.getTitle() + version.getJSONMap().get(ODataServiceVersion.JSON_ASSOCIATION_LINK),
-                link.getHref());
-      }
-    }
-
-    for (Link link : linked.getNavigationLinks()) {
-      for (Annotation annotation : link.getAnnotations()) {
-        valuable(jgen, annotation, link.getTitle() + "@" + annotation.getTerm());
-      }
-
-      if (StringUtils.isNotBlank(link.getHref())) {
-        jgen.writeStringField(
-                link.getTitle() + version.getJSONMap().get(ODataServiceVersion.JSON_NAVIGATION_LINK),
-                link.getHref());
-      }
-
-      if (link.getInlineEntity() != null) {
-        jgen.writeFieldName(link.getTitle());
-        new JSONEntitySerializer(version, serverMode).doSerialize(link.getInlineEntity(), jgen);
-      } else if (link.getInlineEntitySet() != null) {
-        jgen.writeArrayFieldStart(link.getTitle());
-        JSONEntitySerializer entitySerializer = new JSONEntitySerializer(version, serverMode);
-        for (Entity subEntry : link.getInlineEntitySet().getEntities()) {
-          entitySerializer.doSerialize(subEntry, jgen);
-        }
-        jgen.writeEndArray();
-      }
-    }
-  }
-
-  private void collection(final JsonGenerator jgen, final String itemType, final CollectionValue value)
-          throws IOException {
-
-    jgen.writeStartArray();
-    for (Value item : value.get()) {
-      value(jgen, itemType, item);
-    }
-    jgen.writeEndArray();
-  }
-
-  protected void primitiveValue(final JsonGenerator jgen, final EdmTypeInfo typeInfo, final PrimitiveValue value)
-          throws IOException {
-
-    final boolean isNumber = typeInfo == null
-            ? NumberUtils.isNumber(value.get())
-            : ArrayUtils.contains(NUMBER_TYPES, typeInfo.getPrimitiveTypeKind());
-    final boolean isBoolean = typeInfo == null
-            ? (value.get().equalsIgnoreCase(Boolean.TRUE.toString())
-            || value.get().equalsIgnoreCase(Boolean.FALSE.toString()))
-            : typeInfo.getPrimitiveTypeKind() == EdmPrimitiveTypeKind.Boolean;
-
-    if (isNumber) {
-      jgen.writeNumber(value.get());
-    } else if (isBoolean) {
-      jgen.writeBoolean(BooleanUtils.toBoolean(value.get()));
-    } else {
-      jgen.writeString(value.get());
-    }
-  }
-
-  private void value(final JsonGenerator jgen, final String type, final Value value) throws IOException {
-    final EdmTypeInfo typeInfo = type == null
-            ? null
-            : new EdmTypeInfo.Builder().setTypeExpression(type).build();
-
-    if (value == null || value.isNull()) {
-      jgen.writeNull();
-    } else if (value.isPrimitive()) {
-      primitiveValue(jgen, typeInfo, value.asPrimitive());
-    } else if (value.isEnum()) {
-      jgen.writeString(value.asEnum().get());
-    } else if (value.isGeospatial()) {
-      jgen.writeStartObject();
-      geoSerializer.serialize(jgen, value.asGeospatial().get());
-      jgen.writeEndObject();
-    } else if (value.isCollection()) {
-      collection(jgen, typeInfo == null ? null : typeInfo.getFullQualifiedName().toString(), value.asCollection());
-    } else if (value.isComplex()) {
-      jgen.writeStartObject();
-
-      if (typeInfo != null) {
-        jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_TYPE), typeInfo.external(version));
-      }
-
-      for (Property property : value.asComplex().get()) {
-        valuable(jgen, property, property.getName());
-      }
-      if (value.isLinkedComplex()) {
-        links(value.asLinkedComplex(), jgen);
-      }
-
-      jgen.writeEndObject();
-    }
-  }
-
-  protected void valuable(final JsonGenerator jgen, final Valuable valuable, final String name) throws IOException {
-    if (!Constants.VALUE.equals(name) && !(valuable instanceof Annotation) && !valuable.getValue().isComplex()) {
-      String type = valuable.getType();
-      if (StringUtils.isBlank(type) && valuable.getValue().isPrimitive() || valuable.getValue().isNull()) {
-        type = EdmPrimitiveTypeKind.String.getFullQualifiedName().toString();
-      }
-      if (StringUtils.isNotBlank(type)) {
-        jgen.writeFieldName(
-                name + StringUtils.prependIfMissing(version.getJSONMap().get(ODataServiceVersion.JSON_TYPE), "@"));
-        jgen.writeString(new EdmTypeInfo.Builder().setTypeExpression(type).build().external(version));
-      }
-    }
-
-    if (valuable instanceof Annotatable) {
-      for (Annotation annotation : ((Annotatable) valuable).getAnnotations()) {
-        valuable(jgen, annotation, name + "@" + annotation.getTerm());
-      }
-    }
-
-    jgen.writeFieldName(name);
-    value(jgen, valuable.getType(), valuable.getValue());
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/AbstractODataDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/AbstractODataDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/AbstractODataDeserializer.java
deleted file mode 100644
index 548d79d..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/AbstractODataDeserializer.java
+++ /dev/null
@@ -1,101 +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.op;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.domain.ODataError;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.api.format.Format;
-import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializer;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
-import org.apache.olingo.commons.core.data.AtomDeserializer;
-import org.apache.olingo.commons.core.data.JsonDeserializer;
-
-import com.fasterxml.aalto.stax.InputFactoryImpl;
-import com.fasterxml.aalto.stax.OutputFactoryImpl;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.InjectableValues;
-import com.fasterxml.jackson.databind.deser.DeserializationProblemHandler;
-import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule;
-import com.fasterxml.jackson.dataformat.xml.XmlFactory;
-import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-
-public abstract class AbstractODataDeserializer {
-
-  protected final ODataServiceVersion version;
-  protected final ODataDeserializer deserializer;
-
-  public AbstractODataDeserializer(final ODataServiceVersion version, final boolean serverMode, final Format format) {
-    this.version = version;
-    if (format == ODataFormat.XML || format == ODataPubFormat.ATOM) {
-      deserializer = new AtomDeserializer(version);
-    } else {
-      deserializer = new JsonDeserializer(version, serverMode);
-    }
-  }
-
-  public ResWrap<EntitySet> toEntitySet(final InputStream input) throws ODataDeserializerException {
-    return deserializer.toEntitySet(input);
-  }
-
-  public ResWrap<Entity> toEntity(final InputStream input) throws ODataDeserializerException {
-    return deserializer.toEntity(input);
-  }
-
-  public ResWrap<Property> toProperty(final InputStream input) throws ODataDeserializerException {
-    return deserializer.toProperty(input);
-  }
-
-  public ODataError toError(final InputStream input) throws ODataDeserializerException {
-    return deserializer.toError(input);
-  }
-
-  protected XmlMapper getXmlMapper() {
-    final XmlMapper xmlMapper = new XmlMapper(
-        new XmlFactory(new InputFactoryImpl(), new OutputFactoryImpl()), new JacksonXmlModule());
-
-    xmlMapper.setInjectableValues(new InjectableValues.Std().
-        addValue(ODataServiceVersion.class, version).
-        addValue(Boolean.class, Boolean.FALSE));
-
-    xmlMapper.addHandler(new DeserializationProblemHandler() {
-      @Override
-      public boolean handleUnknownProperty(final DeserializationContext ctxt, final JsonParser jp,
-          final com.fasterxml.jackson.databind.JsonDeserializer<?> deserializer,
-          final Object beanOrClass, final String propertyName)
-          throws IOException, JsonProcessingException {
-
-        // skip any unknown property
-        ctxt.getParser().skipChildren();
-        return true;
-      }
-    });
-    return xmlMapper;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/InjectableSerializerProvider.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/InjectableSerializerProvider.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/InjectableSerializerProvider.java
deleted file mode 100644
index 1fed74a..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/InjectableSerializerProvider.java
+++ /dev/null
@@ -1,42 +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.op;
-
-import com.fasterxml.jackson.databind.SerializationConfig;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.ser.DefaultSerializerProvider;
-import com.fasterxml.jackson.databind.ser.SerializerFactory;
-
-public class InjectableSerializerProvider extends DefaultSerializerProvider {
-
-  private static final long serialVersionUID = 3432260063063739646L;
-
-  public InjectableSerializerProvider(
-          final SerializerProvider src, final SerializationConfig config, final SerializerFactory factory) {
-
-    super(src, config, factory);
-  }
-
-  @Override
-  public InjectableSerializerProvider createInstance(
-          final SerializationConfig config, final SerializerFactory factory) {
-
-    return this;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AbstractAtomDealer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AbstractAtomDealer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AbstractAtomDealer.java
new file mode 100644
index 0000000..5bf98d3
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AbstractAtomDealer.java
@@ -0,0 +1,137 @@
+/*
+ * 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.serialization;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+
+abstract class AbstractAtomDealer {
+
+  protected static final String TYPE_TEXT = "text";
+
+  protected final ODataServiceVersion version;
+
+  protected final QName etagQName;
+
+  protected final QName metadataEtagQName;
+
+  protected final QName inlineQName;
+
+  protected final QName actionQName;
+
+  protected final QName propertiesQName;
+
+  protected final QName typeQName;
+
+  protected final QName nullQName;
+
+  protected final QName elementQName;
+
+  protected final QName countQName;
+
+  protected final QName uriQName;
+
+  protected final QName nextQName;
+
+  protected final QName annotationQName;
+
+  protected final QName contextQName;
+
+  protected final QName entryRefQName;
+
+  protected final QName propertyValueQName;
+
+  protected final QName deletedEntryQName;
+
+  protected final QName reasonQName;
+
+  protected final QName linkQName;
+
+  protected final QName deletedLinkQName;
+
+  protected final QName errorCodeQName;
+
+  protected final QName errorMessageQName;
+
+  protected final QName errorTargetQName;
+
+  public AbstractAtomDealer(final ODataServiceVersion version) {
+    this.version = version;
+
+    this.etagQName =
+            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ATTR_ETAG);
+    this.metadataEtagQName =
+            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ATTR_METADATAETAG);
+    this.inlineQName =
+            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ELEM_INLINE);
+    this.actionQName =
+            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ELEM_ACTION);
+    this.propertiesQName =
+            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.PROPERTIES);
+    this.typeQName = new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATTR_TYPE);
+    this.nullQName = new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATTR_NULL);
+    this.elementQName = version.compareTo(ODataServiceVersion.V40) < 0
+            ? new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES), Constants.ELEM_ELEMENT)
+            : new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ELEM_ELEMENT);
+    this.countQName =
+            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ELEM_COUNT);
+    this.uriQName =
+            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES), Constants.ELEM_URI);
+    this.nextQName =
+            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES), Constants.NEXT_LINK_REL);
+    this.annotationQName =
+            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ANNOTATION);
+    this.contextQName =
+            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.CONTEXT);
+    this.entryRefQName =
+            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ELEM_ENTRY_REF);
+    this.propertyValueQName =
+            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.VALUE);
+
+    this.deletedEntryQName = new QName(Constants.NS_ATOM_TOMBSTONE, Constants.ATOM_ELEM_DELETED_ENTRY);
+    this.reasonQName =
+            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ELEM_REASON);
+    this.linkQName =
+            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ELEM_LINK);
+    this.deletedLinkQName =
+            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ELEM_DELETED_LINK);
+
+    this.errorCodeQName =
+            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ERROR_CODE);
+    this.errorMessageQName =
+            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ERROR_MESSAGE);
+    this.errorTargetQName =
+            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ERROR_TARGET);
+  }
+
+  protected void namespaces(final XMLStreamWriter writer) throws XMLStreamException {
+    writer.writeNamespace(StringUtils.EMPTY, Constants.NS_ATOM);
+    writer.writeNamespace(XMLConstants.XML_NS_PREFIX, XMLConstants.XML_NS_URI);
+    writer.writeNamespace(Constants.PREFIX_METADATA, version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA));
+    writer.writeNamespace(
+            Constants.PREFIX_DATASERVICES, version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES));
+    writer.writeNamespace(Constants.PREFIX_GML, Constants.NS_GML);
+    writer.writeNamespace(Constants.PREFIX_GEORSS, Constants.NS_GEORSS);
+  }
+}


[6/9] [OLINGO-317] Rename and move of some packages and classes

Posted by mi...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ODataClientImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ODataClientImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ODataClientImpl.java
index a0813eb..6da23bb 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ODataClientImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ODataClientImpl.java
@@ -25,9 +25,9 @@ import org.apache.olingo.client.api.communication.request.cud.v3.CUDRequestFacto
 import org.apache.olingo.client.api.communication.request.cud.v3.UpdateType;
 import org.apache.olingo.client.api.communication.request.invoke.InvokeRequestFactory;
 import org.apache.olingo.client.api.communication.request.retrieve.v3.RetrieveRequestFactory;
-import org.apache.olingo.client.api.op.v3.ODataBinder;
-import org.apache.olingo.client.api.op.v3.ODataDeserializer;
-import org.apache.olingo.client.api.op.v3.ODataReader;
+import org.apache.olingo.client.api.serialization.v3.ODataBinder;
+import org.apache.olingo.client.api.serialization.v3.ODataDeserializer;
+import org.apache.olingo.client.api.serialization.v3.ODataReader;
 import org.apache.olingo.client.api.uri.v3.FilterFactory;
 import org.apache.olingo.client.api.uri.v3.URIBuilder;
 import org.apache.olingo.client.api.v3.Configuration;
@@ -38,9 +38,9 @@ import org.apache.olingo.client.core.communication.request.batch.v3.BatchRequest
 import org.apache.olingo.client.core.communication.request.cud.v3.CUDRequestFactoryImpl;
 import org.apache.olingo.client.core.communication.request.invoke.v3.InvokeRequestFactoryImpl;
 import org.apache.olingo.client.core.communication.request.retrieve.v3.RetrieveRequestFactoryImpl;
-import org.apache.olingo.client.core.op.impl.v3.ODataBinderImpl;
-import org.apache.olingo.client.core.op.impl.v3.ODataDeserializerImpl;
-import org.apache.olingo.client.core.op.impl.v3.ODataReaderImpl;
+import org.apache.olingo.client.core.serialization.v3.ODataBinderImpl;
+import org.apache.olingo.client.core.serialization.v3.ODataDeserializerImpl;
+import org.apache.olingo.client.core.serialization.v3.ODataReaderImpl;
 import org.apache.olingo.client.core.uri.v3.FilterFactoryImpl;
 import org.apache.olingo.client.core.uri.v3.URIBuilderImpl;
 import org.apache.olingo.commons.api.domain.v3.ODataObjectFactory;
@@ -48,10 +48,10 @@ import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.api.format.Format;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataSerializer;
-import org.apache.olingo.commons.core.data.AtomSerializer;
-import org.apache.olingo.commons.core.data.JsonSerializer;
+import org.apache.olingo.commons.api.serialization.ODataSerializer;
 import org.apache.olingo.commons.core.domain.v3.ODataObjectFactoryImpl;
+import org.apache.olingo.commons.core.serialization.AtomSerializer;
+import org.apache.olingo.commons.core.serialization.JsonSerializer;
 
 public class ODataClientImpl extends AbstractODataClient<UpdateType> implements ODataClient {
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ODataClientImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ODataClientImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ODataClientImpl.java
index 4907a0b..2ae30e2 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ODataClientImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ODataClientImpl.java
@@ -26,9 +26,9 @@ import org.apache.olingo.client.api.communication.request.cud.v4.UpdateType;
 import org.apache.olingo.client.api.communication.request.invoke.InvokeRequestFactory;
 import org.apache.olingo.client.api.communication.request.retrieve.v4.RetrieveRequestFactory;
 import org.apache.olingo.client.api.communication.request.v4.AsyncRequestFactory;
-import org.apache.olingo.client.api.op.v4.ODataBinder;
-import org.apache.olingo.client.api.op.v4.ODataDeserializer;
-import org.apache.olingo.client.api.op.v4.ODataReader;
+import org.apache.olingo.client.api.serialization.v4.ODataBinder;
+import org.apache.olingo.client.api.serialization.v4.ODataDeserializer;
+import org.apache.olingo.client.api.serialization.v4.ODataReader;
 import org.apache.olingo.client.api.uri.v4.FilterFactory;
 import org.apache.olingo.client.api.uri.v4.SearchFactory;
 import org.apache.olingo.client.api.uri.v4.URIBuilder;
@@ -41,9 +41,9 @@ import org.apache.olingo.client.core.communication.request.cud.v4.CUDRequestFact
 import org.apache.olingo.client.core.communication.request.invoke.v4.InvokeRequestFactoryImpl;
 import org.apache.olingo.client.core.communication.request.retrieve.v4.RetrieveRequestFactoryImpl;
 import org.apache.olingo.client.core.communication.request.v4.AsyncRequestFactoryImpl;
-import org.apache.olingo.client.core.op.impl.v4.ODataBinderImpl;
-import org.apache.olingo.client.core.op.impl.v4.ODataDeserializerImpl;
-import org.apache.olingo.client.core.op.impl.v4.ODataReaderImpl;
+import org.apache.olingo.client.core.serialization.v4.ODataBinderImpl;
+import org.apache.olingo.client.core.serialization.v4.ODataDeserializerImpl;
+import org.apache.olingo.client.core.serialization.v4.ODataReaderImpl;
 import org.apache.olingo.client.core.uri.v4.FilterFactoryImpl;
 import org.apache.olingo.client.core.uri.v4.URIBuilderImpl;
 import org.apache.olingo.commons.api.domain.v4.ODataObjectFactory;
@@ -51,10 +51,10 @@ import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.api.format.Format;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataSerializer;
-import org.apache.olingo.commons.core.data.AtomSerializer;
-import org.apache.olingo.commons.core.data.JsonSerializer;
+import org.apache.olingo.commons.api.serialization.ODataSerializer;
 import org.apache.olingo.commons.core.domain.v4.ODataObjectFactoryImpl;
+import org.apache.olingo.commons.core.serialization.AtomSerializer;
+import org.apache.olingo.commons.core.serialization.JsonSerializer;
 
 public class ODataClientImpl extends AbstractODataClient<UpdateType> implements ODataClient {
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntitySetTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntitySetTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntitySetTest.java
index dd5057d..d335232 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntitySetTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntitySetTest.java
@@ -31,7 +31,7 @@ import org.apache.olingo.commons.api.data.EntitySet;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 import org.junit.Test;
 
 public class EntitySetTest extends AbstractTest {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntityTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntityTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntityTest.java
index 1d4a04f..faca1f6 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntityTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntityTest.java
@@ -37,7 +37,7 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.geo.Geospatial;
 import org.apache.olingo.commons.api.edm.geo.GeospatialCollection;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 import org.junit.Test;
 
 public class EntityTest extends AbstractTest {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/ErrorTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/ErrorTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/ErrorTest.java
index 1b340e9..bdccec8 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/ErrorTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/ErrorTest.java
@@ -24,7 +24,7 @@ import static org.junit.Assert.assertNotNull;
 import org.apache.olingo.client.api.v3.ODataClient;
 import org.apache.olingo.commons.api.domain.ODataError;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 import org.apache.olingo.client.core.AbstractTest;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PropertyTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PropertyTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PropertyTest.java
index b561f28..99c000a 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PropertyTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PropertyTest.java
@@ -37,8 +37,8 @@ import org.apache.olingo.commons.api.domain.v3.ODataProperty;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
-import org.apache.olingo.commons.api.op.ODataSerializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataSerializerException;
 import org.junit.Test;
 
 public class PropertyTest extends AbstractTest {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/ServiceDocumentTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/ServiceDocumentTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/ServiceDocumentTest.java
index b14c635..fab9b1f 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/ServiceDocumentTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/ServiceDocumentTest.java
@@ -21,7 +21,7 @@ package org.apache.olingo.client.core.v3;
 import org.apache.olingo.client.api.v3.ODataClient;
 import org.apache.olingo.commons.api.domain.ODataServiceDocument;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 import org.apache.olingo.client.core.AbstractTest;
 
 import static org.junit.Assert.assertNotNull;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntitySetTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntitySetTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntitySetTest.java
index 453a8ab..651272e 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntitySetTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntitySetTest.java
@@ -33,7 +33,7 @@ import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.domain.v4.ODataEntity;
 import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 import org.junit.Test;
 
 public class EntitySetTest extends AbstractTest {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
index 38cbd8d..ebfeb7d 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
@@ -44,7 +44,7 @@ import org.apache.olingo.commons.api.domain.v4.ODataValue;
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmDateTimeOffset;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmDuration;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ErrorTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ErrorTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ErrorTest.java
index b221ade..baf26e6 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ErrorTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ErrorTest.java
@@ -24,7 +24,7 @@ import static org.junit.Assert.assertNotNull;
 import org.apache.olingo.client.api.v4.ODataClient;
 import org.apache.olingo.commons.api.domain.ODataError;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 import org.apache.olingo.client.core.AbstractTest;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PropertyTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PropertyTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PropertyTest.java
index 1535355..c4355ed 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PropertyTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PropertyTest.java
@@ -32,8 +32,8 @@ import org.apache.olingo.commons.api.domain.ODataComplexValue;
 import org.apache.olingo.commons.api.domain.v4.ODataProperty;
 import org.apache.olingo.commons.api.domain.v4.ODataValue;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
-import org.apache.olingo.commons.api.op.ODataSerializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataSerializerException;
 import org.junit.Test;
 
 public class PropertyTest extends AbstractTest {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ServiceDocumentTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ServiceDocumentTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ServiceDocumentTest.java
index 403fbcf..fb298c7 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ServiceDocumentTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ServiceDocumentTest.java
@@ -28,7 +28,7 @@ import org.apache.olingo.client.api.data.ServiceDocument;
 import org.apache.olingo.client.api.v4.ODataClient;
 import org.apache.olingo.commons.api.domain.ODataServiceDocument;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 import org.apache.olingo.client.core.AbstractTest;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataDeserializer.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataDeserializer.java
deleted file mode 100755
index 9b6bd5a..0000000
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataDeserializer.java
+++ /dev/null
@@ -1,65 +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.api.op;
-
-import java.io.InputStream;
-
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.domain.ODataError;
-
-/**
- * Interface for de-serialization.
- */
-public interface ODataDeserializer {
-
-  /**
-   * Gets an entity set object from the given InputStream.
-   *
-   * @param input stream to be de-serialized.
-   * @return {@link EntitySet} instance.
-   */
-  ResWrap<EntitySet> toEntitySet(InputStream input) throws ODataDeserializerException;
-
-  /**
-   * Gets an entity object from the given InputStream.
-   *
-   * @param input stream to be de-serialized.
-   * @return {@link Entity} instance.
-   */
-  ResWrap<Entity> toEntity(InputStream input) throws ODataDeserializerException;
-
-  /**
-   * Gets a property object from the given InputStream.
-   *
-   * @param input stream to be de-serialized.
-   * @return Property instance.
-   */
-  ResWrap<Property> toProperty(InputStream input) throws ODataDeserializerException;
-
-  /**
-   * Gets the ODataError object represented by the given InputStream.
-   *
-   * @param input stream to be parsed and de-serialized.
-   * @return
-   */
-  ODataError toError(InputStream input) throws ODataDeserializerException;
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataDeserializerException.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataDeserializerException.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataDeserializerException.java
deleted file mode 100755
index 7852a5f..0000000
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataDeserializerException.java
+++ /dev/null
@@ -1,38 +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.api.op;
-
-import org.apache.olingo.commons.api.ODataException;
-
-public class ODataDeserializerException extends ODataException {
-
-  private static final long serialVersionUID = -3236099963180859670L;
-
-  public ODataDeserializerException(final String msg) {
-    super(msg);
-  }
-
-  public ODataDeserializerException(final Throwable cause) {
-    super(cause);
-  }
-
-  public ODataDeserializerException(final String msg, final Throwable cause) {
-    super(msg, cause);
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataSerializer.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataSerializer.java
deleted file mode 100644
index 6fc95da..0000000
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataSerializer.java
+++ /dev/null
@@ -1,33 +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.api.op;
-
-import java.io.Writer;
-
-import org.apache.olingo.commons.api.data.ResWrap;
-
-/**
- * Interface for serialization.
- */
-public interface ODataSerializer {
-
-  public <T> void write(final Writer writer, final T obj) throws ODataSerializerException;
-
-  public <T> void write(final Writer writer, final ResWrap<T> container) throws ODataSerializerException;
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataSerializerException.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataSerializerException.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataSerializerException.java
deleted file mode 100755
index 69b5c3f..0000000
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataSerializerException.java
+++ /dev/null
@@ -1,38 +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.api.op;
-
-import org.apache.olingo.commons.api.ODataException;
-
-public class ODataSerializerException extends ODataException {
-
-  private static final long serialVersionUID = -3236099963180859670L;
-
-  public ODataSerializerException(final String msg) {
-    super(msg);
-  }
-
-  public ODataSerializerException(final Throwable cause) {
-    super(cause);
-  }
-
-  public ODataSerializerException(final String msg, final Throwable cause) {
-    super(msg, cause);
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializer.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializer.java
new file mode 100755
index 0000000..abadea6
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializer.java
@@ -0,0 +1,65 @@
+/*
+ * 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.api.serialization;
+
+import java.io.InputStream;
+
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.domain.ODataError;
+
+/**
+ * Interface for de-serialization.
+ */
+public interface ODataDeserializer {
+
+  /**
+   * Gets an entity set object from the given InputStream.
+   *
+   * @param input stream to be de-serialized.
+   * @return {@link EntitySet} instance.
+   */
+  ResWrap<EntitySet> toEntitySet(InputStream input) throws ODataDeserializerException;
+
+  /**
+   * Gets an entity object from the given InputStream.
+   *
+   * @param input stream to be de-serialized.
+   * @return {@link Entity} instance.
+   */
+  ResWrap<Entity> toEntity(InputStream input) throws ODataDeserializerException;
+
+  /**
+   * Gets a property object from the given InputStream.
+   *
+   * @param input stream to be de-serialized.
+   * @return Property instance.
+   */
+  ResWrap<Property> toProperty(InputStream input) throws ODataDeserializerException;
+
+  /**
+   * Gets the ODataError object represented by the given InputStream.
+   *
+   * @param input stream to be parsed and de-serialized.
+   * @return
+   */
+  ODataError toError(InputStream input) throws ODataDeserializerException;
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializerException.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializerException.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializerException.java
new file mode 100755
index 0000000..132635f
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializerException.java
@@ -0,0 +1,38 @@
+/*
+ * 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.api.serialization;
+
+import org.apache.olingo.commons.api.ODataException;
+
+public class ODataDeserializerException extends ODataException {
+
+  private static final long serialVersionUID = -3236099963180859670L;
+
+  public ODataDeserializerException(final String msg) {
+    super(msg);
+  }
+
+  public ODataDeserializerException(final Throwable cause) {
+    super(cause);
+  }
+
+  public ODataDeserializerException(final String msg, final Throwable cause) {
+    super(msg, cause);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataSerializer.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataSerializer.java
new file mode 100644
index 0000000..d75b108
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataSerializer.java
@@ -0,0 +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
+ *
+ *   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.api.serialization;
+
+import java.io.Writer;
+
+import org.apache.olingo.commons.api.data.ResWrap;
+
+/**
+ * Interface for serialization.
+ */
+public interface ODataSerializer {
+
+  public <T> void write(final Writer writer, final T obj) throws ODataSerializerException;
+
+  public <T> void write(final Writer writer, final ResWrap<T> container) throws ODataSerializerException;
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataSerializerException.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataSerializerException.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataSerializerException.java
new file mode 100755
index 0000000..fd241ee
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataSerializerException.java
@@ -0,0 +1,38 @@
+/*
+ * 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.api.serialization;
+
+import org.apache.olingo.commons.api.ODataException;
+
+public class ODataSerializerException extends ODataException {
+
+  private static final long serialVersionUID = -3236099963180859670L;
+
+  public ODataSerializerException(final String msg) {
+    super(msg);
+  }
+
+  public ODataSerializerException(final Throwable cause) {
+    super(cause);
+  }
+
+  public ODataSerializerException(final String msg, final Throwable cause) {
+    super(msg, cause);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractAtomDealer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractAtomDealer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractAtomDealer.java
deleted file mode 100644
index 9c3fec2..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractAtomDealer.java
+++ /dev/null
@@ -1,137 +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 javax.xml.XMLConstants;
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-
-abstract class AbstractAtomDealer {
-
-  protected static final String TYPE_TEXT = "text";
-
-  protected final ODataServiceVersion version;
-
-  protected final QName etagQName;
-
-  protected final QName metadataEtagQName;
-
-  protected final QName inlineQName;
-
-  protected final QName actionQName;
-
-  protected final QName propertiesQName;
-
-  protected final QName typeQName;
-
-  protected final QName nullQName;
-
-  protected final QName elementQName;
-
-  protected final QName countQName;
-
-  protected final QName uriQName;
-
-  protected final QName nextQName;
-
-  protected final QName annotationQName;
-
-  protected final QName contextQName;
-
-  protected final QName entryRefQName;
-
-  protected final QName propertyValueQName;
-
-  protected final QName deletedEntryQName;
-
-  protected final QName reasonQName;
-
-  protected final QName linkQName;
-
-  protected final QName deletedLinkQName;
-
-  protected final QName errorCodeQName;
-
-  protected final QName errorMessageQName;
-
-  protected final QName errorTargetQName;
-
-  public AbstractAtomDealer(final ODataServiceVersion version) {
-    this.version = version;
-
-    this.etagQName =
-            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ATTR_ETAG);
-    this.metadataEtagQName =
-            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ATTR_METADATAETAG);
-    this.inlineQName =
-            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ELEM_INLINE);
-    this.actionQName =
-            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ELEM_ACTION);
-    this.propertiesQName =
-            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.PROPERTIES);
-    this.typeQName = new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATTR_TYPE);
-    this.nullQName = new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATTR_NULL);
-    this.elementQName = version.compareTo(ODataServiceVersion.V40) < 0
-            ? new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES), Constants.ELEM_ELEMENT)
-            : new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ELEM_ELEMENT);
-    this.countQName =
-            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ELEM_COUNT);
-    this.uriQName =
-            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES), Constants.ELEM_URI);
-    this.nextQName =
-            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES), Constants.NEXT_LINK_REL);
-    this.annotationQName =
-            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ANNOTATION);
-    this.contextQName =
-            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.CONTEXT);
-    this.entryRefQName =
-            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ELEM_ENTRY_REF);
-    this.propertyValueQName =
-            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.VALUE);
-
-    this.deletedEntryQName = new QName(Constants.NS_ATOM_TOMBSTONE, Constants.ATOM_ELEM_DELETED_ENTRY);
-    this.reasonQName =
-            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ELEM_REASON);
-    this.linkQName =
-            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ELEM_LINK);
-    this.deletedLinkQName =
-            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ELEM_DELETED_LINK);
-
-    this.errorCodeQName =
-            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ERROR_CODE);
-    this.errorMessageQName =
-            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ERROR_MESSAGE);
-    this.errorTargetQName =
-            new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ERROR_TARGET);
-  }
-
-  protected void namespaces(final XMLStreamWriter writer) throws XMLStreamException {
-    writer.writeNamespace(StringUtils.EMPTY, Constants.NS_ATOM);
-    writer.writeNamespace(XMLConstants.XML_NS_PREFIX, XMLConstants.XML_NS_URI);
-    writer.writeNamespace(Constants.PREFIX_METADATA, version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA));
-    writer.writeNamespace(
-            Constants.PREFIX_DATASERVICES, version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES));
-    writer.writeNamespace(Constants.PREFIX_GML, Constants.NS_GML);
-    writer.writeNamespace(Constants.PREFIX_GEORSS, Constants.NS_GEORSS);
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomDeserializer.java
deleted file mode 100644
index dec0028..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomDeserializer.java
+++ /dev/null
@@ -1,882 +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.io.InputStream;
-import java.net.URI;
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLEventReader;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.events.Attribute;
-import javax.xml.stream.events.StartElement;
-import javax.xml.stream.events.XMLEvent;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.Annotation;
-import org.apache.olingo.commons.api.data.CollectionValue;
-import org.apache.olingo.commons.api.data.DeletedEntity.Reason;
-import org.apache.olingo.commons.api.data.Delta;
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.data.Valuable;
-import org.apache.olingo.commons.api.data.Value;
-import org.apache.olingo.commons.api.data.v3.LinkCollection;
-import org.apache.olingo.commons.api.domain.ODataError;
-import org.apache.olingo.commons.api.domain.ODataOperation;
-import org.apache.olingo.commons.api.domain.ODataPropertyType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.commons.api.op.ODataDeserializer;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
-import org.apache.olingo.commons.core.data.v3.LinkCollectionImpl;
-import org.apache.olingo.commons.core.data.v4.DeltaImpl;
-import org.apache.olingo.commons.core.edm.EdmTypeInfo;
-
-import com.fasterxml.aalto.stax.InputFactoryImpl;
-
-public class AtomDeserializer extends AbstractAtomDealer implements ODataDeserializer {
-
-  protected static final XMLInputFactory FACTORY = new InputFactoryImpl();
-
-  private final AtomGeoValueDeserializer geoDeserializer;
-
-  protected XMLEventReader getReader(final InputStream input) throws XMLStreamException {
-    return FACTORY.createXMLEventReader(input);
-  }
-
-  public AtomDeserializer(final ODataServiceVersion version) {
-    super(version);
-    this.geoDeserializer = new AtomGeoValueDeserializer();
-  }
-
-  private Value fromPrimitive(final XMLEventReader reader, final StartElement start,
-      final EdmTypeInfo typeInfo) throws XMLStreamException {
-
-    Value value = null;
-
-    boolean foundEndProperty = false;
-    while (reader.hasNext() && !foundEndProperty) {
-      final XMLEvent event = reader.nextEvent();
-
-      if (event.isStartElement() && typeInfo != null && typeInfo.getPrimitiveTypeKind().isGeospatial()) {
-        final EdmPrimitiveTypeKind geoType = EdmPrimitiveTypeKind.valueOfFQN(
-            version, typeInfo.getFullQualifiedName().toString());
-        value = new GeospatialValueImpl(this.geoDeserializer.deserialize(reader, event.asStartElement(), geoType));
-      }
-
-      if (event.isCharacters() && !event.asCharacters().isWhiteSpace()
-          && (typeInfo == null || !typeInfo.getPrimitiveTypeKind().isGeospatial())) {
-
-        value = new PrimitiveValueImpl(event.asCharacters().getData());
-      }
-
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndProperty = true;
-      }
-    }
-
-    return value == null ? new PrimitiveValueImpl(StringUtils.EMPTY) : value;
-  }
-
-  private Value fromComplexOrEnum(final XMLEventReader reader, final StartElement start)
-      throws XMLStreamException {
-
-    Value value = null;
-
-    boolean foundEndProperty = false;
-    while (reader.hasNext() && !foundEndProperty) {
-      final XMLEvent event = reader.nextEvent();
-
-      if (event.isStartElement()) {
-        if (value == null) {
-          value = version.compareTo(ODataServiceVersion.V40) < 0
-              ? new ComplexValueImpl()
-              : new LinkedComplexValueImpl();
-        }
-
-        if (Constants.QNAME_ATOM_ELEM_LINK.equals(event.asStartElement().getName())) {
-          final LinkImpl link = new LinkImpl();
-          final Attribute rel = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REL));
-          if (rel != null) {
-            link.setRel(rel.getValue());
-          }
-          final Attribute title = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TITLE));
-          if (title != null) {
-            link.setTitle(title.getValue());
-          }
-          final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
-          if (href != null) {
-            link.setHref(href.getValue());
-          }
-          final Attribute type = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TYPE));
-          if (type != null) {
-            link.setType(type.getValue());
-          }
-
-          if (link.getRel().startsWith(
-              version.getNamespaceMap().get(ODataServiceVersion.NAVIGATION_LINK_REL))) {
-
-            value.asLinkedComplex().getNavigationLinks().add(link);
-            inline(reader, event.asStartElement(), link);
-          } else if (link.getRel().startsWith(
-              version.getNamespaceMap().get(ODataServiceVersion.ASSOCIATION_LINK_REL))) {
-
-            value.asLinkedComplex().getAssociationLinks().add(link);
-          }
-        } else {
-          value.asComplex().get().add(property(reader, event.asStartElement()));
-        }
-      }
-
-      if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
-        value = new EnumValueImpl(event.asCharacters().getData());
-      }
-
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndProperty = true;
-      }
-    }
-
-    return value;
-  }
-
-  private CollectionValue fromCollection(final XMLEventReader reader, final StartElement start,
-      final EdmTypeInfo typeInfo) throws XMLStreamException {
-
-    final CollectionValueImpl value = new CollectionValueImpl();
-
-    final EdmTypeInfo type = typeInfo == null
-        ? null
-        : new EdmTypeInfo.Builder().setTypeExpression(typeInfo.getFullQualifiedName().toString()).build();
-
-    boolean foundEndProperty = false;
-    while (reader.hasNext() && !foundEndProperty) {
-      final XMLEvent event = reader.nextEvent();
-
-      if (event.isStartElement()) {
-        switch (guessPropertyType(reader, typeInfo)) {
-        case COMPLEX:
-        case ENUM:
-          value.get().add(fromComplexOrEnum(reader, event.asStartElement()));
-          break;
-
-        case PRIMITIVE:
-          value.get().add(fromPrimitive(reader, event.asStartElement(), type));
-          break;
-
-        default:
-          // do not add null or empty values
-        }
-      }
-
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndProperty = true;
-      }
-    }
-
-    return value;
-  }
-
-  private ODataPropertyType guessPropertyType(final XMLEventReader reader, final EdmTypeInfo typeInfo)
-      throws XMLStreamException {
-
-    XMLEvent child = null;
-    while (reader.hasNext() && child == null) {
-      final XMLEvent event = reader.peek();
-      if (event.isCharacters() && event.asCharacters().isWhiteSpace()) {
-        reader.nextEvent();
-      } else {
-        child = event;
-      }
-    }
-
-    final ODataPropertyType type;
-    if (child == null) {
-      type = typeInfo == null || typeInfo.isPrimitiveType()
-          ? ODataPropertyType.PRIMITIVE
-          : ODataPropertyType.ENUM;
-    } else {
-      if (child.isStartElement()) {
-        if (Constants.NS_GML.equals(child.asStartElement().getName().getNamespaceURI())) {
-          type = ODataPropertyType.PRIMITIVE;
-        } else if (elementQName.equals(child.asStartElement().getName())) {
-          type = ODataPropertyType.COLLECTION;
-        } else {
-          type = ODataPropertyType.COMPLEX;
-        }
-      } else if (child.isCharacters()) {
-        type = typeInfo == null || typeInfo.isPrimitiveType()
-            ? ODataPropertyType.PRIMITIVE
-            : ODataPropertyType.ENUM;
-      } else {
-        type = ODataPropertyType.EMPTY;
-      }
-    }
-
-    return type;
-  }
-
-  private Property property(final XMLEventReader reader, final StartElement start)
-      throws XMLStreamException {
-
-    final PropertyImpl property = new PropertyImpl();
-
-    if (ODataServiceVersion.V40 == version && propertyValueQName.equals(start.getName())) {
-      // retrieve name from context
-      final Attribute context = start.getAttributeByName(contextQName);
-      if (context != null) {
-        property.setName(StringUtils.substringAfterLast(context.getValue(), "/"));
-      }
-    } else {
-      property.setName(start.getName().getLocalPart());
-    }
-
-    valuable(property, reader, start);
-
-    return property;
-  }
-
-  private void valuable(final Valuable valuable, final XMLEventReader reader, final StartElement start)
-      throws XMLStreamException {
-
-    final Attribute nullAttr = start.getAttributeByName(this.nullQName);
-
-    Value value;
-    if (nullAttr == null) {
-      final Attribute typeAttr = start.getAttributeByName(this.typeQName);
-      final String typeAttrValue = typeAttr == null ? null : typeAttr.getValue();
-
-      final EdmTypeInfo typeInfo = StringUtils.isBlank(typeAttrValue)
-          ? null
-          : new EdmTypeInfo.Builder().setTypeExpression(typeAttrValue).build();
-
-      if (typeInfo != null) {
-        valuable.setType(typeInfo.internal());
-      }
-
-      final ODataPropertyType propType = typeInfo == null
-          ? guessPropertyType(reader, typeInfo)
-          : typeInfo.isCollection()
-              ? ODataPropertyType.COLLECTION
-              : typeInfo.isPrimitiveType()
-                  ? ODataPropertyType.PRIMITIVE
-                  : ODataPropertyType.COMPLEX;
-
-      switch (propType) {
-      case COLLECTION:
-        value = fromCollection(reader, start, typeInfo);
-        break;
-
-      case COMPLEX:
-        value = fromComplexOrEnum(reader, start);
-        break;
-
-      case PRIMITIVE:
-        // No type specified? Defaults to Edm.String          
-        if (typeInfo == null) {
-          valuable.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName().toString());
-        }
-        value = fromPrimitive(reader, start, typeInfo);
-        break;
-
-      case EMPTY:
-      default:
-        value = new PrimitiveValueImpl(StringUtils.EMPTY);
-      }
-    } else {
-      value = new NullValueImpl();
-    }
-
-    valuable.setValue(value);
-  }
-
-  @Override
-  public ResWrap<Property> toProperty(final InputStream input) throws ODataDeserializerException {
-    try {
-      final XMLEventReader reader = getReader(input);
-      final StartElement start = skipBeforeFirstStartElement(reader);
-      return getContainer(start, property(reader, start));
-    } catch (XMLStreamException e) {
-      throw new ODataDeserializerException(e);
-    }
-  }
-
-  private StartElement skipBeforeFirstStartElement(final XMLEventReader reader) throws XMLStreamException {
-    StartElement startEvent = null;
-    while (reader.hasNext() && startEvent == null) {
-      final XMLEvent event = reader.nextEvent();
-      if (event.isStartElement()) {
-        startEvent = event.asStartElement();
-      }
-    }
-    if (startEvent == null) {
-      throw new IllegalArgumentException("Cannot find any XML start element");
-    }
-
-    return startEvent;
-  }
-
-  private void common(final XMLEventReader reader, final StartElement start,
-      final AbstractODataObject object, final String key) throws XMLStreamException {
-
-    boolean foundEndElement = false;
-    while (reader.hasNext() && !foundEndElement) {
-      final XMLEvent event = reader.nextEvent();
-
-      if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
-        try {
-          object.setCommonProperty(key, event.asCharacters().getData());
-        } catch (ParseException e) {
-          throw new XMLStreamException("While parsing Atom entry or feed common elements", e);
-        }
-      }
-
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndElement = true;
-      }
-    }
-  }
-
-  private void inline(final XMLEventReader reader, final StartElement start, final LinkImpl link)
-      throws XMLStreamException {
-
-    boolean foundEndElement = false;
-    while (reader.hasNext() && !foundEndElement) {
-      final XMLEvent event = reader.nextEvent();
-
-      if (event.isStartElement()) {
-        if (inlineQName.equals(event.asStartElement().getName())) {
-          StartElement inline = null;
-          while (reader.hasNext() && inline == null) {
-            final XMLEvent innerEvent = reader.peek();
-            if (innerEvent.isCharacters() && innerEvent.asCharacters().isWhiteSpace()) {
-              reader.nextEvent();
-            } else if (innerEvent.isStartElement()) {
-              inline = innerEvent.asStartElement();
-            }
-          }
-          if (inline != null) {
-            if (Constants.QNAME_ATOM_ELEM_ENTRY.equals(inline.getName())) {
-              link.setInlineEntity(entity(reader, inline));
-            }
-            if (Constants.QNAME_ATOM_ELEM_FEED.equals(inline.getName())) {
-              link.setInlineEntitySet(entitySet(reader, inline));
-            }
-          }
-        } else if (annotationQName.equals(event.asStartElement().getName())) {
-          link.getAnnotations().add(annotation(reader, event.asStartElement()));
-        }
-      }
-
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndElement = true;
-      }
-    }
-  }
-
-  public ResWrap<Delta> delta(final InputStream input) throws XMLStreamException {
-    final XMLEventReader reader = getReader(input);
-    final StartElement start = skipBeforeFirstStartElement(reader);
-    return getContainer(start, delta(reader, start));
-  }
-
-  private Delta delta(final XMLEventReader reader, final StartElement start) throws XMLStreamException {
-    if (!Constants.QNAME_ATOM_ELEM_FEED.equals(start.getName())) {
-      return null;
-    }
-    final DeltaImpl delta = new DeltaImpl();
-    final Attribute xmlBase = start.getAttributeByName(Constants.QNAME_ATTR_XML_BASE);
-    if (xmlBase != null) {
-      delta.setBaseURI(xmlBase.getValue());
-    }
-
-    boolean foundEndFeed = false;
-    while (reader.hasNext() && !foundEndFeed) {
-      final XMLEvent event = reader.nextEvent();
-      if (event.isStartElement()) {
-        if (countQName.equals(event.asStartElement().getName())) {
-          count(reader, event.asStartElement(), delta);
-        } else if (Constants.QNAME_ATOM_ELEM_ID.equals(event.asStartElement().getName())) {
-          common(reader, event.asStartElement(), delta, "id");
-        } else if (Constants.QNAME_ATOM_ELEM_TITLE.equals(event.asStartElement().getName())) {
-          common(reader, event.asStartElement(), delta, "title");
-        } else if (Constants.QNAME_ATOM_ELEM_SUMMARY.equals(event.asStartElement().getName())) {
-          common(reader, event.asStartElement(), delta, "summary");
-        } else if (Constants.QNAME_ATOM_ELEM_UPDATED.equals(event.asStartElement().getName())) {
-          common(reader, event.asStartElement(), delta, "updated");
-        } else if (Constants.QNAME_ATOM_ELEM_LINK.equals(event.asStartElement().getName())) {
-          final Attribute rel = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REL));
-          if (rel != null) {
-            if (Constants.NEXT_LINK_REL.equals(rel.getValue())) {
-              final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
-              if (href != null) {
-                delta.setNext(URI.create(href.getValue()));
-              }
-            }
-            if (Constants.DELTA_LINK_REL.equals(rel.getValue())) {
-              final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
-              if (href != null) {
-                delta.setDeltaLink(URI.create(href.getValue()));
-              }
-            }
-          }
-        } else if (Constants.QNAME_ATOM_ELEM_ENTRY.equals(event.asStartElement().getName())) {
-          delta.getEntities().add(entity(reader, event.asStartElement()));
-        } else if (deletedEntryQName.equals(event.asStartElement().getName())) {
-          final DeletedEntityImpl deletedEntity = new DeletedEntityImpl();
-
-          final Attribute ref = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REF));
-          if (ref != null) {
-            deletedEntity.setId(URI.create(ref.getValue()));
-          }
-          final Attribute reason = event.asStartElement().getAttributeByName(reasonQName);
-          if (reason != null) {
-            deletedEntity.setReason(Reason.valueOf(reason.getValue()));
-          }
-
-          delta.getDeletedEntities().add(deletedEntity);
-        } else if (linkQName.equals(event.asStartElement().getName())
-            || deletedLinkQName.equals(event.asStartElement().getName())) {
-
-          final DeltaLinkImpl link = new DeltaLinkImpl();
-
-          final Attribute source = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_SOURCE));
-          if (source != null) {
-            link.setSource(URI.create(source.getValue()));
-          }
-          final Attribute relationship =
-              event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_RELATIONSHIP));
-          if (relationship != null) {
-            link.setRelationship(relationship.getValue());
-          }
-          final Attribute target = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TARGET));
-          if (target != null) {
-            link.setTarget(URI.create(target.getValue()));
-          }
-
-          if (linkQName.equals(event.asStartElement().getName())) {
-            delta.getAddedLinks().add(link);
-          } else {
-            delta.getDeletedLinks().add(link);
-          }
-        }
-      }
-
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndFeed = true;
-      }
-    }
-
-    return delta;
-  }
-
-  public ResWrap<LinkCollection> linkCollection(final InputStream input) throws XMLStreamException {
-    final XMLEventReader reader = getReader(input);
-    final StartElement start = skipBeforeFirstStartElement(reader);
-    return getContainer(start, linkCollection(reader, start));
-  }
-
-  private LinkCollection linkCollection(final XMLEventReader reader, final StartElement start)
-      throws XMLStreamException {
-
-    final LinkCollectionImpl linkCollection = new LinkCollectionImpl();
-
-    boolean isURI = false;
-    boolean isNext = false;
-    while (reader.hasNext()) {
-      final XMLEvent event = reader.nextEvent();
-      if (event.isStartElement()) {
-        isURI = uriQName.equals(event.asStartElement().getName());
-        isNext = nextQName.equals(event.asStartElement().getName());
-      }
-
-      if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
-        if (isURI) {
-          linkCollection.getLinks().add(URI.create(event.asCharacters().getData()));
-          isURI = false;
-        } else if (isNext) {
-          linkCollection.setNext(URI.create(event.asCharacters().getData()));
-          isNext = false;
-        }
-      }
-    }
-
-    return linkCollection;
-  }
-
-  private void properties(final XMLEventReader reader, final StartElement start, final EntityImpl entity)
-      throws XMLStreamException {
-
-    final Map<String, List<Annotation>> annotations = new HashMap<String, List<Annotation>>();
-
-    boolean foundEndProperties = false;
-    while (reader.hasNext() && !foundEndProperties) {
-      final XMLEvent event = reader.nextEvent();
-
-      if (event.isStartElement()) {
-        if (annotationQName.equals(event.asStartElement().getName())) {
-          final String target = event.asStartElement().
-              getAttributeByName(QName.valueOf(Constants.ATTR_TARGET)).getValue();
-          if (!annotations.containsKey(target)) {
-            annotations.put(target, new ArrayList<Annotation>());
-          }
-          annotations.get(target).add(annotation(reader, event.asStartElement()));
-        } else {
-          entity.getProperties().add(property(reader, event.asStartElement()));
-        }
-      }
-
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndProperties = true;
-      }
-    }
-
-    for (Property property : entity.getProperties()) {
-      if (annotations.containsKey(property.getName())) {
-        property.getAnnotations().addAll(annotations.get(property.getName()));
-      }
-    }
-  }
-
-  private Annotation annotation(final XMLEventReader reader, final StartElement start)
-      throws XMLStreamException {
-
-    final Annotation annotation = new AnnotationImpl();
-
-    annotation.setTerm(start.getAttributeByName(QName.valueOf(Constants.ATOM_ATTR_TERM)).getValue());
-    valuable(annotation, reader, start);
-
-    return annotation;
-  }
-
-  private EntityImpl entityRef(final StartElement start) throws XMLStreamException {
-    final EntityImpl entity = new EntityImpl();
-
-    final Attribute entityRefId = start.getAttributeByName(Constants.QNAME_ATOM_ATTR_ID);
-    if (entityRefId != null) {
-      entity.setId(URI.create(entityRefId.getValue()));
-    }
-
-    return entity;
-  }
-
-  private Entity entity(final XMLEventReader reader, final StartElement start) throws XMLStreamException {
-    final EntityImpl entity;
-    if (entryRefQName.equals(start.getName())) {
-      entity = entityRef(start);
-    } else if (Constants.QNAME_ATOM_ELEM_ENTRY.equals(start.getName())) {
-      entity = new EntityImpl();
-      final Attribute xmlBase = start.getAttributeByName(Constants.QNAME_ATTR_XML_BASE);
-      if (xmlBase != null) {
-        entity.setBaseURI(xmlBase.getValue());
-      }
-
-      final Attribute etag = start.getAttributeByName(etagQName);
-      if (etag != null) {
-        entity.setETag(etag.getValue());
-      }
-
-      boolean foundEndEntry = false;
-      while (reader.hasNext() && !foundEndEntry) {
-        final XMLEvent event = reader.nextEvent();
-
-        if (event.isStartElement()) {
-          if (Constants.QNAME_ATOM_ELEM_ID.equals(event.asStartElement().getName())) {
-            common(reader, event.asStartElement(), entity, "id");
-          } else if (Constants.QNAME_ATOM_ELEM_TITLE.equals(event.asStartElement().getName())) {
-            common(reader, event.asStartElement(), entity, "title");
-          } else if (Constants.QNAME_ATOM_ELEM_SUMMARY.equals(event.asStartElement().getName())) {
-            common(reader, event.asStartElement(), entity, "summary");
-          } else if (Constants.QNAME_ATOM_ELEM_UPDATED.equals(event.asStartElement().getName())) {
-            common(reader, event.asStartElement(), entity, "updated");
-          } else if (Constants.QNAME_ATOM_ELEM_CATEGORY.equals(event.asStartElement().getName())) {
-            final Attribute term = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATOM_ATTR_TERM));
-            if (term != null) {
-              entity.setType(new EdmTypeInfo.Builder().setTypeExpression(term.getValue()).build().internal());
-            }
-          } else if (Constants.QNAME_ATOM_ELEM_LINK.equals(event.asStartElement().getName())) {
-            final LinkImpl link = new LinkImpl();
-            final Attribute rel = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REL));
-            if (rel != null) {
-              link.setRel(rel.getValue());
-            }
-            final Attribute title = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TITLE));
-            if (title != null) {
-              link.setTitle(title.getValue());
-            }
-            final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
-            if (href != null) {
-              link.setHref(href.getValue());
-            }
-            final Attribute type = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TYPE));
-            if (type != null) {
-              link.setType(type.getValue());
-            }
-
-            if (Constants.SELF_LINK_REL.equals(link.getRel())) {
-              entity.setSelfLink(link);
-            } else if (Constants.EDIT_LINK_REL.equals(link.getRel())) {
-              entity.setEditLink(link);
-            } else if (Constants.EDITMEDIA_LINK_REL.equals(link.getRel())) {
-              final Attribute mediaETag = event.asStartElement().getAttributeByName(etagQName);
-              if (mediaETag != null) {
-                entity.setMediaETag(mediaETag.getValue());
-              }
-            } else if (link.getRel().startsWith(
-                version.getNamespaceMap().get(ODataServiceVersion.NAVIGATION_LINK_REL))) {
-
-              entity.getNavigationLinks().add(link);
-              inline(reader, event.asStartElement(), link);
-            } else if (link.getRel().startsWith(
-                version.getNamespaceMap().get(ODataServiceVersion.ASSOCIATION_LINK_REL))) {
-
-              entity.getAssociationLinks().add(link);
-            } else if (link.getRel().startsWith(
-                version.getNamespaceMap().get(ODataServiceVersion.MEDIA_EDIT_LINK_REL))) {
-
-              final Attribute metag = event.asStartElement().getAttributeByName(etagQName);
-              if (metag != null) {
-                link.setMediaETag(metag.getValue());
-              }
-              entity.getMediaEditLinks().add(link);
-            }
-          } else if (actionQName.equals(event.asStartElement().getName())) {
-            final ODataOperation operation = new ODataOperation();
-            final Attribute metadata =
-                event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_METADATA));
-            if (metadata != null) {
-              operation.setMetadataAnchor(metadata.getValue());
-            }
-            final Attribute title = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TITLE));
-            if (title != null) {
-              operation.setTitle(title.getValue());
-            }
-            final Attribute target = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TARGET));
-            if (target != null) {
-              operation.setTarget(URI.create(target.getValue()));
-            }
-
-            entity.getOperations().add(operation);
-          } else if (Constants.QNAME_ATOM_ELEM_CONTENT.equals(event.asStartElement().getName())) {
-            final Attribute type = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TYPE));
-            if (type == null || ContentType.APPLICATION_XML.equals(type.getValue())) {
-              properties(reader, skipBeforeFirstStartElement(reader), entity);
-            } else {
-              entity.setMediaContentType(type.getValue());
-              final Attribute src = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATOM_ATTR_SRC));
-              if (src != null) {
-                entity.setMediaContentSource(URI.create(src.getValue()));
-              }
-            }
-          } else if (propertiesQName.equals(event.asStartElement().getName())) {
-            properties(reader, event.asStartElement(), entity);
-          } else if (annotationQName.equals(event.asStartElement().getName())) {
-            entity.getAnnotations().add(annotation(reader, event.asStartElement()));
-          }
-        }
-
-        if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-          foundEndEntry = true;
-        }
-      }
-    } else {
-      entity = null;
-    }
-
-    return entity;
-  }
-
-  @Override
-  public ResWrap<Entity> toEntity(final InputStream input) throws ODataDeserializerException {
-    try {
-      final XMLEventReader reader = getReader(input);
-      final StartElement start = skipBeforeFirstStartElement(reader);
-      return getContainer(start, entity(reader, start));
-    } catch (XMLStreamException e) {
-      throw new ODataDeserializerException(e);
-    }
-  }
-
-  private void count(final XMLEventReader reader, final StartElement start, final EntitySet entitySet)
-      throws XMLStreamException {
-
-    boolean foundEndElement = false;
-    while (reader.hasNext() && !foundEndElement) {
-      final XMLEvent event = reader.nextEvent();
-
-      if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
-        entitySet.setCount(Integer.valueOf(event.asCharacters().getData()));
-      }
-
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndElement = true;
-      }
-    }
-  }
-
-  private EntitySet entitySet(final XMLEventReader reader, final StartElement start) throws XMLStreamException {
-    if (!Constants.QNAME_ATOM_ELEM_FEED.equals(start.getName())) {
-      return null;
-    }
-    final EntitySetImpl entitySet = new EntitySetImpl();
-    final Attribute xmlBase = start.getAttributeByName(Constants.QNAME_ATTR_XML_BASE);
-    if (xmlBase != null) {
-      entitySet.setBaseURI(xmlBase.getValue());
-    }
-
-    boolean foundEndFeed = false;
-    while (reader.hasNext() && !foundEndFeed) {
-      final XMLEvent event = reader.nextEvent();
-      if (event.isStartElement()) {
-        if (countQName.equals(event.asStartElement().getName())) {
-          count(reader, event.asStartElement(), entitySet);
-        } else if (Constants.QNAME_ATOM_ELEM_ID.equals(event.asStartElement().getName())) {
-          common(reader, event.asStartElement(), entitySet, "id");
-        } else if (Constants.QNAME_ATOM_ELEM_TITLE.equals(event.asStartElement().getName())) {
-          common(reader, event.asStartElement(), entitySet, "title");
-        } else if (Constants.QNAME_ATOM_ELEM_SUMMARY.equals(event.asStartElement().getName())) {
-          common(reader, event.asStartElement(), entitySet, "summary");
-        } else if (Constants.QNAME_ATOM_ELEM_UPDATED.equals(event.asStartElement().getName())) {
-          common(reader, event.asStartElement(), entitySet, "updated");
-        } else if (Constants.QNAME_ATOM_ELEM_LINK.equals(event.asStartElement().getName())) {
-          final Attribute rel = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REL));
-          if (rel != null) {
-            if (Constants.NEXT_LINK_REL.equals(rel.getValue())) {
-              final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
-              if (href != null) {
-                entitySet.setNext(URI.create(href.getValue()));
-              }
-            }
-            if (Constants.DELTA_LINK_REL.equals(rel.getValue())) {
-              final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
-              if (href != null) {
-                entitySet.setDeltaLink(URI.create(href.getValue()));
-              }
-            }
-          }
-        } else if (Constants.QNAME_ATOM_ELEM_ENTRY.equals(event.asStartElement().getName())) {
-          entitySet.getEntities().add(entity(reader, event.asStartElement()));
-        } else if (entryRefQName.equals(event.asStartElement().getName())) {
-          entitySet.getEntities().add(entityRef(event.asStartElement()));
-        } else if (annotationQName.equals(event.asStartElement().getName())) {
-          entitySet.getAnnotations().add(annotation(reader, event.asStartElement()));
-        }
-      }
-
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndFeed = true;
-      }
-    }
-
-    return entitySet;
-  }
-
-  @Override
-  public ResWrap<EntitySet> toEntitySet(final InputStream input) throws ODataDeserializerException {
-    try {
-      final XMLEventReader reader = getReader(input);
-      final StartElement start = skipBeforeFirstStartElement(reader);
-      return getContainer(start, entitySet(reader, start));
-    } catch (XMLStreamException e) {
-      throw new ODataDeserializerException(e);
-    }
-  }
-
-  private ODataError error(final XMLEventReader reader, final StartElement start) throws XMLStreamException {
-    final ODataErrorImpl error = new ODataErrorImpl();
-
-    boolean setCode = false;
-    boolean codeSet = false;
-    boolean setMessage = false;
-    boolean messageSet = false;
-    boolean setTarget = false;
-    boolean targetSet = false;
-
-    boolean foundEndElement = false;
-    while (reader.hasNext() && !foundEndElement) {
-      final XMLEvent event = reader.nextEvent();
-
-      if (event.isStartElement()) {
-        if (errorCodeQName.equals(event.asStartElement().getName())) {
-          setCode = true;
-        } else if (errorMessageQName.equals(event.asStartElement().getName())) {
-          setMessage = true;
-        } else if (errorTargetQName.equals(event.asStartElement().getName())) {
-          setTarget = true;
-        }
-      }
-
-      if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
-        if (setCode && !codeSet) {
-          error.setCode(event.asCharacters().getData());
-          setCode = false;
-          codeSet = true;
-        }
-        if (setMessage && !messageSet) {
-          error.setMessage(event.asCharacters().getData());
-          setMessage = false;
-          messageSet = true;
-        }
-        if (setTarget && !targetSet) {
-          error.setTarget(event.asCharacters().getData());
-          setTarget = false;
-          targetSet = true;
-        }
-      }
-
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndElement = true;
-      }
-    }
-
-    return error;
-  }
-
-  @Override
-  public ODataError toError(final InputStream input) throws ODataDeserializerException {
-    try {
-      final XMLEventReader reader = getReader(input);
-      final StartElement start = skipBeforeFirstStartElement(reader);
-      return error(reader, start);
-    } catch (XMLStreamException e) {
-      throw new ODataDeserializerException(e);
-    }
-  }
-
-  private <T> ResWrap<T> getContainer(final StartElement start, final T object) {
-    final Attribute context = start.getAttributeByName(contextQName);
-    final Attribute metadataETag = start.getAttributeByName(metadataEtagQName);
-
-    return new ResWrap<T>(
-        context == null ? null : URI.create(context.getValue()),
-        metadataETag == null ? null : metadataETag.getValue(),
-        object);
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomGeoValueDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomGeoValueDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomGeoValueDeserializer.java
deleted file mode 100644
index 41a129f..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomGeoValueDeserializer.java
+++ /dev/null
@@ -1,267 +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.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import javax.xml.stream.XMLEventReader;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.events.Attribute;
-import javax.xml.stream.events.StartElement;
-import javax.xml.stream.events.XMLEvent;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.GeoUtils;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.geo.Geospatial;
-import org.apache.olingo.commons.api.edm.geo.GeospatialCollection;
-import org.apache.olingo.commons.api.edm.geo.LineString;
-import org.apache.olingo.commons.api.edm.geo.MultiLineString;
-import org.apache.olingo.commons.api.edm.geo.MultiPoint;
-import org.apache.olingo.commons.api.edm.geo.MultiPolygon;
-import org.apache.olingo.commons.api.edm.geo.Point;
-import org.apache.olingo.commons.api.edm.geo.Polygon;
-import org.apache.olingo.commons.api.edm.geo.SRID;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmDouble;
-
-class AtomGeoValueDeserializer {
-
-  private List<Point> points(final XMLEventReader reader, final StartElement start,
-          final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
-
-    final List<Point> result = new ArrayList<Point>();
-
-    boolean foundEndProperty = false;
-    while (reader.hasNext() && !foundEndProperty) {
-      final XMLEvent event = reader.nextEvent();
-
-      if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
-        final String[] pointInfo = event.asCharacters().getData().split(" ");
-
-        final Point point = new Point(GeoUtils.getDimension(type), srid);
-        try {
-          point.setX(EdmDouble.getInstance().valueOfString(pointInfo[0], null, null,
-                  Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, Double.class));
-          point.setY(EdmDouble.getInstance().valueOfString(pointInfo[1], null, null,
-                  Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, Double.class));
-        } catch (EdmPrimitiveTypeException e) {
-          throw new XMLStreamException("While deserializing point coordinates as double", e);
-        }
-        result.add(point);
-      }
-
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndProperty = true;
-      }
-    }
-
-    // handles bad input, e.g. things like <gml:pos/>
-    if (result.isEmpty()) {
-      result.add(new Point(GeoUtils.getDimension(type), srid));
-    }
-    
-    return result;
-  }
-
-  private MultiPoint multipoint(final XMLEventReader reader, final StartElement start,
-          final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
-
-    List<Point> points = Collections.<Point>emptyList();
-
-    boolean foundEndProperty = false;
-    while (reader.hasNext() && !foundEndProperty) {
-      final XMLEvent event = reader.nextEvent();
-
-      if (event.isStartElement() && event.asStartElement().getName().equals(Constants.QNAME_POINTMEMBERS)) {
-        points = points(reader, event.asStartElement(), type, null);
-      }
-
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndProperty = true;
-      }
-    }
-
-    return new MultiPoint(GeoUtils.getDimension(type), srid, points);
-  }
-
-  private LineString lineString(final XMLEventReader reader, final StartElement start,
-          final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
-
-    return new LineString(GeoUtils.getDimension(type), srid, points(reader, start, type, null));
-  }
-
-  private Polygon polygon(final XMLEventReader reader, final StartElement start,
-          final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
-
-    List<Point> extPoints = null;
-    List<Point> intPoints = null;
-
-    boolean foundEndProperty = false;
-    while (reader.hasNext() && !foundEndProperty) {
-      final XMLEvent event = reader.nextEvent();
-
-      if (event.isStartElement()) {
-        if (event.asStartElement().getName().equals(Constants.QNAME_POLYGON_EXTERIOR)) {
-          extPoints = points(reader, event.asStartElement(), type, null);
-        }
-        if (event.asStartElement().getName().equals(Constants.QNAME_POLYGON_INTERIOR)) {
-          intPoints = points(reader, event.asStartElement(), type, null);
-        }
-      }
-
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndProperty = true;
-      }
-    }
-
-    return new Polygon(GeoUtils.getDimension(type), srid, intPoints, extPoints);
-  }
-
-  private MultiLineString multiLineString(final XMLEventReader reader, final StartElement start,
-          final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
-
-    final List<LineString> lineStrings = new ArrayList<LineString>();
-
-    boolean foundEndProperty = false;
-    while (reader.hasNext() && !foundEndProperty) {
-      final XMLEvent event = reader.nextEvent();
-
-      if (event.isStartElement() && event.asStartElement().getName().equals(Constants.QNAME_LINESTRING)) {
-        lineStrings.add(lineString(reader, event.asStartElement(), type, null));
-      }
-
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndProperty = true;
-      }
-    }
-
-    return new MultiLineString(GeoUtils.getDimension(type), srid, lineStrings);
-  }
-
-  private MultiPolygon multiPolygon(final XMLEventReader reader, final StartElement start,
-          final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
-
-    final List<Polygon> polygons = new ArrayList<Polygon>();
-
-    boolean foundEndProperty = false;
-    while (reader.hasNext() && !foundEndProperty) {
-      final XMLEvent event = reader.nextEvent();
-
-      if (event.isStartElement() && event.asStartElement().getName().equals(Constants.QNAME_POLYGON)) {
-        polygons.add(polygon(reader, event.asStartElement(), type, null));
-      }
-
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndProperty = true;
-      }
-    }
-
-    return new MultiPolygon(GeoUtils.getDimension(type), srid, polygons);
-  }
-
-  private GeospatialCollection collection(final XMLEventReader reader, final StartElement start,
-          final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
-
-    final List<Geospatial> geospatials = new ArrayList<Geospatial>();
-
-    boolean foundEndCollection = false;
-    while (reader.hasNext() && !foundEndCollection) {
-      final XMLEvent event = reader.nextEvent();
-
-      if (event.isStartElement() && event.asStartElement().getName().equals(Constants.QNAME_GEOMEMBERS)) {
-        boolean foundEndMembers = false;
-        while (reader.hasNext() && !foundEndMembers) {
-          final XMLEvent subevent = reader.nextEvent();
-
-          if (subevent.isStartElement()) {
-            geospatials.add(deserialize(reader, subevent.asStartElement(),
-                    GeoUtils.getType(GeoUtils.getDimension(type), subevent.asStartElement().getName().getLocalPart())));
-          }
-
-          if (subevent.isEndElement() && Constants.QNAME_GEOMEMBERS.equals(subevent.asEndElement().getName())) {
-            foundEndMembers = true;
-          }
-        }
-      }
-
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndCollection = true;
-      }
-    }
-
-    return new GeospatialCollection(GeoUtils.getDimension(type), srid, geospatials);
-  }
-
-  public Geospatial deserialize(final XMLEventReader reader, final StartElement start,
-          final EdmPrimitiveTypeKind type) throws XMLStreamException {
-
-    SRID srid = null;
-    final Attribute srsName = start.getAttributeByName(Constants.QNAME_ATTR_SRSNAME);
-    if (srsName != null) {
-      srid = SRID.valueOf(StringUtils.substringAfterLast(srsName.getValue(), "/"));
-    }
-
-    Geospatial value;
-
-    switch (type) {
-      case GeographyPoint:
-      case GeometryPoint:
-        value = points(reader, start, type, srid).get(0);
-        break;
-
-      case GeographyMultiPoint:
-      case GeometryMultiPoint:
-        value = multipoint(reader, start, type, srid);
-        break;
-
-      case GeographyLineString:
-      case GeometryLineString:
-        value = lineString(reader, start, type, srid);
-        break;
-
-      case GeographyMultiLineString:
-      case GeometryMultiLineString:
-        value = multiLineString(reader, start, type, srid);
-        break;
-
-      case GeographyPolygon:
-      case GeometryPolygon:
-        value = polygon(reader, start, type, srid);
-        break;
-
-      case GeographyMultiPolygon:
-      case GeometryMultiPolygon:
-        value = multiPolygon(reader, start, type, srid);
-        break;
-
-      case GeographyCollection:
-      case GeometryCollection:
-        value = collection(reader, start, type, srid);
-        break;
-
-      default:
-        value = null;
-    }
-
-    return value;
-  }
-
-}