You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2014/06/24 06:57:26 UTC

[01/23] [OLINGO-317] First presentable state

Repository: olingo-odata4
Updated Branches:
  refs/heads/clientjune 0e84b4cef -> f40643f92


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/LinkCollectionImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/LinkCollectionImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/LinkCollectionImpl.java
new file mode 100755
index 0000000..3310723
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/LinkCollectionImpl.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.commons.core.data.v3;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.olingo.commons.api.data.v3.LinkCollection;
+
+public class LinkCollectionImpl implements LinkCollection {
+
+  private final List<URI> links = new ArrayList<URI>();
+  private URI next;
+  private URI metadata;
+
+  /**
+   * Constructor.
+   */
+  public LinkCollectionImpl() {
+  }
+
+  /**
+   * Constructor.
+   *
+   * @param next next page link.
+   */
+  public LinkCollectionImpl(final URI next) {
+    this.next = next;
+  }
+
+  @Override
+  public List<URI> getLinks() {
+    return links;
+  }
+
+  @Override
+  public void setNext(final URI next) {
+    this.next = next;
+  }
+
+  @Override
+  public URI getNext() {
+    return next;
+  }
+
+  /**
+   * Gets the metadata URI.
+   */
+  public URI getMetadata() {
+    return metadata;
+  }
+
+  /**
+   * Sets the metadata URI.
+   *
+   * @param metadata metadata URI.
+   */
+  public void setMetadata(final URI metadata) {
+    this.metadata = metadata;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/XMLLinkCollectionImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/XMLLinkCollectionImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/XMLLinkCollectionImpl.java
deleted file mode 100644
index 8d9001c..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/XMLLinkCollectionImpl.java
+++ /dev/null
@@ -1,70 +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.v3;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.olingo.commons.api.data.v3.LinkCollection;
-
-public class XMLLinkCollectionImpl implements LinkCollection {
-
-  private final List<URI> links = new ArrayList<URI>();
-
-  private URI next;
-
-  /**
-   * Constructor.
-   */
-  public XMLLinkCollectionImpl() {
-  }
-
-  /**
-   * Constructor.
-   *
-   * @param next next page link.
-   */
-  public XMLLinkCollectionImpl(final URI next) {
-    this.next = next;
-  }
-
-  /**
-   * {@inheritDoc }
-   */
-  @Override
-  public List<URI> getLinks() {
-    return links;
-  }
-
-  /**
-   * {@inheritDoc }
-   */
-  @Override
-  public void setNext(final URI next) {
-    this.next = next;
-  }
-
-  /**
-   * {@inheritDoc }
-   */
-  @Override
-  public URI getNext() {
-    return next;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/AbstractDelta.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/AbstractDelta.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/AbstractDelta.java
deleted file mode 100644
index d4a50ed..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/AbstractDelta.java
+++ /dev/null
@@ -1,52 +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.v4;
-
-import java.util.ArrayList;
-import java.util.List;
-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.core.data.AbstractEntitySet;
-
-public abstract class AbstractDelta extends AbstractEntitySet implements Delta {
-
-  private static final long serialVersionUID = 4576771708961553195L;
-
-  private final List<DeletedEntity> deletedEntities = new ArrayList<DeletedEntity>();
-
-  private final List<DeltaLink> addedLinks = new ArrayList<DeltaLink>();
-
-  private final List<DeltaLink> deletedLinks = new ArrayList<DeltaLink>();
-
-  @Override
-  public List<DeletedEntity> getDeletedEntities() {
-    return deletedEntities;
-  }
-
-  @Override
-  public List<DeltaLink> getAddedLinks() {
-    return addedLinks;
-  }
-
-  @Override
-  public List<DeltaLink> getDeletedLinks() {
-    return deletedLinks;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/AtomDeltaImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/AtomDeltaImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/AtomDeltaImpl.java
deleted file mode 100644
index d2f85b2..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/AtomDeltaImpl.java
+++ /dev/null
@@ -1,25 +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.v4;
-
-public class AtomDeltaImpl extends AbstractDelta {
-
-  private static final long serialVersionUID = -730729098008847535L;
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/DeltaImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/DeltaImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/DeltaImpl.java
new file mode 100755
index 0000000..021a77d
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/DeltaImpl.java
@@ -0,0 +1,52 @@
+/*
+ * 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.v4;
+
+import java.util.ArrayList;
+import java.util.List;
+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.core.data.EntitySetImpl;
+
+public class DeltaImpl extends EntitySetImpl implements Delta {
+
+  private static final long serialVersionUID = 4576771708961553195L;
+
+  private final List<DeletedEntity> deletedEntities = new ArrayList<DeletedEntity>();
+
+  private final List<DeltaLink> addedLinks = new ArrayList<DeltaLink>();
+
+  private final List<DeltaLink> deletedLinks = new ArrayList<DeltaLink>();
+
+  @Override
+  public List<DeletedEntity> getDeletedEntities() {
+    return deletedEntities;
+  }
+
+  @Override
+  public List<DeltaLink> getAddedLinks() {
+    return addedLinks;
+  }
+
+  @Override
+  public List<DeltaLink> getDeletedLinks() {
+    return deletedLinks;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/JSONDeltaImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/JSONDeltaImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/JSONDeltaImpl.java
deleted file mode 100644
index 7b60d5f..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/JSONDeltaImpl.java
+++ /dev/null
@@ -1,29 +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.v4;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import org.apache.olingo.commons.core.data.JSONDeltaDeserializer;
-
-@JsonDeserialize(using = JSONDeltaDeserializer.class)
-public class JSONDeltaImpl extends AbstractDelta {
-
-  private static final long serialVersionUID = -7948494801560470246L;
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/AbstractJacksonTool.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/AbstractJacksonTool.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/AbstractJacksonTool.java
deleted file mode 100644
index c4c32ad..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/AbstractJacksonTool.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.op;
-
-import com.fasterxml.aalto.stax.InputFactoryImpl;
-import com.fasterxml.aalto.stax.OutputFactoryImpl;
-import com.fasterxml.jackson.annotation.JsonInclude;
-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.JsonDeserializer;
-import com.fasterxml.jackson.databind.ObjectMapper;
-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;
-import java.io.IOException;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-abstract class AbstractJacksonTool {
-
-  protected static final Logger LOG = LoggerFactory.getLogger(AbstractJacksonTool.class);
-
-  protected final ODataServiceVersion version;
-
-  protected AbstractJacksonTool(final ODataServiceVersion client) {
-    this.version = client;
-  }
-
-  protected ObjectMapper getObjectMapper() {
-    final ObjectMapper mapper = new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);
-
-    mapper.setInjectableValues(new InjectableValues.Std().
-            addValue(ODataServiceVersion.class, version).
-            addValue(Boolean.class, Boolean.FALSE));
-
-    mapper.setSerializerProvider(new InjectableSerializerProvider(mapper.getSerializerProvider(),
-            mapper.getSerializationConfig().withAttribute(ODataServiceVersion.class, version).
-            withAttribute(Boolean.class, Boolean.FALSE),
-            mapper.getSerializerFactory()));
-
-    return mapper;
-  }
-
-  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 JsonDeserializer<?> deserializer, final Object beanOrClass, final String propertyName)
-              throws IOException, JsonProcessingException {
-
-        // skip any unknown property
-        LOG.warn("Skipping unknown property {}", propertyName);
-        ctxt.getParser().skipChildren();
-        return true;
-      }
-    });
-    return xmlMapper;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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
index f584868..a2ef134 100644
--- 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
@@ -18,109 +18,84 @@
  */
 package org.apache.olingo.commons.core.op;
 
-import com.fasterxml.jackson.core.type.TypeReference;
+import java.io.IOException;
 import java.io.InputStream;
-import java.lang.reflect.Type;
-import java.net.URI;
+
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.domain.ODataError;
 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.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.api.op.CommonODataDeserializer;
+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.api.data.ResWrap;
-import org.apache.olingo.commons.core.data.AtomEntityImpl;
-import org.apache.olingo.commons.core.data.AtomEntitySetImpl;
-import org.apache.olingo.commons.core.data.AtomPropertyImpl;
-import org.apache.olingo.commons.core.data.JSONEntityImpl;
-import org.apache.olingo.commons.core.data.JSONEntitySetImpl;
-import org.apache.olingo.commons.core.data.JSONODataErrorImpl;
-import org.apache.olingo.commons.core.data.JSONPropertyImpl;
-import org.apache.olingo.commons.core.data.XMLODataErrorImpl;
-
-public abstract class AbstractODataDeserializer extends AbstractJacksonTool implements CommonODataDeserializer {
+import org.apache.olingo.commons.core.data.JsonDeserializer;
 
-  private static final long serialVersionUID = -4244158979195609909L;
+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;
 
-  private final AtomDeserializer atomDeserializer;
+public abstract class AbstractODataDeserializer {
 
-  public AbstractODataDeserializer(final ODataServiceVersion version) {
-    super(version);
+  protected final ODataServiceVersion version;
+  protected final ODataDeserializer deserializer;
 
-    this.atomDeserializer = new AtomDeserializer(version);
+  public AbstractODataDeserializer(final ODataServiceVersion version, final Format format) {
+    this.version = version;
+    if (format == ODataFormat.XML || format == ODataPubFormat.ATOM) {
+      deserializer = new AtomDeserializer(version);
+    } else {
+      deserializer = new JsonDeserializer(version, false);
+    }
   }
 
-  @Override
-  public ResWrap<EntitySet> toEntitySet(final InputStream input, final ODataPubFormat format) {
-    return format == ODataPubFormat.ATOM
-            ? this.<EntitySet, AtomEntitySetImpl>atom(input, AtomEntitySetImpl.class)
-            : this.<EntitySet, JSONEntitySetImpl>json(input, JSONEntitySetImpl.class);
+  public ResWrap<EntitySet> toEntitySet(final InputStream input) throws ODataDeserializerException {
+    return deserializer.toEntitySet(input);
   }
 
-  @Override
-  public ResWrap<Entity> toEntity(final InputStream input, final ODataPubFormat format) {
-    return format == ODataPubFormat.ATOM
-            ? this.<Entity, AtomEntityImpl>atom(input, AtomEntityImpl.class)
-            : this.<Entity, JSONEntityImpl>json(input, JSONEntityImpl.class);
+  public ResWrap<Entity> toEntity(final InputStream input) throws ODataDeserializerException {
+    return deserializer.toEntity(input);
   }
 
-  @Override
-  public ResWrap<Property> toProperty(final InputStream input, final ODataFormat format) {
-    return format == ODataFormat.XML
-            ? this.<Property, AtomPropertyImpl>atom(input, AtomPropertyImpl.class)
-            : this.<Property, JSONPropertyImpl>json(input, JSONPropertyImpl.class);
+  public ResWrap<Property> toProperty(final InputStream input) throws ODataDeserializerException {
+    return deserializer.toProperty(input);
   }
 
-  @Override
-  public ODataError toError(final InputStream input, final boolean isXML) {
-    return isXML
-            ? this.<ODataError, XMLODataErrorImpl>atom(input, XMLODataErrorImpl.class).getPayload()
-            : this.<ODataError, JSONODataErrorImpl>json(input, JSONODataErrorImpl.class).getPayload();
+  public ODataError toError(final InputStream input) throws ODataDeserializerException {
+    return deserializer.toError(input);
   }
 
-  /*
-   * ------------------ Protected methods ------------------
-   */
-  protected <T, V extends T> ResWrap<T> atom(final InputStream input, final Class<V> reference) {
-    try {
-      return atomDeserializer.<T, V>read(input, reference);
-    } catch (Exception e) {
-      throw new IllegalArgumentException("While deserializing " + reference.getName(), e);
-    }
-  }
+  protected XmlMapper getXmlMapper() {
+    final XmlMapper xmlMapper = new XmlMapper(
+        new XmlFactory(new InputFactoryImpl(), new OutputFactoryImpl()), new JacksonXmlModule());
 
-  @SuppressWarnings("unchecked")
-  protected <T, V extends T> ResWrap<T> xml(final InputStream input, final Class<V> reference) {
-    try {
-      final T obj = getXmlMapper().readValue(input, new TypeReference<V>() {
-        @Override
-        public Type getType() {
-          return reference;
-        }
-      });
+    xmlMapper.setInjectableValues(new InjectableValues.Std().
+        addValue(ODataServiceVersion.class, version).
+        addValue(Boolean.class, Boolean.FALSE));
 
-      return obj instanceof ResWrap ? (ResWrap<T>) obj : new ResWrap<T>((URI) null, null, obj);
-    } catch (Exception e) {
-      throw new IllegalArgumentException("While deserializing " + reference.getName(), e);
-    }
-  }
-
-  @SuppressWarnings("unchecked")
-  protected <T, V extends T> ResWrap<T> json(final InputStream input, final Class<V> reference) {
-    try {
-      final T obj = getObjectMapper().readValue(input, new TypeReference<V>() {
-        @Override
-        public Type getType() {
-          return reference;
-        }
-      });
+    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 {
 
-      return obj instanceof ResWrap ? (ResWrap<T>) obj : new ResWrap<T>((URI) null, null, obj);
-    } catch (Exception e) {
-      throw new IllegalArgumentException("While deserializing " + reference.getName(), e);
-    }
+        // skip any unknown property
+        ctxt.getParser().skipChildren();
+        return true;
+      }
+    });
+    return xmlMapper;
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/AbstractODataSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/AbstractODataSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/AbstractODataSerializer.java
deleted file mode 100644
index 32b9e99..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/AbstractODataSerializer.java
+++ /dev/null
@@ -1,141 +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.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import org.apache.olingo.commons.api.Constants;
-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.format.ODataFormat;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.api.op.ODataSerializer;
-import org.apache.olingo.commons.core.data.AtomEntityImpl;
-import org.apache.olingo.commons.core.data.AtomEntitySetImpl;
-import org.apache.olingo.commons.core.data.AtomPropertyImpl;
-import org.apache.olingo.commons.core.data.AtomSerializer;
-import org.apache.olingo.commons.core.data.JSONEntityImpl;
-import org.apache.olingo.commons.core.data.JSONEntitySetImpl;
-import org.apache.olingo.commons.core.data.JSONPropertyImpl;
-
-public abstract class AbstractODataSerializer extends AbstractJacksonTool implements ODataSerializer {
-
-  private static final long serialVersionUID = -357777648541325363L;
-
-  private final AtomSerializer atomSerializer;
-
-  public AbstractODataSerializer(final ODataServiceVersion version) {
-    super(version);
-
-    this.atomSerializer = new AtomSerializer(version);
-  }
-
-  @Override
-  public void entitySet(final EntitySet obj, final OutputStream out) {
-    entitySet(obj, new OutputStreamWriter(out));
-  }
-
-  @Override
-  public void entitySet(final EntitySet obj, final Writer writer) {
-    if (obj instanceof AtomEntitySetImpl) {
-      atom((AtomEntitySetImpl) obj, writer);
-    } else {
-      json((JSONEntitySetImpl) obj, writer);
-    }
-  }
-
-  @Override
-  public void entity(final Entity obj, final OutputStream out) {
-    entity(obj, new OutputStreamWriter(out));
-  }
-
-  @Override
-  public void entity(final Entity obj, final Writer writer) {
-    if (obj instanceof AtomEntityImpl) {
-      atom((AtomEntityImpl) obj, writer);
-    } else {
-      json((JSONEntityImpl) obj, writer);
-    }
-  }
-
-  @Override
-  public void property(final Property obj, final OutputStream out) {
-    property(obj, new OutputStreamWriter(out));
-  }
-
-  @Override
-  public void property(final Property obj, final Writer writer) {
-    if (obj instanceof AtomPropertyImpl) {
-      atom((AtomPropertyImpl) obj, writer);
-    } else {
-      json((JSONPropertyImpl) obj, writer);
-    }
-  }
-
-  @Override
-  public void link(final Link link, final ODataFormat format, final OutputStream out) {
-    link(link, format, new OutputStreamWriter(out));
-  }
-
-  @Override
-  public void link(final Link link, final ODataFormat format, final Writer writer) {
-    if (format == ODataFormat.XML) {
-      atom(link, writer);
-    } else {
-      jsonLink(link, writer);
-    }
-  }
-
-  /*
-   * ------------------ Protected methods ------------------
-   */
-  protected <T> void atom(final T obj, final Writer writer) {
-    try {
-      atomSerializer.write(writer, obj);
-    } catch (Exception e) {
-      throw new IllegalArgumentException("While serializing Atom object", e);
-    }
-  }
-
-  protected <T> void json(final T obj, final Writer writer) {
-    try {
-      getObjectMapper().writeValue(writer, obj);
-    } catch (IOException e) {
-      throw new IllegalArgumentException("While serializing JSON object", e);
-    }
-  }
-
-  protected void jsonLink(final Link link, final Writer writer) {
-    final ObjectMapper mapper = getObjectMapper();
-    final ObjectNode uri = mapper.createObjectNode();
-    uri.put(Constants.JSON_URL, link.getHref());
-
-    try {
-      mapper.writeValue(writer, uri);
-    } catch (Exception e) {
-      throw new IllegalArgumentException("While serializing JSON link", e);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/ResourceFactory.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/ResourceFactory.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/ResourceFactory.java
deleted file mode 100644
index a2efe34..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/ResourceFactory.java
+++ /dev/null
@@ -1,125 +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 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.format.ODataPubFormat;
-import org.apache.olingo.commons.core.data.AtomEntityImpl;
-import org.apache.olingo.commons.core.data.AtomEntitySetImpl;
-import org.apache.olingo.commons.core.data.AtomPropertyImpl;
-import org.apache.olingo.commons.core.data.JSONEntityImpl;
-import org.apache.olingo.commons.core.data.JSONEntitySetImpl;
-import org.apache.olingo.commons.core.data.JSONPropertyImpl;
-
-public class ResourceFactory {
-
-  /**
-   * Gets a new instance of <tt>EntitySet</tt>.
-   *
-   * @param resourceClass reference class.
-   * @return {@link EntitySet} object.
-   */
-  public static EntitySet newEntitySet(final Class<? extends EntitySet> resourceClass) {
-    EntitySet result = null;
-
-    if (AtomEntitySetImpl.class.equals(resourceClass)) {
-      result = new AtomEntitySetImpl();
-    }
-    if (JSONEntitySetImpl.class.equals(resourceClass)) {
-      result = new JSONEntitySetImpl();
-    }
-
-    return result;
-  }
-
-  /**
-   * Gets a new instance of <tt>Entity</tt>.
-   *
-   * @param resourceClass reference class.
-   * @return {@link Entity} object.
-   */
-  public static Entity newEntity(final Class<? extends Entity> resourceClass) {
-    Entity result = null;
-    if (AtomEntityImpl.class.equals(resourceClass)) {
-      result = new AtomEntityImpl();
-    }
-    if (JSONEntityImpl.class.equals(resourceClass)) {
-      result = new JSONEntityImpl();
-    }
-
-    return result;
-  }
-
-  public static Property newProperty(final Class<? extends Entity> resourceClass) {
-    Property result = null;
-    if (AtomEntityImpl.class.equals(resourceClass)) {
-      result = new AtomPropertyImpl();
-    }
-    if (JSONEntityImpl.class.equals(resourceClass)) {
-      result = new JSONPropertyImpl();
-    }
-
-    return result;
-  }
-
-  /**
-   * Gets entity set reference class from the given format.
-   *
-   * @param isXML whether it is JSON or XML / Atom
-   * @return resource reference class.
-   */
-  public static Class<? extends EntitySet> entitySetClassForFormat(final boolean isXML) {
-    return isXML ? AtomEntitySetImpl.class : JSONEntitySetImpl.class;
-  }
-
-  /**
-   * Gets entity reference class from the given format.
-   *
-   * @param isXML whether it is JSON or XML / Atom
-   * @return resource reference class.
-   */
-  public static Class<? extends Entity> entityClassForFormat(final boolean isXML) {
-    return isXML ? AtomEntityImpl.class : JSONEntityImpl.class;
-  }
-
-  /**
-   * Gets <tt>Entity</tt> object from entity set resource.
-   *
-   * @param resourceClass entity set reference class.
-   * @return {@link Entity} object.
-   */
-  public static Class<? extends Entity> entityClassForEntitySet(final Class<? extends EntitySet> resourceClass) {
-    Class<? extends Entity> result = null;
-
-    if (AtomEntitySetImpl.class.equals(resourceClass)) {
-      result = AtomEntityImpl.class;
-    }
-    if (JSONEntitySetImpl.class.equals(resourceClass)) {
-      result = JSONEntityImpl.class;
-    }
-
-    return result;
-  }
-
-  public static ODataPubFormat formatForEntityClass(final Class<? extends Entity> reference) {
-    return reference.equals(AtomEntityImpl.class) ? ODataPubFormat.ATOM : ODataPubFormat.JSON;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java
index fd57c89..0eaf440 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java
@@ -20,7 +20,12 @@ package org.apache.olingo.server.api.serializer;
 
 import java.io.InputStream;
 
+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.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
 
 public interface ODataSerializer {
 
@@ -30,4 +35,7 @@ public interface ODataSerializer {
 
   InputStream metadataDocument(Edm edm);
 
+  InputStream entity(EdmEntityType edmEntityType, Entity entity, ContextURL contextURL);
+
+  InputStream entitySet(EdmEntitySet edmEntitySet, EntitySet entitySet, ContextURL contextURL);
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
index e5ca20c..cf9f3f3 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
@@ -18,16 +18,31 @@
  */
 package org.apache.olingo.server.core;
 
+import java.io.IOException;
+import java.net.URI;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.UUID;
 
 import org.apache.olingo.commons.api.ODataRuntimeException;
+import org.apache.olingo.commons.api.data.ContextURL;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.api.http.HttpContentType;
 import org.apache.olingo.commons.api.http.HttpMethod;
 import org.apache.olingo.commons.api.http.HttpHeader;
+import org.apache.olingo.commons.core.data.EntityImpl;
+import org.apache.olingo.commons.core.data.EntitySetImpl;
+import org.apache.olingo.commons.core.data.PrimitiveValueImpl;
+import org.apache.olingo.commons.core.data.PropertyImpl;
+import org.apache.olingo.commons.core.op.InjectableSerializerProvider;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
@@ -37,13 +52,19 @@ import org.apache.olingo.server.api.processor.EntitySetProcessor;
 import org.apache.olingo.server.api.processor.MetadataProcessor;
 import org.apache.olingo.server.api.processor.Processor;
 import org.apache.olingo.server.api.processor.ServiceDocumentProcessor;
+import org.apache.olingo.server.api.serializer.ODataSerializer;
 import org.apache.olingo.server.api.uri.UriInfo;
 import org.apache.olingo.server.api.uri.UriResource;
 import org.apache.olingo.server.api.uri.UriResourceNavigation;
 import org.apache.olingo.server.api.uri.UriResourcePartTyped;
+import org.apache.olingo.server.core.serializer.utils.CircleStreamBuffer;
 import org.apache.olingo.server.core.uri.parser.Parser;
 import org.apache.olingo.server.core.uri.validator.UriValidator;
 
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.databind.InjectableValues;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
 public class ODataHandler {
 
   private final OData odata;
@@ -113,6 +134,39 @@ public class ODataHandler {
     UriResource lastPathSegment = uriInfo.getUriResourceParts().get(lastPathSegmentIndex);
     switch (lastPathSegment.getKind()) {
     case entitySet:
+      long time = System.nanoTime();
+      ResWrap<EntitySet> wrap = new ResWrap<EntitySet>(
+          ContextURL.getInstance(URI.create("dummyContextURL")), "dummyMetadataETag",
+          createEntitySet());
+      System.out.println((System.nanoTime() - time) / 1000 + " microseconds");
+      time = System.nanoTime();
+      CircleStreamBuffer buffer = new CircleStreamBuffer();
+      if (false) {
+        ObjectMapper mapper = new ObjectMapper().setSerializationInclusion(Include.NON_NULL);
+        mapper.setInjectableValues(new InjectableValues.Std()
+            .addValue(ODataServiceVersion.class, ODataServiceVersion.V40)
+            .addValue(Boolean.class, Boolean.TRUE));
+        mapper.setSerializerProvider(new InjectableSerializerProvider(mapper.getSerializerProvider(),
+            mapper.getSerializationConfig()
+                .withAttribute(ODataServiceVersion.class, ODataServiceVersion.V40)
+                .withAttribute(Boolean.class, Boolean.TRUE),
+            mapper.getSerializerFactory()));
+        try {
+          mapper.writeValue(buffer.getOutputStream(), wrap);
+        } catch (final IOException e) {}
+        response.setContent(buffer.getInputStream());
+      } else {
+        ODataSerializer serializer = odata.createSerializer(org.apache.olingo.server.api.serializer.ODataFormat.JSON);
+        response.setContent(serializer.entitySet(
+            edm.getEntityContainer(new FullQualifiedName("com.sap.odata.test1", "Container"))
+                .getEntitySet("ESAllPrim"),
+            wrap.getPayload(),
+            ContextURL.getInstance(URI.create("dummyContextURL"))));
+      }
+      System.out.println((System.nanoTime() - time) / 1000 + " microseconds");
+      response.setStatusCode(200);
+      response.setHeader("Content-Type", ContentType.APPLICATION_JSON);
+
       if (((UriResourcePartTyped) lastPathSegment).isCollection()) {
         if (request.getMethod().equals(HttpMethod.GET)) {
           EntitySetProcessor esp = selectProcessor(EntitySetProcessor.class);
@@ -186,4 +240,34 @@ public class ODataHandler {
       }
     }
   }
+
+  protected Entity createEntity() {
+    Entity entity = new EntityImpl();
+    Property property = new PropertyImpl();
+    property.setName("PropertyString");
+    property.setType("String"); //"dummyType");
+    property.setValue(new PrimitiveValueImpl("dummyValue"));
+    entity.getProperties().add(property);
+    Property propertyInt = new PropertyImpl();
+    propertyInt.setName("PropertyInt16");
+    // propertyInt.setType("Edm.Int32");
+    propertyInt.setValue(new PrimitiveValueImpl("042"));
+    entity.getProperties().add(propertyInt);
+    Property propertyGuid = new PropertyImpl();
+    propertyGuid.setName("PropertyGuid");
+    propertyGuid.setType("Edm.Guid");
+    propertyGuid.setValue(new PrimitiveValueImpl(UUID.randomUUID().toString()));
+    entity.getProperties().add(propertyGuid);
+    return entity;
+  }
+
+  protected EntitySet createEntitySet() {
+    EntitySet entitySet = new EntitySetImpl();
+    entitySet.setCount(4242);
+    entitySet.setNext(URI.create("nextLinkURI"));
+    for (int i = 0; i < 1000; i++) {
+      entitySet.getEntities().add(createEntity());
+    }
+    return entitySet;
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataJsonSerializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataJsonSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataJsonSerializer.java
index 333d5b7..62634da 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataJsonSerializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataJsonSerializer.java
@@ -23,8 +23,19 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStreamWriter;
 
+import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.ODataRuntimeException;
+import org.apache.olingo.commons.api.data.ContextURL;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
+import org.apache.olingo.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.core.edm.primitivetype.EdmPrimitiveTypeFactory;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
 import org.apache.olingo.server.core.serializer.json.ServiceDocumentJsonSerializer;
 import org.apache.olingo.server.core.serializer.utils.CircleStreamBuffer;
@@ -84,4 +95,97 @@ public class ODataJsonSerializer implements ODataSerializer {
   public InputStream metadataDocument(final Edm edm) {
     throw new ODataRuntimeException("Metadata in JSON format not supported!");
   }
+
+  @Override
+  public InputStream entity(final EdmEntityType edmEntityType, final Entity entity, final ContextURL contextURL) {
+    CircleStreamBuffer buffer = new CircleStreamBuffer();
+    try {
+      JsonGenerator json = new JsonFactory().createGenerator(buffer.getOutputStream());
+      writeEntity(edmEntityType, entity, contextURL, json);
+      json.close();
+    } catch (final IOException e) {
+      throw new ODataRuntimeException(e);
+    }
+    return buffer.getInputStream();
+  }
+
+  protected void writeEntity(final EdmEntityType entityType, final Entity entity, final ContextURL contextURL,
+      JsonGenerator json) throws IOException {
+    json.writeStartObject();
+    if (contextURL != null) {
+      json.writeStringField(Constants.JSON_CONTEXT, contextURL.getURI().toASCIIString());
+    }
+    if (entity.getETag() != null) {
+      json.writeStringField("@odata.etag", entity.getETag());
+    }
+    if (entity.getMediaETag() != null) {
+      json.writeStringField("@odata.mediaEtag", entity.getMediaETag());
+    }
+    if (entity.getMediaContentType() != null) {
+      json.writeStringField("@odata.mediaContentType", entity.getMediaContentType());
+    }
+    for (final String propertyName : entityType.getPropertyNames()) {
+      json.writeFieldName(propertyName);
+      final EdmProperty edmProperty = (EdmProperty) entityType.getProperty(propertyName);
+      final Property property = entity.getProperty(propertyName);
+      if (property == null) {
+        if (edmProperty.isNullable() == Boolean.FALSE) {
+          throw new ODataRuntimeException("Non-nullable property not present!");
+        } else {
+          json.writeNull();
+        }
+      } else {
+        if (edmProperty.isPrimitive()) {
+          final EdmPrimitiveType type = (EdmPrimitiveType) edmProperty.getType();
+          final String value = property.getValue().asPrimitive().get();
+          if (type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Boolean)) {
+            json.writeBoolean(Boolean.parseBoolean(value));
+          } else if (type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Byte)
+              || type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Decimal)
+              || type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Double)
+              || type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Int16)
+              || type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Int32)
+              || type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Int64)
+              || type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.SByte)
+              || type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Single)) {
+            json.writeNumber(value);
+          } else {
+            json.writeString(value);
+          }
+        } else {
+          throw new ODataRuntimeException("Non-primitive properties not yet supported!");
+        }
+      }
+    }
+    json.writeEndObject();
+  }
+
+  @Override
+  public InputStream entitySet(final EdmEntitySet edmEntitySet, final EntitySet entitySet,
+      final ContextURL contextURL) {
+    CircleStreamBuffer buffer = new CircleStreamBuffer();
+    try {
+      JsonGenerator json = new JsonFactory().createGenerator(buffer.getOutputStream());
+      json.writeStartObject();
+      if (contextURL != null) {
+        json.writeStringField(Constants.JSON_CONTEXT, contextURL.getURI().toASCIIString());
+      }
+      if (entitySet.getCount() != null) {
+        json.writeNumberField("@odata.count", entitySet.getCount());
+      }
+      json.writeFieldName(Constants.VALUE);
+      json.writeStartArray();
+      for (Entity entity : entitySet.getEntities()) {
+        writeEntity(edmEntitySet.getEntityType(), entity, null, json);
+      }
+      json.writeEndArray();
+      if (entitySet.getNext() != null) {
+        json.writeStringField("@odata.nextLink", entitySet.getNext().toASCIIString());
+      }
+      json.close();
+    } catch (final IOException e) {
+      throw new ODataRuntimeException(e);
+    }
+    return buffer.getInputStream();
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataXmlSerializerImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataXmlSerializerImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataXmlSerializerImpl.java
index a8a943f..169f7a8 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataXmlSerializerImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataXmlSerializerImpl.java
@@ -25,7 +25,12 @@ import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.olingo.commons.api.ODataRuntimeException;
+import org.apache.olingo.commons.api.data.ContextURL;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
 import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
 import org.apache.olingo.server.core.serializer.utils.CircleStreamBuffer;
 import org.apache.olingo.server.core.serializer.xml.MetadataDocumentXmlSerializer;
@@ -70,4 +75,14 @@ public class ODataXmlSerializerImpl implements ODataSerializer {
     }
   }
 
+  @Override
+  public InputStream entity(EdmEntityType edmEntityType, Entity entity, ContextURL contextURL) {
+    throw new ODataRuntimeException("Entity serialization not implemented for XML format");
+  }
+
+  @Override
+  public InputStream entitySet(EdmEntitySet edmEntitySet, EntitySet entitySet, ContextURL contextURL) {
+    throw new ODataRuntimeException("Entityset serialization not implemented for XML format");
+  }
+
 }


[19/23] [OLINGO-317] Rename and move of some packages and classes

Posted by ch...@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));
+  }
+}


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

Posted by ch...@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/clientjune
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.


[20/23] [OLINGO-317] Rename and move of some packages and classes

Posted by ch...@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;
-  }
-}


[11/23] git commit: [OLINGO-317] Finished DeSerializer refactoring

Posted by ch...@apache.org.
[OLINGO-317] Finished DeSerializer refactoring


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

Branch: refs/heads/clientjune
Commit: 70afb2acc50aef1270858bad75eb8dc125b08c3f
Parents: 46a3417
Author: Michael Bolz <mi...@sap.com>
Authored: Wed Jun 11 13:39:53 2014 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Wed Jun 11 14:29:57 2014 +0200

----------------------------------------------------------------------
 .../org/apache/olingo/fit/AbstractServices.java | 114 ++++++++++-------
 .../java/org/apache/olingo/fit/V4Services.java  |   2 +-
 .../olingo/fit/utils/AbstractUtilities.java     |  54 ++++----
 .../org/apache/olingo/fit/utils/Commons.java    |  15 +--
 .../org/apache/olingo/fit/utils/FSManager.java  |  18 +--
 .../apache/olingo/fit/utils/JSONUtilities.java  |  42 +++----
 .../org/apache/olingo/fit/utils/XMLElement.java |  12 +-
 .../olingo/fit/utils/XMLEventReaderWrapper.java |   6 +-
 .../apache/olingo/fit/utils/XMLUtilities.java   |   6 +-
 .../communication/request/AbstractRequest.java  |   4 +-
 .../cud/ODataEntityCreateRequestImpl.java       |  17 ++-
 .../cud/ODataEntityUpdateRequestImpl.java       |  17 ++-
 .../cud/ODataPropertyUpdateRequestImpl.java     |   5 +-
 .../cud/v3/ODataLinkCreateRequestImpl.java      |  11 +-
 .../cud/v3/ODataLinkUpdateRequestImpl.java      |  19 +--
 .../invoke/AbstractODataInvokeRequest.java      |  18 +--
 .../retrieve/ODataEntityRequestImpl.java        |   5 +-
 .../retrieve/ODataEntitySetRequestImpl.java     |   5 +-
 .../retrieve/ODataPropertyRequestImpl.java      |   2 +-
 .../request/retrieve/ODataRawRequestImpl.java   |   7 +-
 .../ODataServiceDocumentRequestImpl.java        |   3 +-
 .../v3/ODataLinkCollectionRequestImpl.java      |   2 +-
 .../retrieve/v4/ODataDeltaRequestImpl.java      |   2 +-
 .../ODataMediaEntityCreateRequestImpl.java      |   7 +-
 .../ODataMediaEntityUpdateRequestImpl.java      |   7 +-
 .../client/core/op/AbstractODataBinder.java     |  34 ++---
 .../core/op/impl/v3/ODataDeserializerImpl.java  |   7 +-
 .../client/core/op/impl/v4/ODataBinderImpl.java |  13 +-
 .../core/op/impl/v4/ODataDeserializerImpl.java  |   4 +-
 .../olingo/client/core/v3/ODataClientImpl.java  |   2 +-
 .../olingo/client/core/v4/ODataClientImpl.java  |   2 +-
 .../core/data/AbstractAnnotatedObject.java      |  23 +++-
 .../commons/core/data/AbstractODataObject.java  |   6 +-
 .../core/data/AbstractPayloadObject.java        |  48 -------
 .../commons/core/data/AnnotationImpl.java       |   4 -
 .../commons/core/data/DeletedEntityImpl.java    |   3 -
 .../olingo/commons/core/data/DeltaLinkImpl.java |   4 -
 .../olingo/commons/core/data/EntityImpl.java    |   7 --
 .../olingo/commons/core/data/EntitySetImpl.java |   2 -
 .../data/JSONLinkCollectionDeserializer.java    |  80 ++++++++++++
 .../commons/core/data/JsonSerializer.java       |   2 +-
 .../olingo/commons/core/data/LinkImpl.java      |   8 --
 .../olingo/commons/core/data/PropertyImpl.java  |   4 -
 .../core/data/v3/JSONLinkCollectionImpl.java    | 118 -----------------
 .../core/data/v3/LinkCollectionImpl.java        |   4 +-
 .../olingo/commons/core/data/v4/DeltaImpl.java  |   4 -
 .../core/op/AbstractODataDeserializer.java      |   4 +-
 .../apache/olingo/server/core/ODataHandler.java | 101 +--------------
 lib/server-tecsvc/pom.xml                       |  16 +++
 .../olingo/server/tecsvc/TechnicalServlet.java  |   6 +-
 .../tecsvc/processor/SampleJsonProcessor.java   | 126 +++++++++++++++++++
 51 files changed, 494 insertions(+), 538 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/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 71a7bf5..ad931b9 100644
--- a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
+++ b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
@@ -73,6 +73,7 @@ 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.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.api.format.ContentType;
@@ -80,6 +81,7 @@ 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.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;
@@ -201,7 +203,7 @@ public abstract class AbstractServices {
     try {
       final boolean continueOnError = prefer.contains("odata.continue-on-error");
       return xml.createBatchResponse(
-              exploreMultipart(attachment.getAllAttachments(), BOUNDARY, continueOnError), BOUNDARY);
+              exploreMultipart(attachment.getAllAttachments(), BOUNDARY, continueOnError));
     } catch (IOException e) {
       return xml.createFaultResponse(Accept.XML.toString(version), e);
     }
@@ -638,17 +640,11 @@ public abstract class AbstractServices {
         final Accept contentTypeValue = Accept.parse(contentType, version);
         if (Accept.ATOM == contentTypeValue) {
           container = atomDeserializer.toEntity(IOUtils.toInputStream(entity, Constants.ENCODING));
-          entry = container.getPayload();
         } else {
-          final ResWrap<Entity> jcontainer = jsonDeserializer.toEntity(
-              IOUtils.toInputStream(entity, Constants.ENCODING));
-          entry = jcontainer.getPayload();
-
-          container = new ResWrap<Entity>(
-                  jcontainer.getContextURL(),
-                  jcontainer.getMetadataETag(),
-                  entry);
+          container = jsonDeserializer.toEntity(IOUtils.toInputStream(entity, Constants.ENCODING));
         }
+        entry = container.getPayload();
+        updateInlineEntities(entry);
 
         entityKey = xml.getDefaultEntryKey(entitySetName, entry);
       }
@@ -1116,7 +1112,7 @@ public abstract class AbstractServices {
       } catch (Exception e) {
         LOG.error("Error retrieving entity", e);
         return xml.createFaultResponse(accept, e);
-      }
+     }
     } else {
       return internal;
     }
@@ -1348,8 +1344,7 @@ public abstract class AbstractServices {
       } else {
         final Property pchanges = xml.readProperty(
                 Accept.parse(contentType, version),
-                IOUtils.toInputStream(changes, Constants.ENCODING),
-                entry.getType());
+                IOUtils.toInputStream(changes, Constants.ENCODING));
 
         toBeReplaced.setValue(pchanges.getValue());
       }
@@ -1710,26 +1705,16 @@ public abstract class AbstractServices {
           final ByteArrayOutputStream content = new ByteArrayOutputStream();
           final OutputStreamWriter writer = new OutputStreamWriter(content, Constants.ENCODING);
 
-          if (linkInfo.isFeed()) {
-            final ResWrap<EntitySet> container = atomDeserializer.toEntitySet(stream);
-
-            if (acceptType == Accept.ATOM) {
-              atomSerializer.write(writer, container);
-            } else {
-              jsonSerializer.write(writer, container);
-            }
-            writer.flush();
-            writer.close();
+          final ResWrap<?> container = linkInfo.isFeed() ?
+              atomDeserializer.toEntitySet(stream) :
+              atomDeserializer.toEntity(stream);
+          if (acceptType == Accept.ATOM) {
+            atomSerializer.write(writer, container);
           } else {
-            final ResWrap<Entity> container = atomDeserializer.toEntity(stream);
-            if (acceptType == Accept.ATOM) {
-              atomSerializer.write(writer, container);
-            } else {
-              jsonSerializer.write(writer, container);
-            }
-            writer.flush();
-            writer.close();
+            jsonSerializer.write(writer, container);
           }
+          writer.flush();
+          writer.close();
 
           final String basePath = Commons.getEntityBasePath(entitySetName, entityId);
 
@@ -1797,20 +1782,17 @@ public abstract class AbstractServices {
 
     final ResWrap<Property> container = new ResWrap<Property>(
             URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX)
-            + (version.compareTo(ODataServiceVersion.V40) >= 0
-            ? entitySetName + "(" + entityId + ")/" + path
-            : property.getType())),
+                + (version.compareTo(ODataServiceVersion.V40) >= 0 ?
+                    entitySetName + "(" + entityId + ")/" + path : property.getType())),
             entryContainer.getMetadataETag(),
             property);
 
-    return xml.createResponse(
-            null,
-            searchForValue
-            ? IOUtils.toInputStream(
-            container.getPayload().getValue() == null || container.getPayload().getValue().isNull()
-            ? StringUtils.EMPTY
-            : container.getPayload().getValue().asPrimitive().get(), Constants.ENCODING)
-            : utils.writeProperty(acceptType, container),
+    return xml.createResponse(null,
+            searchForValue ?
+                IOUtils.toInputStream(container.getPayload().getValue() == null
+                || container.getPayload().getValue().isNull() ? StringUtils.EMPTY :
+                  container.getPayload().getValue().asPrimitive().get(), Constants.ENCODING) :
+                utils.writeProperty(acceptType, container),
             Commons.getETag(Commons.getEntityBasePath(entitySetName, entityId), version),
             acceptType);
   }
@@ -1871,6 +1853,54 @@ public abstract class AbstractServices {
     return utils;
   }
 
+  protected void updateInlineEntities(Entity entity) {
+    final String type = entity.getType();
+    EntityType entityType;
+    Map<String, NavigationProperty> navProperties = Collections.emptyMap();
+    if (type != null && type.length() > 0) {
+      entityType = metadata.getEntityOrComplexType(type);
+      navProperties = entityType.getNavigationPropertyMap();
+    }
+
+    for (Property property : entity.getProperties()) {
+      if (navProperties.containsKey(property.getName())) {
+        Link alink = new LinkImpl();
+        alink.setTitle(property.getName());
+        alink.getAnnotations().addAll(property.getAnnotations());
+
+        alink.setType(navProperties.get(property.getName()).isEntitySet()
+                ? Constants.get(version, ConstantKey.ATOM_LINK_FEED)
+                : Constants.get(version, ConstantKey.ATOM_LINK_ENTRY));
+
+        alink.setRel(Constants.get(version, ConstantKey.ATOM_LINK_REL) + property.getName());
+
+        if (property.getValue().isComplex()) {
+          Entity inline = new EntityImpl();
+          inline.setType(navProperties.get(property.getName()).getType());
+          for (Property prop : property.getValue().asComplex().get()) {
+            inline.getProperties().add(prop);
+          }
+          alink.setInlineEntity(inline);
+
+        } else if (property.getValue().isCollection()) {
+          EntitySet inline = new EntitySetImpl();
+          for (Value value : property.getValue().asCollection().get()) {
+            Entity inlineEntity = new EntityImpl();
+            inlineEntity.setType(navProperties.get(property.getName()).getType());
+            for (Property prop : value.asComplex().get()) {
+              inlineEntity.getProperties().add(prop);
+            }
+            inline.getEntities().add(inlineEntity);
+          }
+          alink.setInlineEntitySet(inline);
+        } else {
+          throw new IllegalStateException("Invalid navigation property " + property);
+        }
+        entity.getNavigationLinks().add(alink);
+      }
+    }
+  }
+
   protected void normalizeAtomEntry(final Entity entry, final String entitySetName, final String entityKey) {
     final org.apache.olingo.fit.metadata.EntitySet entitySet = metadata.getEntitySet(entitySetName);
     final EntityType entityType = metadata.getEntityOrComplexType(entitySet.getType());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/fit/src/main/java/org/apache/olingo/fit/V4Services.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/V4Services.java b/fit/src/main/java/org/apache/olingo/fit/V4Services.java
index 81f70ee..eaa66d0 100644
--- a/fit/src/main/java/org/apache/olingo/fit/V4Services.java
+++ b/fit/src/main/java/org/apache/olingo/fit/V4Services.java
@@ -134,7 +134,7 @@ public class V4Services extends AbstractServices {
 
         return xml.createResponse(feed, null, Accept.JSON_FULLMETA);
       } else {
-        throw new Exception("Unexpected crossjoin pattern");
+        throw new IOException("Unexpected crossjoin pattern");
       }
     } catch (Exception e) {
       return xml.createFaultResponse(Accept.JSON.toString(version), e);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/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 99a3320..4706aa4 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
@@ -100,7 +100,7 @@ public abstract class AbstractUtilities {
     this.fsManager = FSManager.instance(version);
     atomDeserializer = new FITAtomDeserializer(version);
     jsonDeserializer = new JsonDeserializer(version, true);
-    atomSerializer = new AtomSerializer(version);
+    atomSerializer = new AtomSerializer(version, true);
     jsonSerializer = new JsonSerializer(version, true);
   }
 
@@ -116,7 +116,6 @@ public abstract class AbstractUtilities {
    * @param is
    * @param links links to be added.
    * @return
-   * @throws IOException
    */
   protected abstract InputStream addLinks(
       final String entitySetName, final String entitykey, final InputStream is, final Set<String> links)
@@ -128,6 +127,7 @@ public abstract class AbstractUtilities {
    * @param is
    * @return
    * @throws IOException
+   * @throws XMLStreamException 
    */
   protected abstract Set<String> retrieveAllLinkNames(final InputStream is) throws Exception;
 
@@ -137,10 +137,8 @@ public abstract class AbstractUtilities {
    * @param entitySetName
    * @param is
    * @return
-   * @throws IOException
    */
-  protected abstract NavigationLinks retrieveNavigationInfo(
-      final String entitySetName, final InputStream is)
+  protected abstract NavigationLinks retrieveNavigationInfo(final String entitySetName, final InputStream is)
       throws Exception;
 
   /**
@@ -151,7 +149,6 @@ public abstract class AbstractUtilities {
    * @param is
    * @param links
    * @return
-   * @throws IOException
    */
   protected abstract InputStream normalizeLinks(
       final String entitySetName, final String entityKey, final InputStream is, final NavigationLinks links)
@@ -219,13 +216,13 @@ public abstract class AbstractUtilities {
     Set<String> linksToBeKept;
     try {
       linksToBeKept = new HashSet<String>(navigationProperties.keySet());
-    } catch (Exception e) {
+    } catch (NullPointerException e) {
       linksToBeKept = Collections.<String> emptySet();
     }
 
     for (String availableLink : new HashSet<String>(linksToBeKept)) {
       try {
-        fsManager.resolve(Commons.getLinksPath(version, entitySetName, key, availableLink, Accept.JSON_FULLMETA));
+        fsManager.resolve(Commons.getLinksPath(entitySetName, key, availableLink, Accept.JSON_FULLMETA));
       } catch (Exception e) {
         linksToBeKept.remove(availableLink);
       }
@@ -350,7 +347,7 @@ public abstract class AbstractUtilities {
       final String entitySetName,
       final String entityKey,
       final String linkName,
-      final Collection<String> links) throws IOException {
+      final Collection<String> links) throws Exception {
 
     final HashSet<String> uris = new HashSet<String>();
 
@@ -371,7 +368,7 @@ public abstract class AbstractUtilities {
 
   public void putLinksInMemory(
       final String basePath, final String entitySetName, final String linkName, final Collection<String> uris)
-      throws IOException {
+      throws Exception {
 
     fsManager.putInMemory(
         Commons.getLinksAsJSON(version, entitySetName, new SimpleEntry<String, Collection<String>>(linkName, uris)),
@@ -416,7 +413,7 @@ public abstract class AbstractUtilities {
     return createResponse(null, entity, etag, accept, null);
   }
 
-  public Response createBatchResponse(final InputStream stream, final String boundary) {
+  public Response createBatchResponse(final InputStream stream) {
     final Response.ResponseBuilder builder = version.compareTo(ODataServiceVersion.V30) <= 0
         ? Response.accepted(stream)
         : Response.ok(stream);
@@ -590,8 +587,7 @@ public abstract class AbstractUtilities {
     return IOUtils.toInputStream(writer.toString(), Constants.ENCODING);
   }
 
-  public Property readProperty(final Accept accept, final InputStream property, final String entryType)
-      throws ODataDeserializerException {
+  public Property readProperty(final Accept accept, final InputStream property) throws ODataDeserializerException {
     return (Accept.ATOM == accept || Accept.XML == accept ?
         atomDeserializer.toProperty(property) : jsonDeserializer.toProperty(property))
         .getPayload();
@@ -611,14 +607,14 @@ public abstract class AbstractUtilities {
   }
 
   private String getDefaultEntryKey(final String entitySetName, final Entity entry, final String propertyName)
-      throws Exception {
+      throws IOException {
 
     String res;
     if (entry.getProperty(propertyName) == null) {
       if (Commons.SEQUENCE.containsKey(entitySetName)) {
         res = String.valueOf(Commons.SEQUENCE.get(entitySetName) + 1);
       } else {
-        throw new Exception(String.format("Unable to retrieve entity key value for %s", entitySetName));
+        throw new IOException(String.format("Unable to retrieve entity key value for %s", entitySetName));
       }
     } else {
       res = entry.getProperty(propertyName).getValue().asPrimitive().get();
@@ -639,7 +635,7 @@ public abstract class AbstractUtilities {
             productID = Commons.SEQUENCE.get(entitySetName) + 1;
             res = "OrderID=1" + ",ProductID=" + String.valueOf(productID);
           } else {
-            throw new Exception(String.format("Unable to retrieve entity key value for %s", entitySetName));
+            throw new IOException(String.format("Unable to retrieve entity key value for %s", entitySetName));
           }
         } else {
           productID = Integer.valueOf(entity.getProperty("OrderID").getValue().asPrimitive().get());
@@ -654,7 +650,7 @@ public abstract class AbstractUtilities {
             messageId = Commons.SEQUENCE.get(entitySetName) + 1;
             res = "FromUsername=1" + ",MessageId=" + String.valueOf(messageId);
           } else {
-            throw new Exception(String.format("Unable to retrieve entity key value for %s", entitySetName));
+            throw new IOException(String.format("Unable to retrieve entity key value for %s", entitySetName));
           }
         } else {
           messageId = Integer.valueOf(entity.getProperty("MessageId").getValue().asPrimitive().get());
@@ -697,7 +693,7 @@ public abstract class AbstractUtilities {
             productDetailId = Commons.SEQUENCE.get(entitySetName) + 1;
             res = "ProductID=" + String.valueOf(productId) + ",ProductDetailID=" + String.valueOf(productDetailId);
           } else {
-            throw new Exception(String.format("Unable to retrieve entity key value for %s", entitySetName));
+            throw new IOException(String.format("Unable to retrieve entity key value for %s", entitySetName));
           }
           Commons.SEQUENCE.put(entitySetName, productDetailId);
         } else {
@@ -715,7 +711,7 @@ public abstract class AbstractUtilities {
       } else if ("People".equals(entitySetName)) {
         res = getDefaultEntryKey(entitySetName, entity, "PersonID");
       } else {
-        throw new Exception(String.format("EntitySet '%s' not found", entitySetName));
+        throw new IOException(String.format("EntitySet '%s' not found", entitySetName));
       }
 
       return res;
@@ -740,7 +736,7 @@ public abstract class AbstractUtilities {
    */
   public LinkInfo readLinks(
       final String entitySetName, final String entityId, final String linkName, final Accept accept)
-      throws Exception {
+          throws Exception {
 
     final String basePath = getLinksBasePath(entitySetName, entityId);
 
@@ -857,9 +853,11 @@ public abstract class AbstractUtilities {
       throws Exception;
 
   protected abstract InputStream replaceLink(
-      final InputStream toBeChanged, final String linkName, final InputStream replacement) throws Exception;
+      final InputStream toBeChanged, final String linkName, final InputStream replacement)
+          throws Exception;
 
-  public abstract InputStream selectEntity(final InputStream entity, final String[] propertyNames) throws Exception;
+  public abstract InputStream selectEntity(final InputStream entity, final String[] propertyNames)
+      throws Exception;
 
   protected abstract Accept getDefaultFormat();
 
@@ -869,16 +867,20 @@ public abstract class AbstractUtilities {
       final InputStream content, final String title, final String href) throws Exception;
 
   public abstract InputStream addOperation(
-      final InputStream content, final String name, final String metaAnchor, final String href) throws Exception;
+      final InputStream content, final String name, final String metaAnchor, final String href)
+      throws Exception;
 
   protected abstract InputStream replaceProperty(
       final InputStream src, final InputStream replacement, final List<String> path, final boolean justValue)
       throws Exception;
 
-  protected abstract InputStream deleteProperty(final InputStream src, final List<String> path) throws Exception;
+  protected abstract InputStream deleteProperty(final InputStream src, final List<String> path)
+      throws Exception;
 
-  public abstract Map.Entry<String, List<String>> extractLinkURIs(final InputStream is) throws Exception;
+  public abstract Map.Entry<String, List<String>> extractLinkURIs(final InputStream is)
+      throws Exception;
 
   public abstract Map.Entry<String, List<String>> extractLinkURIs(
-      final String entitySetName, final String entityId, final String linkName) throws Exception;
+      final String entitySetName, final String entityId, final String linkName)
+          throws Exception;
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/fit/src/main/java/org/apache/olingo/fit/utils/Commons.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/Commons.java b/fit/src/main/java/org/apache/olingo/fit/utils/Commons.java
index c9f4128..16d984c 100644
--- a/fit/src/main/java/org/apache/olingo/fit/utils/Commons.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/Commons.java
@@ -122,20 +122,13 @@ public abstract class Commons {
             + (StringUtils.isNotBlank(entityKey) ? getEntityKey(entityKey) + File.separatorChar : "");
   }
 
-  public static String getLinksURI(
-          final ODataServiceVersion version,
-          final String entitySetName,
-          final String entityId,
-          final String linkName) throws IOException {
+  public static String getLinksURI(final String entitySetName, final String entityId, final String linkName)
+      throws IOException {
     return getEntityURI(entitySetName, entityId) + "/" + linkName;
   }
 
-  public static String getLinksPath(
-          final ODataServiceVersion version,
-          final String entitySetName,
-          final String entityId,
-          final String linkName,
-          final Accept accept) throws IOException {
+  public static String getLinksPath(final String entitySetName, final String entityId,
+      final String linkName, final Accept accept) throws IOException {
     return getLinksPath(ODataServiceVersion.V30, getEntityBasePath(entitySetName, entityId), linkName, accept);
 
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/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 374d0f5..650a98f 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
@@ -65,14 +65,14 @@ public class FSManager {
 
   private final ODataServiceVersion version;
 
-  public static FSManager instance(final ODataServiceVersion version) throws Exception {
+  public static FSManager instance(final ODataServiceVersion version) throws IOException {
     if (!instance.containsKey(version)) {
       instance.put(version, new FSManager(version));
     }
     return instance.get(version);
   }
 
-  private FSManager(final ODataServiceVersion version) throws Exception {
+  private FSManager(final ODataServiceVersion version) throws IOException {
     this.version = version;
     fsManager = VFS.getManager();
 
@@ -150,15 +150,15 @@ public class FSManager {
     try {
       final FileObject fileObject = fsManager.resolveFile(fs + path);
 
-      if (!fileObject.exists()) {
+      if (fileObject.exists()) {
+        // return new in-memory content
+        return fileObject.getContent().getInputStream();
+      } else {
         LOG.warn("In-memory path '{}' not found", path);
         throw new NotFoundException();
       }
-
-      // return new in-memory content
-      return fileObject.getContent().getInputStream();
-    } catch (IOException e) {
-      throw new NotFoundException(e);
+    } catch (FileSystemException e) {
+      throw new NotFoundException();
     }
   }
 
@@ -227,4 +227,4 @@ public class FSManager {
       }
     });
   }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/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 fe3f511..23a95cd 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
@@ -20,6 +20,7 @@ package org.apache.olingo.fit.utils;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 import java.io.InputStream;
 import java.util.AbstractMap.SimpleEntry;
 import java.util.ArrayList;
@@ -73,21 +74,21 @@ public class JSONUtilities extends AbstractUtilities {
   @Override
   protected InputStream addLinks(
           final String entitySetName, final String entitykey, final InputStream is, final Set<String> links)
-          throws Exception {
+          throws IOException {
 
     final ObjectNode srcNode = (ObjectNode) mapper.readTree(is);
     IOUtils.closeQuietly(is);
 
     for (String link : links) {
       srcNode.set(link + Constants.get(version, ConstantKey.JSON_NAVIGATION_SUFFIX),
-              new TextNode(Commons.getLinksURI(version, entitySetName, entitykey, link)));
+              new TextNode(Commons.getLinksURI(entitySetName, entitykey, link)));
     }
 
     return IOUtils.toInputStream(srcNode.toString(), Constants.ENCODING);
   }
 
   @Override
-  protected Set<String> retrieveAllLinkNames(InputStream is) throws Exception {
+  protected Set<String> retrieveAllLinkNames(InputStream is) throws IOException {
     final ObjectNode srcNode = (ObjectNode) mapper.readTree(is);
     IOUtils.closeQuietly(is);
 
@@ -115,7 +116,7 @@ public class JSONUtilities extends AbstractUtilities {
 
   @Override
   protected NavigationLinks retrieveNavigationInfo(final String entitySetName, final InputStream is)
-          throws Exception {
+          throws IOException {
 
     final ObjectNode srcNode = (ObjectNode) mapper.readTree(is);
     IOUtils.closeQuietly(is);
@@ -150,13 +151,10 @@ public class JSONUtilities extends AbstractUtilities {
     return links;
   }
 
-  /**
-   * {@inheritDoc }
-   */
   @Override
   protected InputStream normalizeLinks(
           final String entitySetName, final String entityKey, final InputStream is, final NavigationLinks links)
-          throws Exception {
+          throws IOException {
 
     final ObjectNode srcNode = (ObjectNode) mapper.readTree(is);
 
@@ -191,9 +189,7 @@ public class JSONUtilities extends AbstractUtilities {
     return IOUtils.toInputStream(srcNode.toString(), Constants.ENCODING);
   }
 
-  public InputStream addJsonInlinecount(
-          final InputStream src, final int count, final Accept accept)
-          throws Exception {
+  public InputStream addJsonInlinecount(final InputStream src, final int count) throws Exception {
 
     final JsonNode srcNode = mapper.readTree(src);
 
@@ -208,7 +204,7 @@ public class JSONUtilities extends AbstractUtilities {
     return res;
   }
 
-  public InputStream wrapJsonEntities(final InputStream entities) throws Exception {
+  public InputStream wrapJsonEntities(final InputStream entities) throws IOException {
 
     final JsonNode node = mapper.readTree(entities);
 
@@ -237,7 +233,7 @@ public class JSONUtilities extends AbstractUtilities {
   }
 
   @Override
-  public InputStream selectEntity(final InputStream src, final String[] propertyNames) throws Exception {
+  public InputStream selectEntity(final InputStream src, final String[] propertyNames) throws IOException {
 
     final ObjectNode srcNode = (ObjectNode) mapper.readTree(src);
 
@@ -264,7 +260,7 @@ public class JSONUtilities extends AbstractUtilities {
   @Override
   public InputStream readEntities(
           final List<String> links, final String linkName, final String next, final boolean forceFeed)
-          throws Exception {
+          throws IOException {
 
     if (links.isEmpty()) {
       throw new NotFoundException();
@@ -312,7 +308,7 @@ public class JSONUtilities extends AbstractUtilities {
   @Override
   protected InputStream replaceLink(
           final InputStream toBeChanged, final String linkName, final InputStream replacement)
-          throws Exception {
+          throws IOException {
 
     final ObjectNode toBeChangedNode = (ObjectNode) mapper.readTree(toBeChanged);
     final ObjectNode replacementNode = (ObjectNode) mapper.readTree(replacement);
@@ -332,7 +328,7 @@ public class JSONUtilities extends AbstractUtilities {
   }
 
   @Override
-  protected Map<String, InputStream> getChanges(final InputStream src) throws Exception {
+  protected Map<String, InputStream> getChanges(final InputStream src) throws IOException {
     final Map<String, InputStream> res = new HashMap<String, InputStream>();
 
     final JsonNode srcObject = mapper.readTree(src);
@@ -348,15 +344,13 @@ public class JSONUtilities extends AbstractUtilities {
 
   @Override
   public Map.Entry<String, List<String>> extractLinkURIs(
-          final String entitySetName, final String entityId, final String linkName)
-          throws Exception {
+          final String entitySetName, final String entityId, final String linkName) throws Exception {
     final LinkInfo links = readLinks(entitySetName, entityId, linkName, Accept.JSON_FULLMETA);
     return extractLinkURIs(links.getLinks());
   }
 
   @Override
-  public Map.Entry<String, List<String>> extractLinkURIs(final InputStream is)
-          throws Exception {
+  public Map.Entry<String, List<String>> extractLinkURIs(final InputStream is) throws IOException {
 
     final ObjectNode srcNode = (ObjectNode) mapper.readTree(is);
     IOUtils.closeQuietly(is);
@@ -383,7 +377,7 @@ public class JSONUtilities extends AbstractUtilities {
 
   @Override
   public InputStream addEditLink(
-          final InputStream content, final String title, final String href) throws Exception {
+          final InputStream content, final String title, final String href) throws IOException {
 
     final ObjectNode srcNode = (ObjectNode) mapper.readTree(content);
     IOUtils.closeQuietly(content);
@@ -394,7 +388,7 @@ public class JSONUtilities extends AbstractUtilities {
 
   @Override
   public InputStream addOperation(final InputStream content, final String name, final String metaAnchor,
-          final String href) throws Exception {
+          final String href) throws IOException {
 
     final ObjectNode srcNode = (ObjectNode) mapper.readTree(content);
     IOUtils.closeQuietly(content);
@@ -410,7 +404,7 @@ public class JSONUtilities extends AbstractUtilities {
   @Override
   public InputStream replaceProperty(
           final InputStream src, final InputStream replacement, final List<String> path, final boolean justValue)
-          throws Exception {
+          throws IOException {
 
     final ObjectNode srcNode = (ObjectNode) mapper.readTree(src);
     IOUtils.closeQuietly(src);
@@ -440,7 +434,7 @@ public class JSONUtilities extends AbstractUtilities {
   }
 
   @Override
-  public InputStream deleteProperty(final InputStream src, final List<String> path) throws Exception {
+  public InputStream deleteProperty(final InputStream src, final List<String> path) throws IOException {
 
     final ObjectNode srcNode = (ObjectNode) mapper.readTree(src);
     IOUtils.closeQuietly(src);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/fit/src/main/java/org/apache/olingo/fit/utils/XMLElement.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/XMLElement.java b/fit/src/main/java/org/apache/olingo/fit/utils/XMLElement.java
index b412ba3..c8a0ee8 100644
--- a/fit/src/main/java/org/apache/olingo/fit/utils/XMLElement.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/XMLElement.java
@@ -24,10 +24,12 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
+
 import javax.xml.stream.XMLEventReader;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.events.EndElement;
 import javax.xml.stream.events.StartElement;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.slf4j.Logger;
@@ -66,7 +68,8 @@ public class XMLElement {
     return new ByteArrayInputStream(content.toByteArray());
   }
 
-  public XMLEventReader getContentReader(final ODataServiceVersion version) throws Exception {
+  public XMLEventReader getContentReader(final ODataServiceVersion version)
+      throws XMLStreamException, IOException {
     return new XMLEventReaderWrapper(getContent(), version);
   }
 
@@ -83,7 +86,7 @@ public class XMLElement {
     IOUtils.closeQuietly(content);
   }
 
-  public InputStream toStream() throws Exception {
+  public InputStream toStream() {
     InputStream res;
     try {
       final ByteArrayOutputStream bos = new ByteArrayOutputStream();
@@ -98,7 +101,10 @@ public class XMLElement {
       osw.close();
 
       res = new ByteArrayInputStream(bos.toByteArray());
-    } catch (Exception e) {
+    } catch (IOException e) {
+      LOG.error("Error serializing element", e);
+      res = null;
+    } catch (XMLStreamException e) {
       LOG.error("Error serializing element", e);
       res = null;
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/fit/src/main/java/org/apache/olingo/fit/utils/XMLEventReaderWrapper.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/XMLEventReaderWrapper.java b/fit/src/main/java/org/apache/olingo/fit/utils/XMLEventReaderWrapper.java
index 7bae6d8..1774f0c 100644
--- a/fit/src/main/java/org/apache/olingo/fit/utils/XMLEventReaderWrapper.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/XMLEventReaderWrapper.java
@@ -19,13 +19,16 @@
 package org.apache.olingo.fit.utils;
 
 import java.io.ByteArrayInputStream;
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.nio.charset.Charset;
+
 import javax.xml.stream.XMLEventReader;
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.events.XMLEvent;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 
@@ -43,7 +46,8 @@ public class XMLEventReaderWrapper implements XMLEventReader {
 
   private XMLEvent nextGivenEvent = null;
 
-  public XMLEventReaderWrapper(final InputStream stream, final ODataServiceVersion version) throws Exception {
+  public XMLEventReaderWrapper(final InputStream stream, final ODataServiceVersion version)
+      throws IOException, XMLStreamException {
     final StringBuilder startBuilder = new StringBuilder();
     startBuilder.append("<").append(CONTENT).
             append(" xmlns:m").append("=\"").append(Constants.get(version, ConstantKey.METADATA_NS)).append("\"").

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java b/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java
index 84a6cd2..f5ba1c1 100644
--- a/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java
@@ -155,7 +155,7 @@ public class XMLUtilities extends AbstractUtilities {
       final Set<Attribute> attributes = new HashSet<Attribute>();
       attributes.add(eventFactory.createAttribute(new QName("title"), link));
       attributes.add(eventFactory.createAttribute(new QName("href"),
-              Commons.getLinksURI(version, entitySetName, entitykey, link)));
+              Commons.getLinksURI(entitySetName, entitykey, link)));
       attributes.add(eventFactory.createAttribute(new QName("rel"),
               Constants.get(version, ConstantKey.ATOM_LINK_REL) + link));
       attributes.add(eventFactory.createAttribute(new QName("type"),
@@ -727,9 +727,7 @@ public class XMLUtilities extends AbstractUtilities {
     return new SimpleEntry<Integer, XMLElement>(Integer.valueOf(depth - 1), getXmlElement(start, reader));
   }
 
-  public InputStream addAtomInlinecount(
-          final InputStream feed, final int count, final Accept accept)
-          throws Exception {
+  public InputStream addAtomInlinecount(final InputStream feed, final int count) throws Exception {
     final XMLEventReader reader = getEventReader(feed);
 
     final ByteArrayOutputStream bos = new ByteArrayOutputStream();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/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 da9b40f..d86f599 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
@@ -50,12 +50,12 @@ public abstract class AbstractRequest {
     // If using and Edm enabled client, checks that the cached service root matches the request URI
     if (odataClient instanceof CommonEdmEnabledODataClient
         && !request.getURI().toASCIIString().startsWith(
-            ((CommonEdmEnabledODataClient) odataClient).getServiceRoot())) {
+            ((CommonEdmEnabledODataClient<?>) odataClient).getServiceRoot())) {
 
       throw new IllegalArgumentException(
           String.format("The current request URI %s does not match the configured service root %s",
               request.getURI().toASCIIString(),
-              ((CommonEdmEnabledODataClient) odataClient).getServiceRoot()));
+              ((CommonEdmEnabledODataClient<?>) odataClient).getServiceRoot()));
     }
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/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 10236e0..67a6950 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
@@ -28,17 +28,16 @@ import org.apache.http.client.methods.HttpPost;
 import org.apache.olingo.client.api.CommonODataClient;
 import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
 import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
-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.client.api.http.HttpClientException;
 import org.apache.olingo.client.api.http.HttpMethod;
-import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
 import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
-import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.client.core.uri.URIUtils;
 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;
 
 /**
  * This class implements an OData create request.
@@ -74,7 +73,7 @@ public class ODataEntityCreateRequestImpl<E extends CommonODataEntity>
     try {
       return odataClient.getWriter().writeEntity(entity, ODataPubFormat.fromString(getContentType()));
     } catch (final ODataSerializerException e) {
-      throw new HttpClientException(e);
+      throw new IllegalArgumentException(e);
     }
   }
 
@@ -132,7 +131,7 @@ public class ODataEntityCreateRequestImpl<E extends CommonODataEntity>
           
           entity = (E) odataClient.getBinder().getODataEntity(resource);
         } catch (final ODataDeserializerException e) {
-          throw new HttpClientException(e);
+          throw new IllegalArgumentException(e);
         } finally {
           this.close();
         }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/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 acbe764..1165042 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
@@ -28,17 +28,16 @@ import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
 import org.apache.olingo.client.api.CommonODataClient;
 import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
 import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
-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.client.api.http.HttpClientException;
 import org.apache.olingo.client.api.http.HttpMethod;
-import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
 import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
-import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.client.core.uri.URIUtils;
 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;
 
 /**
  * This class implements an OData update request.
@@ -89,7 +88,7 @@ public class ODataEntityUpdateRequestImpl<E extends CommonODataEntity>
     try {
       return odataClient.getWriter().writeEntity(changes, ODataPubFormat.fromString(getContentType()));
     } catch (final ODataSerializerException e) {
-      throw new HttpClientException(e);
+      throw new IllegalArgumentException(e);
     }
   }
 
@@ -130,7 +129,7 @@ public class ODataEntityUpdateRequestImpl<E extends CommonODataEntity>
 
           entity = (E) odataClient.getBinder().getODataEntity(resource);
         } catch (final ODataDeserializerException e) {
-          throw new HttpClientException(e);
+          throw new IllegalArgumentException(e);
         } finally {
           this.close();
         }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/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 759ebbb..5f9014d 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
@@ -28,7 +28,6 @@ import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
 import org.apache.olingo.client.api.CommonODataClient;
 import org.apache.olingo.client.api.communication.request.cud.ODataPropertyUpdateRequest;
 import org.apache.olingo.client.api.communication.response.ODataPropertyUpdateResponse;
-import org.apache.olingo.client.api.http.HttpClientException;
 import org.apache.olingo.client.api.http.HttpMethod;
 import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
 import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
@@ -84,7 +83,7 @@ public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest<OD
     try {
       return odataClient.getWriter().writeProperty(property, ODataFormat.fromString(getContentType()));
     } catch (final ODataSerializerException e) {
-      throw new HttpClientException(e);
+      throw new IllegalArgumentException(e);
     }
   }
 
@@ -122,7 +121,7 @@ public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest<OD
 
           property = odataClient.getBinder().getODataProperty(resource);
         } catch (final ODataDeserializerException e) {
-          throw new HttpClientException(e);
+          throw new IllegalArgumentException(e);
         } finally {
           this.close();
         }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/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 df31813..293908a 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
@@ -28,14 +28,13 @@ import org.apache.http.client.methods.HttpPost;
 import org.apache.olingo.client.api.CommonODataClient;
 import org.apache.olingo.client.api.communication.request.cud.v3.ODataLinkCreateRequest;
 import org.apache.olingo.client.api.communication.response.ODataLinkOperationResponse;
-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.client.api.http.HttpClientException;
 import org.apache.olingo.client.api.http.HttpMethod;
-import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
 import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
+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;
 
 /**
  * This class implements an insert link OData request.
@@ -81,7 +80,7 @@ public class ODataLinkCreateRequestImpl extends AbstractODataBasicRequest<ODataL
     try {
       return odataClient.getWriter().writeLink(link, ODataFormat.fromString(getContentType()));
     } catch (final ODataSerializerException e) {
-      throw new HttpClientException(e);
+      throw new IllegalArgumentException(e);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/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 ae1756c..5392ac6 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
@@ -28,14 +28,13 @@ import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
 import org.apache.olingo.client.api.CommonODataClient;
 import org.apache.olingo.client.api.communication.request.cud.v3.ODataLinkUpdateRequest;
 import org.apache.olingo.client.api.communication.response.ODataLinkOperationResponse;
-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.client.api.http.HttpClientException;
 import org.apache.olingo.client.api.http.HttpMethod;
-import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
 import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
+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;
 
 /**
  * This class implements an update link OData request.
@@ -81,7 +80,7 @@ public class ODataLinkUpdateRequestImpl extends AbstractODataBasicRequest<ODataL
     try {
       return odataClient.getWriter().writeLink(link, ODataFormat.fromString(getContentType()));
     } catch (final ODataSerializerException e) {
-      throw new HttpClientException(e);
+      throw new IllegalArgumentException(e);
     }
   }
 
@@ -92,14 +91,6 @@ public class ODataLinkUpdateRequestImpl extends AbstractODataBasicRequest<ODataL
 
     /**
      * Constructor.
-     * <p>
-     * Just to create response templates to be initialized from batch.
-     */
-    private ODataLinkUpdateResponseImpl() {
-    }
-
-    /**
-     * Constructor.
      *
      * @param client HTTP client.
      * @param res HTTP response.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/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 8ecd827..7fcaa65 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
@@ -34,21 +34,21 @@ import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
 import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest;
 import org.apache.olingo.client.api.communication.request.invoke.ODataNoContent;
 import org.apache.olingo.client.api.communication.response.ODataInvokeResponse;
+import org.apache.olingo.client.api.http.HttpClientException;
+import org.apache.olingo.client.api.http.HttpMethod;
+import org.apache.olingo.client.api.v4.ODataClient;
+import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
+import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
+import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.commons.api.domain.CommonODataEntity;
 import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
-import org.apache.olingo.commons.api.domain.ODataInvokeResult;
 import org.apache.olingo.commons.api.domain.CommonODataProperty;
+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.client.api.http.HttpClientException;
-import org.apache.olingo.client.api.http.HttpMethod;
-import org.apache.olingo.client.api.v4.ODataClient;
-import org.apache.olingo.client.core.uri.URIUtils;
-import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
-import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
 
 /**
  * This class implements an OData invoke operation request.
@@ -143,7 +143,7 @@ public abstract class AbstractODataInvokeRequest<T extends ODataInvokeResult>
       try {
         return odataClient.getWriter().writeEntity(tmp, getPOSTParameterFormat());
       } catch (final ODataSerializerException e) {
-        throw new HttpClientException(e);
+        throw new IllegalArgumentException(e);
       }
     }
 
@@ -228,7 +228,7 @@ public abstract class AbstractODataInvokeRequest<T extends ODataInvokeResult>
         } catch (IOException e) {
           throw new HttpClientException(e);
         } catch (final ODataDeserializerException e) {
-          throw new HttpClientException(e);
+          throw new IllegalArgumentException(e);
         } finally {
           this.close();
         }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/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 2904577..cecbcd1 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
@@ -25,9 +25,8 @@ import org.apache.http.client.HttpClient;
 import org.apache.olingo.client.api.CommonODataClient;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
 import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
-import org.apache.olingo.client.api.http.HttpClientException;
-import org.apache.olingo.commons.api.data.ResWrap;
 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;
@@ -89,7 +88,7 @@ public class ODataEntityRequestImpl<E extends CommonODataEntity>
 
           entity = (E) odataClient.getBinder().getODataEntity(resource);
         } catch (final ODataDeserializerException e) {
-          throw new HttpClientException(e);
+          throw new IllegalArgumentException(e);
         } finally {
           this.close();
         }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/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 90df1e2..6e7df50 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
@@ -25,9 +25,8 @@ import org.apache.http.client.HttpClient;
 import org.apache.olingo.client.api.CommonODataClient;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
 import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
-import org.apache.olingo.client.api.http.HttpClientException;
-import org.apache.olingo.commons.api.data.ResWrap;
 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;
@@ -98,7 +97,7 @@ public class ODataEntitySetRequestImpl<ES extends CommonODataEntitySet>
 
           entitySet = (ES) odataClient.getBinder().getODataEntitySet(resource);
         } catch (final ODataDeserializerException e) {
-          throw new HttpClientException(e);
+          throw new IllegalArgumentException(e);
         } finally {
           this.close();
         }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/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 0be7920..c409d99 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
@@ -89,7 +89,7 @@ public class ODataPropertyRequestImpl<T extends CommonODataProperty>
         } catch (IOException e) {
           throw new HttpClientException(e);
         } catch (final ODataDeserializerException e) {
-          throw new HttpClientException(e);
+          throw new IllegalArgumentException(e);
         } finally {
           this.close();
         }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/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 faa8a28..b2632b7 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
@@ -28,13 +28,12 @@ import org.apache.http.client.HttpClient;
 import org.apache.olingo.client.api.CommonODataClient;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataRawRequest;
 import org.apache.olingo.client.api.communication.response.ODataRawResponse;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
-import org.apache.olingo.client.api.http.HttpClientException;
 import org.apache.olingo.client.api.http.HttpMethod;
 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;
 
 /**
  * This class implements a generic OData request.
@@ -101,7 +100,7 @@ public class ODataRawRequestImpl extends AbstractODataRequest<ODataPubFormat>
         return odataClient.getReader().
                 read(new ByteArrayInputStream(obj), getContentType(), reference);
       } catch (final ODataDeserializerException e) {
-        throw new HttpClientException(e);
+        throw new IllegalArgumentException(e);
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/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 b8605f9..cd11e91 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
@@ -26,7 +26,6 @@ import org.apache.olingo.client.api.CommonODataClient;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataServiceDocumentRequest;
 import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
 import org.apache.olingo.client.api.data.ServiceDocument;
-import org.apache.olingo.client.api.http.HttpClientException;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.domain.ODataServiceDocument;
 import org.apache.olingo.commons.api.format.ODataFormat;
@@ -91,7 +90,7 @@ public class ODataServiceDocumentRequestImpl extends AbstractODataRetrieveReques
 
           serviceDocument = odataClient.getBinder().getODataServiceDocument(resource.getPayload());
         } catch (final ODataDeserializerException e) {
-          throw new HttpClientException(e);
+          throw new IllegalArgumentException(e);
         } finally {
           this.close();
         }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/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 9cd5419..8c5ef8c 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
@@ -89,7 +89,7 @@ public class ODataLinkCollectionRequestImpl extends AbstractODataRetrieveRequest
         } catch (IOException e) {
           throw new HttpClientException(e);
         } catch (final ODataDeserializerException e) {
-          throw new HttpClientException(e);
+          throw new IllegalArgumentException(e);
         } finally {
           this.close();
         }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/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 00a61cc..41708b9 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
@@ -74,7 +74,7 @@ public class ODataDeltaRequestImpl extends AbstractODataRetrieveRequest<ODataDel
         } catch (IOException e) {
           throw new HttpClientException(e);
         } catch (final ODataDeserializerException e) {
-          throw new HttpClientException(e);
+          throw new IllegalArgumentException(e);
         } finally {
           this.close();
         }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/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 4e27bea..d669129 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
@@ -28,13 +28,12 @@ import org.apache.olingo.client.api.CommonODataClient;
 import org.apache.olingo.client.api.communication.request.streamed.MediaEntityCreateStreamManager;
 import org.apache.olingo.client.api.communication.request.streamed.ODataMediaEntityCreateRequest;
 import org.apache.olingo.client.api.communication.response.ODataMediaEntityCreateResponse;
-import org.apache.olingo.commons.api.domain.CommonODataEntity;
-import org.apache.olingo.client.api.http.HttpClientException;
 import org.apache.olingo.client.api.http.HttpMethod;
 import org.apache.olingo.client.core.communication.request.AbstractODataStreamManager;
 import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
-import org.apache.olingo.commons.api.data.ResWrap;
 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;
 
 /**
@@ -128,7 +127,7 @@ public class ODataMediaEntityCreateRequestImpl<E extends CommonODataEntity>
 
           entity = (E) odataClient.getBinder().getODataEntity(resource);
         } catch (final ODataDeserializerException e) {
-          throw new HttpClientException(e);
+          throw new IllegalArgumentException(e);
         } finally {
           this.close();
         }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/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 f06bed2..87a6fdb 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
@@ -28,13 +28,12 @@ import org.apache.olingo.client.api.CommonODataClient;
 import org.apache.olingo.client.api.communication.request.streamed.MediaEntityUpdateStreamManager;
 import org.apache.olingo.client.api.communication.request.streamed.ODataMediaEntityUpdateRequest;
 import org.apache.olingo.client.api.communication.response.ODataMediaEntityUpdateResponse;
-import org.apache.olingo.commons.api.domain.CommonODataEntity;
-import org.apache.olingo.client.api.http.HttpClientException;
 import org.apache.olingo.client.api.http.HttpMethod;
 import org.apache.olingo.client.core.communication.request.AbstractODataStreamManager;
 import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
-import org.apache.olingo.commons.api.data.ResWrap;
 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;
 
 /**
@@ -129,7 +128,7 @@ public class ODataMediaEntityUpdateRequestImpl<E extends CommonODataEntity>
 
           entity = (E) odataClient.getBinder().getODataEntity(resource);
         } catch (final ODataDeserializerException e) {
-          throw new HttpClientException(e);
+          throw new IllegalArgumentException(e);
         } finally {
           this.close();
         }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/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
index 5b0376b..1327e43 100644
--- 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
@@ -347,23 +347,23 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
       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 (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) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/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
index d238a75..348d524 100644
--- 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
@@ -36,14 +36,15 @@ 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 Format format) {
-    super(version, format);
+  public ODataDeserializerImpl(final ODataServiceVersion version, final boolean serverMode, final Format format) {
+    super(version, serverMode, format);
     this.format = format;
   }
 
@@ -68,7 +69,7 @@ public class ODataDeserializerImpl extends AbstractODataDeserializer implements
     try {
       return format == ODataFormat.XML ?
           new AtomDeserializer(version).linkCollection(input) :
-          null; //json(input, LinkCollection.class);
+          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/70afb2ac/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
index 0d3631a..9151b74 100644
--- 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
@@ -279,15 +279,14 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
 
   @Override
   public ODataProperty getODataProperty(final ResWrap<Property> resource) {
+    final Property payload = resource.getPayload();
     final EdmTypeInfo typeInfo = buildTypeInfo(resource.getContextURL(), resource.getMetadataETag(),
-            resource.getPayload().getName(), resource.getPayload().getType());
+        payload.getName(), payload.getType());
 
-    final ODataProperty property = new ODataPropertyImpl(resource.getPayload().getName(),
-            getODataValue(typeInfo == null
-                    ? null
-                    : typeInfo.getFullQualifiedName(),
-                    resource.getPayload(), resource.getContextURL(), resource.getMetadataETag()));
-    odataAnnotations(resource.getPayload(), property);
+    final ODataProperty property = new ODataPropertyImpl(payload.getName(),
+        getODataValue(typeInfo == null ? null : typeInfo.getFullQualifiedName(),
+            payload, resource.getContextURL(), resource.getMetadataETag()));
+    odataAnnotations(payload, property);
 
     return property;
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/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
index 445db39..61e6ac6 100644
--- 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
@@ -44,8 +44,8 @@ public class ODataDeserializerImpl extends AbstractODataDeserializer implements
 
   private final Format format;
 
-  public ODataDeserializerImpl(final ODataServiceVersion version, final Format format) {
-    super(version, format);
+  public ODataDeserializerImpl(final ODataServiceVersion version, final boolean serverMode, final Format format) {
+    super(version, serverMode, format);
     this.format = format;
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/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 2042a9a..a0813eb 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
@@ -104,7 +104,7 @@ public class ODataClientImpl extends AbstractODataClient<UpdateType> implements
 
   @Override
   public ODataDeserializer getDeserializer(final Format format) {
-    return new ODataDeserializerImpl(getServiceVersion(), format);
+    return new ODataDeserializerImpl(getServiceVersion(), false, format);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/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 9f38353..4907a0b 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
@@ -115,7 +115,7 @@ public class ODataClientImpl extends AbstractODataClient<UpdateType> implements
 
   @Override
   public ODataDeserializer getDeserializer(final Format format) {
-    return new ODataDeserializerImpl(getServiceVersion(), format);
+    return new ODataDeserializerImpl(getServiceVersion(), false, format);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractAnnotatedObject.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractAnnotatedObject.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractAnnotatedObject.java
index 6383c80..a265f5c 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractAnnotatedObject.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractAnnotatedObject.java
@@ -20,12 +20,15 @@ package org.apache.olingo.commons.core.data;
 
 import java.util.ArrayList;
 import java.util.List;
+
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
 import org.apache.olingo.commons.api.data.Annotatable;
 import org.apache.olingo.commons.api.data.Annotation;
 
-public abstract class AbstractAnnotatedObject extends AbstractPayloadObject implements Annotatable {
-
-  private static final long serialVersionUID = 4163841499530412213L;
+public abstract class AbstractAnnotatedObject implements Annotatable {
 
   private final List<Annotation> annotations = new ArrayList<Annotation>();
 
@@ -34,4 +37,18 @@ public abstract class AbstractAnnotatedObject extends AbstractPayloadObject impl
     return annotations;
   }
 
+  @Override
+  public boolean equals(final Object obj) {
+    return EqualsBuilder.reflectionEquals(this, obj);
+  }
+
+  @Override
+  public int hashCode() {
+    return HashCodeBuilder.reflectionHashCode(this);
+  }
+
+  @Override
+  public String toString() {
+    return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractODataObject.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractODataObject.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractODataObject.java
index b3eb7f9..e768417 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractODataObject.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractODataObject.java
@@ -21,14 +21,10 @@ package org.apache.olingo.commons.core.data;
 import java.net.URI;
 import java.text.ParseException;
 
-abstract class AbstractODataObject extends AbstractAnnotatedObject {
-
-  private static final long serialVersionUID = -4391162864875546927L;
+public abstract class AbstractODataObject extends AbstractAnnotatedObject {
 
   private URI baseURI;
-
   private URI id;
-
   private String title;
 
   public URI getBaseURI() {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractPayloadObject.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractPayloadObject.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractPayloadObject.java
deleted file mode 100644
index bad009d..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractPayloadObject.java
+++ /dev/null
@@ -1,48 +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.Serializable;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
-
-/**
- * Abstract representation of a payload (Atom, JSON) object.
- */
-public abstract class AbstractPayloadObject implements Serializable {
-
-  private static final long serialVersionUID = 1634654241914156675L;
-
-  @Override
-  public boolean equals(final Object obj) {
-    return EqualsBuilder.reflectionEquals(this, obj);
-  }
-
-  @Override
-  public int hashCode() {
-    return HashCodeBuilder.reflectionHashCode(this);
-  }
-
-  @Override
-  public String toString() {
-    return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AnnotationImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AnnotationImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AnnotationImpl.java
index e6a277e..626c00e 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AnnotationImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AnnotationImpl.java
@@ -23,12 +23,8 @@ import org.apache.olingo.commons.api.data.Value;
 
 public class AnnotationImpl extends AbstractAnnotatedObject implements Annotation {
 
-  private static final long serialVersionUID = -2532246000091187020L;
-
   private String term;
-
   private String type;
-
   private Value value;
 
   @Override


[18/23] [OLINGO-317] Rename and move of some packages and classes

Posted by ch...@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;
-  }
-
-}


[22/23] git commit: [OLINGO-326] URIbuilder issue on android, and uri format issue of addressing derived types

Posted by ch...@apache.org.
[OLINGO-326] URIbuilder issue on android, and uri format issue of addressing derived types


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

Branch: refs/heads/clientjune
Commit: 1e8ad44a00ad68a63b2996582096621c887b3f19
Parents: b15439f
Author: challenh <ch...@microsoft.com>
Authored: Tue Jun 17 10:32:44 2014 +0800
Committer: challenh <ch...@microsoft.com>
Committed: Tue Jun 17 10:32:44 2014 +0800

----------------------------------------------------------------------
 .../olingo/ext/proxy/commons/FilterImpl.java    | 10 +++--
 .../olingo/client/api/CommonConfiguration.java  | 25 ++++++++++++
 .../client/core/AbstractConfiguration.java      | 12 ++++++
 .../client/core/uri/AbstractURIBuilder.java     | 41 +++++++++++++-------
 4 files changed, 71 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1e8ad44a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/FilterImpl.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/FilterImpl.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/FilterImpl.java
index 42ce646..f328ac7 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/FilterImpl.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/FilterImpl.java
@@ -150,10 +150,12 @@ public class FilterImpl<T extends Serializable, EC extends AbstractEntityCollect
 
   @Override
   public EC getResult() {
-    final CommonURIBuilder<?> uriBuilder = client.newURIBuilder(this.baseURI.toASCIIString()).
-            appendDerivedEntityTypeSegment(new FullQualifiedName(
-                            ClassUtils.getNamespace(typeRef), ClassUtils.getEntityTypeName(typeRef)).toString());
-
+    CommonURIBuilder<?> uriBuilder = client.newURIBuilder(this.baseURI.toASCIIString());
+    
+    if(this.client.getConfiguration().isAddressingDerivedTypes()){
+    	uriBuilder = uriBuilder.appendDerivedEntityTypeSegment(new FullQualifiedName(
+    			ClassUtils.getNamespace(typeRef), ClassUtils.getEntityTypeName(typeRef)).toString());
+    }
     if (StringUtils.isNotBlank(filter)) {
       uriBuilder.filter(filter);
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1e8ad44a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonConfiguration.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonConfiguration.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonConfiguration.java
index 2e3a0d8..46f12b3 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonConfiguration.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonConfiguration.java
@@ -203,6 +203,31 @@ public interface CommonConfiguration extends Serializable {
   void setKeyAsSegment(boolean value);
 
   /**
+   * Gets whether query URIs in request should contain fully qualified type name.
+   * - OData Intermediate Conformance Level:
+   * MUST support casting to a derived type according to [OData-URL] if derived types are present in the model.
+   * <br/>
+   * Example: http://host/service/Customers/Model.VipCustomer(102) or 
+   * http://host/service/Customers/Model.VipCustomer
+   *
+   * @return whether query URIs in request should contain fully qualified type name.
+   * segment.
+   */
+  boolean isAddressingDerivedTypes() ;
+
+  /**
+   * Sets whether query URIs in request should contain fully qualified type name.
+   * - OData Intermediate Conformance Level:
+   * MUST support casting to a derived type according to [OData-URL] if derived types are present in the model.
+   * <br/>
+   * Example: http://host/service/Customers/Model.VipCustomer(102) or 
+   * http://host/service/Customers/Model.VipCustomer
+   *
+   * @param value 'TRUE' to use this feature.
+   */
+  void setAddressingDerivedTypes(final boolean value);
+
+  /**
    * Retrieves request executor service.
    *
    * @return request executor service.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1e8ad44a/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractConfiguration.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractConfiguration.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractConfiguration.java
index dc9ee6c..888452a 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractConfiguration.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractConfiguration.java
@@ -51,6 +51,8 @@ public abstract class AbstractConfiguration implements CommonConfiguration {
   private static final String USE_XHTTP_METHOD = "useHTTPMethod";
 
   private static final String KEY_AS_SEGMENT = "keyAsSegment";
+  
+  private static final String ADDRESS_DERIVED_TYPE = "addressDerivedType";
 
   private static final String GZIP_COMPRESSION = "gzipCompression";
 
@@ -213,6 +215,16 @@ public abstract class AbstractConfiguration implements CommonConfiguration {
   }
 
   @Override
+  public boolean isAddressingDerivedTypes() {
+    return (Boolean) getProperty(ADDRESS_DERIVED_TYPE, true);
+  }
+
+  @Override
+  public void setAddressingDerivedTypes(final boolean value) {
+    setProperty(ADDRESS_DERIVED_TYPE, value);
+  }
+  
+  @Override
   public ExecutorService getExecutor() {
     return executor;
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1e8ad44a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/AbstractURIBuilder.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/AbstractURIBuilder.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/AbstractURIBuilder.java
index 5b0b533..7a7c630 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/AbstractURIBuilder.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/AbstractURIBuilder.java
@@ -24,9 +24,14 @@ import java.net.URISyntaxException;
 import java.net.URLDecoder;
 import java.util.ArrayList;
 import java.util.LinkedHashMap;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+
 import org.apache.commons.lang3.StringUtils;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.utils.URLEncodedUtils;
+import org.apache.http.message.BasicNameValuePair;
 import org.apache.olingo.client.api.CommonConfiguration;
 import org.apache.olingo.client.api.uri.CommonURIBuilder;
 import org.apache.olingo.client.api.uri.QueryOption;
@@ -269,7 +274,9 @@ public abstract class AbstractURIBuilder<UB extends CommonURIBuilder<?>> impleme
             break;
 
           default:
-            segmentsBuilder.append('/');
+            if(segmentsBuilder.length() > 0 && segmentsBuilder.charAt(segmentsBuilder.length()-1) != '/') {
+              segmentsBuilder.append('/');
+            }
         }
       }
 
@@ -284,19 +291,27 @@ public abstract class AbstractURIBuilder<UB extends CommonURIBuilder<?>> impleme
     }
 
     try {
-      final org.apache.http.client.utils.URIBuilder builder =
-              new org.apache.http.client.utils.URIBuilder(segmentsBuilder.toString());
-
-      for (Map.Entry<String, String> option : queryOptions.entrySet()) {
-        builder.addParameter("$" + option.getKey(), option.getValue());
+      StringBuilder sb = segmentsBuilder;
+      if((queryOptions.size() + parameters.size()) > 0){
+          sb.append("?");
+          List<NameValuePair> list1 = new LinkedList<NameValuePair>();
+          for (Map.Entry<String, String> option : queryOptions.entrySet()) {
+        	list1.add(new BasicNameValuePair("$" + option.getKey(), option.getValue()));
+          }
+          for (Map.Entry<String, String> parameter : parameters.entrySet()) {
+    		list1.add(new BasicNameValuePair("@" + parameter.getKey(), parameter.getValue()));
+          }
+
+          // don't use UriBuilder.build():
+          // it will try to call URLEncodedUtils.format(Iterable<>,Charset) method,
+          // which works in desktop java application, however, throws NoSuchMethodError in android OS,
+          // so here manually construct the URL by its overload URLEncodedUtils.format(List<>,String).
+          String queryStr = URLEncodedUtils.format(list1, "UTF-8");
+          sb.append(queryStr);
       }
-
-      for (Map.Entry<String, String> parameter : parameters.entrySet()) {
-        builder.addParameter("@" + parameter.getKey(), parameter.getValue());
-      }
-
-      return builder.build().normalize();
-    } catch (URISyntaxException e) {
+      
+      return URI.create(sb.toString());
+    } catch (IllegalArgumentException e) {
       throw new IllegalArgumentException("Could not build valid URI", e);
     }
   }


[12/23] git commit: Removing unnecessary dependency - looks like a refuse

Posted by ch...@apache.org.
Removing unnecessary dependency - looks like a refuse


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

Branch: refs/heads/clientjune
Commit: 634d75b7993d0b4ec6221ac6b2e13e6edd9d31de
Parents: 70afb2a
Author: Francesco Chicchiriccò <--global>
Authored: Thu Jun 12 08:27:10 2014 +0200
Committer: Francesco Chicchiriccò <--global>
Committed: Thu Jun 12 08:27:10 2014 +0200

----------------------------------------------------------------------
 lib/server-tecsvc/pom.xml | 5 -----
 1 file changed, 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/634d75b7/lib/server-tecsvc/pom.xml
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/pom.xml b/lib/server-tecsvc/pom.xml
index 3925fbd..b5fb60e 100644
--- a/lib/server-tecsvc/pom.xml
+++ b/lib/server-tecsvc/pom.xml
@@ -151,11 +151,6 @@
       <artifactId>commons-io</artifactId>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>org.apache.olingo</groupId>
-      <artifactId>core</artifactId>
-      <version>0.1.0-SNAPSHOT</version>
-    </dependency>
   </dependencies>
 
 </project>


[17/23] [OLINGO-317] Rename and move of some packages and classes

Posted by ch...@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);
-  }
-}


[16/23] [OLINGO-317] Rename and move of some packages and classes

Posted by ch...@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);
+  }
+}


[07/23] [OLINGO-317] First presentable state

Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 0c60609..99a3320 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
@@ -18,8 +18,6 @@
  */
 package org.apache.olingo.fit.utils;
 
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
@@ -37,31 +35,30 @@ import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
 import java.util.regex.Pattern;
+
 import javax.ws.rs.NotFoundException;
 import javax.ws.rs.core.Response;
-import javax.xml.stream.XMLStreamException;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.vfs2.FileObject;
 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.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.core.data.AtomEntityImpl;
-import org.apache.olingo.commons.core.data.AtomEntitySetImpl;
-import org.apache.olingo.commons.core.data.AtomPropertyImpl;
+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.JSONEntityImpl;
-import org.apache.olingo.commons.core.data.JSONEntitySetImpl;
-import org.apache.olingo.commons.core.data.JSONPropertyImpl;
+import org.apache.olingo.commons.core.data.JsonDeserializer;
+import org.apache.olingo.commons.core.data.JsonSerializer;
 import org.apache.olingo.fit.UnsupportedMediaTypeException;
 import org.apache.olingo.fit.metadata.Metadata;
 import org.apache.olingo.fit.metadata.NavigationProperty;
 import org.apache.olingo.fit.serializer.FITAtomDeserializer;
-import org.apache.olingo.fit.serializer.JSONEntryContainer;
-import org.apache.olingo.fit.serializer.JSONFeedContainer;
-import org.apache.olingo.fit.serializer.JSONPropertyContainer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -90,27 +87,21 @@ public abstract class AbstractUtilities {
   public static final String BOUNDARY = "boundary";
 
   protected final ODataServiceVersion version;
-
   protected final Metadata metadata;
-
   protected final FSManager fsManager;
-
-  protected final DataBinder dataBinder;
-
-  protected final FITAtomDeserializer atomDeserializer;
-
-  protected final AtomSerializer atomSerializer;
-
-  protected final ObjectMapper mapper;
+  protected final ODataDeserializer atomDeserializer;
+  protected final ODataDeserializer jsonDeserializer;
+  protected final ODataSerializer atomSerializer;
+  protected final ODataSerializer jsonSerializer;
 
   public AbstractUtilities(final ODataServiceVersion version, final Metadata metadata) throws Exception {
     this.version = version;
     this.metadata = metadata;
     this.fsManager = FSManager.instance(version);
-    this.dataBinder = new DataBinder(version, metadata);
-    this.atomDeserializer = Commons.getAtomDeserializer(version);
-    this.atomSerializer = Commons.getAtomSerializer(version);
-    this.mapper = Commons.getJSONMapper(version);
+    atomDeserializer = new FITAtomDeserializer(version);
+    jsonDeserializer = new JsonDeserializer(version, true);
+    atomSerializer = new AtomSerializer(version);
+    jsonSerializer = new JsonSerializer(version, true);
   }
 
   public boolean isMediaContent(final String entityName) {
@@ -128,8 +119,8 @@ public abstract class AbstractUtilities {
    * @throws IOException
    */
   protected abstract InputStream addLinks(
-          final String entitySetName, final String entitykey, final InputStream is, final Set<String> links)
-          throws Exception;
+      final String entitySetName, final String entitykey, final InputStream is, final Set<String> links)
+      throws Exception;
 
   /**
    * Retrieve all entity link names.
@@ -149,8 +140,8 @@ public abstract class AbstractUtilities {
    * @throws IOException
    */
   protected abstract NavigationLinks retrieveNavigationInfo(
-          final String entitySetName, final InputStream is)
-          throws Exception;
+      final String entitySetName, final InputStream is)
+      throws Exception;
 
   /**
    * Normalize navigation info and add edit link if missing.
@@ -163,28 +154,28 @@ public abstract class AbstractUtilities {
    * @throws IOException
    */
   protected abstract InputStream normalizeLinks(
-          final String entitySetName, final String entityKey, final InputStream is, final NavigationLinks links)
-          throws Exception;
+      final String entitySetName, final String entityKey, final InputStream is, final NavigationLinks links)
+      throws Exception;
 
   public InputStream saveSingleEntity(
-          final String key,
-          final String entitySetName,
-          final InputStream is) throws Exception {
+      final String key,
+      final String entitySetName,
+      final InputStream is) throws Exception {
 
     return saveSingleEntity(key, entitySetName, is, null);
   }
 
   public InputStream saveSingleEntity(
-          final String key,
-          final String entitySetName,
-          final InputStream is,
-          final NavigationLinks links) throws Exception {
+      final String key,
+      final String entitySetName,
+      final InputStream is,
+      final NavigationLinks links) throws Exception {
 
     // -----------------------------------------
     // 0. Get the path
     // -----------------------------------------
     final String path =
-            entitySetName + File.separatorChar + Commons.getEntityKey(key) + File.separatorChar
+        entitySetName + File.separatorChar + Commons.getEntityKey(key) + File.separatorChar
             + Constants.get(version, ConstantKey.ENTITY);
     // -----------------------------------------
 
@@ -203,7 +194,7 @@ public abstract class AbstractUtilities {
     return fo.getContent().getInputStream();
   }
 
-  private InputStream toInputStream(final AtomEntityImpl entry) throws XMLStreamException {
+  private InputStream toInputStream(final Entity entry) throws ODataSerializerException {
     final StringWriter writer = new StringWriter();
     atomSerializer.write(writer, entry);
 
@@ -211,10 +202,10 @@ public abstract class AbstractUtilities {
   }
 
   public InputStream addOrReplaceEntity(
-          final String key,
-          final String entitySetName,
-          final InputStream is,
-          final AtomEntityImpl entry) throws Exception {
+      final String key,
+      final String entitySetName,
+      final InputStream is,
+      final Entity entry) throws Exception {
 
     final ByteArrayOutputStream bos = new ByteArrayOutputStream();
     IOUtils.copy(is, bos);
@@ -229,7 +220,7 @@ public abstract class AbstractUtilities {
     try {
       linksToBeKept = new HashSet<String>(navigationProperties.keySet());
     } catch (Exception e) {
-      linksToBeKept = Collections.<String>emptySet();
+      linksToBeKept = Collections.<String> emptySet();
     }
 
     for (String availableLink : new HashSet<String>(linksToBeKept)) {
@@ -263,7 +254,7 @@ public abstract class AbstractUtilities {
     // 3. Normalize navigation info; add edit link; ... and save entity ....
     // -----------------------------------------
     final InputStream createdEntity =
-            saveSingleEntity(entityKey, entitySetName, new ByteArrayInputStream(bos.toByteArray()), links);
+        saveSingleEntity(entityKey, entitySetName, new ByteArrayInputStream(bos.toByteArray()), links);
     // -----------------------------------------
 
     bos.reset();
@@ -273,7 +264,7 @@ public abstract class AbstractUtilities {
     // 4. Add navigation links to be kept
     // -----------------------------------------
     final InputStream normalizedEntity =
-            addLinks(entitySetName, entityKey, new ByteArrayInputStream(bos.toByteArray()), linksToBeKept);
+        addLinks(entitySetName, entityKey, new ByteArrayInputStream(bos.toByteArray()), linksToBeKept);
     // -----------------------------------------
 
     IOUtils.closeQuietly(bos);
@@ -282,8 +273,8 @@ public abstract class AbstractUtilities {
     // 5. save the entity
     // -----------------------------------------
     final FileObject fo = fsManager.putInMemory(
-            normalizedEntity,
-            fsManager.getAbsolutePath(path + Constants.get(version, ConstantKey.ENTITY), getDefaultFormat()));
+        normalizedEntity,
+        fsManager.getAbsolutePath(path + Constants.get(version, ConstantKey.ENTITY), getDefaultFormat()));
     // -----------------------------------------
 
     // -----------------------------------------
@@ -297,30 +288,28 @@ public abstract class AbstractUtilities {
 
     for (final Link link : entry.getNavigationLinks()) {
       final NavigationProperty navProp =
-              navigationProperties == null ? null : navigationProperties.get(link.getTitle());
+          navigationProperties == null ? null : navigationProperties.get(link.getTitle());
       if (navProp != null) {
         final String inlineEntitySetName = navProp.getTarget();
         if (link.getInlineEntity() != null) {
-          final String inlineEntryKey = getDefaultEntryKey(
-                  inlineEntitySetName, (AtomEntityImpl) link.getInlineEntity());
+          final String inlineEntryKey = getDefaultEntryKey(inlineEntitySetName, link.getInlineEntity());
 
           addOrReplaceEntity(
-                  inlineEntryKey,
-                  inlineEntitySetName,
-                  toInputStream((AtomEntityImpl) link.getInlineEntity()),
-                  (AtomEntityImpl) link.getInlineEntity());
+              inlineEntryKey,
+              inlineEntitySetName,
+              toInputStream(link.getInlineEntity()),
+              link.getInlineEntity());
 
           hrefs.add(inlineEntitySetName + "(" + inlineEntryKey + ")");
         } else if (link.getInlineEntitySet() != null) {
           for (Entity subentry : link.getInlineEntitySet().getEntities()) {
-            final String inlineEntryKey = getDefaultEntryKey(
-                    inlineEntitySetName, (AtomEntityImpl) subentry);
+            final String inlineEntryKey = getDefaultEntryKey(inlineEntitySetName, subentry);
 
             addOrReplaceEntity(
-                    inlineEntryKey,
-                    inlineEntitySetName,
-                    toInputStream((AtomEntityImpl) subentry),
-                    (AtomEntityImpl) subentry);
+                inlineEntryKey,
+                inlineEntitySetName,
+                toInputStream(subentry),
+                subentry);
 
             hrefs.add(inlineEntitySetName + "(" + inlineEntryKey + ")");
           }
@@ -337,9 +326,9 @@ public abstract class AbstractUtilities {
   }
 
   public void addMediaEntityValue(
-          final String entitySetName,
-          final String entityKey,
-          final InputStream is) throws Exception {
+      final String entitySetName,
+      final String entityKey,
+      final InputStream is) throws Exception {
 
     // -----------------------------------------
     // 0. Get default entry key and path (N.B. operation will consume/close the stream; use a copy instead)
@@ -351,17 +340,17 @@ public abstract class AbstractUtilities {
     // 1. save the media entity value
     // -----------------------------------------
     fsManager.putInMemory(is, fsManager.getAbsolutePath(path
-            + Constants.get(version, ConstantKey.MEDIA_CONTENT_FILENAME), null));
+        + Constants.get(version, ConstantKey.MEDIA_CONTENT_FILENAME), null));
     IOUtils.closeQuietly(is);
     // -----------------------------------------
   }
 
   public void putLinksInMemory(
-          final String basePath,
-          final String entitySetName,
-          final String entityKey,
-          final String linkName,
-          final Collection<String> links) throws IOException {
+      final String basePath,
+      final String entitySetName,
+      final String entityKey,
+      final String linkName,
+      final Collection<String> links) throws IOException {
 
     final HashSet<String> uris = new HashSet<String>();
 
@@ -372,8 +361,7 @@ public abstract class AbstractUtilities {
       try {
         final Map.Entry<String, List<String>> currents = extractLinkURIs(entitySetName, entityKey, linkName);
         uris.addAll(currents.getValue());
-      } catch (Exception ignore) {
-      }
+      } catch (Exception ignore) {}
     }
 
     uris.addAll(links);
@@ -382,20 +370,20 @@ public abstract class AbstractUtilities {
   }
 
   public void putLinksInMemory(
-          final String basePath, final String entitySetName, final String linkName, final Collection<String> uris)
-          throws IOException {
+      final String basePath, final String entitySetName, final String linkName, final Collection<String> uris)
+      throws IOException {
 
     fsManager.putInMemory(
-            Commons.getLinksAsJSON(version, entitySetName, new SimpleEntry<String, Collection<String>>(linkName, uris)),
-            Commons.getLinksPath(version, basePath, linkName, Accept.JSON_FULLMETA));
+        Commons.getLinksAsJSON(version, entitySetName, new SimpleEntry<String, Collection<String>>(linkName, uris)),
+        Commons.getLinksPath(version, basePath, linkName, Accept.JSON_FULLMETA));
 
     fsManager.putInMemory(
-            Commons.getLinksAsATOM(version, new SimpleEntry<String, Collection<String>>(linkName, uris)),
-            Commons.getLinksPath(version, basePath, linkName, Accept.XML));
+        Commons.getLinksAsATOM(version, new SimpleEntry<String, Collection<String>>(linkName, uris)),
+        Commons.getLinksPath(version, basePath, linkName, Accept.XML));
   }
 
   public Response createResponse(
-          final String location, final InputStream entity, final String etag, final Accept accept) {
+      final String location, final InputStream entity, final String etag, final Accept accept) {
     return createResponse(location, entity, etag, accept, null);
   }
 
@@ -430,26 +418,26 @@ public abstract class AbstractUtilities {
 
   public Response createBatchResponse(final InputStream stream, final String boundary) {
     final Response.ResponseBuilder builder = version.compareTo(ODataServiceVersion.V30) <= 0
-            ? Response.accepted(stream)
-            : Response.ok(stream);
+        ? Response.accepted(stream)
+        : Response.ok(stream);
     builder.header(Constants.get(version, ConstantKey.ODATA_SERVICE_VERSION), version.toString() + ";");
     return builder.build();
   }
 
   public Response createResponse(
-          final InputStream entity,
-          final String etag,
-          final Accept accept,
-          final Response.Status status) {
+      final InputStream entity,
+      final String etag,
+      final Accept accept,
+      final Response.Status status) {
     return createResponse(null, entity, etag, accept, status);
   }
 
   public Response createResponse(
-          final String location,
-          final InputStream entity,
-          final String etag,
-          final Accept accept,
-          final Response.Status status) {
+      final String location,
+      final InputStream entity,
+      final String etag,
+      final Accept accept,
+      final Response.Status status) {
 
     final Response.ResponseBuilder builder = Response.ok();
     if (version.compareTo(ODataServiceVersion.V30) <= 0) {
@@ -543,130 +531,87 @@ public abstract class AbstractUtilities {
     return builder.build();
   }
 
-  public AtomEntitySetImpl readEntitySet(final Accept accept, final InputStream entitySet)
-          throws XMLStreamException, IOException {
-
-    final AtomEntitySetImpl entry;
-
-    if (accept == Accept.ATOM || accept == Accept.XML) {
-      final ResWrap<AtomEntitySetImpl> container = atomDeserializer.read(entitySet, AtomEntitySetImpl.class);
-      entry = container.getPayload();
-    } else {
-      final ResWrap<JSONEntitySetImpl> container =
-              mapper.readValue(entitySet, new TypeReference<JSONEntitySetImpl>() {
-      });
-      entry = dataBinder.toAtomEntitySet(container.getPayload());
-    }
-
-    return entry;
+  public EntitySet readEntitySet(final Accept accept, final InputStream entitySet)
+      throws ODataDeserializerException {
+    return (accept == Accept.ATOM || accept == Accept.XML ?
+        atomDeserializer.toEntitySet(entitySet) : jsonDeserializer.toEntitySet(entitySet))
+        .getPayload();
   }
 
-  public InputStream writeEntitySet(final Accept accept, final ResWrap<AtomEntitySetImpl> container)
-          throws XMLStreamException, IOException {
+  public InputStream writeEntitySet(final Accept accept, final ResWrap<EntitySet> container)
+      throws ODataSerializerException, IOException {
 
     final StringWriter writer = new StringWriter();
     if (accept == Accept.ATOM || accept == Accept.XML) {
       atomSerializer.write(writer, container);
-      writer.flush();
-      writer.close();
     } else {
-      mapper.writeValue(
-              writer, new JSONFeedContainer(container.getContextURL(),
-              container.getMetadataETag(), dataBinder.toJSONEntitySet(container.getPayload())));
+      jsonSerializer.write(writer, container);
     }
+    writer.flush();
+    writer.close();
 
     return IOUtils.toInputStream(writer.toString(), Constants.ENCODING);
   }
 
-  public ResWrap<AtomEntityImpl> readContainerEntity(final Accept accept, final InputStream entity)
-          throws XMLStreamException, IOException {
-    final ResWrap<AtomEntityImpl> container;
-
-    if (accept == Accept.ATOM || accept == Accept.XML) {
-      container = atomDeserializer.read(entity, AtomEntityImpl.class);
-    } else {
-      final ResWrap<JSONEntityImpl> jcontainer =
-              mapper.readValue(entity, new TypeReference<JSONEntityImpl>() {
-      });
-      container = new ResWrap<AtomEntityImpl>(
-              jcontainer.getContextURL(),
-              jcontainer.getMetadataETag(),
-              dataBinder.toAtomEntity(jcontainer.getPayload()));
-    }
-
-    return container;
+  public ResWrap<Entity> readContainerEntity(final Accept accept, final InputStream entity)
+      throws ODataDeserializerException {
+    return accept == Accept.ATOM || accept == Accept.XML ?
+        atomDeserializer.toEntity(entity) : jsonDeserializer.toEntity(entity);
   }
 
-  public AtomEntityImpl readEntity(final Accept accept, final InputStream entity)
-          throws XMLStreamException, IOException {
-
+  public Entity readEntity(final Accept accept, final InputStream entity)
+      throws IOException, ODataDeserializerException {
     return readContainerEntity(accept, entity).getPayload();
   }
 
-  public InputStream writeEntity(final Accept accept, final ResWrap<AtomEntityImpl> container)
-          throws XMLStreamException, IOException {
+  public InputStream writeEntity(final Accept accept, final ResWrap<Entity> container)
+      throws ODataSerializerException {
+    StringWriter writer = new StringWriter();
 
-    final StringWriter writer = new StringWriter();
     if (accept == Accept.ATOM || accept == Accept.XML) {
       atomSerializer.write(writer, container);
     } else {
-      mapper.writeValue(
-              writer, new JSONEntryContainer(container.getContextURL(), container.getMetadataETag(),
-              dataBinder.toJSONEntity(container.getPayload())));
+      jsonSerializer.write(writer, container);
     }
 
     return IOUtils.toInputStream(writer.toString(), Constants.ENCODING);
   }
 
   public InputStream writeProperty(final Accept accept, final Property property)
-          throws XMLStreamException, IOException {
+      throws ODataSerializerException {
 
     final StringWriter writer = new StringWriter();
     if (accept == Accept.XML || accept == Accept.ATOM) {
-      atomSerializer.write(writer, property instanceof AtomPropertyImpl
-              ? property : dataBinder.toAtomProperty((JSONPropertyImpl) property, property.getType()));
+      atomSerializer.write(writer, property);
     } else {
-      mapper.writeValue(writer, property instanceof JSONPropertyImpl
-              ? property : dataBinder.toJSONProperty((AtomPropertyImpl) property));
+      jsonSerializer.write(writer, property);
     }
 
     return IOUtils.toInputStream(writer.toString(), Constants.ENCODING);
   }
 
-  public AtomPropertyImpl readProperty(final Accept accept, final InputStream property, final String entryType)
-          throws XMLStreamException, IOException {
-    final AtomPropertyImpl atomProperty;
-    if (Accept.ATOM == accept || Accept.XML == accept) {
-      final ResWrap<AtomPropertyImpl> container = atomDeserializer.read(property, AtomPropertyImpl.class);
-      atomProperty = container.getPayload();
-    } else {
-      final ResWrap<JSONPropertyImpl> jcontainer = mapper.readValue(property,
-              new TypeReference<JSONPropertyImpl>() {
-      });
-
-      atomProperty = dataBinder.toAtomProperty(jcontainer.getPayload(), entryType);
-    }
-
-    return atomProperty;
+  public Property readProperty(final Accept accept, final InputStream property, final String entryType)
+      throws ODataDeserializerException {
+    return (Accept.ATOM == accept || Accept.XML == accept ?
+        atomDeserializer.toProperty(property) : jsonDeserializer.toProperty(property))
+        .getPayload();
   }
 
-  public InputStream writeProperty(final Accept accept, final ResWrap<AtomPropertyImpl> container)
-          throws XMLStreamException, IOException {
+  public InputStream writeProperty(final Accept accept, final ResWrap<Property> container)
+      throws ODataSerializerException {
 
     final StringWriter writer = new StringWriter();
     if (accept == Accept.XML || accept == Accept.ATOM) {
       atomSerializer.write(writer, container);
     } else {
-      mapper.writeValue(
-              writer, new JSONPropertyContainer(container.getContextURL(), container.getMetadataETag(),
-              dataBinder.toJSONProperty(container.getPayload())));
+      jsonSerializer.write(writer, container);
     }
 
     return IOUtils.toInputStream(writer.toString(), Constants.ENCODING);
   }
 
-  private String getDefaultEntryKey(final String entitySetName, final AtomEntityImpl entry, final String propertyName)
-          throws Exception {
+  private String getDefaultEntryKey(final String entitySetName, final Entity entry, final String propertyName)
+      throws Exception {
 
     String res;
     if (entry.getProperty(propertyName) == null) {
@@ -683,7 +628,7 @@ public abstract class AbstractUtilities {
     return res;
   }
 
-  public String getDefaultEntryKey(final String entitySetName, final AtomEntityImpl entity) throws IOException {
+  public String getDefaultEntryKey(final String entitySetName, final Entity entity) throws IOException {
     try {
       String res;
 
@@ -699,7 +644,7 @@ public abstract class AbstractUtilities {
         } else {
           productID = Integer.valueOf(entity.getProperty("OrderID").getValue().asPrimitive().get());
           res = "OrderID=" + entity.getProperty("OrderID").getValue().asPrimitive().get()
-                  + ",ProductID=" + entity.getProperty("ProductID").getValue().asPrimitive().get();
+              + ",ProductID=" + entity.getProperty("ProductID").getValue().asPrimitive().get();
         }
         Commons.SEQUENCE.put(entitySetName, productID);
       } else if ("Message".equals(entitySetName)) {
@@ -714,7 +659,7 @@ public abstract class AbstractUtilities {
         } else {
           messageId = Integer.valueOf(entity.getProperty("MessageId").getValue().asPrimitive().get());
           res = "FromUsername=" + entity.getProperty("FromUsername").getValue().asPrimitive().get()
-                  + ",MessageId=" + entity.getProperty("MessageId").getValue().asPrimitive().get();
+              + ",MessageId=" + entity.getProperty("MessageId").getValue().asPrimitive().get();
         }
         Commons.SEQUENCE.put(entitySetName, messageId);
       } else if ("Order".equals(entitySetName)) {
@@ -759,7 +704,7 @@ public abstract class AbstractUtilities {
           productId = Integer.valueOf(entity.getProperty("ProductID").getValue().asPrimitive().get());
           productDetailId = Integer.valueOf(entity.getProperty("ProductDetailID").getValue().asPrimitive().get());
           res = "ProductID=" + entity.getProperty("ProductID").getValue().asPrimitive().get()
-                  + ",ProductDetailID=" + entity.getProperty("ProductDetailID").getValue().asPrimitive().get();
+              + ",ProductDetailID=" + entity.getProperty("ProductDetailID").getValue().asPrimitive().get();
         }
         Commons.SEQUENCE.put(entitySetName, productDetailId);
         Commons.SEQUENCE.put("Products", productId);
@@ -781,7 +726,7 @@ public abstract class AbstractUtilities {
 
   public String getLinksBasePath(final String entitySetName, final String entityId) {
     return entitySetName + File.separatorChar + Commons.getEntityKey(entityId) + File.separatorChar
-            + Constants.get(version, ConstantKey.LINKS_FILE_PATH) + File.separatorChar;
+        + Constants.get(version, ConstantKey.LINKS_FILE_PATH) + File.separatorChar;
   }
 
   /**
@@ -794,8 +739,8 @@ public abstract class AbstractUtilities {
    * @return a pair of ETag/links stream
    */
   public LinkInfo readLinks(
-          final String entitySetName, final String entityId, final String linkName, final Accept accept)
-          throws Exception {
+      final String entitySetName, final String entityId, final String linkName, final Accept accept)
+      throws Exception {
 
     final String basePath = getLinksBasePath(entitySetName, entityId);
 
@@ -809,16 +754,16 @@ public abstract class AbstractUtilities {
   }
 
   public InputStream putMediaInMemory(
-          final String entitySetName, final String entityId, final InputStream value)
-          throws IOException {
+      final String entitySetName, final String entityId, final InputStream value)
+      throws IOException {
     return putMediaInMemory(entitySetName, entityId, null, value);
   }
 
   public InputStream putMediaInMemory(
-          final String entitySetName, final String entityId, final String name, final InputStream value)
-          throws IOException {
+      final String entitySetName, final String entityId, final String name, final InputStream value)
+      throws IOException {
     final FileObject fo = fsManager.putInMemory(value, fsManager.getAbsolutePath(
-            Commons.getEntityBasePath(entitySetName, entityId)
+        Commons.getEntityBasePath(entitySetName, entityId)
             + (name == null ? Constants.get(version, ConstantKey.MEDIA_CONTENT_FILENAME) : name), null));
 
     return fo.getContent().getInputStream();
@@ -829,14 +774,14 @@ public abstract class AbstractUtilities {
   }
 
   public Map.Entry<String, InputStream> readMediaEntity(
-          final String entitySetName, final String entityId, final String name) {
+      final String entitySetName, final String entityId, final String name) {
     final String basePath = Commons.getEntityBasePath(entitySetName, entityId);
     return new SimpleEntry<String, InputStream>(basePath, fsManager.readFile(basePath
-            + (name == null ? Constants.get(version, ConstantKey.MEDIA_CONTENT_FILENAME) : name)));
+        + (name == null ? Constants.get(version, ConstantKey.MEDIA_CONTENT_FILENAME) : name)));
   }
 
   public Map.Entry<String, InputStream> readEntity(
-          final String entitySetName, final String entityId, final Accept accept) {
+      final String entitySetName, final String entityId, final Accept accept) {
 
     if (accept == Accept.XML || accept == Accept.TEXT) {
       throw new UnsupportedMediaTypeException("Unsupported media type");
@@ -844,14 +789,14 @@ public abstract class AbstractUtilities {
 
     final String basePath = Commons.getEntityBasePath(entitySetName, entityId);
     return new SimpleEntry<String, InputStream>(basePath,
-            fsManager.readFile(basePath + Constants.get(version, ConstantKey.ENTITY), accept));
+        fsManager.readFile(basePath + Constants.get(version, ConstantKey.ENTITY), accept));
   }
 
   public InputStream expandEntity(
-          final String entitySetName,
-          final String entityId,
-          final String linkName)
-          throws Exception {
+      final String entitySetName,
+      final String entityId,
+      final String linkName)
+      throws Exception {
 
     // --------------------------------
     // 0. Retrieve all 'linkName' navigation link uris (NotFoundException if missing) 
@@ -865,18 +810,18 @@ public abstract class AbstractUtilities {
     final Map<String, NavigationProperty> navigationProperties = metadata.getNavigationProperties(entitySetName);
 
     return readEntities(
-            links.getValue(),
-            linkName,
-            links.getKey(),
-            navigationProperties.get(linkName).isEntitySet());
+        links.getValue(),
+        linkName,
+        links.getKey(),
+        navigationProperties.get(linkName).isEntitySet());
   }
 
   public InputStream expandEntity(
-          final String entitySetName,
-          final String entityId,
-          final InputStream entity,
-          final String linkName)
-          throws Exception {
+      final String entitySetName,
+      final String entityId,
+      final InputStream entity,
+      final String linkName)
+      throws Exception {
     // --------------------------------
     // 2. Retrieve expanded object (entry or feed)
     // --------------------------------
@@ -885,14 +830,14 @@ public abstract class AbstractUtilities {
   }
 
   public InputStream deleteProperty(
-          final String entitySetName,
-          final String entityId,
-          final List<String> path,
-          final Accept accept) throws Exception {
+      final String entitySetName,
+      final String entityId,
+      final List<String> path,
+      final Accept accept) throws Exception {
     final String basePath = Commons.getEntityBasePath(entitySetName, entityId);
 
     final Accept acceptType = accept == null || Accept.TEXT == accept
-            ? Accept.XML : accept.getExtension().equals(Accept.JSON.getExtension()) ? Accept.JSON_FULLMETA : accept;
+        ? Accept.XML : accept.getExtension().equals(Accept.JSON.getExtension()) ? Accept.JSON_FULLMETA : accept;
 
     // read atom
     InputStream stream = fsManager.readFile(basePath + Constants.get(version, ConstantKey.ENTITY), acceptType);
@@ -902,17 +847,17 @@ public abstract class AbstractUtilities {
 
     // save atom
     fsManager.putInMemory(stream,
-            fsManager.getAbsolutePath(basePath + Constants.get(version, ConstantKey.ENTITY), acceptType));
+        fsManager.getAbsolutePath(basePath + Constants.get(version, ConstantKey.ENTITY), acceptType));
 
     return fsManager.readFile(basePath + Constants.get(version, ConstantKey.ENTITY), acceptType);
   }
 
   public abstract InputStream readEntities(
-          final List<String> links, final String linkName, final String next, final boolean forceFeed)
-          throws Exception;
+      final List<String> links, final String linkName, final String next, final boolean forceFeed)
+      throws Exception;
 
   protected abstract InputStream replaceLink(
-          final InputStream toBeChanged, final String linkName, final InputStream replacement) throws Exception;
+      final InputStream toBeChanged, final String linkName, final InputStream replacement) throws Exception;
 
   public abstract InputStream selectEntity(final InputStream entity, final String[] propertyNames) throws Exception;
 
@@ -921,19 +866,19 @@ public abstract class AbstractUtilities {
   protected abstract Map<String, InputStream> getChanges(final InputStream src) throws Exception;
 
   public abstract InputStream addEditLink(
-          final InputStream content, final String title, final String href) throws Exception;
+      final InputStream content, final String title, final String href) throws Exception;
 
   public abstract InputStream addOperation(
-          final InputStream content, final String name, final String metaAnchor, final String href) throws Exception;
+      final InputStream content, final String name, final String metaAnchor, final String href) throws Exception;
 
   protected abstract InputStream replaceProperty(
-          final InputStream src, final InputStream replacement, final List<String> path, final boolean justValue)
-          throws Exception;
+      final InputStream src, final InputStream replacement, final List<String> path, final boolean justValue)
+      throws Exception;
 
   protected abstract InputStream deleteProperty(final InputStream src, final List<String> path) throws Exception;
 
   public abstract Map.Entry<String, List<String>> extractLinkURIs(final InputStream is) throws Exception;
 
   public abstract Map.Entry<String, List<String>> extractLinkURIs(
-          final String entitySetName, final String entityId, final String linkName) throws Exception;
+      final String entitySetName, final String entityId, final String linkName) throws Exception;
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/fit/src/main/java/org/apache/olingo/fit/utils/Commons.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/Commons.java b/fit/src/main/java/org/apache/olingo/fit/utils/Commons.java
index 65b7eae..c9f4128 100644
--- a/fit/src/main/java/org/apache/olingo/fit/utils/Commons.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/Commons.java
@@ -18,15 +18,6 @@
  */
 package org.apache.olingo.fit.utils;
 
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.InjectableValues;
-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.JsonNodeFactory;
-import com.fasterxml.jackson.databind.node.ObjectNode;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
@@ -42,19 +33,25 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.regex.Pattern;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.apache.commons.lang3.tuple.Pair;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.core.data.AtomSerializer;
-import org.apache.olingo.commons.core.op.InjectableSerializerProvider;
 import org.apache.olingo.fit.metadata.Metadata;
-import org.apache.olingo.fit.serializer.FITAtomDeserializer;
 import org.codehaus.plexus.util.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+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.ArrayNode;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
 public abstract class Commons {
 
   /**
@@ -62,15 +59,6 @@ public abstract class Commons {
    */
   protected static final Logger LOG = LoggerFactory.getLogger(Commons.class);
 
-  private static final Map<ODataServiceVersion, FITAtomDeserializer> ATOM_DESERIALIZER =
-          new EnumMap<ODataServiceVersion, FITAtomDeserializer>(ODataServiceVersion.class);
-
-  private static final Map<ODataServiceVersion, AtomSerializer> ATOM_SERIALIZER =
-          new EnumMap<ODataServiceVersion, AtomSerializer>(ODataServiceVersion.class);
-
-  private static final Map<ODataServiceVersion, ObjectMapper> JSON_MAPPER =
-          new EnumMap<ODataServiceVersion, ObjectMapper>(ODataServiceVersion.class);
-
   private static final EnumMap<ODataServiceVersion, Metadata> METADATA =
           new EnumMap<ODataServiceVersion, Metadata>(ODataServiceVersion.class);
 
@@ -109,41 +97,6 @@ public abstract class Commons {
             new ImmutablePair<String, EdmPrimitiveTypeKind>("ID", EdmPrimitiveTypeKind.Guid));
   }
 
-  public static FITAtomDeserializer getAtomDeserializer(final ODataServiceVersion version) {
-    if (!ATOM_DESERIALIZER.containsKey(version)) {
-      ATOM_DESERIALIZER.put(version, new FITAtomDeserializer(version));
-    }
-    return ATOM_DESERIALIZER.get(version);
-  }
-
-  public static AtomSerializer getAtomSerializer(final ODataServiceVersion version) {
-    if (!ATOM_SERIALIZER.containsKey(version)) {
-      ATOM_SERIALIZER.put(version, new AtomSerializer(version, true));
-    }
-
-    return ATOM_SERIALIZER.get(version);
-  }
-
-  public static ObjectMapper getJSONMapper(final ODataServiceVersion version) {
-    if (!JSON_MAPPER.containsKey(version)) {
-      final ObjectMapper mapper = new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);
-
-      mapper.setInjectableValues(new InjectableValues.Std()
-              .addValue(Boolean.class, Boolean.TRUE)
-              .addValue(ODataServiceVersion.class, version));
-
-      mapper.setSerializerProvider(new InjectableSerializerProvider(mapper.getSerializerProvider(),
-              mapper.getSerializationConfig()
-              .withAttribute(ODataServiceVersion.class, version)
-              .withAttribute(Boolean.class, Boolean.TRUE),
-              mapper.getSerializerFactory()));
-
-      JSON_MAPPER.put(version, mapper);
-    }
-
-    return JSON_MAPPER.get(version);
-  }
-
   public static Metadata getMetadata(final ODataServiceVersion version) {
     if (!METADATA.containsKey(version)) {
       final InputStream is = Commons.class.getResourceAsStream("/" + version.name() + "/metadata.xml");

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/fit/src/main/java/org/apache/olingo/fit/utils/DataBinder.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/DataBinder.java b/fit/src/main/java/org/apache/olingo/fit/utils/DataBinder.java
deleted file mode 100644
index 4dbd725..0000000
--- a/fit/src/main/java/org/apache/olingo/fit/utils/DataBinder.java
+++ /dev/null
@@ -1,347 +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.fit.utils;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import org.apache.commons.lang3.StringUtils;
-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.Value;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.core.data.AtomEntityImpl;
-import org.apache.olingo.commons.core.data.AtomEntitySetImpl;
-import org.apache.olingo.commons.core.data.AtomPropertyImpl;
-import org.apache.olingo.commons.core.data.CollectionValueImpl;
-import org.apache.olingo.commons.core.data.ComplexValueImpl;
-import org.apache.olingo.commons.core.data.JSONEntityImpl;
-import org.apache.olingo.commons.core.data.JSONEntitySetImpl;
-import org.apache.olingo.commons.core.data.JSONPropertyImpl;
-import org.apache.olingo.commons.core.data.LinkImpl;
-import org.apache.olingo.fit.metadata.EntityType;
-import org.apache.olingo.fit.metadata.Metadata;
-import org.apache.olingo.fit.metadata.NavigationProperty;
-import org.springframework.beans.BeanUtils;
-
-public class DataBinder {
-
-  private final ODataServiceVersion version;
-
-  private final Metadata metadata;
-
-  public DataBinder(final ODataServiceVersion version, final Metadata metadata) {
-    this.version = version;
-    this.metadata = metadata;
-  }
-
-  public JSONEntitySetImpl toJSONEntitySet(final AtomEntitySetImpl atomEntitySet) {
-    final JSONEntitySetImpl jsonEntitySet = new JSONEntitySetImpl();
-
-    BeanUtils.copyProperties(atomEntitySet, jsonEntitySet, "baseURI", "metadataContextURL");
-    jsonEntitySet.setBaseURI(atomEntitySet.getBaseURI() == null
-            ? null
-            : atomEntitySet.getBaseURI().toASCIIString() + "/$metadata");
-
-    final Collection<Entity> entries = jsonEntitySet.getEntities();
-    for (Entity entity : atomEntitySet.getEntities()) {
-      entries.add(toJSONEntity((AtomEntityImpl) entity));
-    }
-
-    return jsonEntitySet;
-  }
-
-  public AtomEntitySetImpl toAtomEntitySet(final JSONEntitySetImpl jsonEntitySet) {
-    final AtomEntitySetImpl atomEntitySet = new AtomEntitySetImpl();
-
-    BeanUtils.copyProperties(jsonEntitySet, atomEntitySet, "baseURI", "metadataContextURL");
-    atomEntitySet.setBaseURI(jsonEntitySet.getBaseURI() == null
-            ? null
-            : jsonEntitySet.getBaseURI().toASCIIString() + "/$metadata");
-
-    final Collection<Entity> entries = atomEntitySet.getEntities();
-    for (Entity entity : jsonEntitySet.getEntities()) {
-      entries.add(toAtomEntity((JSONEntityImpl) entity));
-    }
-
-    return atomEntitySet;
-  }
-
-  public JSONEntityImpl toJSONEntity(final AtomEntityImpl atomEntity) {
-    final JSONEntityImpl jsonEntity = new JSONEntityImpl();
-    jsonEntity.getAnnotations().addAll(atomEntity.getAnnotations());
-
-    BeanUtils.copyProperties(atomEntity, jsonEntity, "baseURI", "properties", "links");
-    // This shouldn't ever happen, but...
-    if (atomEntity.getType() != null && atomEntity.getType().startsWith("Collection(")) {
-      jsonEntity.setType(atomEntity.getType().replaceAll("^Collection\\(", "").replaceAll("\\)$", ""));
-    }
-    jsonEntity.setBaseURI(atomEntity.getBaseURI() == null ? null : atomEntity.getBaseURI().toASCIIString());
-    jsonEntity.getOperations().addAll(atomEntity.getOperations());
-
-    for (Link link : atomEntity.getMediaEditLinks()) {
-      final Link jlink = new LinkImpl();
-      jlink.setHref(link.getHref());
-      jlink.setTitle(link.getTitle());
-      jlink.setType(link.getType());
-      jlink.setRel(link.getRel());
-
-      if (link.getInlineEntity() instanceof AtomEntityImpl) {
-        final Entity inlineEntity = link.getInlineEntity();
-        if (inlineEntity instanceof AtomEntityImpl) {
-          jlink.setInlineEntity(toJSONEntity((AtomEntityImpl) link.getInlineEntity()));
-        }
-      } else if (link.getInlineEntitySet() instanceof AtomEntitySetImpl) {
-        final EntitySet inlineEntitySet = link.getInlineEntitySet();
-        if (inlineEntitySet instanceof AtomEntitySetImpl) {
-          jlink.setInlineEntitySet(toJSONEntitySet((AtomEntitySetImpl) link.getInlineEntitySet()));
-        }
-      }
-
-      jsonEntity.getMediaEditLinks().add(jlink);
-    }
-
-    for (Link link : atomEntity.getNavigationLinks()) {
-      final Link jlink = new LinkImpl();
-      jlink.setHref(link.getHref());
-      jlink.setTitle(link.getTitle());
-      jlink.setType(link.getType());
-      jlink.setRel(link.getRel());
-      jlink.getAnnotations().addAll(link.getAnnotations());
-
-      if (link.getInlineEntity() instanceof AtomEntityImpl) {
-        final Entity inlineEntity = link.getInlineEntity();
-        if (inlineEntity instanceof AtomEntityImpl) {
-          jlink.setInlineEntity(toJSONEntity((AtomEntityImpl) link.getInlineEntity()));
-        }
-      } else if (link.getInlineEntitySet() instanceof AtomEntitySetImpl) {
-        final EntitySet inlineEntitySet = link.getInlineEntitySet();
-        if (inlineEntitySet instanceof AtomEntitySetImpl) {
-          jlink.setInlineEntitySet(toJSONEntitySet((AtomEntitySetImpl) link.getInlineEntitySet()));
-        }
-      }
-
-      jsonEntity.getNavigationLinks().add(jlink);
-    }
-
-    final Collection<Property> properties = jsonEntity.getProperties();
-    for (Property property : atomEntity.getProperties()) {
-      properties.add(toJSONProperty((AtomPropertyImpl) property));
-    }
-
-    jsonEntity.getAnnotations().addAll(atomEntity.getAnnotations());
-
-    return jsonEntity;
-  }
-
-  public AtomEntityImpl toAtomEntity(final JSONEntityImpl jsonEntity) {
-    final AtomEntityImpl atomEntity = new AtomEntityImpl();
-
-    BeanUtils.copyProperties(jsonEntity, atomEntity, "baseURI", "properties", "links");
-    atomEntity.setBaseURI(jsonEntity.getBaseURI() == null ? null : jsonEntity.getBaseURI().toASCIIString());
-
-    for (Link link : jsonEntity.getMediaEditLinks()) {
-      final Link alink = new LinkImpl();
-      alink.setHref(link.getHref());
-      alink.setTitle(link.getTitle());
-      alink.setRel(link.getRel());
-      alink.setType(link.getType());
-
-      if (link.getInlineEntity() instanceof JSONEntityImpl) {
-        final Entity inlineEntity = link.getInlineEntity();
-        if (inlineEntity instanceof JSONEntityImpl) {
-          alink.setInlineEntity(toAtomEntity((JSONEntityImpl) link.getInlineEntity()));
-        }
-      } else if (link.getInlineEntitySet() instanceof JSONEntitySetImpl) {
-        final EntitySet inlineEntitySet = link.getInlineEntitySet();
-        if (inlineEntitySet instanceof JSONEntitySetImpl) {
-          alink.setInlineEntitySet(toAtomEntitySet((JSONEntitySetImpl) link.getInlineEntitySet()));
-        }
-      }
-
-      atomEntity.getMediaEditLinks().add(alink);
-    }
-
-    for (Link link : jsonEntity.getNavigationLinks()) {
-      final Link alink = new LinkImpl();
-      alink.setHref(link.getHref());
-      alink.setTitle(link.getTitle());
-      alink.getAnnotations().addAll(link.getAnnotations());
-
-      final NavigationProperty navPropDetails =
-              metadata.getEntityOrComplexType(jsonEntity.getType()).getNavigationProperty(link.getTitle());
-
-      alink.setType(navPropDetails != null && navPropDetails.isEntitySet()
-              ? Constants.get(ConstantKey.ATOM_LINK_FEED) : Constants.get(ConstantKey.ATOM_LINK_ENTRY));
-      alink.setRel(link.getRel());
-
-      if (link.getInlineEntity() instanceof JSONEntityImpl) {
-        final Entity inlineEntity = link.getInlineEntity();
-        if (inlineEntity instanceof JSONEntityImpl) {
-          alink.setInlineEntity(toAtomEntity((JSONEntityImpl) link.getInlineEntity()));
-        }
-      } else if (link.getInlineEntitySet() instanceof JSONEntitySetImpl) {
-        final EntitySet inlineEntitySet = link.getInlineEntitySet();
-        if (inlineEntitySet instanceof JSONEntitySetImpl) {
-          alink.setInlineEntitySet(toAtomEntitySet((JSONEntitySetImpl) link.getInlineEntitySet()));
-        }
-      }
-
-      atomEntity.getNavigationLinks().add(alink);
-    }
-
-    final EntityType entityType = StringUtils.isBlank(jsonEntity.getType())
-            ? null : metadata.getEntityOrComplexType(jsonEntity.getType());
-    final Map<String, NavigationProperty> navProperties = entityType == null
-            ? Collections.<String, NavigationProperty>emptyMap() : entityType.getNavigationPropertyMap();
-
-    final List<Property> properties = atomEntity.getProperties();
-
-    for (Property property : jsonEntity.getProperties()) {
-      if (navProperties.containsKey(property.getName())) {
-        final Link alink = new LinkImpl();
-        alink.setTitle(property.getName());
-        alink.getAnnotations().addAll(property.getAnnotations());
-
-        alink.setType(navProperties.get(property.getName()).isEntitySet()
-                ? Constants.get(version, ConstantKey.ATOM_LINK_FEED)
-                : Constants.get(version, ConstantKey.ATOM_LINK_ENTRY));
-
-        alink.setRel(Constants.get(version, ConstantKey.ATOM_LINK_REL) + property.getName());
-
-        if (property.getValue().isComplex()) {
-          final Entity inline = new AtomEntityImpl();
-          inline.setType(navProperties.get(property.getName()).getType());
-          for (Property prop : property.getValue().asComplex().get()) {
-            inline.getProperties().add(prop);
-          }
-          alink.setInlineEntity(inline);
-
-        } else if (property.getValue().isCollection()) {
-          final EntitySet inline = new AtomEntitySetImpl();
-          for (Value value : property.getValue().asCollection().get()) {
-            final Entity inlineEntity = new AtomEntityImpl();
-            inlineEntity.setType(navProperties.get(property.getName()).getType());
-            for (Property prop : value.asComplex().get()) {
-              inlineEntity.getProperties().add(toAtomProperty((JSONPropertyImpl) prop, inlineEntity.getType()));
-            }
-            inline.getEntities().add(inlineEntity);
-          }
-          alink.setInlineEntitySet(inline);
-        } else {
-          throw new IllegalStateException("Invalid navigation property " + property);
-        }
-        atomEntity.getNavigationLinks().add(alink);
-      } else {
-        properties.add(toAtomProperty((JSONPropertyImpl) property, atomEntity.getType()));
-      }
-    }
-
-    return atomEntity;
-  }
-
-  public JSONPropertyImpl toJSONProperty(final AtomPropertyImpl atomProperty) {
-    final JSONPropertyImpl jsonProperty = new JSONPropertyImpl();
-    BeanUtils.copyProperties(atomProperty, jsonProperty, "value");
-    jsonProperty.getAnnotations().addAll(atomProperty.getAnnotations());
-
-    if (atomProperty.getValue().isComplex()) {
-      final ComplexValueImpl complex = new ComplexValueImpl();
-      jsonProperty.setValue(complex);
-
-      for (Property field : atomProperty.getValue().asComplex().get()) {
-        complex.get().add(toJSONProperty((AtomPropertyImpl) field));
-      }
-    } else if (atomProperty.getValue().isCollection()) {
-      final CollectionValueImpl collection = new CollectionValueImpl();
-      jsonProperty.setValue(collection);
-
-      for (Value element : atomProperty.getValue().asCollection().get()) {
-        if (element.isComplex()) {
-          final ComplexValueImpl complex = new ComplexValueImpl();
-          collection.get().add(complex);
-
-          for (Property field : element.asComplex().get()) {
-            complex.get().add(toJSONProperty((AtomPropertyImpl) field));
-          }
-        } else {
-          collection.get().add(element);
-        }
-      }
-    } else {
-      jsonProperty.setValue(atomProperty.getValue());
-    }
-
-    return jsonProperty;
-  }
-
-  public AtomPropertyImpl toAtomProperty(final JSONPropertyImpl jsonProperty, final String entryType) {
-    final AtomPropertyImpl atomProperty = new AtomPropertyImpl();
-    atomProperty.setName(jsonProperty.getName());
-    atomProperty.getAnnotations().addAll(jsonProperty.getAnnotations());
-
-    final EntityType entityType = entryType == null
-            ? null
-            : metadata.getEntityOrComplexType(entryType.replaceAll("^Collection\\(", "").replaceAll("\\)$", ""));
-
-    // For non-primitive types, alwasy trust what was sent - if available; otherwise, search metadata
-    if (StringUtils.isNotBlank(jsonProperty.getType())
-            && ((entityType != null && entityType.isOpenType())
-            || jsonProperty.getName() == null
-            || !jsonProperty.getType().startsWith(EdmPrimitiveType.EDM_NAMESPACE))) {
-
-      atomProperty.setType(jsonProperty.getType());
-    } else if (entityType != null) {
-      atomProperty.setType(entityType.getProperty(jsonProperty.getName()).getType());
-    }
-
-    if (jsonProperty.getValue().isComplex()) {
-      final ComplexValueImpl complex = new ComplexValueImpl();
-      atomProperty.setValue(complex);
-
-      for (Property field : jsonProperty.getValue().asComplex().get()) {
-        complex.get().add(toAtomProperty((JSONPropertyImpl) field, atomProperty.getType()));
-      }
-    } else if (jsonProperty.getValue().isCollection()) {
-      final CollectionValueImpl collection = new CollectionValueImpl();
-      atomProperty.setValue(collection);
-
-      for (Value element : jsonProperty.getValue().asCollection().get()) {
-        if (element instanceof ComplexValueImpl) {
-          final ComplexValueImpl complex = new ComplexValueImpl();
-          collection.get().add(complex);
-
-          for (Property field : element.asComplex().get()) {
-            complex.get().add(toAtomProperty((JSONPropertyImpl) field, atomProperty.getType()));
-          }
-        } else {
-          collection.get().add(element);
-        }
-      }
-    } else {
-      atomProperty.setValue(jsonProperty.getValue());
-    }
-
-    return atomProperty;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 b8378cb..374d0f5 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
@@ -18,7 +18,6 @@
  */
 package org.apache.olingo.fit.utils;
 
-import com.fasterxml.jackson.databind.ObjectMapper;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
@@ -28,7 +27,9 @@ import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.util.EnumMap;
 import java.util.Map;
+
 import javax.ws.rs.NotFoundException;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.vfs2.FileObject;
 import org.apache.commons.vfs2.FileSelectInfo;
@@ -37,11 +38,12 @@ import org.apache.commons.vfs2.FileSystemException;
 import org.apache.commons.vfs2.FileSystemManager;
 import org.apache.commons.vfs2.FileType;
 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.core.data.AtomEntityImpl;
+import org.apache.olingo.commons.api.op.ODataSerializerException;
 import org.apache.olingo.commons.core.data.AtomSerializer;
-import org.apache.olingo.fit.serializer.JSONEntryContainer;
+import org.apache.olingo.commons.core.data.JsonSerializer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -59,7 +61,7 @@ public class FSManager {
   private final FileSystemManager fsManager;
 
   private static Map<ODataServiceVersion, FSManager> instance =
-          new EnumMap<ODataServiceVersion, FSManager>(ODataServiceVersion.class);
+      new EnumMap<ODataServiceVersion, FSManager>(ODataServiceVersion.class);
 
   private final ODataServiceVersion version;
 
@@ -79,8 +81,8 @@ public class FSManager {
 
     for (FileObject fo : find(basePath, null)) {
       if (fo.getType() == FileType.FILE
-              && !fo.getName().getBaseName().contains("Metadata")
-              && !fo.getName().getBaseName().contains("metadata")) {
+          && !fo.getName().getBaseName().contains("Metadata")
+          && !fo.getName().getBaseName().contains("metadata")) {
         final String path = fo.getURL().getPath().replace(absoluteBaseFolder, "//" + version.name());
         putInMemory(fo.getContent().getInputStream(), path);
       }
@@ -89,7 +91,7 @@ public class FSManager {
 
   public String getAbsolutePath(final String relativePath, final Accept accept) {
     return File.separatorChar + version.name() + File.separatorChar + relativePath
-            + (accept == null ? "" : accept.getExtension());
+        + (accept == null ? "" : accept.getExtension());
   }
 
   public final FileObject putInMemory(final InputStream is, final String path) throws IOException {
@@ -112,31 +114,21 @@ public class FSManager {
     return memObject;
   }
 
-  public void putInMemory(final ResWrap<AtomEntityImpl> container, final String relativePath,
-          final DataBinder dataBinder) throws IOException {
-    try {
-      final AtomSerializer atomSerializer = Commons.getAtomSerializer(version);
+  public void putInMemory(final ResWrap<Entity> container, final String relativePath)
+      throws IOException, ODataSerializerException {
+    ByteArrayOutputStream content = new ByteArrayOutputStream();
+    OutputStreamWriter writer = new OutputStreamWriter(content, Constants.ENCODING);
 
-      final ByteArrayOutputStream content = new ByteArrayOutputStream();
-      final OutputStreamWriter writer = new OutputStreamWriter(content, Constants.ENCODING);
+    new AtomSerializer(version, true).write(writer, container);
+    writer.flush();
 
-      atomSerializer.write(writer, container);
-      writer.flush();
+    putInMemory(new ByteArrayInputStream(content.toByteArray()), getAbsolutePath(relativePath, Accept.ATOM));
+    content.reset();
 
-      putInMemory(new ByteArrayInputStream(content.toByteArray()), getAbsolutePath(relativePath, Accept.ATOM));
-      content.reset();
+    new JsonSerializer(version, true).write(writer, container);
+    writer.flush();
 
-      final ObjectMapper mapper = Commons.getJSONMapper(version);
-      mapper.writeValue(
-              writer, new JSONEntryContainer(
-                      container.getContextURL(),
-                      container.getMetadataETag(),
-                      dataBinder.toJSONEntity(container.getPayload())));
-
-      putInMemory(new ByteArrayInputStream(content.toByteArray()), getAbsolutePath(relativePath, Accept.JSON_FULLMETA));
-    } catch (Exception e) {
-      throw new IOException(e);
-    }
+    putInMemory(new ByteArrayInputStream(content.toByteArray()), getAbsolutePath(relativePath, Accept.JSON_FULLMETA));
   }
 
   public InputStream readRes(final String relativePath, final Accept accept) {
@@ -235,4 +227,4 @@ public class FSManager {
       }
     });
   }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 7c6a54b..fe3f511 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
@@ -18,10 +18,6 @@
  */
 package org.apache.olingo.fit.utils;
 
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.fasterxml.jackson.databind.node.TextNode;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
@@ -33,17 +29,40 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+
 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;
 
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.InjectableValues;
+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;
+import com.fasterxml.jackson.databind.node.TextNode;
+
 public class JSONUtilities extends AbstractUtilities {
 
+  private final ObjectMapper mapper;
+
   public JSONUtilities(final ODataServiceVersion version, final Metadata metadata) throws Exception {
     super(version, metadata);
+
+    mapper = new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);
+    mapper.setInjectableValues(new InjectableValues.Std()
+            .addValue(Boolean.class, Boolean.TRUE)
+            .addValue(ODataServiceVersion.class, version));
+    mapper.setSerializerProvider(new InjectableSerializerProvider(mapper.getSerializerProvider(),
+            mapper.getSerializationConfig()
+            .withAttribute(ODataServiceVersion.class, version)
+            .withAttribute(Boolean.class, Boolean.TRUE),
+            mapper.getSerializerFactory()));
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 e606564..d292232 100644
--- a/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
@@ -21,6 +21,7 @@ package org.apache.olingo.fit;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.StringWriter;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.olingo.client.api.CommonODataClient;
 import org.apache.olingo.commons.api.data.Entity;
@@ -28,8 +29,9 @@ import org.apache.olingo.commons.api.data.EntitySet;
 import org.apache.olingo.commons.api.domain.CommonODataEntity;
 import org.apache.olingo.commons.api.domain.CommonODataProperty;
 import org.apache.olingo.commons.api.domain.ODataValue;
-import org.apache.olingo.commons.core.data.AtomEntityImpl;
-import org.apache.olingo.commons.core.data.JSONEntityImpl;
+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.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -46,7 +48,9 @@ public abstract class AbstractBaseTestITCase {
   protected void debugEntity(final Entity entity, final String message) {
     if (LOG.isDebugEnabled()) {
       final StringWriter writer = new StringWriter();
-      getClient().getSerializer().entity(entity, writer);
+      try {
+        getClient().getSerializer(ODataFormat.JSON).write(writer, entity);
+      } catch (final ODataSerializerException e) {}
       writer.flush();
       LOG.debug(message + "\n{}", writer.toString());
     }
@@ -55,7 +59,9 @@ public abstract class AbstractBaseTestITCase {
   protected void debugEntitySet(final EntitySet entitySet, final String message) {
     if (LOG.isDebugEnabled()) {
       final StringWriter writer = new StringWriter();
-      getClient().getSerializer().entitySet(entitySet, writer);
+      try {
+        getClient().getSerializer(ODataFormat.JSON).write(writer, entitySet);
+      } catch (final ODataSerializerException e) {}
       writer.flush();
       LOG.debug(message + "\n{}", writer.toString());
     }
@@ -72,12 +78,16 @@ public abstract class AbstractBaseTestITCase {
   protected void debugODataEntity(final CommonODataEntity entity, final String message) {
     if (LOG.isDebugEnabled()) {
       StringWriter writer = new StringWriter();
-      getClient().getSerializer().entity(getClient().getBinder().getEntity(entity, AtomEntityImpl.class), writer);
+      try {
+        getClient().getSerializer(ODataPubFormat.ATOM).write(writer, getClient().getBinder().getEntity(entity));
+      } catch (final ODataSerializerException e) {}
       writer.flush();
       LOG.debug(message + " (Atom)\n{}", writer.toString());
 
       writer = new StringWriter();
-      getClient().getSerializer().entity(getClient().getBinder().getEntity(entity, JSONEntityImpl.class), writer);
+      try {
+        getClient().getSerializer(ODataPubFormat.JSON).write(writer, getClient().getBinder().getEntity(entity));
+      } catch (final ODataSerializerException e) {}
       writer.flush();
       LOG.debug(message + " (JSON)\n{}", writer.toString());
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/fit/src/test/java/org/apache/olingo/fit/proxy/v4/MediaEntityTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/MediaEntityTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/MediaEntityTestITCase.java
index 0ffe48a..e1df392 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/MediaEntityTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/MediaEntityTestITCase.java
@@ -18,20 +18,21 @@
  */
 package org.apache.olingo.fit.proxy.v4;
 
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Calendar;
 import java.util.UUID;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.RandomStringUtils;
 import org.apache.olingo.client.api.v4.EdmEnabledODataClient;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.ext.proxy.EntityContainerFactory;
+import org.apache.olingo.fit.proxy.v4.AbstractTestITCase;
 import org.apache.olingo.fit.proxy.v4.demo.odatademo.DemoService;
 import org.apache.olingo.fit.proxy.v4.demo.odatademo.types.Advertisement;
 import org.junit.Test;
@@ -65,7 +66,7 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
     final UUID uuid = UUID.fromString("f89dee73-af9f-4cd4-b330-db93c25ff3c7");
 
     final Advertisement adv = getContainer().getAdvertisements().get(uuid);
-    assertTrue(adv.getAirDate() instanceof Calendar);
+    assertNotNull(adv.getAirDate());
 
     final InputStream is = adv.getStream();
     assertNotNull(is);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/fit/src/test/java/org/apache/olingo/fit/proxy/v4/NonTransactionalMediaEntityTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/NonTransactionalMediaEntityTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/NonTransactionalMediaEntityTestITCase.java
index 1c3c583..2f23551 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/NonTransactionalMediaEntityTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/NonTransactionalMediaEntityTestITCase.java
@@ -18,10 +18,9 @@
  */
 package org.apache.olingo.fit.proxy.v4;
 
+import org.apache.olingo.client.api.v4.EdmEnabledODataClient;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.ext.proxy.EntityContainerFactory;
-
-import org.apache.olingo.client.api.v4.EdmEnabledODataClient;
 import org.apache.olingo.fit.proxy.v4.demo.odatademo.DemoService;
 
 public class NonTransactionalMediaEntityTestITCase extends MediaEntityTestITCase {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/fit/src/test/java/org/apache/olingo/fit/v3/EntityRetrieveTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/EntityRetrieveTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/EntityRetrieveTestITCase.java
index 9314d2a..043e547 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v3/EntityRetrieveTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v3/EntityRetrieveTestITCase.java
@@ -43,7 +43,6 @@ import org.apache.olingo.commons.api.domain.v3.ODataEntity;
 import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.core.op.ResourceFactory;
 import org.junit.Test;
 
 /**
@@ -79,8 +78,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
         final CommonODataEntity inline = ((ODataInlineEntity) link).getEntity();
         assertNotNull(inline);
 
-        debugEntity(client.getBinder().getEntity(
-                inline, ResourceFactory.entityClassForFormat(format == ODataPubFormat.ATOM)), "Just read");
+        debugEntity(client.getBinder().getEntity(inline), "Just read");
 
         final List<? extends CommonODataProperty> properties = inline.getProperties();
         assertEquals(2, properties.size());
@@ -126,8 +124,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
         final CommonODataEntitySet inline = ((ODataInlineEntitySet) link).getEntitySet();
         assertNotNull(inline);
 
-        debugEntitySet(client.getBinder().getEntitySet(inline, ResourceFactory.entitySetClassForFormat(
-                format == ODataPubFormat.ATOM)), "Just read");
+        debugEntitySet(client.getBinder().getEntitySet(inline), "Just read");
 
         found = true;
       }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/fit/src/test/java/org/apache/olingo/fit/v3/EntitySetTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/EntitySetTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/EntitySetTestITCase.java
index 68fb07d..0f8649c 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v3/EntitySetTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v3/EntitySetTestITCase.java
@@ -36,7 +36,6 @@ 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.format.ODataPubFormat;
-import org.apache.olingo.commons.core.op.ResourceFactory;
 import org.junit.Test;
 
 /**
@@ -111,8 +110,7 @@ public class EntitySetTestITCase extends AbstractTestITCase {
 
     assertNotNull(feed);
 
-    debugEntitySet(client.getBinder().getEntitySet(feed, ResourceFactory.entitySetClassForFormat(
-            ODataPubFormat.ATOM == format)), "Just retrieved feed");
+    debugEntitySet(client.getBinder().getEntitySet(feed), "Just retrieved feed");
 
     assertEquals(2, feed.getEntities().size());
     assertNotNull(feed.getNext());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/fit/src/test/java/org/apache/olingo/fit/v4/JSONFormatConformanceTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/JSONFormatConformanceTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/JSONFormatConformanceTestITCase.java
index 346a144..7d48860 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/JSONFormatConformanceTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/JSONFormatConformanceTestITCase.java
@@ -25,6 +25,7 @@ import static org.junit.Assert.assertTrue;
 
 import java.math.BigDecimal;
 import java.net.URI;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
 import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
@@ -116,7 +117,7 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
    * .
    */
   @Test
-  public void item3() throws EdmPrimitiveTypeException {
+  public void item3() throws Exception {
     final String fromSection71 = "{"
             + "\"NullValue\": null,"
             + "\"TrueValue\": true,"
@@ -202,7 +203,7 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
    * MUST interpret all odata annotations defined according to the OData-Version header of the payload (section 4.5).
    */
   @Test
-  public void item4() {
+  public void item4() throws Exception {
     final String fromSection45_1 = "{"
             + "\"@odata.context\": \"http://host/service/$metadata#Customers/$entity\","
             + "\"@odata.metadataEtag\": \"W/\\\"A1FF3E230954908F\\\"\","
@@ -218,7 +219,7 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
             + "}";
 
     final ResWrap<Entity> entity =
-            client.getDeserializer().toEntity(IOUtils.toInputStream(fromSection45_1), ODataPubFormat.JSON);
+            client.getDeserializer(ODataPubFormat.JSON).toEntity(IOUtils.toInputStream(fromSection45_1));
 
     assertEquals("http://host/service/$metadata#Customers/$entity", entity.getContextURL().getURI().toASCIIString());
     assertEquals("W/\"A1FF3E230954908F\"", entity.getMetadataETag());
@@ -240,7 +241,7 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
             + "}";
 
     final ResWrap<EntitySet> entitySet =
-            client.getDeserializer().toEntitySet(IOUtils.toInputStream(fromSection45_2), ODataPubFormat.JSON);
+            client.getDeserializer(ODataPubFormat.JSON).toEntitySet(IOUtils.toInputStream(fromSection45_2));
 
     assertEquals(5, entitySet.getPayload().getCount(), 0);
     assertEquals("Customers?$expand=Orders&$skipToken=5", entitySet.getPayload().getNext().toASCIIString());
@@ -249,10 +250,10 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
 
   /**
    * MUST be prepared to receive any annotations, including custom annotations and <tt>odata</tt> annotations not
-   * defined in the <tt>OData-Version</tt> header of the payload (section 20).
+   * defined in the <tt>OData-Version</tt> header of the payload (section 20). 
    */
   @Test
-  public void item5() throws EdmPrimitiveTypeException {
+  public void item5() throws Exception {
     final String sample = "{"
             + "  \"@odata.context\": \"http://host/service/$metadata#Customers\","
             + "  \"@odata.notdefined\": 11,"

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 1a83849..8c398ca 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
@@ -26,14 +26,15 @@ 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.commons.api.domain.CommonODataObjectFactory;
 import org.apache.olingo.client.api.op.CommonODataBinder;
 import org.apache.olingo.client.api.op.CommonODataReader;
-import org.apache.olingo.commons.api.op.ODataSerializer;
 import org.apache.olingo.client.api.op.ODataWriter;
-import org.apache.olingo.client.api.uri.CommonURIBuilder;
 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;
 
 /**
  * Generic client interface (common to all supported OData protocol versions).
@@ -54,9 +55,9 @@ public interface CommonODataClient<UT extends CommonUpdateType> {
 
   CommonFilterFactory getFilterFactory();
 
-  ODataSerializer getSerializer();
+  ODataSerializer getSerializer(Format format);
 
-  ClientODataDeserializer getDeserializer();
+  ClientODataDeserializer getDeserializer(Format format);
 
   CommonODataReader getReader();
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 f51285d..87cc970 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
@@ -26,6 +26,7 @@ import java.io.OutputStream;
 import java.net.URI;
 import java.util.Iterator;
 import java.util.NoSuchElementException;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.olingo.client.api.CommonODataClient;
@@ -35,6 +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.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -54,8 +56,6 @@ public class ODataEntitySetIterator<ES extends CommonODataEntitySet, E extends C
    */
   private static final Logger LOG = LoggerFactory.getLogger(ODataEntitySetIterator.class);
 
-  private static final long serialVersionUID = 9039605899821494025L;
-
   private final CommonODataClient odataClient;
 
   private final InputStream stream;
@@ -120,8 +120,12 @@ public class ODataEntitySetIterator<ES extends CommonODataEntitySet, E extends C
 
       if (cached == null) {
         available = false;
-        entitySet = (ES) odataClient.getReader().
-                readEntitySet(new ByteArrayInputStream(osEntitySet.toByteArray()), format);
+        try {
+          entitySet = (ES) odataClient.getReader().
+                  readEntitySet(new ByteArrayInputStream(osEntitySet.toByteArray()), format);
+        } catch (final ODataDeserializerException e) {
+          available = false;
+        }
         close();
       }
     }
@@ -209,8 +213,8 @@ public class ODataEntitySetIterator<ES extends CommonODataEntitySet, E extends C
         }
 
         if (c >= 0) {
-          jsonEntity = odataClient.getDeserializer().toEntity(
-                  new ByteArrayInputStream(entity.toByteArray()), ODataPubFormat.JSON);
+          jsonEntity = odataClient.getDeserializer(ODataPubFormat.JSON).toEntity(
+                  new ByteArrayInputStream(entity.toByteArray()));
         }
       } else {
         while ((c = input.read()) >= 0) {
@@ -238,8 +242,8 @@ public class ODataEntitySetIterator<ES extends CommonODataEntitySet, E extends C
         entity.write(">".getBytes(Constants.UTF8));
 
         if (consume(input, "</entry>", entity, true) >= 0) {
-          atomEntity = odataClient.getDeserializer().
-                  toEntity(new ByteArrayInputStream(entity.toByteArray()), ODataPubFormat.ATOM);
+          atomEntity = odataClient.getDeserializer(ODataPubFormat.ATOM).
+                  toEntity(new ByteArrayInputStream(entity.toByteArray()));
         }
       }
     } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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
index 9bca91a..f7586bc 100644
--- 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
@@ -19,13 +19,14 @@
 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.format.ODataFormat;
-import org.apache.olingo.commons.api.op.CommonODataDeserializer;
+import org.apache.olingo.commons.api.op.ODataDeserializer;
+import org.apache.olingo.commons.api.op.ODataDeserializerException;
 
-public interface ClientODataDeserializer extends CommonODataDeserializer {
+public interface ClientODataDeserializer extends ODataDeserializer {
 
   XMLMetadata toMetadata(InputStream input);
 
@@ -33,8 +34,8 @@ public interface ClientODataDeserializer extends CommonODataDeserializer {
    * Gets the ServiceDocument object represented by the given InputStream.
    *
    * @param input stream to be de-serialized.
-   * @param format OData service document format.
    * @return <tt>ServiceDocument</tt> object.
+   * @throws ODataDeserializerException 
    */
-  ResWrap<ServiceDocument> toServiceDocument(InputStream input, ODataFormat format);
+  ResWrap<ServiceDocument> toServiceDocument(InputStream input) throws ODataDeserializerException;
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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
index cf7dc5c..530177c 100644
--- 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
@@ -18,57 +18,52 @@
  */
 package org.apache.olingo.client.api.op;
 
-import java.io.Serializable;
+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.client.api.data.ServiceDocument;
 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.ODataLink;
 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 extends Serializable {
+public interface CommonODataBinder {
 
   /**
    * Gets a <tt>EntitySet</tt> from the given OData entity set.
    *
    * @param entitySet OData entity set.
-   * @param reference reference class.
    * @return {@link EntitySet} object.
    */
-  EntitySet getEntitySet(CommonODataEntitySet entitySet, Class<? extends EntitySet> reference);
+  EntitySet getEntitySet(CommonODataEntitySet entitySet);
 
   /**
    * Gets an <tt>Entity</tt> from the given OData entity.
    *
    * @param entity OData entity.
-   * @param reference reference class.
    * @return {@link Entity} object.
    */
-  Entity getEntity(CommonODataEntity entity, Class<? extends Entity> reference);
+  Entity getEntity(CommonODataEntity entity);
 
   /**
    * Gets a <tt>Link</tt> from the given OData link.
    *
    * @param link OData link.
-   * @param isXML whether it is JSON or XML / Atom
    * @return <tt>Link</tt> object.
    */
-  Link getLink(ODataLink link, boolean isXML);
+  Link getLink(ODataLink link);
 
   /**
    * Gets a <tt>Property</tt> from the given OData property.
    *
    * @param property OData property.
-   * @param reference reference class.
    * @return <tt>Property</tt> object.
    */
-  Property getProperty(CommonODataProperty property, Class<? extends Entity> reference);
+  Property getProperty(CommonODataProperty property);
 
   /**
    * Adds the given property to the given complex value.


[15/23] [OLINGO-317] Rename and move of some packages and classes

Posted by ch...@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);
+    }
+  }
+}


[06/23] [OLINGO-317] First presentable state

Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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
index 897f8f9..056977f 100644
--- 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
@@ -19,18 +19,19 @@
 package org.apache.olingo.client.api.op;
 
 import java.io.InputStream;
-import java.io.Serializable;
 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.ODataError;
 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.
@@ -39,7 +40,7 @@ import org.apache.olingo.commons.api.format.ODataPubFormat;
  * <br/>
  * This class provides method helpers to de-serialize an entire entity set, a set of entities or a single entity.
  */
-public interface CommonODataReader extends Serializable {
+public interface CommonODataReader {
 
   /**
    * Parses a stream into metadata representation.
@@ -64,8 +65,9 @@ public interface CommonODataReader extends Serializable {
    * @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);
+  ODataServiceDocument readServiceDocument(InputStream input, ODataFormat format) throws ODataDeserializerException;
 
   /**
    * De-Serializes a stream into an OData entity set.
@@ -73,8 +75,9 @@ public interface CommonODataReader extends Serializable {
    * @param input stream to de-serialize.
    * @param format de-serialize format
    * @return de-serialized entity set.
+   * @throws ODataDeserializerException 
    */
-  CommonODataEntitySet readEntitySet(InputStream input, ODataPubFormat format);
+  CommonODataEntitySet readEntitySet(InputStream input, ODataPubFormat format) throws ODataDeserializerException;
 
   /**
    * Parses a stream taking care to de-serializes the first OData entity found.
@@ -82,8 +85,9 @@ public interface CommonODataReader extends Serializable {
    * @param input stream to de-serialize.
    * @param format de-serialize format
    * @return entity de-serialized.
+   * @throws ODataDeserializerException 
    */
-  CommonODataEntity readEntity(InputStream input, ODataPubFormat format);
+  CommonODataEntity readEntity(InputStream input, ODataPubFormat format) throws ODataDeserializerException;
 
   /**
    * Parses a stream taking care to de-serialize the first OData entity property found.
@@ -91,17 +95,19 @@ public interface CommonODataReader extends Serializable {
    * @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);
+  CommonODataProperty readProperty(InputStream input, ODataFormat format) throws ODataDeserializerException;
 
   /**
    * Parses a stream into an OData error.
    *
    * @param inputStream stream to de-serialize.
-   * @param isXML 'TRUE' if the error is in XML format.
+   * @param format format
    * @return OData error.
+   * @throws ODataDeserializerException 
    */
-  ODataError readError(InputStream inputStream, boolean isXML);
+  ODataError readError(InputStream inputStream, ODataFormat format) throws ODataDeserializerException;
 
   /**
    * Parses a stream into the object type specified by the given reference.
@@ -111,6 +117,7 @@ public interface CommonODataReader extends Serializable {
    * @param format format
    * @param reference reference.
    * @return read object.
+   * @throws ODataDeserializerException 
    */
-  <T> ResWrap<T> read(InputStream src, String format, Class<T> reference);
+  <T> ResWrap<T> read(InputStream src, String format, Class<T> reference) throws ODataDeserializerException;
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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
index 2f54ecd..6cd8b7a 100644
--- 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
@@ -19,13 +19,14 @@
 package org.apache.olingo.client.api.op;
 
 import java.io.InputStream;
-import java.io.Serializable;
 import java.util.Collection;
+
 import org.apache.olingo.commons.api.domain.CommonODataEntity;
-import org.apache.olingo.commons.api.domain.ODataLink;
 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.
@@ -34,7 +35,7 @@ import org.apache.olingo.commons.api.format.ODataPubFormat;
  * <br/>
  * This interface provides method helpers to serialize a set of entities and a single entity as well.
  */
-public interface ODataWriter extends Serializable {
+public interface ODataWriter {
 
   /**
    * Writes a collection of OData entities.
@@ -42,8 +43,10 @@ public interface ODataWriter extends Serializable {
    * @param entities entities to be serialized.
    * @param format serialization format.
    * @return stream of serialized objects.
+   * @throws ODataSerializerException 
    */
-  InputStream writeEntities(Collection<CommonODataEntity> entities, ODataPubFormat format);
+  InputStream writeEntities(Collection<CommonODataEntity> entities, ODataPubFormat format)
+      throws ODataSerializerException;
 
   /**
    * Serializes a single OData entity.
@@ -51,8 +54,10 @@ public interface ODataWriter extends Serializable {
    * @param entity entity to be serialized.
    * @param format serialization format.
    * @return stream of serialized object.
+   * @throws ODataSerializerException 
    */
-  InputStream writeEntity(CommonODataEntity entity, ODataPubFormat format);
+  InputStream writeEntity(CommonODataEntity entity, ODataPubFormat format)
+      throws ODataSerializerException;
 
   /**
    * Writes a single OData entity property.
@@ -60,8 +65,10 @@ public interface ODataWriter extends Serializable {
    * @param property entity property to be serialized.
    * @param format serialization format.
    * @return stream of serialized object.
+   * @throws ODataSerializerException 
    */
-  InputStream writeProperty(CommonODataProperty property, ODataFormat format);
+  InputStream writeProperty(CommonODataProperty property, ODataFormat format)
+      throws ODataSerializerException;
 
   /**
    * Writes an OData link.
@@ -69,6 +76,8 @@ public interface ODataWriter extends Serializable {
    * @param link link to be serialized.
    * @param format serialization format.
    * @return stream of serialized object.
+   * @throws ODataSerializerException 
    */
-  InputStream writeLink(ODataLink link, ODataFormat format);
+  InputStream writeLink(ODataLink link, ODataFormat format)
+      throws ODataSerializerException;
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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
index ff559a1..e71ed05 100644
--- 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
@@ -19,10 +19,11 @@
 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.format.ODataFormat;
+import org.apache.olingo.commons.api.op.ODataDeserializerException;
 
 public interface ODataDeserializer extends ClientODataDeserializer {
 
@@ -30,9 +31,8 @@ public interface ODataDeserializer extends ClientODataDeserializer {
    * Gets a list of links from the given InputStream.
    *
    * @param input stream to be de-serialized.
-   * @param format OData format.
    * @return de-serialized links.
+   * @throws ODataDeserializerException 
    */
-  ResWrap<LinkCollection> toLinkCollection(InputStream input, ODataFormat format);
-
+  ResWrap<LinkCollection> toLinkCollection(InputStream input) throws ODataDeserializerException;
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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
index 2e72ce4..4b91f16 100644
--- 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
@@ -19,6 +19,7 @@
 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;
@@ -26,17 +27,18 @@ 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);
+  ODataEntitySet readEntitySet(InputStream input, ODataPubFormat format) throws ODataDeserializerException;
 
   @Override
-  ODataEntity readEntity(InputStream input, ODataPubFormat format);
+  ODataEntity readEntity(InputStream input, ODataPubFormat format) throws ODataDeserializerException;
 
   @Override
-  ODataProperty readProperty(InputStream input, ODataFormat format);
+  ODataProperty readProperty(InputStream input, ODataFormat format) throws ODataDeserializerException;
 
   /**
    * Parses a $links request response.
@@ -45,6 +47,5 @@ public interface ODataReader extends CommonODataReader {
    * @param format de-serialize as XML or JSON
    * @return List of URIs.
    */
-  ODataLinkCollection readLinks(InputStream input, ODataFormat format);
-
+  ODataLinkCollection readLinks(InputStream input, ODataFormat format) throws ODataDeserializerException;
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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
index 199e98f..e20c66e 100644
--- 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
@@ -24,7 +24,7 @@ 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.format.ODataPubFormat;
+import org.apache.olingo.commons.api.op.ODataDeserializerException;
 
 public interface ODataDeserializer extends ClientODataDeserializer {
 
@@ -35,8 +35,8 @@ public interface ODataDeserializer extends ClientODataDeserializer {
    * Gets a delta object from the given InputStream.
    *
    * @param input stream to be de-serialized.
-   * @param format Atom or JSON
    * @return {@link Delta} instance.
+   * @throws ODataDeserializerException 
    */
-  ResWrap<Delta> toDelta(InputStream input, ODataPubFormat format);
+  ResWrap<Delta> toDelta(InputStream input) throws ODataDeserializerException;
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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
index c976c05..8877e7e 100644
--- 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
@@ -19,21 +19,23 @@
 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);
+  ODataEntitySet readEntitySet(InputStream input, ODataPubFormat format) throws ODataDeserializerException;
 
   @Override
-  ODataEntity readEntity(InputStream input, ODataPubFormat format);
+  ODataEntity readEntity(InputStream input, ODataPubFormat format) throws ODataDeserializerException;
 
   @Override
-  ODataProperty readProperty(InputStream input, ODataFormat format);
+  ODataProperty readProperty(InputStream input, ODataFormat format) throws ODataDeserializerException;
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 7606313..86e5b6d 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
@@ -29,6 +29,7 @@ import org.apache.olingo.client.api.op.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;
+import org.apache.olingo.commons.api.format.Format;
 
 public interface ODataClient extends CommonODataClient<UpdateType> {
 
@@ -36,7 +37,7 @@ public interface ODataClient extends CommonODataClient<UpdateType> {
   Configuration getConfiguration();
 
   @Override
-  ODataDeserializer getDeserializer();
+  ODataDeserializer getDeserializer(Format format);
 
   @Override
   ODataReader getReader();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 eff7ce7..383a488 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
@@ -31,6 +31,7 @@ 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;
 import org.apache.olingo.commons.api.domain.v4.ODataObjectFactory;
+import org.apache.olingo.commons.api.format.Format;
 
 public interface ODataClient extends CommonODataClient<UpdateType> {
 
@@ -38,7 +39,7 @@ public interface ODataClient extends CommonODataClient<UpdateType> {
   Configuration getConfiguration();
 
   @Override
-  ODataDeserializer getDeserializer();
+  ODataDeserializer getDeserializer(Format format);
 
   @Override
   ODataReader getReader();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 0632c42..da9b40f 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
@@ -16,8 +16,6 @@
 package org.apache.olingo.client.core.communication.request;
 
 import java.io.IOException;
-import java.io.InputStream;
-import org.apache.http.Header;
 
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
@@ -26,11 +24,11 @@ import org.apache.olingo.client.api.CommonEdmEnabledODataClient;
 import org.apache.olingo.client.api.CommonODataClient;
 import org.apache.olingo.client.api.communication.ODataClientErrorException;
 import org.apache.olingo.client.api.communication.ODataServerErrorException;
-import org.apache.olingo.client.api.communication.header.HeaderName;
 import org.apache.olingo.client.api.http.HttpClientException;
 import org.apache.olingo.commons.api.domain.ODataError;
-import org.apache.olingo.commons.core.data.JSONODataErrorImpl;
-import org.apache.olingo.commons.core.data.XMLODataErrorImpl;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.core.data.ODataErrorImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -41,36 +39,28 @@ public abstract class AbstractRequest {
    */
   protected static final Logger LOG = LoggerFactory.getLogger(AbstractRequest.class);
 
-  private ODataError getGenericError(final int code, final String errorMsg, final boolean isXML) {
-    final ODataError error;
-    if (isXML) {
-      error = new XMLODataErrorImpl();
-      ((XMLODataErrorImpl) error).setCode(String.valueOf(code));
-      ((XMLODataErrorImpl) error).setMessage(errorMsg);
-    } else {
-      error = new JSONODataErrorImpl();
-      ((JSONODataErrorImpl) error).setCode(String.valueOf(code));
-      ((JSONODataErrorImpl) error).setMessage(errorMsg);
-    }
-
+  private ODataError getGenericError(final int code, final String errorMsg) {
+    final ODataErrorImpl error = new ODataErrorImpl();
+    error.setCode(String.valueOf(code));
+    error.setMessage(errorMsg);
     return error;
   }
 
   protected void checkRequest(final CommonODataClient<?> odataClient, final HttpUriRequest request) {
     // If using and Edm enabled client, checks that the cached service root matches the request URI
     if (odataClient instanceof CommonEdmEnabledODataClient
-            && !request.getURI().toASCIIString().startsWith(
+        && !request.getURI().toASCIIString().startsWith(
             ((CommonEdmEnabledODataClient) odataClient).getServiceRoot())) {
 
       throw new IllegalArgumentException(
-              String.format("The current request URI %s does not match the configured service root %s",
+          String.format("The current request URI %s does not match the configured service root %s",
               request.getURI().toASCIIString(),
               ((CommonEdmEnabledODataClient) odataClient).getServiceRoot()));
     }
   }
 
   protected void checkResponse(
-          final CommonODataClient<?> odataClient, final HttpResponse response, final String accept) {
+      final CommonODataClient<?> odataClient, final HttpResponse response, final String accept) {
 
     if (response.getStatusLine().getStatusCode() >= 400) {
       try {
@@ -78,27 +68,21 @@ public abstract class AbstractRequest {
         if (httpEntity == null) {
           throw new ODataClientErrorException(response.getStatusLine());
         } else {
-          boolean isXML;
-          if (!accept.contains("json") && !accept.contains("xml")) {
-            isXML = true;
-            for (Header header : response.getHeaders(HeaderName.contentType.toString())) {
-              if (header.getValue() != null && header.getValue().contains("json")) {
-                isXML = false;
-              }
-            }
-          } else {
-            isXML = !accept.contains("json");
-          }
+          ODataFormat format = accept.contains("xml") ? ODataFormat.XML : ODataFormat.JSON;
 
           ODataError error;
           try {
-            error = odataClient.getReader().readError(httpEntity.getContent(), isXML);
-          } catch (IllegalArgumentException e) {
+            error = odataClient.getReader().readError(httpEntity.getContent(), format);
+          } catch (final RuntimeException e) {
+            LOG.warn("Error deserializing error response", e);
+            error = getGenericError(
+                response.getStatusLine().getStatusCode(),
+                response.getStatusLine().getReasonPhrase());
+          } catch (final ODataDeserializerException e) {
             LOG.warn("Error deserializing error response", e);
             error = getGenericError(
-                    response.getStatusLine().getStatusCode(),
-                    response.getStatusLine().getReasonPhrase(),
-                    isXML);
+                response.getStatusLine().getStatusCode(),
+                response.getStatusLine().getReasonPhrase());
           }
 
           if (response.getStatusLine().getStatusCode() >= 500) {
@@ -109,7 +93,7 @@ public abstract class AbstractRequest {
         }
       } catch (IOException e) {
         throw new HttpClientException(
-                "Received '" + response.getStatusLine() + "' but could not extract error body", e);
+            "Received '" + response.getStatusLine() + "' but could not extract error body", e);
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 2822d82..10236e0 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
@@ -20,6 +20,7 @@ package org.apache.olingo.client.core.communication.request.cud;
 
 import java.io.InputStream;
 import java.net.URI;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.HttpClient;
@@ -29,6 +30,9 @@ import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateR
 import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
 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.client.api.http.HttpClientException;
 import org.apache.olingo.client.api.http.HttpMethod;
 import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
@@ -67,7 +71,11 @@ public class ODataEntityCreateRequestImpl<E extends CommonODataEntity>
    */
   @Override
   protected InputStream getPayload() {
-    return odataClient.getWriter().writeEntity(entity, ODataPubFormat.fromString(getContentType()));
+    try {
+      return odataClient.getWriter().writeEntity(entity, ODataPubFormat.fromString(getContentType()));
+    } catch (final ODataSerializerException e) {
+      throw new HttpClientException(e);
+    }
   }
 
   /**
@@ -119,10 +127,12 @@ public class ODataEntityCreateRequestImpl<E extends CommonODataEntity>
     public E getBody() {
       if (entity == null) {
         try {
-          final ResWrap<Entity> resource = odataClient.getDeserializer().
-                  toEntity(getRawResponse(), ODataPubFormat.fromString(getAccept()));
+          final ResWrap<Entity> resource = odataClient.getDeserializer(ODataPubFormat.fromString(getAccept()))
+              .toEntity(getRawResponse());
           
           entity = (E) odataClient.getBinder().getODataEntity(resource);
+        } catch (final ODataDeserializerException e) {
+          throw new HttpClientException(e);
         } finally {
           this.close();
         }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 c3b8359..acbe764 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
@@ -20,6 +20,7 @@ package org.apache.olingo.client.core.communication.request.cud;
 
 import java.io.InputStream;
 import java.net.URI;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.HttpClient;
@@ -29,6 +30,9 @@ import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateR
 import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
 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.client.api.http.HttpClientException;
 import org.apache.olingo.client.api.http.HttpMethod;
 import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
@@ -42,8 +46,8 @@ import org.apache.olingo.commons.api.data.Entity;
  * @param <E> concrete ODataEntity implementation
  */
 public class ODataEntityUpdateRequestImpl<E extends CommonODataEntity>
-        extends AbstractODataBasicRequest<ODataEntityUpdateResponse<E>, ODataPubFormat>
-        implements ODataEntityUpdateRequest<E> {
+    extends AbstractODataBasicRequest<ODataEntityUpdateResponse<E>, ODataPubFormat>
+    implements ODataEntityUpdateRequest<E> {
 
   /**
    * Changes to be applied.
@@ -59,7 +63,7 @@ public class ODataEntityUpdateRequestImpl<E extends CommonODataEntity>
    * @param changes changes to be applied.
    */
   public ODataEntityUpdateRequestImpl(final CommonODataClient<?> odataClient,
-          final HttpMethod method, final URI uri, final E changes) {
+      final HttpMethod method, final URI uri, final E changes) {
 
     super(odataClient, ODataPubFormat.class, method, uri);
     this.changes = changes;
@@ -80,12 +84,13 @@ public class ODataEntityUpdateRequestImpl<E extends CommonODataEntity>
     }
   }
 
-  /**
-   * {@inheritDoc }
-   */
   @Override
   protected InputStream getPayload() {
-    return odataClient.getWriter().writeEntity(changes, ODataPubFormat.fromString(getContentType()));
+    try {
+      return odataClient.getWriter().writeEntity(changes, ODataPubFormat.fromString(getContentType()));
+    } catch (final ODataSerializerException e) {
+      throw new HttpClientException(e);
+    }
   }
 
   /**
@@ -103,8 +108,7 @@ public class ODataEntityUpdateRequestImpl<E extends CommonODataEntity>
      * <p>
      * Just to create response templates to be initialized from batch.
      */
-    private ODataEntityUpdateResponseImpl() {
-    }
+    private ODataEntityUpdateResponseImpl() {}
 
     /**
      * Constructor.
@@ -116,18 +120,17 @@ public class ODataEntityUpdateRequestImpl<E extends CommonODataEntity>
       super(client, res);
     }
 
-    /**
-     * {@inheritDoc ]
-     */
     @Override
     @SuppressWarnings("unchecked")
     public E getBody() {
       if (entity == null) {
         try {
-          final ResWrap<Entity> resource = odataClient.getDeserializer().
-                  toEntity(getRawResponse(), ODataPubFormat.fromString(getAccept()));
+          final ResWrap<Entity> resource = odataClient.getDeserializer(ODataPubFormat.fromString(getAccept()))
+              .toEntity(getRawResponse());
 
           entity = (E) odataClient.getBinder().getODataEntity(resource);
+        } catch (final ODataDeserializerException e) {
+          throw new HttpClientException(e);
         } finally {
           this.close();
         }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 fe2fdbb..759ebbb 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
@@ -20,6 +20,7 @@ package org.apache.olingo.client.core.communication.request.cud;
 
 import java.io.InputStream;
 import java.net.URI;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.HttpClient;
@@ -27,14 +28,17 @@ import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
 import org.apache.olingo.client.api.CommonODataClient;
 import org.apache.olingo.client.api.communication.request.cud.ODataPropertyUpdateRequest;
 import org.apache.olingo.client.api.communication.response.ODataPropertyUpdateResponse;
-import org.apache.olingo.commons.api.domain.CommonODataProperty;
-import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.client.api.http.HttpClientException;
 import org.apache.olingo.client.api.http.HttpMethod;
-import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
 import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
-import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.client.core.uri.URIUtils;
 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;
 
 /**
  * This class implements an OData update entity property request.
@@ -77,7 +81,11 @@ public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest<OD
 
   @Override
   protected InputStream getPayload() {
-    return odataClient.getWriter().writeProperty(property, ODataFormat.fromString(getContentType()));
+    try {
+      return odataClient.getWriter().writeProperty(property, ODataFormat.fromString(getContentType()));
+    } catch (final ODataSerializerException e) {
+      throw new HttpClientException(e);
+    }
   }
 
   /**
@@ -105,17 +113,16 @@ public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest<OD
       super(client, res);
     }
 
-    /**
-     * {@inheritDoc }
-     */
     @Override
     public CommonODataProperty getBody() {
       if (property == null) {
         try {
-          final ResWrap<Property> resource = odataClient.getDeserializer().
-                  toProperty(getRawResponse(), ODataFormat.fromString(getAccept()));
+          final ResWrap<Property> resource = odataClient.getDeserializer(ODataFormat.fromString(getAccept()))
+                  .toProperty(getRawResponse());
 
           property = odataClient.getBinder().getODataProperty(resource);
+        } catch (final ODataDeserializerException e) {
+          throw new HttpClientException(e);
         } finally {
           this.close();
         }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 7c97ec3..df31813 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
@@ -20,6 +20,7 @@ package org.apache.olingo.client.core.communication.request.cud.v3;
 
 import java.io.InputStream;
 import java.net.URI;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.HttpClient;
@@ -29,6 +30,8 @@ import org.apache.olingo.client.api.communication.request.cud.v3.ODataLinkCreate
 import org.apache.olingo.client.api.communication.response.ODataLinkOperationResponse;
 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.client.api.http.HttpClientException;
 import org.apache.olingo.client.api.http.HttpMethod;
 import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
@@ -52,7 +55,7 @@ public class ODataLinkCreateRequestImpl extends AbstractODataBasicRequest<ODataL
    * @param targetURI entity set URI.
    * @param link entity to be linked.
    */
-  ODataLinkCreateRequestImpl(final CommonODataClient odataClient, final URI targetURI, final ODataLink link) {
+  ODataLinkCreateRequestImpl(final CommonODataClient<?> odataClient, final URI targetURI, final ODataLink link) {
     super(odataClient, ODataFormat.class, HttpMethod.POST, targetURI);
     // set request body
     this.link = link;
@@ -73,12 +76,13 @@ public class ODataLinkCreateRequestImpl extends AbstractODataBasicRequest<ODataL
     }
   }
 
-  /**
-   * {@inheritDoc}
-   */
   @Override
   protected InputStream getPayload() {
-    return odataClient.getWriter().writeLink(link, ODataFormat.fromString(getContentType()));
+    try {
+      return odataClient.getWriter().writeLink(link, ODataFormat.fromString(getContentType()));
+    } catch (final ODataSerializerException e) {
+      throw new HttpClientException(e);
+    }
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 c445cc0..ae1756c 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
@@ -20,6 +20,7 @@ package org.apache.olingo.client.core.communication.request.cud.v3;
 
 import java.io.InputStream;
 import java.net.URI;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.HttpClient;
@@ -29,6 +30,8 @@ import org.apache.olingo.client.api.communication.request.cud.v3.ODataLinkUpdate
 import org.apache.olingo.client.api.communication.response.ODataLinkOperationResponse;
 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.client.api.http.HttpClientException;
 import org.apache.olingo.client.api.http.HttpMethod;
 import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
@@ -53,7 +56,7 @@ public class ODataLinkUpdateRequestImpl extends AbstractODataBasicRequest<ODataL
    * @param targetURI entity URI.
    * @param link entity to be linked.
    */
-  ODataLinkUpdateRequestImpl(final CommonODataClient odataClient,
+  ODataLinkUpdateRequestImpl(final CommonODataClient<?> odataClient,
           final HttpMethod method, final URI targetURI, final ODataLink link) {
 
     super(odataClient, ODataFormat.class, method, targetURI);
@@ -61,9 +64,6 @@ public class ODataLinkUpdateRequestImpl extends AbstractODataBasicRequest<ODataL
     this.link = link;
   }
 
-  /**
-   * {@inheritDoc }
-   */
   @Override
   public ODataLinkOperationResponse execute() {
     final InputStream input = getPayload();
@@ -76,12 +76,13 @@ public class ODataLinkUpdateRequestImpl extends AbstractODataBasicRequest<ODataL
     }
   }
 
-  /**
-   * {@inheritDoc }
-   */
   @Override
   protected InputStream getPayload() {
-    return odataClient.getWriter().writeLink(link, ODataFormat.fromString(getContentType()));
+    try {
+      return odataClient.getWriter().writeLink(link, ODataFormat.fromString(getContentType()));
+    } catch (final ODataSerializerException e) {
+      throw new HttpClientException(e);
+    }
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 361741b..8ecd827 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
@@ -23,6 +23,7 @@ import java.io.InputStream;
 import java.net.URI;
 import java.util.LinkedHashMap;
 import java.util.Map;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.HttpClient;
@@ -40,6 +41,8 @@ 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.ODataDeserializerException;
+import org.apache.olingo.commons.api.op.ODataSerializerException;
 import org.apache.olingo.client.api.http.HttpClientException;
 import org.apache.olingo.client.api.http.HttpMethod;
 import org.apache.olingo.client.api.v4.ODataClient;
@@ -137,7 +140,11 @@ public abstract class AbstractODataInvokeRequest<T extends ODataInvokeResult>
         }
       }
 
-      return odataClient.getWriter().writeEntity(tmp, getPOSTParameterFormat());
+      try {
+        return odataClient.getWriter().writeEntity(tmp, getPOSTParameterFormat());
+      } catch (final ODataSerializerException e) {
+        throw new HttpClientException(e);
+      }
     }
 
     return null;
@@ -220,6 +227,8 @@ public abstract class AbstractODataInvokeRequest<T extends ODataInvokeResult>
            }
         } catch (IOException e) {
           throw new HttpClientException(e);
+        } catch (final ODataDeserializerException e) {
+          throw new HttpClientException(e);
         } finally {
           this.close();
         }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 8652086..2904577 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
@@ -19,15 +19,18 @@
 package org.apache.olingo.client.core.communication.request.retrieve;
 
 import java.net.URI;
+
 import org.apache.http.HttpResponse;
 import org.apache.http.client.HttpClient;
 import org.apache.olingo.client.api.CommonODataClient;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
 import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
+import org.apache.olingo.client.api.http.HttpClientException;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.domain.CommonODataEntity;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.op.ODataDeserializerException;
 
 /**
  * This class implements an OData retrieve query request returning a single entity.
@@ -81,10 +84,12 @@ public class ODataEntityRequestImpl<E extends CommonODataEntity>
     public E getBody() {
       if (entity == null) {
         try {
-          final ResWrap<Entity> resource = odataClient.getDeserializer().
-                  toEntity(getRawResponse(), ODataPubFormat.fromString(getContentType()));
+          final ResWrap<Entity> resource = odataClient.getDeserializer(ODataPubFormat.fromString(getContentType()))
+              .toEntity(getRawResponse());
 
           entity = (E) odataClient.getBinder().getODataEntity(resource);
+        } catch (final ODataDeserializerException e) {
+          throw new HttpClientException(e);
         } finally {
           this.close();
         }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 1783789..90df1e2 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
@@ -19,15 +19,18 @@
 package org.apache.olingo.client.core.communication.request.retrieve;
 
 import java.net.URI;
+
 import org.apache.http.HttpResponse;
 import org.apache.http.client.HttpClient;
 import org.apache.olingo.client.api.CommonODataClient;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
 import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
+import org.apache.olingo.client.api.http.HttpClientException;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.data.EntitySet;
 import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.op.ODataDeserializerException;
 
 /**
  * This class implements an OData EntitySet query request.
@@ -45,7 +48,7 @@ public class ODataEntitySetRequestImpl<ES extends CommonODataEntitySet>
    * @param odataClient client instance getting this request
    * @param query query to be executed.
    */
-  public ODataEntitySetRequestImpl(final CommonODataClient odataClient, final URI query) {
+  public ODataEntitySetRequestImpl(final CommonODataClient<?> odataClient, final URI query) {
     super(odataClient, ODataPubFormat.class, query);
   }
 
@@ -90,10 +93,12 @@ public class ODataEntitySetRequestImpl<ES extends CommonODataEntitySet>
     public ES getBody() {
       if (entitySet == null) {
         try {
-          final ResWrap<EntitySet> resource = odataClient.getDeserializer().
-                  toEntitySet(getRawResponse(), ODataPubFormat.fromString(getContentType()));
+          final ResWrap<EntitySet> resource = odataClient.getDeserializer(ODataPubFormat.fromString(getContentType()))
+              .toEntitySet(getRawResponse());
 
           entitySet = (ES) odataClient.getBinder().getODataEntitySet(resource);
+        } catch (final ODataDeserializerException e) {
+          throw new HttpClientException(e);
         } finally {
           this.close();
         }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 f0d6924..0be7920 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
@@ -20,6 +20,7 @@ package org.apache.olingo.client.core.communication.request.retrieve;
 
 import java.io.IOException;
 import java.net.URI;
+
 import org.apache.http.HttpResponse;
 import org.apache.http.client.HttpClient;
 import org.apache.olingo.client.api.CommonODataClient;
@@ -27,6 +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.client.api.http.HttpClientException;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.data.Property;
@@ -80,12 +82,14 @@ public class ODataPropertyRequestImpl<T extends CommonODataProperty>
     public T getBody() {
       if (property == null) {
         try {
-          final ResWrap<Property> resource = odataClient.getDeserializer().toProperty(
-                  res.getEntity().getContent(), ODataFormat.fromString(getContentType()));
+          final ResWrap<Property> resource = odataClient.getDeserializer(ODataFormat.fromString(getContentType()))
+              .toProperty(res.getEntity().getContent());
 
           property = (T) odataClient.getBinder().getODataProperty(resource);
         } catch (IOException e) {
           throw new HttpClientException(e);
+        } catch (final ODataDeserializerException e) {
+          throw new HttpClientException(e);
         } finally {
           this.close();
         }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 003a013..faa8a28 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
@@ -21,6 +21,7 @@ package org.apache.olingo.client.core.communication.request.retrieve;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.net.URI;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.HttpClient;
@@ -28,6 +29,8 @@ import org.apache.olingo.client.api.CommonODataClient;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataRawRequest;
 import org.apache.olingo.client.api.communication.response.ODataRawResponse;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.client.api.http.HttpClientException;
 import org.apache.olingo.client.api.http.HttpMethod;
 import org.apache.olingo.client.core.communication.request.AbstractODataRequest;
 import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
@@ -45,7 +48,7 @@ public class ODataRawRequestImpl extends AbstractODataRequest<ODataPubFormat>
    * @param odataClient client instance getting this request
    * @param uri request URI.
    */
-  ODataRawRequestImpl(final CommonODataClient odataClient, final URI uri) {
+  ODataRawRequestImpl(final CommonODataClient<?> odataClient, final URI uri) {
     super(odataClient, ODataPubFormat.class, HttpMethod.GET, uri);
   }
 
@@ -94,8 +97,12 @@ public class ODataRawRequestImpl extends AbstractODataRequest<ODataPubFormat>
         }
       }
 
-      return odataClient.getReader().
-              read(new ByteArrayInputStream(obj), getContentType(), reference);
+      try {
+        return odataClient.getReader().
+                read(new ByteArrayInputStream(obj), getContentType(), reference);
+      } catch (final ODataDeserializerException e) {
+        throw new HttpClientException(e);
+      }
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 2222c0d..b8605f9 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
@@ -19,21 +19,24 @@
 package org.apache.olingo.client.core.communication.request.retrieve;
 
 import java.net.URI;
+
 import org.apache.http.HttpResponse;
 import org.apache.http.client.HttpClient;
 import org.apache.olingo.client.api.CommonODataClient;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataServiceDocumentRequest;
 import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
 import org.apache.olingo.client.api.data.ServiceDocument;
+import org.apache.olingo.client.api.http.HttpClientException;
 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;
 
 /**
  * This class implements an OData service document request.
  */
 public class ODataServiceDocumentRequestImpl extends AbstractODataRetrieveRequest<ODataServiceDocument, ODataFormat>
-        implements ODataServiceDocumentRequest {
+    implements ODataServiceDocumentRequest {
 
   /**
    * Constructor.
@@ -41,7 +44,7 @@ public class ODataServiceDocumentRequestImpl extends AbstractODataRetrieveReques
    * @param odataClient client instance getting this request
    * @param uri request URI.
    */
-  ODataServiceDocumentRequestImpl(final CommonODataClient odataClient, final URI uri) {
+  ODataServiceDocumentRequestImpl(final CommonODataClient<?> odataClient, final URI uri) {
     super(odataClient, ODataFormat.class, uri);
   }
 
@@ -66,8 +69,7 @@ public class ODataServiceDocumentRequestImpl extends AbstractODataRetrieveReques
      * <p>
      * Just to create response templates to be initialized from batch.
      */
-    private ODataServiceResponseImpl() {
-    }
+    private ODataServiceResponseImpl() {}
 
     /**
      * Constructor.
@@ -83,10 +85,13 @@ public class ODataServiceDocumentRequestImpl extends AbstractODataRetrieveReques
     public ODataServiceDocument getBody() {
       if (serviceDocument == null) {
         try {
-          final ResWrap<ServiceDocument> resource = odataClient.getDeserializer().
-                  toServiceDocument(getRawResponse(), ODataFormat.fromString(getContentType()));
+          final ResWrap<ServiceDocument> resource =
+              odataClient.getDeserializer(ODataFormat.fromString(getContentType()))
+                  .toServiceDocument(getRawResponse());
 
           serviceDocument = odataClient.getBinder().getODataServiceDocument(resource.getPayload());
+        } catch (final ODataDeserializerException e) {
+          throw new HttpClientException(e);
         } finally {
           this.close();
         }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 e64a764..9cd5419 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
@@ -20,6 +20,7 @@ package org.apache.olingo.client.core.communication.request.retrieve.v3;
 
 import java.io.IOException;
 import java.net.URI;
+
 import org.apache.http.HttpResponse;
 import org.apache.http.client.HttpClient;
 import org.apache.olingo.client.api.v3.ODataClient;
@@ -27,6 +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.client.api.http.HttpClientException;
 import org.apache.olingo.client.core.communication.request.retrieve.AbstractODataRetrieveRequest;
 
@@ -78,9 +80,6 @@ public class ODataLinkCollectionRequestImpl extends AbstractODataRetrieveRequest
       super(client, res);
     }
 
-    /**
-     * {@inheritDoc }
-     */
     @Override
     public ODataLinkCollection getBody() {
       if (links == null) {
@@ -89,6 +88,8 @@ public class ODataLinkCollectionRequestImpl extends AbstractODataRetrieveRequest
                   res.getEntity().getContent(), ODataFormat.fromString(getContentType()));
         } catch (IOException e) {
           throw new HttpClientException(e);
+        } catch (final ODataDeserializerException e) {
+          throw new HttpClientException(e);
         } finally {
           this.close();
         }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/XMLMetadataRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/XMLMetadataRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/XMLMetadataRequestImpl.java
index 8a480ee..1304b84 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/XMLMetadataRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/XMLMetadataRequestImpl.java
@@ -21,6 +21,7 @@ package org.apache.olingo.client.core.communication.request.retrieve.v3;
 import java.net.URI;
 import java.util.HashMap;
 import java.util.Map;
+
 import org.apache.commons.lang3.StringUtils;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.HttpClient;
@@ -30,6 +31,7 @@ import org.apache.olingo.client.api.edm.xml.Schema;
 import org.apache.olingo.client.api.edm.xml.XMLMetadata;
 import org.apache.olingo.client.api.v3.ODataClient;
 import org.apache.olingo.client.core.communication.request.retrieve.AbstractMetadataRequestImpl;
+import org.apache.olingo.commons.api.format.ODataFormat;
 
 public class XMLMetadataRequestImpl extends AbstractMetadataRequestImpl<Map<String, Schema>>
         implements XMLMetadataRequest {
@@ -71,7 +73,8 @@ public class XMLMetadataRequestImpl extends AbstractMetadataRequestImpl<Map<Stri
       if (schemas == null) {
         schemas = new HashMap<String, Schema>();
         try {
-          final XMLMetadata metadata = odataClient.getDeserializer().toMetadata(getRawResponse());
+          final XMLMetadata metadata = odataClient.getDeserializer(ODataFormat.XML)
+              .toMetadata(getRawResponse());
           for (Schema schema : metadata.getSchemas()) {
             schemas.put(schema.getNamespace(), schema);
             if (StringUtils.isNotBlank(schema.getAlias())) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 570eb36..00a61cc 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
@@ -20,6 +20,7 @@ package org.apache.olingo.client.core.communication.request.retrieve.v4;
 
 import java.io.IOException;
 import java.net.URI;
+
 import org.apache.http.HttpResponse;
 import org.apache.http.client.HttpClient;
 import org.apache.olingo.client.api.CommonODataClient;
@@ -32,9 +33,10 @@ 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;
 
 public class ODataDeltaRequestImpl extends AbstractODataRetrieveRequest<ODataDelta, ODataPubFormat>
-        implements ODataDeltaRequest {
+    implements ODataDeltaRequest {
 
   public ODataDeltaRequestImpl(final CommonODataClient<?> odataClient, final URI query) {
     super(odataClient, ODataPubFormat.class, query);
@@ -64,12 +66,15 @@ public class ODataDeltaRequestImpl extends AbstractODataRetrieveRequest<ODataDel
     public ODataDelta getBody() {
       if (delta == null) {
         try {
-          final ResWrap<Delta> resource = ((ODataClient) odataClient).getDeserializer().toDelta(
-                  res.getEntity().getContent(), ODataPubFormat.fromString(getContentType()));
+          final ResWrap<Delta> resource = ((ODataClient) odataClient)
+              .getDeserializer(ODataPubFormat.fromString(getContentType()))
+                  .toDelta(res.getEntity().getContent());
 
           delta = ((ODataClient) odataClient).getBinder().getODataDelta(resource);
         } catch (IOException e) {
           throw new HttpClientException(e);
+        } catch (final ODataDeserializerException e) {
+          throw new HttpClientException(e);
         } finally {
           this.close();
         }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/XMLMetadataRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/XMLMetadataRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/XMLMetadataRequestImpl.java
index 865b95c..88fb07a 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/XMLMetadataRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/XMLMetadataRequestImpl.java
@@ -21,6 +21,7 @@ package org.apache.olingo.client.core.communication.request.retrieve.v4;
 import java.net.URI;
 import java.util.HashMap;
 import java.util.Map;
+
 import org.apache.commons.lang3.StringUtils;
 import org.apache.olingo.client.api.communication.request.retrieve.XMLMetadataRequest;
 import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
@@ -35,6 +36,7 @@ import org.apache.olingo.client.api.v4.ODataClient;
 import org.apache.olingo.client.core.communication.request.retrieve.AbstractMetadataRequestImpl;
 import org.apache.olingo.client.core.edm.xml.v4.AnnotationsImpl;
 import org.apache.olingo.client.core.edm.xml.v4.SchemaImpl;
+import org.apache.olingo.commons.api.format.ODataFormat;
 
 public class XMLMetadataRequestImpl extends AbstractMetadataRequestImpl<Map<String, Schema>>
         implements XMLMetadataRequest {
@@ -132,7 +134,7 @@ public class XMLMetadataRequestImpl extends AbstractMetadataRequestImpl<Map<Stri
         @Override
         public XMLMetadata getBody() {
           try {
-            return ((ODataClient) odataClient).getDeserializer().toMetadata(getRawResponse());
+            return ((ODataClient) odataClient).getDeserializer(ODataFormat.XML).toMetadata(getRawResponse());
           } finally {
             this.close();
           }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 60bca42..4e27bea 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
@@ -21,6 +21,7 @@ package org.apache.olingo.client.core.communication.request.streamed;
 import java.io.InputStream;
 import java.net.URI;
 import java.util.concurrent.TimeUnit;
+
 import org.apache.http.HttpResponse;
 import org.apache.http.client.HttpClient;
 import org.apache.olingo.client.api.CommonODataClient;
@@ -28,11 +29,13 @@ import org.apache.olingo.client.api.communication.request.streamed.MediaEntityCr
 import org.apache.olingo.client.api.communication.request.streamed.ODataMediaEntityCreateRequest;
 import org.apache.olingo.client.api.communication.response.ODataMediaEntityCreateResponse;
 import org.apache.olingo.commons.api.domain.CommonODataEntity;
+import org.apache.olingo.client.api.http.HttpClientException;
 import org.apache.olingo.client.api.http.HttpMethod;
 import org.apache.olingo.client.core.communication.request.AbstractODataStreamManager;
 import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.op.ODataDeserializerException;
 
 /**
  * This class implements an OData Media Entity create request. Get instance by using ODataStreamedRequestFactory.
@@ -115,17 +118,17 @@ public class ODataMediaEntityCreateRequestImpl<E extends CommonODataEntity>
       super(client, res);
     }
 
-    /**
-     * {@inheritDoc }
-     */
     @Override
     @SuppressWarnings("unchecked")
     public E getBody() {
       if (entity == null) {
         try {
-          final ResWrap<Entity> resource = odataClient.getDeserializer().toEntity(getRawResponse(), getFormat());
+          final ResWrap<Entity> resource = odataClient.getDeserializer(getFormat())
+              .toEntity(getRawResponse());
 
           entity = (E) odataClient.getBinder().getODataEntity(resource);
+        } catch (final ODataDeserializerException e) {
+          throw new HttpClientException(e);
         } finally {
           this.close();
         }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 a63efa8..f06bed2 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
@@ -21,6 +21,7 @@ package org.apache.olingo.client.core.communication.request.streamed;
 import java.io.InputStream;
 import java.net.URI;
 import java.util.concurrent.TimeUnit;
+
 import org.apache.http.HttpResponse;
 import org.apache.http.client.HttpClient;
 import org.apache.olingo.client.api.CommonODataClient;
@@ -28,11 +29,13 @@ import org.apache.olingo.client.api.communication.request.streamed.MediaEntityUp
 import org.apache.olingo.client.api.communication.request.streamed.ODataMediaEntityUpdateRequest;
 import org.apache.olingo.client.api.communication.response.ODataMediaEntityUpdateResponse;
 import org.apache.olingo.commons.api.domain.CommonODataEntity;
+import org.apache.olingo.client.api.http.HttpClientException;
 import org.apache.olingo.client.api.http.HttpMethod;
 import org.apache.olingo.client.core.communication.request.AbstractODataStreamManager;
 import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.op.ODataDeserializerException;
 
 /**
  * This class implements an OData Media Entity create request. Get instance by using ODataStreamedRequestFactory.
@@ -122,9 +125,11 @@ public class ODataMediaEntityUpdateRequestImpl<E extends CommonODataEntity>
     public E getBody() {
       if (entity == null) {
         try {
-          final ResWrap<Entity> resource = odataClient.getDeserializer().toEntity(getRawResponse(), getFormat());
+          final ResWrap<Entity> resource = odataClient.getDeserializer(getFormat()).toEntity(getRawResponse());
 
           entity = (E) odataClient.getBinder().getODataEntity(resource);
+        } catch (final ODataDeserializerException e) {
+          throw new HttpClientException(e);
         } finally {
           this.close();
         }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/main/java/org/apache/olingo/client/core/data/AbstractServiceDocument.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/AbstractServiceDocument.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/AbstractServiceDocument.java
deleted file mode 100644
index 9631e85..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/AbstractServiceDocument.java
+++ /dev/null
@@ -1,139 +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.data;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
-import org.apache.olingo.client.api.data.ServiceDocument;
-import org.apache.olingo.client.api.data.ServiceDocumentItem;
-import org.apache.olingo.commons.api.Constants;
-
-public abstract class AbstractServiceDocument implements ServiceDocument {
-
-  private String title;
-
-  private final List<ServiceDocumentItem> entitySets = new ArrayList<ServiceDocumentItem>();
-
-  private String metadata;
-
-  @Override
-  public URI getBaseURI() {
-    URI baseURI = null;
-    if (metadata != null) {
-      final String metadataURI = getMetadata();
-      baseURI = URI.create(metadataURI.substring(0, metadataURI.indexOf(Constants.METADATA)));
-    }
-
-    return baseURI;
-  }
-
-  /**
-   * Gets the metadata URI.
-   *
-   * @return the metadata URI
-   */
-  public String getMetadata() {
-    return metadata;
-  }
-
-  /**
-   * Sets the metadata URI.
-   *
-   * @param metadata metadata URI.
-   */
-  public void setMetadata(final String metadata) {
-    this.metadata = metadata;
-  }
-
-  @Override
-  public String getTitle() {
-    return title;
-  }
-
-  public void setTitle(final String title) {
-    this.title = title;
-  }
-
-  protected ServiceDocumentItem getByName(final List<ServiceDocumentItem> elements, final String name) {
-    ServiceDocumentItem result = null;
-    for (ServiceDocumentItem element : elements) {
-      if (name.equals(element.getName())) {
-        result = element;
-      }
-    }
-    return result;
-  }
-
-  @Override
-  public List<ServiceDocumentItem> getEntitySets() {
-    return entitySets;
-  }
-
-  @Override
-  public ServiceDocumentItem getEntitySetByName(final String name) {
-    return getByName(getEntitySets(), name);
-  }
-
-  @Override
-  public List<ServiceDocumentItem> getFunctionImports() {
-    return Collections.<ServiceDocumentItem>emptyList();
-  }
-
-  @Override
-  public ServiceDocumentItem getFunctionImportByName(final String name) {
-    return getByName(getFunctionImports(), name);
-  }
-
-  @Override
-  public List<ServiceDocumentItem> getSingletons() {
-    return Collections.<ServiceDocumentItem>emptyList();
-  }
-
-  @Override
-  public ServiceDocumentItem getSingletonByName(final String name) {
-    return getByName(getSingletons(), name);
-  }
-
-  @Override
-  public List<ServiceDocumentItem> getRelatedServiceDocuments() {
-    return Collections.<ServiceDocumentItem>emptyList();
-  }
-
-  @Override
-  public boolean equals(final Object obj) {
-    return EqualsBuilder.reflectionEquals(this, obj);
-  }
-
-  @Override
-  public int hashCode() {
-    return HashCodeBuilder.reflectionHashCode(this);
-  }
-
-  @Override
-  public String toString() {
-    return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 4f84fc6..1bf5c4d 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
@@ -18,34 +18,36 @@
  */
 package org.apache.olingo.client.core.data;
 
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
 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.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.core.data.ODataJacksonDeserializer;
+import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.core.data.JsonDeserializer;
 
-public class JSONServiceDocumentDeserializer extends ODataJacksonDeserializer<ResWrap<AbstractServiceDocument>> {
+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;
 
-  @Override
-  protected ResWrap<AbstractServiceDocument> doDeserialize(
-          final JsonParser parser, final DeserializationContext ctxt)
-          throws IOException, JsonProcessingException {
+public class JSONServiceDocumentDeserializer extends JsonDeserializer {
+
+  public JSONServiceDocumentDeserializer(final ODataServiceVersion version, final boolean serverMode) {
+    super(version, serverMode);
+  }
+
+  protected ResWrap<ServiceDocument> doDeserialize(final JsonParser parser) throws IOException {
 
     final ObjectNode tree = (ObjectNode) parser.getCodec().readTree(parser);
 
-    final AbstractServiceDocument serviceDocument = ODataServiceVersion.V30 == version
-            ? new org.apache.olingo.client.core.data.v3.JSONServiceDocumentImpl()
-            : new org.apache.olingo.client.core.data.v4.JSONServiceDocumentImpl();
+    ServiceDocumentImpl serviceDocument = new ServiceDocumentImpl();
 
     final String metadataETag;
     if (tree.hasNonNull(Constants.JSON_METADATA_ETAG)) {
@@ -87,6 +89,15 @@ public class JSONServiceDocumentDeserializer extends ODataJacksonDeserializer<Re
       }
     }
 
-    return new ResWrap<AbstractServiceDocument>(contextURL, metadataETag, serviceDocument);
+    return new ResWrap<ServiceDocument>(contextURL, metadataETag, serviceDocument);
+  }
+
+  public ResWrap<ServiceDocument> toServiceDocument(final 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/46a34178/lib/client-core/src/main/java/org/apache/olingo/client/core/data/ServiceDocumentImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/ServiceDocumentImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/ServiceDocumentImpl.java
new file mode 100755
index 0000000..ec10e9d
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/ServiceDocumentImpl.java
@@ -0,0 +1,141 @@
+/*
+ * 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.data;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import org.apache.olingo.client.api.data.ServiceDocument;
+import org.apache.olingo.client.api.data.ServiceDocumentItem;
+import org.apache.olingo.commons.api.Constants;
+
+public class ServiceDocumentImpl implements ServiceDocument {
+
+  private String title;
+
+  private final List<ServiceDocumentItem> entitySets = new ArrayList<ServiceDocumentItem>();
+  private final List<ServiceDocumentItem> functionImports = new ArrayList<ServiceDocumentItem>();
+  private final List<ServiceDocumentItem> singletons = new ArrayList<ServiceDocumentItem>();
+  private final List<ServiceDocumentItem> relatedServiceDocuments = new ArrayList<ServiceDocumentItem>();
+
+  private String metadata;
+
+  @Override
+  public URI getBaseURI() {
+    URI baseURI = null;
+    if (metadata != null) {
+      final String metadataURI = getMetadata();
+      baseURI = URI.create(metadataURI.substring(0, metadataURI.indexOf(Constants.METADATA)));
+    }
+
+    return baseURI;
+  }
+
+  /**
+   * Gets the metadata URI.
+   *
+   * @return the metadata URI
+   */
+  public String getMetadata() {
+    return metadata;
+  }
+
+  /**
+   * Sets the metadata URI.
+   *
+   * @param metadata metadata URI.
+   */
+  public void setMetadata(final String metadata) {
+    this.metadata = metadata;
+  }
+
+  @Override
+  public String getTitle() {
+    return title;
+  }
+
+  public void setTitle(final String title) {
+    this.title = title;
+  }
+
+  protected ServiceDocumentItem getByName(final List<ServiceDocumentItem> elements, final String name) {
+    ServiceDocumentItem result = null;
+    for (ServiceDocumentItem element : elements) {
+      if (name.equals(element.getName())) {
+        result = element;
+      }
+    }
+    return result;
+  }
+
+  @Override
+  public List<ServiceDocumentItem> getEntitySets() {
+    return entitySets;
+  }
+
+  @Override
+  public ServiceDocumentItem getEntitySetByName(final String name) {
+    return getByName(getEntitySets(), name);
+  }
+
+  @Override
+  public List<ServiceDocumentItem> getFunctionImports() {
+    return functionImports;
+  }
+
+  @Override
+  public ServiceDocumentItem getFunctionImportByName(final String name) {
+    return getByName(getFunctionImports(), name);
+  }
+
+  @Override
+  public List<ServiceDocumentItem> getSingletons() {
+    return singletons;
+  }
+
+  @Override
+  public ServiceDocumentItem getSingletonByName(final String name) {
+    return getByName(getSingletons(), name);
+  }
+
+  @Override
+  public List<ServiceDocumentItem> getRelatedServiceDocuments() {
+    return relatedServiceDocuments;
+  }
+
+  @Override
+  public boolean equals(final Object obj) {
+    return EqualsBuilder.reflectionEquals(this, obj);
+  }
+
+  @Override
+  public int hashCode() {
+    return HashCodeBuilder.reflectionHashCode(this);
+  }
+
+  @Override
+  public String toString() {
+    return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
+  }
+}


[13/23] [OLINGO-317] Rename and move of some packages and classes

Posted by ch...@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/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());
+  }
+}


[05/23] [OLINGO-317] First presentable state

Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 6b38382..22d5dc8 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
@@ -18,22 +18,27 @@
  */
 package org.apache.olingo.client.core.data;
 
-import org.apache.olingo.commons.core.data.ODataJacksonDeserializer;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.JsonToken;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser;
-
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.URI;
 
 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;
 
-public class XMLServiceDocumentDeserializer extends ODataJacksonDeserializer<ResWrap<ServiceDocument>> {
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.dataformat.xml.XmlFactory;
+import com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser;
+
+public class XMLServiceDocumentDeserializer extends JsonDeserializer {
+
+  public XMLServiceDocumentDeserializer(final ODataServiceVersion version, final boolean serverMode) {
+    super(version, serverMode);
+  }
 
   private String getName(final JsonParser jp) throws IOException {
     String title = jp.nextTextValue();
@@ -47,11 +52,11 @@ public class XMLServiceDocumentDeserializer extends ODataJacksonDeserializer<Res
   }
 
   private ServiceDocumentItemImpl deserializeElement(final JsonParser jp, final String elementName)
-          throws IOException {
+      throws IOException {
 
     final ServiceDocumentItemImpl element = new ServiceDocumentItemImpl();
     for (; jp.getCurrentToken() != JsonToken.END_OBJECT
-            || !elementName.equals(((FromXmlParser) jp).getStaxReader().getLocalName()); jp.nextToken()) {
+        || !elementName.equals(((FromXmlParser) jp).getStaxReader().getLocalName()); jp.nextToken()) {
 
       final JsonToken token = jp.getCurrentToken();
       if (token == JsonToken.FIELD_NAME) {
@@ -66,20 +71,16 @@ public class XMLServiceDocumentDeserializer extends ODataJacksonDeserializer<Res
     return element;
   }
 
-  @Override
-  protected ResWrap<ServiceDocument> doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
-          throws IOException, JsonProcessingException {
+  protected ResWrap<ServiceDocument> doDeserialize(final JsonParser jp) throws IOException {
 
-    final AbstractServiceDocument sdoc = ODataServiceVersion.V30 == version
-            ? new org.apache.olingo.client.core.data.v3.XMLServiceDocumentImpl()
-            : new org.apache.olingo.client.core.data.v4.XMLServiceDocumentImpl();
+    ServiceDocumentImpl sdoc = new ServiceDocumentImpl();
 
     URI contextURL = null;
     String metadataETag = null;
     String base = null;
 
     for (; jp.getCurrentToken() != JsonToken.END_OBJECT
-            || !"service".equals(((FromXmlParser) jp).getStaxReader().getLocalName()); jp.nextToken()) {
+        || !"service".equals(((FromXmlParser) jp).getStaxReader().getLocalName()); jp.nextToken()) {
 
       final JsonToken token = jp.getCurrentToken();
       if (token == JsonToken.FIELD_NAME) {
@@ -112,11 +113,20 @@ public class XMLServiceDocumentDeserializer extends ODataJacksonDeserializer<Res
     }
 
     sdoc.setMetadata((contextURL == null
-            ? URIUtils.getURI(base, "$metadata")
-            : URIUtils.getURI(base, contextURL.toASCIIString())).toASCIIString());
+        ? URIUtils.getURI(base, "$metadata")
+        : URIUtils.getURI(base, contextURL.toASCIIString())).toASCIIString());
 
     return new ResWrap<ServiceDocument>(
-            contextURL == null ? null : URIUtils.getURI(sdoc.getBaseURI(), contextURL),
-            metadataETag, sdoc);
+        contextURL == null ? null : URIUtils.getURI(sdoc.getBaseURI(), contextURL),
+        metadataETag, sdoc);
+  }
+
+  public ResWrap<ServiceDocument> toServiceDocument(InputStream input) throws ODataDeserializerException {
+    try {
+      JsonParser parser = new XmlFactory().createParser(input);
+      return doDeserialize(parser);
+    } catch (final IOException e) {
+      throw new ODataDeserializerException(e);
+    }
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v3/JSONServiceDocumentImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v3/JSONServiceDocumentImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v3/JSONServiceDocumentImpl.java
deleted file mode 100644
index af957a1..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v3/JSONServiceDocumentImpl.java
+++ /dev/null
@@ -1,35 +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.data.v3;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-
-
-import org.apache.olingo.client.core.data.AbstractServiceDocument;
-import org.apache.olingo.client.core.data.JSONServiceDocumentDeserializer;
-
-/**
- * Service document, represented via JSON.
- */
-@JsonDeserialize(using = JSONServiceDocumentDeserializer.class)
-public class JSONServiceDocumentImpl extends AbstractServiceDocument {
-
-  private static final long serialVersionUID = 4195734928526398830L;
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v3/XMLServiceDocumentImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v3/XMLServiceDocumentImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v3/XMLServiceDocumentImpl.java
deleted file mode 100644
index e09b092..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v3/XMLServiceDocumentImpl.java
+++ /dev/null
@@ -1,30 +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.data.v3;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-
-
-import org.apache.olingo.client.api.data.ServiceDocument;
-import org.apache.olingo.client.core.data.AbstractServiceDocument;
-import org.apache.olingo.client.core.data.XMLServiceDocumentDeserializer;
-
-@JsonDeserialize(using = XMLServiceDocumentDeserializer.class)
-public class XMLServiceDocumentImpl extends AbstractServiceDocument implements ServiceDocument {
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v4/AbstractServiceDocument.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v4/AbstractServiceDocument.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v4/AbstractServiceDocument.java
deleted file mode 100644
index 45ce766..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v4/AbstractServiceDocument.java
+++ /dev/null
@@ -1,49 +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.data.v4;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.client.api.data.ServiceDocumentItem;
-
-public abstract class AbstractServiceDocument
-        extends org.apache.olingo.client.core.data.AbstractServiceDocument {
-
-  private List<ServiceDocumentItem> functionImports = new ArrayList<ServiceDocumentItem>();
-
-  private List<ServiceDocumentItem> singletons = new ArrayList<ServiceDocumentItem>();
-
-  private List<ServiceDocumentItem> relatedServiceDocuments = new ArrayList<ServiceDocumentItem>();
-
-  @Override
-  public List<ServiceDocumentItem> getFunctionImports() {
-    return functionImports;
-  }
-
-  @Override
-  public List<ServiceDocumentItem> getSingletons() {
-    return singletons;
-  }
-
-  @Override
-  public List<ServiceDocumentItem> getRelatedServiceDocuments() {
-    return relatedServiceDocuments;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v4/JSONServiceDocumentImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v4/JSONServiceDocumentImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v4/JSONServiceDocumentImpl.java
deleted file mode 100644
index f3dfd91..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v4/JSONServiceDocumentImpl.java
+++ /dev/null
@@ -1,28 +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.data.v4;
-
-import org.apache.olingo.client.api.data.ServiceDocument;
-import org.apache.olingo.client.core.data.JSONServiceDocumentDeserializer;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-
-@JsonDeserialize(using = JSONServiceDocumentDeserializer.class)
-public class JSONServiceDocumentImpl extends AbstractServiceDocument implements ServiceDocument {
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v4/XMLServiceDocumentImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v4/XMLServiceDocumentImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v4/XMLServiceDocumentImpl.java
deleted file mode 100644
index b3c64b6..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v4/XMLServiceDocumentImpl.java
+++ /dev/null
@@ -1,28 +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.data.v4;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-
-import org.apache.olingo.client.api.data.ServiceDocument;
-import org.apache.olingo.client.core.data.XMLServiceDocumentDeserializer;
-
-@JsonDeserialize(using = XMLServiceDocumentDeserializer.class)
-public class XMLServiceDocumentImpl extends AbstractServiceDocument implements ServiceDocument {
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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
index c52b0c1..5b0376b 100644
--- 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
@@ -21,6 +21,7 @@ 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;
@@ -65,23 +66,23 @@ 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.ODataPubFormat;
+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.JSONPropertyImpl;
 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.apache.olingo.commons.core.op.ResourceFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public abstract class AbstractODataBinder implements CommonODataBinder {
 
-  private static final long serialVersionUID = 454285889193689536L;
-
   /**
    * Logger.
    */
@@ -99,15 +100,15 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
 
     for (ServiceDocumentItem entitySet : resource.getEntitySets()) {
       serviceDocument.getEntitySets().
-              put(entitySet.getName(), URIUtils.getURI(resource.getBaseURI(), entitySet.getUrl()));
+          put(entitySet.getName(), URIUtils.getURI(resource.getBaseURI(), entitySet.getUrl()));
     }
 
     return serviceDocument;
   }
 
   @Override
-  public EntitySet getEntitySet(final CommonODataEntitySet odataEntitySet, final Class<? extends EntitySet> reference) {
-    final EntitySet entitySet = ResourceFactory.newEntitySet(reference);
+  public EntitySet getEntitySet(final CommonODataEntitySet odataEntitySet) {
+    final EntitySet entitySet = new EntitySetImpl();
 
     entitySet.setCount(odataEntitySet.getCount());
 
@@ -117,13 +118,13 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
     }
 
     for (CommonODataEntity entity : odataEntitySet.getEntities()) {
-      entitySet.getEntities().add(getEntity(entity, ResourceFactory.entityClassForEntitySet(reference)));
+      entitySet.getEntities().add(getEntity(entity));
     }
 
     return entitySet;
   }
 
-  protected void links(final ODataLinked odataLinked, final Linked linked, final Class<? extends Entity> reference) {
+  protected void links(final ODataLinked odataLinked, final Linked linked) {
     // -------------------------------------------------------------
     // Append navigation links (handling inline entity / entity set as well)
     // -------------------------------------------------------------
@@ -131,8 +132,7 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
     for (ODataLink link : odataLinked.getNavigationLinks()) {
       // append link 
       LOG.debug("Append navigation link\n{}", link);
-      linked.getNavigationLinks().add(getLink(link,
-              ResourceFactory.formatForEntityClass(reference) == ODataPubFormat.ATOM));
+      linked.getNavigationLinks().add(getLink(link));
     }
     // -------------------------------------------------------------
 
@@ -141,15 +141,14 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
     // -------------------------------------------------------------
     for (ODataLink link : odataLinked.getAssociationLinks()) {
       LOG.debug("Append association link\n{}", link);
-      linked.getAssociationLinks().add(getLink(link,
-              ResourceFactory.formatForEntityClass(reference) == ODataPubFormat.ATOM));
+      linked.getAssociationLinks().add(getLink(link));
     }
     // -------------------------------------------------------------
   }
 
   @Override
-  public Entity getEntity(final CommonODataEntity odataEntity, final Class<? extends Entity> reference) {
-    final Entity entity = ResourceFactory.newEntity(reference);
+  public Entity getEntity(final CommonODataEntity odataEntity) {
+    final Entity entity = new EntityImpl();
 
     entity.setType(odataEntity.getTypeName() == null ? null : odataEntity.getTypeName().toString());
 
@@ -174,15 +173,14 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
     }
     // -------------------------------------------------------------
 
-    links(odataEntity, entity, reference);
+    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,
-              ResourceFactory.formatForEntityClass(reference) == ODataPubFormat.ATOM));
+      entity.getMediaEditLinks().add(getLink(link));
     }
     // -------------------------------------------------------------
 
@@ -193,14 +191,14 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
     }
 
     for (CommonODataProperty property : odataEntity.getProperties()) {
-      entity.getProperties().add(getProperty(property, reference));
+      entity.getProperties().add(getProperty(property));
     }
 
     return entity;
   }
 
   @Override
-  public Link getLink(final ODataLink link, boolean isXML) {
+  public Link getLink(final ODataLink link) {
     final Link linkResource = new LinkImpl();
     linkResource.setRel(link.getRel());
     linkResource.setTitle(link.getName());
@@ -213,40 +211,40 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
       final CommonODataEntity inlineEntity = ((ODataInlineEntity) link).getEntity();
       LOG.debug("Append in-line entity\n{}", inlineEntity);
 
-      linkResource.setInlineEntity(getEntity(inlineEntity, ResourceFactory.entityClassForFormat(isXML)));
+      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, ResourceFactory.entitySetClassForFormat(isXML)));
+      linkResource.setInlineEntitySet(getEntitySet(InlineEntitySet));
     }
 
     return linkResource;
   }
 
-  protected Value getValue(final ODataValue value, final Class<? extends Entity> reference) {
+  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());
+          ? 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(), reference));
+        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(), reference));
+        valueResource.asCollection().get().add(getValue(itor.next()));
       }
     }
 
@@ -259,19 +257,21 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
   public CommonODataEntitySet getODataEntitySet(final ResWrap<EntitySet> resource) {
     if (LOG.isDebugEnabled()) {
       final StringWriter writer = new StringWriter();
-      client.getSerializer().entitySet(resource.getPayload(), writer);
+      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();
+        ? 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()));
+        ? client.getObjectFactory().newEntitySet()
+        : client.getObjectFactory().newEntitySet(URIUtils.getURI(base, next.toASCIIString()));
 
     if (resource.getPayload().getCount() != null) {
       entitySet.setCount(resource.getPayload().getCount());
@@ -279,14 +279,14 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
 
     for (Entity entityResource : resource.getPayload().getEntities()) {
       add(entitySet, getODataEntity(
-              new ResWrap<Entity>(resource.getContextURL(), resource.getMetadataETag(), entityResource)));
+          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) {
+      final Linked linked, final ODataLinked odataLinked, final String metadataETag, final URI base) {
 
     for (Link link : linked.getNavigationLinks()) {
       final Entity inlineEntity = link.getInlineEntity();
@@ -298,35 +298,35 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
           final EdmNavigationProperty navProp = ((EdmStructuredType) edmType).getNavigationProperty(link.getTitle());
           if (navProp != null) {
             linkType = navProp.isCollection()
-                    ? ODataLinkType.ENTITY_SET_NAVIGATION
-                    : ODataLinkType.ENTITY_NAVIGATION;
+                ? 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());
+              ? ODataLinkType.ENTITY_NAVIGATION
+              : ODataLinkType.fromString(client.getServiceVersion(), link.getRel(), link.getType());
         }
 
         odataLinked.addLink(linkType == ODataLinkType.ENTITY_NAVIGATION
-                ? client.getObjectFactory().
+            ? client.getObjectFactory().
                 newEntityNavigationLink(link.getTitle(), URIUtils.getURI(base, link.getHref()))
-                : client.getObjectFactory().
+            : 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))));
+            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))));
+            URIUtils.getURI(base, link.getHref()), ODataLinkType.ENTITY_SET_NAVIGATION, link.getTitle(),
+            getODataEntitySet(new ResWrap<EntitySet>(
+                inlineEntitySet.getBaseURI() == null ? base : inlineEntitySet.getBaseURI(),
+                metadataETag,
+                inlineEntitySet))));
       }
     }
   }
@@ -368,7 +368,7 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
         }
         if (type == null) {
           type = new EdmTypeInfo.Builder().setEdm(edm).
-                  setTypeExpression(contextURL.getEntitySetOrSingletonOrType()).build().getType();
+              setTypeExpression(contextURL.getEntitySetOrSingletonOrType()).build().getType();
         }
       } else {
         type = edm.getEntityType(new FullQualifiedName(contextURL.getDerivedEntity()));
@@ -382,13 +382,15 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
   public CommonODataEntity getODataEntity(final ResWrap<Entity> resource) {
     if (LOG.isDebugEnabled()) {
       final StringWriter writer = new StringWriter();
-      client.getSerializer().entity(resource.getPayload(), writer);
+      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();
+        ? resource.getPayload().getBaseURI() : resource.getContextURL().getServiceRoot();
 
     final EdmType edmType = findType(resource.getContextURL(), resource.getMetadataETag());
     FullQualifiedName typeName = null;
@@ -401,9 +403,9 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
     }
 
     final CommonODataEntity entity = resource.getPayload().getSelfLink() == null
-            ? client.getObjectFactory().newEntity(typeName)
-            : client.getObjectFactory().newEntity(typeName,
-                    URIUtils.getURI(base, resource.getPayload().getSelfLink().getHref()));
+        ? 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());
@@ -415,14 +417,14 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
 
     for (Link link : resource.getPayload().getAssociationLinks()) {
       entity.addLink(client.getObjectFactory().
-              newAssociationLink(link.getTitle(), URIUtils.getURI(base, link.getHref())));
+          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())));
+          newMediaEditLink(link.getTitle(), URIUtils.getURI(base, link.getHref())));
     }
 
     for (ODataOperation operation : resource.getPayload().getOperations()) {
@@ -452,7 +454,7 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
   }
 
   protected EdmTypeInfo buildTypeInfo(final ContextURL contextURL, final String metadataETag,
-          final String propertyName, final String propertyType) {
+      final String propertyName, final String propertyType) {
 
     FullQualifiedName typeName = null;
     final EdmType type = findType(contextURL, metadataETag);
@@ -488,23 +490,23 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
   protected abstract CommonODataProperty getODataProperty(EdmType type, Property resource);
 
   protected ODataValue getODataValue(final FullQualifiedName type,
-          final Valuable valuable, final ContextURL contextURL, final String metadataETag) {
+      final Valuable valuable, final ContextURL contextURL, final String metadataETag) {
 
     ODataValue value = null;
-    if (valuable.getValue().isPrimitive()) {
+    if (valuable.getValue().isGeospatial()) {
       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().isGeospatial()) {
+          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().
-              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();
+          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());
 
@@ -515,7 +517,7 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
       value = client.getObjectFactory().newCollectionValue(type == null ? null : "Collection(" + type.toString() + ")");
 
       for (Value _value : valuable.getValue().asCollection().get()) {
-        final Property fake = new JSONPropertyImpl();
+        final Property fake = new PropertyImpl();
         fake.setValue(_value);
         value.asCollection().add(getODataValue(type, fake, contextURL, metadataETag));
       }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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
index 18aa0cf..1b60736 100644
--- 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
@@ -21,6 +21,7 @@ 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;
@@ -43,14 +44,13 @@ 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 {
 
-  private static final long serialVersionUID = -1988865870981207079L;
-
   /**
    * Logger.
    */
@@ -64,7 +64,7 @@ public abstract class AbstractODataReader implements CommonODataReader {
 
   @Override
   public Edm readMetadata(final InputStream input) {
-    return readMetadata(client.getDeserializer().toMetadata(input).getSchemaByNsOrAlias());
+    return readMetadata(client.getDeserializer(ODataFormat.XML).toMetadata(input).getSchemaByNsOrAlias());
   }
 
   @Override
@@ -73,19 +73,21 @@ public abstract class AbstractODataReader implements CommonODataReader {
   }
 
   @Override
-  public ODataServiceDocument readServiceDocument(final InputStream input, final ODataFormat format) {
+  public ODataServiceDocument readServiceDocument(final InputStream input, final ODataFormat format)
+      throws ODataDeserializerException {
     return client.getBinder().getODataServiceDocument(
-            client.getDeserializer().toServiceDocument(input, format).getPayload());
+            client.getDeserializer(format).toServiceDocument(input).getPayload());
   }
 
   @Override
-  public ODataError readError(final InputStream inputStream, final boolean isXML) {
-    return client.getDeserializer().toError(inputStream, isXML);
+  public ODataError readError(final InputStream inputStream, final ODataFormat format )
+      throws ODataDeserializerException {
+    return client.getDeserializer(format).toError(inputStream);
   }
 
   @Override
-  @SuppressWarnings("unchecked")
-  public <T> ResWrap<T> read(final InputStream src, final String format, final Class<T> reference) {
+  public <T> ResWrap<T> read(final InputStream src, final String format, final Class<T> reference)
+      throws ODataDeserializerException {
     ResWrap<T> res;
 
     try {
@@ -96,20 +98,20 @@ public abstract class AbstractODataReader implements CommonODataReader {
                 reference.cast(new ODataEntitySetIterator<CommonODataEntitySet, CommonODataEntity>(
                                 client, src, ODataPubFormat.fromString(format))));
       } else if (CommonODataEntitySet.class.isAssignableFrom(reference)) {
-        final ResWrap<EntitySet> resource = client.getDeserializer().
-                toEntitySet(src, ODataPubFormat.fromString(format));
+        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().toEntity(src, ODataPubFormat.fromString(format));
+        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().toProperty(src, ODataFormat.fromString(format));
+        final ResWrap<Property> container = client.getDeserializer(ODataFormat.fromString(format)).toProperty(src);
         res = new ResWrap<T>(
                 container.getContextURL(),
                 container.getMetadataETag(),
@@ -130,7 +132,7 @@ public abstract class AbstractODataReader implements CommonODataReader {
                 reference.cast(readMetadata(src)));
       } else if (ODataServiceDocument.class.isAssignableFrom(reference)) {
         final ResWrap<ServiceDocument> resource =
-                client.getDeserializer().toServiceDocument(src, ODataFormat.fromString(format));
+                client.getDeserializer(ODataFormat.fromString(format)).toServiceDocument(src);
         res = new ResWrap<T>(
                 resource.getContextURL(),
                 resource.getMetadataETag(),
@@ -139,7 +141,7 @@ public abstract class AbstractODataReader implements CommonODataReader {
         res = new ResWrap<T>(
                 (URI) null,
                 null,
-                reference.cast(readError(src, !format.toString().contains("json"))));
+                reference.cast(readError(src, ODataFormat.fromString(format))));
       } else {
         throw new IllegalArgumentException("Invalid reference type " + reference);
       }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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
index a1c7e5e..71fe85d 100644
--- 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
@@ -18,38 +18,46 @@
  */
 package org.apache.olingo.client.core.op;
 
-import org.apache.olingo.commons.core.op.ResourceFactory;
 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.ODataLink;
 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.client.api.op.ODataWriter;
+import org.apache.olingo.commons.api.op.ODataSerializerException;
 
 public class ODataWriterImpl implements ODataWriter {
 
-  private static final long serialVersionUID = 3265794768412314485L;
-
-  protected final CommonODataClient client;
+  protected final CommonODataClient<?> client;
 
-  public ODataWriterImpl(final CommonODataClient client) {
+  public ODataWriterImpl(final CommonODataClient<?> client) {
     this.client = client;
   }
 
   @Override
-  public InputStream writeEntities(final Collection<CommonODataEntity> entities, final ODataPubFormat format) {
-    final ByteArrayOutputStream output = new ByteArrayOutputStream();
+  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().entity(client.getBinder().getEntity(
-                entity, ResourceFactory.entityClassForFormat(format == ODataPubFormat.ATOM)), output);
+        client.getSerializer(format).write(writer, client.getBinder().getEntity(entity));
       }
 
       return new ByteArrayInputStream(output.toByteArray());
@@ -59,16 +67,23 @@ public class ODataWriterImpl implements ODataWriter {
   }
 
   @Override
-  public InputStream writeEntity(final CommonODataEntity entity, final ODataPubFormat format) {
+  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) {
+  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().property(client.getBinder().getProperty(
-              property, ResourceFactory.entityClassForFormat(format == ODataFormat.XML)), output);
+      client.getSerializer(format).write(writer, client.getBinder().getProperty(property));
 
       return new ByteArrayInputStream(output.toByteArray());
     } finally {
@@ -77,10 +92,16 @@ public class ODataWriterImpl implements ODataWriter {
   }
 
   @Override
-  public InputStream writeLink(final ODataLink link, final ODataFormat format) {
+  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().link(client.getBinder().getLink(link, format == ODataFormat.XML), format, output);
+      client.getSerializer(format).write(writer, client.getBinder().getLink(link));
 
       return new ByteArrayInputStream(output.toByteArray());
     } finally {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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
index e59ad66..932a766 100644
--- 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
@@ -35,21 +35,19 @@ 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;
-import org.apache.olingo.commons.core.op.ResourceFactory;
 
 public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder {
 
-  private static final long serialVersionUID = 8970843539708952308L;
-
   public ODataBinderImpl(final ODataClientImpl client) {
     super(client);
   }
 
   @Override
   public void add(final ODataComplexValue<CommonODataProperty> complex, final CommonODataProperty property) {
-    complex.add((ODataProperty) property);
+    complex.add(property);
   }
 
   @Override
@@ -63,10 +61,10 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
   }
 
   @Override
-  public Property getProperty(final CommonODataProperty property, final Class<? extends Entity> reference) {
-    final Property propertyResource = ResourceFactory.newProperty(reference);
+  public Property getProperty(final CommonODataProperty property) {
+    final Property propertyResource = new PropertyImpl();
     propertyResource.setName(property.getName());
-    propertyResource.setValue(getValue(property.getValue(), reference));
+    propertyResource.setValue(getValue(property.getValue()));
 
     if (property.hasPrimitiveValue()) {
       propertyResource.setType(property.getPrimitiveValue().getTypeName());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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
index 2c5ae59..d238a75 100644
--- 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
@@ -20,27 +20,31 @@ 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.commons.api.data.v3.LinkCollection;
-import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.client.api.op.v3.ODataDeserializer;
-import org.apache.olingo.commons.core.data.v3.JSONLinkCollectionImpl;
-import org.apache.olingo.commons.core.data.v3.XMLLinkCollectionImpl;
-import org.apache.olingo.client.core.data.v3.JSONServiceDocumentImpl;
-import org.apache.olingo.client.core.data.v4.XMLServiceDocumentImpl;
+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.core.op.AbstractODataDeserializer;
+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.op.AbstractODataDeserializer;
 
 public class ODataDeserializerImpl extends AbstractODataDeserializer implements ODataDeserializer {
 
-  private static final long serialVersionUID = -8221085862548914611L;
+  private final Format format;
 
-  public ODataDeserializerImpl(final ODataServiceVersion version) {
-    super(version);
+  public ODataDeserializerImpl(final ODataServiceVersion version, final Format format) {
+    super(version, format);
+    this.format = format;
   }
 
   @Override
@@ -53,16 +57,20 @@ public class ODataDeserializerImpl extends AbstractODataDeserializer implements
   }
 
   @Override
-  public ResWrap<ServiceDocument> toServiceDocument(final InputStream input, final ODataFormat format) {
-    return format == ODataFormat.XML
-            ? this.<ServiceDocument, XMLServiceDocumentImpl>xml(input, XMLServiceDocumentImpl.class)
-            : this.<ServiceDocument, JSONServiceDocumentImpl>json(input, JSONServiceDocumentImpl.class);
+  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, final ODataFormat format) {
-    return format == ODataFormat.XML
-            ? this.<LinkCollection, XMLLinkCollectionImpl>atom(input, XMLLinkCollectionImpl.class)
-            : this.<LinkCollection, JSONLinkCollectionImpl>json(input, JSONLinkCollectionImpl.class);
+  public ResWrap<LinkCollection> toLinkCollection(final InputStream input) throws ODataDeserializerException {
+    try {
+      return format == ODataFormat.XML ?
+          new AtomDeserializer(version).linkCollection(input) :
+          null; //json(input, LinkCollection.class);
+    } catch (final XMLStreamException e) {
+      throw new ODataDeserializerException(e);
+    }
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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
index c64d5c8..16a897d 100644
--- 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
@@ -31,42 +31,46 @@ 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 {
 
-  private static final long serialVersionUID = -2481293269536406956L;
-
   public ODataReaderImpl(final ODataClient client) {
     super(client);
   }
 
   @Override
-  public ODataEntitySet readEntitySet(final InputStream input, final ODataPubFormat format) {
-    return ((ODataClient) client).getBinder().getODataEntitySet(client.getDeserializer().toEntitySet(input, format));
+  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) {
-    return ((ODataClient) client).getBinder().getODataEntity(client.getDeserializer().toEntity(input, format));
+  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) {
-    return ((ODataClient) client).getBinder().getODataProperty(client.getDeserializer().toProperty(input, format));
+  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) {
+  public ODataLinkCollection readLinks(final InputStream input, final ODataFormat format)
+      throws ODataDeserializerException {
     return ((ODataClient) client).getBinder().getLinkCollection(
-            ((ODataClient) client).getDeserializer().toLinkCollection(input, format).getPayload());
+            ((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) {
+  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().toLinkCollection(src, ODataFormat.fromString(format));
+              ((ODataClient) client).getDeserializer(ODataFormat.fromString(format)).toLinkCollection(src);
 
       return new ResWrap<T>(
               container.getContextURL(),

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataSerializerImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataSerializerImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataSerializerImpl.java
deleted file mode 100644
index 40b5b06..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataSerializerImpl.java
+++ /dev/null
@@ -1,32 +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.commons.core.op.AbstractODataSerializer;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-
-public class ODataSerializerImpl extends AbstractODataSerializer {
-
-  private static final long serialVersionUID = -8861908250297989806L;
-
-  public ODataSerializerImpl(final ODataServiceVersion version) {
-    super(version);
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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
index a23d2e8..0d3631a 100644
--- 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
@@ -19,6 +19,7 @@
 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;
@@ -69,24 +70,22 @@ 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;
-import org.apache.olingo.commons.core.op.ResourceFactory;
 
 public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder {
 
-  private static final long serialVersionUID = -6371110655960799393L;
-
   public ODataBinderImpl(final ODataClient client) {
     super(client);
   }
 
   @Override
   public void add(final ODataComplexValue<CommonODataProperty> complex, final CommonODataProperty property) {
-    complex.add((ODataProperty) property);
+    complex.add(property);
   }
 
   @Override
@@ -122,10 +121,9 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
     return serviceDocument;
   }
 
-  private void updateValuable(final Valuable propertyResource, final ODataValuable odataValuable,
-          final Class<? extends Entity> reference) {
+  private void updateValuable(final Valuable propertyResource, final ODataValuable odataValuable) {
 
-    propertyResource.setValue(getValue(odataValuable.getValue(), reference));
+    propertyResource.setValue(getValue(odataValuable.getValue()));
 
     if (odataValuable.hasPrimitiveValue()) {
       propertyResource.setType(odataValuable.getPrimitiveValue().getTypeName());
@@ -138,62 +136,61 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
     }
   }
 
-  private void annotations(final ODataAnnotatable odataAnnotatable, final Annotatable annotatable,
-          final Class<? extends Entity> reference) {
+  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, reference);
+      updateValuable(annotation, odataAnnotation);
 
       annotatable.getAnnotations().add(annotation);
     }
   }
 
   @Override
-  public EntitySet getEntitySet(final CommonODataEntitySet odataEntitySet, final Class<? extends EntitySet> reference) {
-    final EntitySet entitySet = super.getEntitySet(odataEntitySet, reference);
+  public EntitySet getEntitySet(final CommonODataEntitySet odataEntitySet) {
+    final EntitySet entitySet = super.getEntitySet(odataEntitySet);
     entitySet.setDeltaLink(((ODataEntitySet) odataEntitySet).getDeltaLink());
-    annotations((ODataEntitySet) odataEntitySet, entitySet, ResourceFactory.entityClassForEntitySet(reference));
+    annotations((ODataEntitySet) odataEntitySet, entitySet);
     return entitySet;
   }
 
   @Override
-  protected void links(final ODataLinked odataLinked, final Linked linked, Class<? extends Entity> reference) {
-    super.links(odataLinked, linked, reference);
+  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, reference);
+        annotations((ODataLink) odataLink, link);
       }
     }
   }
 
   @Override
-  public Entity getEntity(final CommonODataEntity odataEntity, final Class<? extends Entity> reference) {
-    final Entity entity = super.getEntity(odataEntity, reference);
+  public Entity getEntity(final CommonODataEntity odataEntity) {
+    final Entity entity = super.getEntity(odataEntity);
     entity.setId(((ODataEntity) odataEntity).getId());
-    annotations((ODataEntity) odataEntity, entity, reference);
+    annotations((ODataEntity) odataEntity, entity);
     return entity;
   }
 
   @Override
-  public Property getProperty(final CommonODataProperty property, final Class<? extends Entity> reference) {
+  public Property getProperty(final CommonODataProperty property) {
     final ODataProperty _property = (ODataProperty) property;
 
-    final Property propertyResource = ResourceFactory.newProperty(reference);
+    final Property propertyResource = new PropertyImpl();
     propertyResource.setName(_property.getName());
-    updateValuable(propertyResource, _property, reference);
-    annotations(_property, propertyResource, reference);
+    updateValuable(propertyResource, _property);
+    annotations(_property, propertyResource);
 
     return propertyResource;
   }
 
   @Override
-  protected Value getValue(final ODataValue value, final Class<? extends Entity> reference) {
+  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()) {
@@ -201,7 +198,7 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
       valueResource = new EnumValueImpl(
               ((org.apache.olingo.commons.api.domain.v4.ODataValue) value).asEnum().getValue());
     } else {
-      valueResource = super.getValue(value, reference);
+      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()) {
@@ -211,8 +208,8 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
 
         final ODataLinkedComplexValue linked =
                 ((org.apache.olingo.commons.api.domain.v4.ODataValue) value).asLinkedComplex();
-        annotations(linked, lcValueResource, reference);
-        links(linked, lcValueResource, reference);
+        annotations(linked, lcValueResource);
+        links(linked, lcValueResource);
 
         valueResource = lcValueResource;
       }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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
index 0e0f72c..445db39 100644
--- 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
@@ -20,28 +20,33 @@ 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.commons.api.format.ODataFormat;
 import org.apache.olingo.client.api.op.v4.ODataDeserializer;
-import org.apache.olingo.client.core.data.v4.JSONServiceDocumentImpl;
-import org.apache.olingo.client.core.data.v4.XMLServiceDocumentImpl;
+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.core.op.AbstractODataDeserializer;
 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.core.data.v4.AtomDeltaImpl;
-import org.apache.olingo.commons.core.data.v4.JSONDeltaImpl;
+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 static final long serialVersionUID = 8593081342440470415L;
+  private final Format format;
 
-  public ODataDeserializerImpl(final ODataServiceVersion version) {
-    super(version);
+  public ODataDeserializerImpl(final ODataServiceVersion version, final Format format) {
+    super(version, format);
+    this.format = format;
   }
 
   @Override
@@ -54,18 +59,20 @@ public class ODataDeserializerImpl extends AbstractODataDeserializer implements
   }
 
   @Override
-  public ResWrap<ServiceDocument> toServiceDocument(final InputStream input, final ODataFormat format) {
-    return format == ODataFormat.XML
-            ? this.<ServiceDocument, XMLServiceDocumentImpl>xml(input, XMLServiceDocumentImpl.class)
-            : this.<ServiceDocument, JSONServiceDocumentImpl>json(input, JSONServiceDocumentImpl.class);
-
+  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, final ODataPubFormat format) {
-    return format == ODataPubFormat.ATOM
-            ? this.<Delta, AtomDeltaImpl>atom(input, AtomDeltaImpl.class)
-            : this.<Delta, JSONDeltaImpl>json(input, JSONDeltaImpl.class);
+  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/46a34178/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
index 71c2244..ce146e5 100644
--- 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
@@ -19,6 +19,7 @@
 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;
@@ -27,27 +28,29 @@ 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 {
 
-  private static final long serialVersionUID = -2481293269536406956L;
-
   public ODataReaderImpl(final ODataClient client) {
     super(client);
   }
 
   @Override
-  public ODataEntitySet readEntitySet(final InputStream input, final ODataPubFormat format) {
-    return ((ODataClient) client).getBinder().getODataEntitySet(client.getDeserializer().toEntitySet(input, format));
+  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) {
-    return ((ODataClient) client).getBinder().getODataEntity(client.getDeserializer().toEntity(input, format));
+  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) {
-    return ((ODataClient) client).getBinder().getODataProperty(client.getDeserializer().toProperty(input, format));
+  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/46a34178/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataSerializerImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataSerializerImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataSerializerImpl.java
deleted file mode 100644
index f75fb3e..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataSerializerImpl.java
+++ /dev/null
@@ -1,32 +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 org.apache.olingo.commons.core.op.AbstractODataSerializer;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-
-public class ODataSerializerImpl extends AbstractODataSerializer {
-
-  private static final long serialVersionUID = 7587265188399685309L;
-
-  public ODataSerializerImpl(final ODataServiceVersion version) {
-    super(version);
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 8d696ec..2042a9a 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
@@ -18,8 +18,6 @@
  */
 package org.apache.olingo.client.core.v3;
 
-import org.apache.olingo.client.api.v3.ODataClient;
-import org.apache.olingo.client.api.v3.Configuration;
 import org.apache.olingo.client.api.communication.header.HeaderName;
 import org.apache.olingo.client.api.communication.header.ODataHeaders;
 import org.apache.olingo.client.api.communication.request.batch.v3.BatchRequestFactory;
@@ -27,12 +25,13 @@ 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.commons.api.op.ODataSerializer;
-import org.apache.olingo.client.api.op.v3.ODataDeserializer;
 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.uri.v3.URIBuilder;
 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;
+import org.apache.olingo.client.api.v3.ODataClient;
 import org.apache.olingo.client.core.AbstractODataClient;
 import org.apache.olingo.client.core.communication.header.ODataHeadersImpl;
 import org.apache.olingo.client.core.communication.request.batch.v3.BatchRequestFactoryImpl;
@@ -42,25 +41,24 @@ import org.apache.olingo.client.core.communication.request.retrieve.v3.RetrieveR
 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.op.impl.v3.ODataSerializerImpl;
-import org.apache.olingo.client.core.uri.v3.URIBuilderImpl;
 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;
 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.core.domain.v3.ODataObjectFactoryImpl;
 
 public class ODataClientImpl extends AbstractODataClient<UpdateType> implements ODataClient {
 
-  private static final long serialVersionUID = -1655712193243609209L;
-
   protected final Configuration configuration = new ConfigurationImpl();
 
   private final FilterFactory filterFactory = new FilterFactoryImpl(getServiceVersion());
 
-  private final ODataDeserializer deserializer = new ODataDeserializerImpl(getServiceVersion());
-
-  private final ODataSerializer serializer = new ODataSerializerImpl(getServiceVersion());
-
   private final ODataReader reader = new ODataReaderImpl(this);
 
   private final ODataBinder binder = new ODataBinderImpl(this);
@@ -105,13 +103,15 @@ public class ODataClientImpl extends AbstractODataClient<UpdateType> implements
   }
 
   @Override
-  public ODataDeserializer getDeserializer() {
-    return deserializer;
+  public ODataDeserializer getDeserializer(final Format format) {
+    return new ODataDeserializerImpl(getServiceVersion(), format);
   }
 
   @Override
-  public ODataSerializer getSerializer() {
-    return serializer;
+  public ODataSerializer getSerializer(final Format format) {
+    return format instanceof ODataPubFormat && format == ODataPubFormat.ATOM
+        || format instanceof ODataFormat && format == ODataFormat.XML ?
+        new AtomSerializer(getServiceVersion()) : new JsonSerializer(getServiceVersion(), false);
   }
 
   @Override
@@ -134,7 +134,6 @@ public class ODataClientImpl extends AbstractODataClient<UpdateType> implements
     return retrieveReqFact;
   }
 
-  @SuppressWarnings("unchecked")
   @Override
   public CUDRequestFactory getCUDRequestFactory() {
     return cudReqFact;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 4b4efd4..9f38353 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
@@ -18,8 +18,6 @@
  */
 package org.apache.olingo.client.core.v4;
 
-import org.apache.olingo.client.api.v4.ODataClient;
-import org.apache.olingo.client.api.v4.Configuration;
 import org.apache.olingo.client.api.communication.header.HeaderName;
 import org.apache.olingo.client.api.communication.header.ODataHeaders;
 import org.apache.olingo.client.api.communication.request.batch.v4.BatchRequestFactory;
@@ -28,13 +26,14 @@ 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.commons.api.op.ODataSerializer;
 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.uri.v4.URIBuilder;
 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;
+import org.apache.olingo.client.api.v4.Configuration;
+import org.apache.olingo.client.api.v4.ODataClient;
 import org.apache.olingo.client.core.AbstractODataClient;
 import org.apache.olingo.client.core.communication.header.ODataHeadersImpl;
 import org.apache.olingo.client.core.communication.request.batch.v4.BatchRequestFactoryImpl;
@@ -45,27 +44,26 @@ import org.apache.olingo.client.core.communication.request.v4.AsyncRequestFactor
 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.op.impl.v4.ODataSerializerImpl;
-import org.apache.olingo.client.core.uri.v4.URIBuilderImpl;
 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;
 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.core.domain.v4.ODataObjectFactoryImpl;
 
 public class ODataClientImpl extends AbstractODataClient<UpdateType> implements ODataClient {
 
-  private static final long serialVersionUID = -6653176125573631964L;
-
   protected final Configuration configuration = new ConfigurationImpl();
 
   private final FilterFactory filterFactory = new FilterFactoryImpl(getServiceVersion());
 
   private final SearchFactory searchFactory = new SearchFactoryImpl();
 
-  private final ODataDeserializer deserializer = new ODataDeserializerImpl(getServiceVersion());
-
-  private final ODataSerializer serializer = new ODataSerializerImpl(getServiceVersion());
-
   private final ODataReader reader = new ODataReaderImpl(this);
 
   private final ODataBinder binder = new ODataBinderImpl(this);
@@ -116,13 +114,15 @@ public class ODataClientImpl extends AbstractODataClient<UpdateType> implements
   }
 
   @Override
-  public ODataDeserializer getDeserializer() {
-    return deserializer;
+  public ODataDeserializer getDeserializer(final Format format) {
+    return new ODataDeserializerImpl(getServiceVersion(), format);
   }
 
   @Override
-  public ODataSerializer getSerializer() {
-    return serializer;
+  public ODataSerializer getSerializer(final Format format) {
+    return format instanceof ODataPubFormat && format == ODataPubFormat.ATOM
+        || format instanceof ODataFormat && format == ODataFormat.XML ?
+        new AtomSerializer(getServiceVersion()) : new JsonSerializer(getServiceVersion(), false);
   }
 
   @Override
@@ -150,7 +150,6 @@ public class ODataClientImpl extends AbstractODataClient<UpdateType> implements
     return retrieveReqFact;
   }
 
-  @SuppressWarnings("unchecked")
   @Override
   public CUDRequestFactory getCUDRequestFactory() {
     return cudReqFact;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/AtomTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/AtomTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/AtomTest.java
index 1b047a8..2fcdb4c 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/AtomTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/AtomTest.java
@@ -69,10 +69,10 @@ public class AtomTest extends AbstractTest {
 
   protected void entitySet(final String filename, final ODataPubFormat format) throws Exception {
     final StringWriter writer = new StringWriter();
-    getClient().getSerializer().entitySet(getClient().getDeserializer().toEntitySet(
-            getClass().getResourceAsStream("Customer." + getSuffix(format)), format).getPayload(), writer);
+    getClient().getSerializer(format).write(writer, getClient().getDeserializer(format).toEntitySet(
+        getClass().getResourceAsStream(filename + "." + getSuffix(format))).getPayload());
 
-    assertSimilar("Customer." + getSuffix(format), writer.toString());
+    assertSimilar(filename + "." + getSuffix(format), writer.toString());
   }
 
   @Test
@@ -82,8 +82,8 @@ public class AtomTest extends AbstractTest {
 
   protected void entity(final String filename, final ODataPubFormat format) throws Exception {
     final StringWriter writer = new StringWriter();
-    getClient().getSerializer().entity(getClient().getDeserializer().toEntity(
-            getClass().getResourceAsStream(filename + "." + getSuffix(format)), format).getPayload(), writer);
+    getClient().getSerializer(format).write(writer, getClient().getDeserializer(format).toEntity(
+        getClass().getResourceAsStream(filename + "." + getSuffix(format))).getPayload());
 
     assertSimilar(filename + "." + getSuffix(format), writer.toString());
   }
@@ -102,9 +102,8 @@ public class AtomTest extends AbstractTest {
 
   protected void property(final String filename, final ODataFormat format) throws Exception {
     final StringWriter writer = new StringWriter();
-    getClient().getSerializer().property(getClient().getDeserializer().
-            toProperty(getClass().getResourceAsStream(filename + "." + getSuffix(format)), format).getPayload(),
-            writer);
+    getClient().getSerializer(format).write(writer, getClient().getDeserializer(format).toProperty(
+        getClass().getResourceAsStream(filename + "." + getSuffix(format))).getPayload());
 
     assertSimilar(filename + "." + getSuffix(format), writer.toString());
   }


[09/23] git commit: [OLINGO-317] First presentable state

Posted by ch...@apache.org.
[OLINGO-317] First presentable state


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

Branch: refs/heads/clientjune
Commit: 46a34178253d4a9d106d4d728f8ad812db05592a
Parents: 0e84b4c
Author: mibo <mi...@mirb.de>
Authored: Mon Jun 9 14:43:34 2014 +0200
Committer: mibo <mi...@mirb.de>
Committed: Mon Jun 9 14:43:34 2014 +0200

----------------------------------------------------------------------
 .gitignore                                      |   3 +-
 .../org/apache/olingo/fit/AbstractServices.java | 208 +++---
 .../java/org/apache/olingo/fit/V4Services.java  | 694 +++++++++----------
 .../fit/serializer/JSONEntryContainer.java      |  36 -
 .../fit/serializer/JSONFeedContainer.java       |  36 -
 .../fit/serializer/JSONPropertyContainer.java   |  36 -
 .../olingo/fit/utils/AbstractUtilities.java     | 367 +++++-----
 .../org/apache/olingo/fit/utils/Commons.java    |  65 +-
 .../org/apache/olingo/fit/utils/DataBinder.java | 347 ----------
 .../org/apache/olingo/fit/utils/FSManager.java  |  50 +-
 .../apache/olingo/fit/utils/JSONUtilities.java  |  27 +-
 .../olingo/fit/AbstractBaseTestITCase.java      |  22 +-
 .../fit/proxy/v4/MediaEntityTestITCase.java     |   9 +-
 .../NonTransactionalMediaEntityTestITCase.java  |   3 +-
 .../olingo/fit/v3/EntityRetrieveTestITCase.java |   7 +-
 .../olingo/fit/v3/EntitySetTestITCase.java      |   4 +-
 .../fit/v4/JSONFormatConformanceTestITCase.java |  13 +-
 .../olingo/client/api/CommonODataClient.java    |  11 +-
 .../api/domain/ODataEntitySetIterator.java      |  20 +-
 .../client/api/op/ClientODataDeserializer.java  |  11 +-
 .../olingo/client/api/op/CommonODataBinder.java |  19 +-
 .../olingo/client/api/op/CommonODataReader.java |  27 +-
 .../olingo/client/api/op/ODataWriter.java       |  23 +-
 .../client/api/op/v3/ODataDeserializer.java     |   8 +-
 .../olingo/client/api/op/v3/ODataReader.java    |  11 +-
 .../client/api/op/v4/ODataDeserializer.java     |   6 +-
 .../olingo/client/api/op/v4/ODataReader.java    |   8 +-
 .../olingo/client/api/v3/ODataClient.java       |   3 +-
 .../olingo/client/api/v4/ODataClient.java       |   3 +-
 .../communication/request/AbstractRequest.java  |  58 +-
 .../cud/ODataEntityCreateRequestImpl.java       |  16 +-
 .../cud/ODataEntityUpdateRequestImpl.java       |  31 +-
 .../cud/ODataPropertyUpdateRequestImpl.java     |  27 +-
 .../cud/v3/ODataLinkCreateRequestImpl.java      |  14 +-
 .../cud/v3/ODataLinkUpdateRequestImpl.java      |  17 +-
 .../invoke/AbstractODataInvokeRequest.java      |  11 +-
 .../retrieve/ODataEntityRequestImpl.java        |   9 +-
 .../retrieve/ODataEntitySetRequestImpl.java     |  11 +-
 .../retrieve/ODataPropertyRequestImpl.java      |   8 +-
 .../request/retrieve/ODataRawRequestImpl.java   |  13 +-
 .../ODataServiceDocumentRequestImpl.java        |  17 +-
 .../v3/ODataLinkCollectionRequestImpl.java      |   7 +-
 .../retrieve/v3/XMLMetadataRequestImpl.java     |   5 +-
 .../retrieve/v4/ODataDeltaRequestImpl.java      |  11 +-
 .../retrieve/v4/XMLMetadataRequestImpl.java     |   4 +-
 .../ODataMediaEntityCreateRequestImpl.java      |  11 +-
 .../ODataMediaEntityUpdateRequestImpl.java      |   7 +-
 .../core/data/AbstractServiceDocument.java      | 139 ----
 .../data/JSONServiceDocumentDeserializer.java   |  43 +-
 .../client/core/data/ServiceDocumentImpl.java   | 141 ++++
 .../data/XMLServiceDocumentDeserializer.java    |  52 +-
 .../core/data/v3/JSONServiceDocumentImpl.java   |  35 -
 .../core/data/v3/XMLServiceDocumentImpl.java    |  30 -
 .../core/data/v4/AbstractServiceDocument.java   |  49 --
 .../core/data/v4/JSONServiceDocumentImpl.java   |  28 -
 .../core/data/v4/XMLServiceDocumentImpl.java    |  28 -
 .../client/core/op/AbstractODataBinder.java     | 148 ++--
 .../client/core/op/AbstractODataReader.java     |  32 +-
 .../olingo/client/core/op/ODataWriterImpl.java  |  55 +-
 .../client/core/op/impl/v3/ODataBinderImpl.java |  12 +-
 .../core/op/impl/v3/ODataDeserializerImpl.java  |  44 +-
 .../client/core/op/impl/v3/ODataReaderImpl.java |  28 +-
 .../core/op/impl/v3/ODataSerializerImpl.java    |  32 -
 .../client/core/op/impl/v4/ODataBinderImpl.java |  51 +-
 .../core/op/impl/v4/ODataDeserializerImpl.java  |  45 +-
 .../client/core/op/impl/v4/ODataReaderImpl.java |  19 +-
 .../core/op/impl/v4/ODataSerializerImpl.java    |  32 -
 .../olingo/client/core/v3/ODataClientImpl.java  |  35 +-
 .../olingo/client/core/v4/ODataClientImpl.java  |  33 +-
 .../apache/olingo/client/core/v3/AtomTest.java  |  15 +-
 .../olingo/client/core/v3/EntitySetTest.java    |  18 +-
 .../olingo/client/core/v3/EntityTest.java       |  59 +-
 .../apache/olingo/client/core/v3/ErrorTest.java |  19 +-
 .../olingo/client/core/v3/MetadataTest.java     |   5 +-
 .../olingo/client/core/v3/PropertyTest.java     |  23 +-
 .../client/core/v3/ServiceDocumentTest.java     |   7 +-
 .../olingo/client/core/v4/EntitySetTest.java    |  25 +-
 .../olingo/client/core/v4/EntityTest.java       | 101 ++-
 .../apache/olingo/client/core/v4/ErrorTest.java |  13 +-
 .../apache/olingo/client/core/v4/JSONTest.java  |  45 +-
 .../olingo/client/core/v4/MetadataTest.java     |  13 +-
 .../olingo/client/core/v4/PropertyTest.java     |  31 +-
 .../client/core/v4/ServiceDocumentTest.java     |  12 +-
 .../commons/api/op/CommonODataDeserializer.java |  71 --
 .../commons/api/op/ODataDeserializer.java       |  65 ++
 .../api/op/ODataDeserializerException.java      |  38 +
 .../olingo/commons/api/op/ODataSerializer.java  |  79 +--
 .../api/op/ODataSerializerException.java        |  38 +
 .../commons/core/data/AbstractEntity.java       | 193 ------
 .../commons/core/data/AbstractEntitySet.java    |  74 --
 .../core/data/AbstractJsonDeserializer.java     | 372 ----------
 .../core/data/AbstractJsonSerializer.java       | 248 -------
 .../commons/core/data/AbstractODataError.java   |  89 ---
 .../commons/core/data/AbstractProperty.java     |  63 --
 .../commons/core/data/AtomDeserializer.java     | 259 +++----
 .../commons/core/data/AtomEntityImpl.java       |  25 -
 .../commons/core/data/AtomEntitySetImpl.java    |  28 -
 .../commons/core/data/AtomPropertyImpl.java     |  25 -
 .../commons/core/data/AtomSerializer.java       | 115 +--
 .../olingo/commons/core/data/EntityImpl.java    | 193 ++++++
 .../olingo/commons/core/data/EntitySetImpl.java |  74 ++
 .../core/data/JSONDeltaDeserializer.java        |  57 +-
 .../core/data/JSONEntityDeserializer.java       |  29 +-
 .../commons/core/data/JSONEntityImpl.java       |  33 -
 .../commons/core/data/JSONEntitySerializer.java |  33 +-
 .../core/data/JSONEntitySetDeserializer.java    |  34 +-
 .../commons/core/data/JSONEntitySetImpl.java    |  35 -
 .../core/data/JSONEntitySetSerializer.java      |  49 +-
 .../core/data/JSONODataErrorDeserializer.java   |  40 +-
 .../data/JSONODataErrorDetailDeserializer.java  |  25 +-
 .../core/data/JSONODataErrorDetailImpl.java     |  62 --
 .../commons/core/data/JSONODataErrorImpl.java   |  26 -
 .../core/data/JSONPropertyDeserializer.java     |  30 +-
 .../commons/core/data/JSONPropertyImpl.java     |  33 -
 .../core/data/JSONPropertySerializer.java       |  29 +-
 .../commons/core/data/JsonDeserializer.java     | 463 +++++++++++++
 .../commons/core/data/JsonSerializer.java       | 315 +++++++++
 .../commons/core/data/ODataErrorDetailImpl.java |  57 ++
 .../commons/core/data/ODataErrorImpl.java       |  89 +++
 .../core/data/ODataJacksonDeserializer.java     |  98 ---
 .../core/data/ODataJacksonSerializer.java       |  57 --
 .../olingo/commons/core/data/PropertyImpl.java  |  63 ++
 .../commons/core/data/XMLODataErrorImpl.java    |  23 -
 .../core/data/v3/LinkCollectionImpl.java        |  78 +++
 .../core/data/v3/XMLLinkCollectionImpl.java     |  70 --
 .../commons/core/data/v4/AbstractDelta.java     |  52 --
 .../commons/core/data/v4/AtomDeltaImpl.java     |  25 -
 .../olingo/commons/core/data/v4/DeltaImpl.java  |  52 ++
 .../commons/core/data/v4/JSONDeltaImpl.java     |  29 -
 .../commons/core/op/AbstractJacksonTool.java    |  86 ---
 .../core/op/AbstractODataDeserializer.java      | 135 ++--
 .../core/op/AbstractODataSerializer.java        | 141 ----
 .../olingo/commons/core/op/ResourceFactory.java | 125 ----
 .../server/api/serializer/ODataSerializer.java  |   8 +
 .../apache/olingo/server/core/ODataHandler.java |  84 +++
 .../core/serializer/ODataJsonSerializer.java    | 104 +++
 .../core/serializer/ODataXmlSerializerImpl.java |  15 +
 137 files changed, 3761 insertions(+), 4823 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 947434b..45f5089 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@
 .project
 .classpath
 .settings
+.idea
 target
 bin
 *.bak
@@ -10,4 +11,4 @@ classes
 *.local
 nb-configuration.xml
 .externalToolBuilders
-maven-eclipse.xml
\ No newline at end of file
+maven-eclipse.xml

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 7fd0b58..71a7bf5 100644
--- a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
+++ b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
@@ -18,9 +18,6 @@
  */
 package org.apache.olingo.fit;
 
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
@@ -41,6 +38,7 @@ import java.util.Map;
 import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+
 import javax.mail.Header;
 import javax.mail.internet.MimeBodyPart;
 import javax.ws.rs.Consumes;
@@ -61,6 +59,7 @@ import javax.ws.rs.core.MultivaluedHashMap;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.tuple.Pair;
@@ -69,44 +68,45 @@ import org.apache.cxf.jaxrs.ext.multipart.Attachment;
 import org.apache.cxf.jaxrs.ext.multipart.Multipart;
 import org.apache.cxf.jaxrs.ext.multipart.MultipartBody;
 import org.apache.olingo.commons.api.data.ComplexValue;
-import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.format.ContentType;
 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.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.core.data.AtomEntitySetImpl;
-import org.apache.olingo.commons.core.data.LinkImpl;
-import org.apache.olingo.commons.core.data.AtomEntityImpl;
-import org.apache.olingo.commons.core.data.AtomPropertyImpl;
+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.core.data.JSONEntityImpl;
-import org.apache.olingo.commons.core.data.JSONPropertyImpl;
+import org.apache.olingo.commons.core.data.EntityImpl;
+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.fit.metadata.EntityType;
+import org.apache.olingo.fit.metadata.Metadata;
 import org.apache.olingo.fit.metadata.NavigationProperty;
 import org.apache.olingo.fit.methods.MERGE;
 import org.apache.olingo.fit.methods.PATCH;
 import org.apache.olingo.fit.serializer.FITAtomDeserializer;
+import org.apache.olingo.fit.utils.AbstractUtilities;
 import org.apache.olingo.fit.utils.Accept;
-import org.apache.olingo.fit.utils.FSManager;
 import org.apache.olingo.fit.utils.Commons;
-import org.apache.olingo.fit.utils.JSONUtilities;
-import org.apache.olingo.fit.utils.AbstractUtilities;
-import org.apache.olingo.fit.utils.XMLUtilities;
-import org.apache.olingo.fit.utils.LinkInfo;
-import org.apache.olingo.fit.metadata.Metadata;
-import org.apache.olingo.fit.serializer.JSONFeedContainer;
-import org.apache.olingo.fit.serializer.JSONEntryContainer;
 import org.apache.olingo.fit.utils.ConstantKey;
 import org.apache.olingo.fit.utils.Constants;
-import org.apache.olingo.fit.utils.DataBinder;
+import org.apache.olingo.fit.utils.FSManager;
+import org.apache.olingo.fit.utils.JSONUtilities;
+import org.apache.olingo.fit.utils.LinkInfo;
+import org.apache.olingo.fit.utils.XMLUtilities;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
 public abstract class AbstractServices {
 
   /**
@@ -123,28 +123,24 @@ public abstract class AbstractServices {
   protected static final String BOUNDARY = "batch_243234_25424_ef_892u748";
 
   protected final ODataServiceVersion version;
-
   protected final Metadata metadata;
 
-  protected final FITAtomDeserializer atomDeserializer;
-
-  protected final AtomSerializer atomSerializer;
-
-  protected final ObjectMapper mapper;
-
-  protected final DataBinder dataBinder;
+  protected final ODataDeserializer atomDeserializer;
+  protected final ODataDeserializer jsonDeserializer;
+  protected final ODataSerializer atomSerializer;
+  protected final ODataSerializer jsonSerializer;
 
   protected final XMLUtilities xml;
-
   protected final JSONUtilities json;
 
   public AbstractServices(final ODataServiceVersion version, final Metadata metadata) throws Exception {
     this.version = version;
     this.metadata = metadata;
-    this.atomDeserializer = Commons.getAtomDeserializer(version);
-    this.atomSerializer = Commons.getAtomSerializer(version);
-    this.mapper = Commons.getJSONMapper(version);
-    this.dataBinder = new DataBinder(version, metadata);
+
+    atomDeserializer = new FITAtomDeserializer(version);
+    jsonDeserializer = new JsonDeserializer(version, true);
+    atomSerializer = new AtomSerializer(version, true);
+    jsonSerializer = new JsonSerializer(version, true);
 
     this.xml = new XMLUtilities(version, metadata);
     this.json = new JSONUtilities(version, metadata);
@@ -223,9 +219,9 @@ public abstract class AbstractServices {
   @GET
   @Path("/StoredPIs(1000)")
   public Response getStoredPI(@Context UriInfo uriInfo) {
-    final JSONEntityImpl entity = new JSONEntityImpl();
+    final Entity entity = new EntityImpl();
     entity.setType("Microsoft.Test.OData.Services.ODataWCFService.StoredPI");
-    final Property id = new JSONPropertyImpl();
+    final Property id = new PropertyImpl();
     id.setType("Edm.Int32");
     id.setName("StoredPIID");
     id.setValue(new PrimitiveValueImpl("1000"));
@@ -239,7 +235,7 @@ public abstract class AbstractServices {
     final ByteArrayOutputStream content = new ByteArrayOutputStream();
     final OutputStreamWriter writer = new OutputStreamWriter(content, Constants.ENCODING);
     try {
-      mapper.writeValue(writer, new JSONEntryContainer(null, null, entity));
+      jsonSerializer.write(writer, new ResWrap<Entity>((URI) null, null, entity));
       return xml.createResponse(new ByteArrayInputStream(content.toByteArray()), null, Accept.JSON_FULLMETA);
     } catch (Exception e) {
       LOG.error("While creating StoredPI", e);
@@ -261,7 +257,7 @@ public abstract class AbstractServices {
 
   protected Response bodyPartRequest(final MimeBodyPart body, final Map<String, String> references) throws Exception {
     @SuppressWarnings("unchecked")
-    final Enumeration<Header> en = (Enumeration<Header>) body.getAllHeaders();
+    final Enumeration<Header> en = body.getAllHeaders();
 
     Header header = en.nextElement();
     final String request =
@@ -455,22 +451,19 @@ public abstract class AbstractServices {
 
       final Accept contentTypeValue = Accept.parse(contentType, version);
 
-      final AtomEntityImpl entryChanges;
+      final Entity entryChanges;
 
       if (contentTypeValue == Accept.XML || contentTypeValue == Accept.TEXT) {
         throw new UnsupportedMediaTypeException("Unsupported media type");
       } else if (contentTypeValue == Accept.ATOM) {
-        entryChanges = atomDeserializer.<AtomEntityImpl, AtomEntityImpl>read(
-                IOUtils.toInputStream(changes, Constants.ENCODING), AtomEntityImpl.class).getPayload();
+        entryChanges = atomDeserializer.toEntity(
+                IOUtils.toInputStream(changes, Constants.ENCODING)).getPayload();
       } else {
-        final ResWrap<JSONEntityImpl> jcont = mapper.readValue(IOUtils.toInputStream(changes, Constants.ENCODING),
-                new TypeReference<JSONEntityImpl>() {
-        });
-
-        entryChanges = dataBinder.toAtomEntity(jcont.getPayload());
+        final ResWrap<Entity> jcont = jsonDeserializer.toEntity(IOUtils.toInputStream(changes, Constants.ENCODING));
+        entryChanges = jcont.getPayload();
       }
 
-      final ResWrap<AtomEntityImpl> container = atomDeserializer.read(entityInfo.getValue(), AtomEntityImpl.class);
+      final ResWrap<Entity> container = atomDeserializer.toEntity(entityInfo.getValue());
 
       for (Property property : entryChanges.getProperties()) {
         final Property _property = container.getPayload().getProperty(property.getName());
@@ -494,13 +487,13 @@ public abstract class AbstractServices {
       final InputStream res = xml.addOrReplaceEntity(
               entityId, entitySetName, new ByteArrayInputStream(content.toByteArray()), container.getPayload());
 
-      final ResWrap<AtomEntityImpl> cres = atomDeserializer.read(res, AtomEntityImpl.class);
+      final ResWrap<Entity> cres = atomDeserializer.toEntity(res);
 
       normalizeAtomEntry(cres.getPayload(), entitySetName, entityId);
 
       final String path = Commons.getEntityBasePath(entitySetName, entityId);
       FSManager.instance(version).putInMemory(
-              cres, path + File.separatorChar + Constants.get(version, ConstantKey.ENTITY), dataBinder);
+              cres, path + File.separatorChar + Constants.get(version, ConstantKey.ENTITY));
 
       final Response response;
       if ("return-content".equalsIgnoreCase(prefer)) {
@@ -551,19 +544,16 @@ public abstract class AbstractServices {
               IOUtils.toInputStream(entity, Constants.ENCODING),
               xml.readEntity(acceptType, IOUtils.toInputStream(entity, Constants.ENCODING)));
 
-      final ResWrap<AtomEntityImpl> cres;
+      final ResWrap<Entity> cres;
       if (acceptType == Accept.ATOM) {
-        cres = atomDeserializer.read(res, AtomEntityImpl.class);
+        cres = atomDeserializer.toEntity(res);
       } else {
-        final ResWrap<JSONEntityImpl> jcont = mapper.readValue(res, new TypeReference<JSONEntityImpl>() {
-        });
-        cres = new ResWrap<AtomEntityImpl>(jcont.getContextURL(), jcont.getMetadataETag(),
-                dataBinder.toAtomEntity(jcont.getPayload()));
+        cres = jsonDeserializer.toEntity(res);
       }
 
       final String path = Commons.getEntityBasePath(entitySetName, entityId);
       FSManager.instance(version).putInMemory(
-              cres, path + File.separatorChar + Constants.get(version, ConstantKey.ENTITY), dataBinder);
+              cres, path + File.separatorChar + Constants.get(version, ConstantKey.ENTITY));
 
       final Response response;
       if ("return-content".equalsIgnoreCase(prefer)) {
@@ -611,14 +601,14 @@ public abstract class AbstractServices {
         throw new UnsupportedMediaTypeException("Unsupported media type");
       }
 
-      final ResWrap<AtomEntityImpl> container;
+      final ResWrap<Entity> container;
 
       final org.apache.olingo.fit.metadata.EntitySet entitySet = metadata.getEntitySet(entitySetName);
 
-      final AtomEntityImpl entry;
+      final Entity entry;
       final String entityKey;
       if (xml.isMediaContent(entitySetName)) {
-        entry = new AtomEntityImpl();
+        entry = new EntityImpl();
         entry.setMediaContentType(ContentType.WILDCARD);
         entry.setType(entitySet.getType());
 
@@ -628,7 +618,7 @@ public abstract class AbstractServices {
 
         final Pair<String, EdmPrimitiveTypeKind> id = Commons.getMediaContent().get(entitySetName);
         if (id != null) {
-          final AtomPropertyImpl prop = new AtomPropertyImpl();
+          final Property prop = new PropertyImpl();
           prop.setName(id.getKey());
           prop.setType(id.getValue().toString());
           prop.setValue(new PrimitiveValueImpl(entityKey));
@@ -643,21 +633,18 @@ public abstract class AbstractServices {
 
         entry.setMediaContentSource(URI.create(editLink.getHref() + "/$value"));
 
-        container = new ResWrap<AtomEntityImpl>((URI) null, null, entry);
+        container = new ResWrap<Entity>((URI) null, null, entry);
       } else {
         final Accept contentTypeValue = Accept.parse(contentType, version);
         if (Accept.ATOM == contentTypeValue) {
-          container = atomDeserializer.read(IOUtils.toInputStream(entity, Constants.ENCODING), AtomEntityImpl.class);
+          container = atomDeserializer.toEntity(IOUtils.toInputStream(entity, Constants.ENCODING));
           entry = container.getPayload();
         } else {
-          final ResWrap<JSONEntityImpl> jcontainer =
-                  mapper.readValue(IOUtils.toInputStream(entity, Constants.ENCODING),
-                  new TypeReference<JSONEntityImpl>() {
-          });
-
-          entry = dataBinder.toAtomEntity(jcontainer.getPayload());
+          final ResWrap<Entity> jcontainer = jsonDeserializer.toEntity(
+              IOUtils.toInputStream(entity, Constants.ENCODING));
+          entry = jcontainer.getPayload();
 
-          container = new ResWrap<AtomEntityImpl>(
+          container = new ResWrap<Entity>(
                   jcontainer.getContextURL(),
                   jcontainer.getMetadataETag(),
                   entry);
@@ -677,14 +664,14 @@ public abstract class AbstractServices {
       final InputStream serialization =
               xml.addOrReplaceEntity(entityKey, entitySetName, new ByteArrayInputStream(content.toByteArray()), entry);
 
-      ResWrap<AtomEntityImpl> result = atomDeserializer.read(serialization, AtomEntityImpl.class);
-      result = new ResWrap<AtomEntityImpl>(
+      ResWrap<Entity> result = atomDeserializer.toEntity(serialization);
+      result = new ResWrap<Entity>(
               URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX)
               + entitySetName + Constants.get(version, ConstantKey.ODATA_METADATA_ENTITY_SUFFIX)),
               null, result.getPayload());
 
       final String path = Commons.getEntityBasePath(entitySetName, entityKey);
-      FSManager.instance(version).putInMemory(result, path + Constants.get(version, ConstantKey.ENTITY), dataBinder);
+      FSManager.instance(version).putInMemory(result, path + Constants.get(version, ConstantKey.ENTITY));
 
       final String location = uriInfo.getRequestUri().toASCIIString() + "(" + entityKey + ")";
 
@@ -734,7 +721,7 @@ public abstract class AbstractServices {
       final Map.Entry<String, InputStream> entityInfo = xml.readEntity("Person", entityId, Accept.ATOM);
 
       final InputStream entity = entityInfo.getValue();
-      final ResWrap<AtomEntityImpl> container = atomDeserializer.read(entity, AtomEntityImpl.class);
+      final ResWrap<Entity> container = atomDeserializer.toEntity(entity);
 
       container.getPayload().getProperty("Salary").setValue(new PrimitiveValueImpl("0"));
       container.getPayload().getProperty("Title").setValue(new PrimitiveValueImpl("[Sacked]"));
@@ -826,7 +813,7 @@ public abstract class AbstractServices {
       final Map.Entry<String, InputStream> entityInfo = xml.readEntity("Product", entityId, Accept.ATOM);
 
       final InputStream entity = entityInfo.getValue();
-      final ResWrap<AtomEntityImpl> container = atomDeserializer.read(entity, AtomEntityImpl.class);
+      final ResWrap<Entity> container = atomDeserializer.toEntity(entity);
 
       final Entity param = xml.readEntity(utils.getKey(), IOUtils.toInputStream(argument, Constants.ENCODING));
 
@@ -861,7 +848,7 @@ public abstract class AbstractServices {
       final Map.Entry<String, InputStream> entityInfo = xml.readEntity("ComputerDetail", entityId, Accept.ATOM);
 
       final InputStream entity = entityInfo.getValue();
-      final ResWrap<AtomEntityImpl> container = atomDeserializer.read(entity, AtomEntityImpl.class);
+      final ResWrap<Entity> container = atomDeserializer.toEntity(entity);
 
       final Entity param = xml.readEntity(utils.getKey(), IOUtils.toInputStream(argument, Constants.ENCODING));
 
@@ -985,7 +972,7 @@ public abstract class AbstractServices {
 
         final InputStream feed = FSManager.instance(version).readFile(builder.toString(), Accept.ATOM);
 
-        final ResWrap<AtomEntitySetImpl> container = atomDeserializer.read(feed, AtomEntitySetImpl.class);
+        final ResWrap<EntitySet> container = atomDeserializer.toEntitySet(feed);
 
         setInlineCount(container.getPayload(), count);
 
@@ -1011,13 +998,11 @@ public abstract class AbstractServices {
 
         if (acceptType == Accept.ATOM) {
           atomSerializer.write(writer, container);
-          writer.flush();
-          writer.close();
         } else {
-          mapper.writeValue(
-                  writer, new JSONFeedContainer(container.getContextURL(), container.getMetadataETag(),
-                  dataBinder.toJSONEntitySet(container.getPayload())));
+          jsonSerializer.write(writer, container);
         }
+        writer.flush();
+        writer.close();
 
         return xml.createResponse(
                 location,
@@ -1185,9 +1170,9 @@ public abstract class AbstractServices {
 
       final InputStream entity = entityInfo.getValue();
 
-      ResWrap<AtomEntityImpl> container = atomDeserializer.read(entity, AtomEntityImpl.class);
+      ResWrap<Entity> container = atomDeserializer.toEntity(entity);
       if (container.getContextURL() == null) {
-        container = new ResWrap<AtomEntityImpl>(URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX)
+        container = new ResWrap<Entity>(URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX)
                 + entitySetName + Constants.get(version, ConstantKey.ODATA_METADATA_ENTITY_SUFFIX)),
                 container.getMetadataETag(), container.getPayload());
       }
@@ -1241,15 +1226,13 @@ public abstract class AbstractServices {
             rep.setType(link.getType());
             if (link.getType().equals(Constants.get(version, ConstantKey.ATOM_LINK_ENTRY))) {
               // inline entry
-              final Entity inline = atomDeserializer.<Entity, AtomEntityImpl>read(
-                      xml.expandEntity(entitySetName, entityId, link.getTitle()),
-                      AtomEntityImpl.class).getPayload();
+              final Entity inline = atomDeserializer.toEntity(
+                      xml.expandEntity(entitySetName, entityId, link.getTitle())).getPayload();
               rep.setInlineEntity(inline);
             } else if (link.getType().equals(Constants.get(version, ConstantKey.ATOM_LINK_FEED))) {
               // inline feed
-              final EntitySet inline = atomDeserializer.<EntitySet, AtomEntitySetImpl>read(
-                      xml.expandEntity(entitySetName, entityId, link.getTitle()),
-                      AtomEntitySetImpl.class).getPayload();
+              final EntitySet inline = atomDeserializer.toEntitySet(
+                      xml.expandEntity(entitySetName, entityId, link.getTitle())).getPayload();
               rep.setInlineEntitySet(inline);
             }
             replace.put(link, rep);
@@ -1336,10 +1319,10 @@ public abstract class AbstractServices {
       final FSManager fsManager = FSManager.instance(version);
 
       final String basePath = Commons.getEntityBasePath(entitySetName, entityId);
-      final ResWrap<AtomEntityImpl> container = xml.readContainerEntity(Accept.ATOM,
+      final ResWrap<Entity> container = xml.readContainerEntity(Accept.ATOM,
               fsManager.readFile(basePath + Constants.get(version, ConstantKey.ENTITY), Accept.ATOM));
 
-      final AtomEntityImpl entry = container.getPayload();
+      final Entity entry = container.getPayload();
 
       Property toBeReplaced = null;
       for (String element : path.split("/")) {
@@ -1363,7 +1346,7 @@ public abstract class AbstractServices {
         // just for primitive values
         toBeReplaced.setValue(new PrimitiveValueImpl(changes));
       } else {
-        final AtomPropertyImpl pchanges = xml.readProperty(
+        final Property pchanges = xml.readProperty(
                 Accept.parse(contentType, version),
                 IOUtils.toInputStream(changes, Constants.ENCODING),
                 entry.getType());
@@ -1639,7 +1622,6 @@ public abstract class AbstractServices {
    * @param entityId
    * @param path
    * @param format
-   * @param changes
    * @return
    */
   @DELETE
@@ -1729,34 +1711,24 @@ public abstract class AbstractServices {
           final OutputStreamWriter writer = new OutputStreamWriter(content, Constants.ENCODING);
 
           if (linkInfo.isFeed()) {
-            final ResWrap<EntitySet> container =
-                    atomDeserializer.<EntitySet, AtomEntitySetImpl>read(stream, AtomEntitySetImpl.class);
+            final ResWrap<EntitySet> container = atomDeserializer.toEntitySet(stream);
 
             if (acceptType == Accept.ATOM) {
               atomSerializer.write(writer, container);
-              writer.flush();
-              writer.close();
             } else {
-              mapper.writeValue(
-                      writer,
-                      new JSONFeedContainer(container.getContextURL(),
-                      container.getMetadataETag(),
-                      dataBinder.toJSONEntitySet((AtomEntitySetImpl) container.getPayload())));
+              jsonSerializer.write(writer, container);
             }
+            writer.flush();
+            writer.close();
           } else {
-            final ResWrap<Entity> container =
-                    atomDeserializer.<Entity, AtomEntityImpl>read(stream, AtomEntityImpl.class);
+            final ResWrap<Entity> container = atomDeserializer.toEntity(stream);
             if (acceptType == Accept.ATOM) {
               atomSerializer.write(writer, container);
-              writer.flush();
-              writer.close();
             } else {
-              mapper.writeValue(
-                      writer,
-                      new JSONEntryContainer(container.getContextURL(),
-                      container.getMetadataETag(),
-                      dataBinder.toJSONEntity((AtomEntityImpl) container.getPayload())));
+              jsonSerializer.write(writer, container);
             }
+            writer.flush();
+            writer.close();
           }
 
           final String basePath = Commons.getEntityBasePath(entitySetName, entityId);
@@ -1804,18 +1776,18 @@ public abstract class AbstractServices {
 
     final InputStream entity = entityInfo.getValue();
 
-    final ResWrap<AtomEntityImpl> entryContainer = atomDeserializer.read(entity, AtomEntityImpl.class);
+    final ResWrap<Entity> entryContainer = atomDeserializer.toEntity(entity);
 
     final String[] pathElems = StringUtils.split(path, "/");
-    AtomPropertyImpl property = (AtomPropertyImpl) entryContainer.getPayload().getProperty(pathElems[0]);
+    Property property = entryContainer.getPayload().getProperty(pathElems[0]);
     if (pathElems.length > 1 && property.getValue().isComplex()) {
       for (Property sub : property.getValue().asComplex().get()) {
         if (pathElems[1].equals(sub.getName())) {
-          property = (AtomPropertyImpl) sub;
+          property = sub;
           if (pathElems.length > 2 && property.getValue().isComplex()) {
             for (Property subsub : property.getValue().asComplex().get()) {
               if (pathElems[2].equals(subsub.getName())) {
-                property = (AtomPropertyImpl) subsub;
+                property = subsub;
               }
             }
           }
@@ -1823,7 +1795,7 @@ public abstract class AbstractServices {
       }
     }
 
-    final ResWrap<AtomPropertyImpl> container = new ResWrap<AtomPropertyImpl>(
+    final ResWrap<Property> container = new ResWrap<Property>(
             URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX)
             + (version.compareTo(ODataServiceVersion.V40) >= 0
             ? entitySetName + "(" + entityId + ")/" + path
@@ -1899,13 +1871,13 @@ public abstract class AbstractServices {
     return utils;
   }
 
-  protected void normalizeAtomEntry(final AtomEntityImpl entry, final String entitySetName, final String entityKey) {
+  protected void normalizeAtomEntry(final Entity entry, final String entitySetName, final String entityKey) {
     final org.apache.olingo.fit.metadata.EntitySet entitySet = metadata.getEntitySet(entitySetName);
     final EntityType entityType = metadata.getEntityOrComplexType(entitySet.getType());
     for (Map.Entry<String, org.apache.olingo.fit.metadata.Property> property
             : entityType.getPropertyMap().entrySet()) {
       if (entry.getProperty(property.getKey()) == null && property.getValue().isNullable()) {
-        final AtomPropertyImpl prop = new AtomPropertyImpl();
+        final PropertyImpl prop = new PropertyImpl();
         prop.setName(property.getKey());
         prop.setValue(new NullValueImpl());
         entry.getProperties().add(prop);


[04/23] [OLINGO-317] First presentable state

Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 46a6995..dd5057d 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
@@ -18,19 +18,20 @@
  */
 package org.apache.olingo.client.core.v3;
 
-import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URI;
+
 import org.apache.olingo.client.api.v3.ODataClient;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
 import org.apache.olingo.client.core.AbstractTest;
 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.core.op.ResourceFactory;
+import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.op.ODataDeserializerException;
 import org.junit.Test;
 
 public class EntitySetTest extends AbstractTest {
@@ -40,28 +41,27 @@ public class EntitySetTest extends AbstractTest {
     return v3Client;
   }
 
-  private void read(final ODataPubFormat format) throws IOException {
+  private void read(final ODataPubFormat format) throws IOException, ODataDeserializerException {
     final InputStream input = getClass().getResourceAsStream("Customer." + getSuffix(format));
     final ODataEntitySet entitySet = getClient().getBinder().getODataEntitySet(
-            getClient().getDeserializer().toEntitySet(input, format));
+        getClient().getDeserializer(format).toEntitySet(input));
     assertNotNull(entitySet);
 
     assertEquals(2, entitySet.getEntities().size());
     assertNotNull(entitySet.getNext());
 
     final ODataEntitySet written = getClient().getBinder().getODataEntitySet(new ResWrap<EntitySet>((URI) null, null,
-            getClient().getBinder().getEntitySet(
-                    entitySet, ResourceFactory.entitySetClassForFormat(format == ODataPubFormat.ATOM))));
+        getClient().getBinder().getEntitySet(entitySet)));
     assertEquals(entitySet, written);
   }
 
   @Test
-  public void fromAtom() throws IOException {
+  public void fromAtom() throws Exception {
     read(ODataPubFormat.ATOM);
   }
 
   @Test
-  public void fromJSON() throws IOException {
+  public void fromJSON() throws Exception {
     read(ODataPubFormat.JSON);
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 b73dc0d..1d4a04f 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
@@ -24,19 +24,20 @@ import static org.junit.Assert.assertTrue;
 
 import java.io.InputStream;
 import java.net.URI;
+
 import org.apache.olingo.client.api.v3.ODataClient;
-import org.apache.olingo.commons.api.domain.ODataLink;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
 import org.apache.olingo.client.core.AbstractTest;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.domain.ODataLink;
 import org.apache.olingo.commons.api.domain.v3.ODataEntity;
 import org.apache.olingo.commons.api.domain.v3.ODataProperty;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.core.op.ResourceFactory;
 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.junit.Test;
 
 public class EntityTest extends AbstractTest {
@@ -46,10 +47,10 @@ public class EntityTest extends AbstractTest {
     return v3Client;
   }
 
-  private void readAndWrite(final ODataPubFormat format) {
+  private void readAndWrite(final ODataPubFormat format) throws ODataDeserializerException {
     final InputStream input = getClass().getResourceAsStream("Customer_-10." + getSuffix(format));
     final ODataEntity entity = getClient().getBinder().getODataEntity(
-            getClient().getDeserializer().toEntity(input, format));
+        getClient().getDeserializer(format).toEntity(input));
     assertNotNull(entity);
 
     assertEquals("Microsoft.Test.OData.Services.AstoriaDefaultService.Customer", entity.getTypeName().toString());
@@ -68,25 +69,24 @@ public class EntityTest extends AbstractTest {
     assertTrue(check);
 
     final ODataEntity written = getClient().getBinder().getODataEntity(
-            new ResWrap<Entity>((URI) null, null, getClient().
-            getBinder().getEntity(entity, ResourceFactory.entityClassForFormat(format == ODataPubFormat.ATOM))));
+        new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
     assertEquals(entity, written);
   }
 
   @Test
-  public void fromAtom() {
+  public void fromAtom() throws Exception {
     readAndWrite(ODataPubFormat.ATOM);
   }
 
   @Test
-  public void fromJSON() {
+  public void fromJSON() throws Exception {
     readAndWrite(ODataPubFormat.JSON_FULL_METADATA);
   }
 
-  private void readGeospatial(final ODataPubFormat format) {
+  private void readGeospatial(final ODataPubFormat format) throws ODataDeserializerException {
     final InputStream input = getClass().getResourceAsStream("AllGeoTypesSet_-8." + getSuffix(format));
     final ODataEntity entity = getClient().getBinder().getODataEntity(
-            getClient().getDeserializer().toEntity(input, format));
+        getClient().getDeserializer(format).toEntity(input));
     assertNotNull(entity);
 
     boolean found = false;
@@ -100,78 +100,75 @@ public class EntityTest extends AbstractTest {
     assertTrue(found);
 
     final ODataEntity written = getClient().getBinder().getODataEntity(
-            new ResWrap<Entity>((URI) null, null, getClient().
-            getBinder().getEntity(entity, ResourceFactory.entityClassForFormat(format == ODataPubFormat.ATOM))));
+        new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
     assertEquals(entity, written);
   }
 
   @Test
-  public void withGeospatialFromAtom() {
+  public void withGeospatialFromAtom() throws Exception {
     readGeospatial(ODataPubFormat.ATOM);
   }
 
   @Test
-  public void withGeospatialFromJSON() {
+  public void withGeospatialFromJSON() throws Exception {
     // this needs to be full, otherwise there is no mean to recognize geospatial types
     readGeospatial(ODataPubFormat.JSON_FULL_METADATA);
   }
 
-  private void withActions(final ODataPubFormat format) {
+  private void withActions(final ODataPubFormat format) throws ODataDeserializerException {
     final InputStream input = getClass().getResourceAsStream("ComputerDetail_-10." + getSuffix(format));
     final ODataEntity entity = getClient().getBinder().getODataEntity(
-            getClient().getDeserializer().toEntity(input, format));
+        getClient().getDeserializer(format).toEntity(input));
     assertNotNull(entity);
 
     assertEquals(1, entity.getOperations().size());
     assertEquals("ResetComputerDetailsSpecifications", entity.getOperations().get(0).getTitle());
 
     final ODataEntity written = getClient().getBinder().getODataEntity(
-            new ResWrap<Entity>((URI) null, null, getClient().
-            getBinder().getEntity(entity, ResourceFactory.entityClassForFormat(format == ODataPubFormat.ATOM))));
+        new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
     entity.getOperations().clear();
     assertEquals(entity, written);
   }
 
   @Test
-  public void withActionsFromAtom() {
+  public void withActionsFromAtom() throws Exception {
     withActions(ODataPubFormat.ATOM);
   }
 
   @Test
-  public void withActionsFromJSON() {
+  public void withActionsFromJSON() throws Exception {
     // this needs to be full, otherwise actions will not be provided
     withActions(ODataPubFormat.JSON_FULL_METADATA);
   }
 
-  private void mediaEntity(final ODataPubFormat format) {
+  private void mediaEntity(final ODataPubFormat format) throws ODataDeserializerException {
     final InputStream input = getClass().getResourceAsStream("Car_16." + getSuffix(format));
     final ODataEntity entity = getClient().getBinder().getODataEntity(
-            getClient().getDeserializer().toEntity(input, format));
+        getClient().getDeserializer(format).toEntity(input));
     assertNotNull(entity);
     assertTrue(entity.isMediaEntity());
     assertNotNull(entity.getMediaContentSource());
     assertNotNull(entity.getMediaContentType());
 
     final ODataEntity written = getClient().getBinder().getODataEntity(
-            new ResWrap<Entity>((URI) null, null, getClient().
-            getBinder().getEntity(entity, ResourceFactory.entityClassForFormat(format == ODataPubFormat.ATOM))));
+        new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
     assertEquals(entity, written);
   }
 
   @Test
-  public void mediaEntityFromAtom() {
+  public void mediaEntityFromAtom() throws Exception {
     mediaEntity(ODataPubFormat.ATOM);
   }
 
   @Test
-  public void mediaEntityFromJSON() {
+  public void mediaEntityFromJSON() throws Exception {
     mediaEntity(ODataPubFormat.JSON_FULL_METADATA);
   }
 
-  private void issue128(final ODataPubFormat format) throws EdmPrimitiveTypeException {
+  private void issue128(final ODataPubFormat format) throws EdmPrimitiveTypeException, ODataDeserializerException {
     final InputStream input = getClass().getResourceAsStream("AllGeoTypesSet_-5." + getSuffix(format));
     final ODataEntity entity = getClient().getBinder().getODataEntity(
-            getClient().getDeserializer().toEntity(input, format));
+        getClient().getDeserializer(format).toEntity(input));
     assertNotNull(entity);
 
     final ODataProperty geogCollection = entity.getProperty("GeogCollection");
@@ -186,12 +183,12 @@ public class EntityTest extends AbstractTest {
   }
 
   @Test
-  public void issue128FromAtom() throws EdmPrimitiveTypeException {
+  public void issue128FromAtom() throws Exception {
     issue128(ODataPubFormat.ATOM);
   }
 
   @Test
-  public void issue128FromJSON() throws EdmPrimitiveTypeException {
+  public void issue128FromJSON() throws Exception {
     issue128(ODataPubFormat.JSON_FULL_METADATA);
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 b2cf8e3..1b340e9 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,6 +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.client.core.AbstractTest;
 import org.junit.Test;
 
@@ -34,40 +35,40 @@ public class ErrorTest extends AbstractTest {
     return v3Client;
   }
 
-  private ODataError error(final String name, final ODataPubFormat format) {
-    final ODataError error = getClient().getDeserializer().toError(
-            getClass().getResourceAsStream(name + "." + getSuffix(format)), format == ODataPubFormat.ATOM);
+  private ODataError error(final String name, final ODataPubFormat format) throws ODataDeserializerException {
+    final ODataError error = getClient().getDeserializer(format).toError(
+            getClass().getResourceAsStream(name + "." + getSuffix(format)));
     assertNotNull(error);
     return error;
   }
 
-  private void simple(final ODataPubFormat format) {
+  private void simple(final ODataPubFormat format) throws ODataDeserializerException {
     final ODataError error = error("error", format);
     assertEquals("The URL representing the root of the service only supports GET requests.", error.getMessage());
   }
 
   @Test
-  public void jsonSimple() {
+  public void jsonSimple() throws Exception {
     simple(ODataPubFormat.JSON);
   }
 
   @Test
-  public void atomSimple() {
+  public void atomSimple() throws Exception {
     simple(ODataPubFormat.ATOM);
   }
 
-  private void stacktrace(final ODataPubFormat format) {
+  private void stacktrace(final ODataPubFormat format) throws ODataDeserializerException {
     final ODataError error = error("stacktrace", format);
     assertEquals("Unsupported media type requested.", error.getMessage());
   }
 
   @Test
-  public void jsonStacktrace() {
+  public void jsonStacktrace() throws Exception {
     stacktrace(ODataPubFormat.JSON);
   }
 
   @Test
-  public void atomStacktrace() {
+  public void atomStacktrace() throws Exception {
     stacktrace(ODataPubFormat.ATOM);
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/MetadataTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/MetadataTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/MetadataTest.java
index ecd261c..ee83862 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/MetadataTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/MetadataTest.java
@@ -53,6 +53,7 @@ import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.EdmReturnType;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
 import org.junit.Test;
 
@@ -175,7 +176,7 @@ public class MetadataTest extends AbstractTest {
 
   @Test
   public void parseWithXMLMetadata() {
-    final XMLMetadata metadata = getClient().getDeserializer().
+    final XMLMetadata metadata = getClient().getDeserializer(ODataFormat.XML).
             toMetadata(getClass().getResourceAsStream("metadata.xml"));
     assertNotNull(metadata);
 
@@ -212,7 +213,7 @@ public class MetadataTest extends AbstractTest {
 
   @Test
   public void multipleSchemas() {
-    final XMLMetadata metadata = getClient().getDeserializer().
+    final XMLMetadata metadata = getClient().getDeserializer(ODataFormat.XML).
             toMetadata(getClass().getResourceAsStream("northwind-metadata.xml"));
     assertNotNull(metadata);
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 317d1ac..b561f28 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
@@ -25,6 +25,7 @@ import static org.junit.Assert.assertTrue;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Iterator;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.olingo.client.api.v3.ODataClient;
 import org.apache.olingo.client.core.AbstractTest;
@@ -36,7 +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.junit.Test;
 
 public class PropertyTest extends AbstractTest {
@@ -58,7 +60,8 @@ public class PropertyTest extends AbstractTest {
     assertEquals("-10", value.toString());
   }
 
-  private void primitive(final ODataFormat format) throws IOException, EdmPrimitiveTypeException {
+  private void primitive(final ODataFormat format)
+      throws EdmPrimitiveTypeException, ODataDeserializerException, ODataSerializerException {
     final InputStream input = getClass().getResourceAsStream("Customer_-10_CustomerId." + getSuffix(format));
     final ODataProperty property = getClient().getReader().readProperty(input, format);
     assertNotNull(property);
@@ -83,16 +86,16 @@ public class PropertyTest extends AbstractTest {
   }
 
   @Test
-  public void xmlPrimitive() throws IOException, EdmPrimitiveTypeException {
+  public void xmlPrimitive() throws Exception {
     primitive(ODataFormat.XML);
   }
 
   @Test
-  public void jsonPrimitive() throws IOException, EdmPrimitiveTypeException {
+  public void jsonPrimitive() throws Exception {
     primitive(ODataFormat.JSON);
   }
 
-  private void complex(final ODataFormat format) throws IOException {
+  private void complex(final ODataFormat format) throws ODataDeserializerException, ODataSerializerException {
     final InputStream input = getClass().getResourceAsStream("Customer_-10_PrimaryContactInfo." + getSuffix(format));
     final ODataProperty property = getClient().getReader().readProperty(input, format);
     assertNotNull(property);
@@ -119,16 +122,16 @@ public class PropertyTest extends AbstractTest {
   }
 
   @Test
-  public void xmlComplex() throws IOException {
+  public void xmlComplex() throws Exception {
     complex(ODataFormat.XML);
   }
 
   @Test
-  public void jsonComplex() throws IOException {
+  public void jsonComplex() throws Exception {
     complex(ODataFormat.JSON);
   }
 
-  private void collection(final ODataFormat format) throws IOException {
+  private void collection(final ODataFormat format) throws ODataDeserializerException, ODataSerializerException {
     final InputStream input = getClass().getResourceAsStream("Customer_-10_BackupContactInfo." + getSuffix(format));
     final ODataProperty property = getClient().getReader().readProperty(input, format);
     assertNotNull(property);
@@ -155,12 +158,12 @@ public class PropertyTest extends AbstractTest {
   }
 
   @Test
-  public void xmlCollection() throws IOException {
+  public void xmlCollection() throws Exception {
     collection(ODataFormat.XML);
   }
 
   @Test
-  public void jsonCollection() throws IOException {
+  public void jsonCollection() throws Exception {
     collection(ODataFormat.JSON);
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 0929741..b14c635 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,6 +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.client.core.AbstractTest;
 
 import static org.junit.Assert.assertNotNull;
@@ -39,7 +40,7 @@ public class ServiceDocumentTest extends AbstractTest {
     return format == ODataFormat.XML ? "xml" : "json";
   }
 
-  private void parse(final ODataFormat format) {
+  private void parse(final ODataFormat format) throws ODataDeserializerException {
     final ODataServiceDocument serviceDocument = getClient().getReader().readServiceDocument(
             getClass().getResourceAsStream("serviceDocument." + getFileExtension(format)), format);
     assertNotNull(serviceDocument);
@@ -47,12 +48,12 @@ public class ServiceDocumentTest extends AbstractTest {
   }
 
   @Test
-  public void json() {
+  public void json() throws Exception {
     parse(ODataFormat.JSON);
   }
 
   @Test
-  public void xml() {
+  public void xml() throws Exception {
     parse(ODataFormat.XML);
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 5338e50..453a8ab 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
@@ -25,6 +25,7 @@ import static org.junit.Assert.assertNull;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URI;
+
 import org.apache.olingo.client.api.v4.ODataClient;
 import org.apache.olingo.client.core.AbstractTest;
 import org.apache.olingo.commons.api.data.EntitySet;
@@ -32,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.core.op.ResourceFactory;
+import org.apache.olingo.commons.api.op.ODataDeserializerException;
 import org.junit.Test;
 
 public class EntitySetTest extends AbstractTest {
@@ -42,35 +43,34 @@ public class EntitySetTest extends AbstractTest {
     return v4Client;
   }
 
-  private void read(final ODataPubFormat format) throws IOException {
+  private void read(final ODataPubFormat format) throws IOException, ODataDeserializerException {
     final InputStream input = getClass().getResourceAsStream("Customers." + getSuffix(format));
     final ODataEntitySet entitySet = getClient().getBinder().getODataEntitySet(
-            getClient().getDeserializer().toEntitySet(input, format));
+            getClient().getDeserializer(format).toEntitySet(input));
     assertNotNull(entitySet);
 
     assertEquals(2, entitySet.getEntities().size());
     assertNull(entitySet.getNext());
 
     final ODataEntitySet written = getClient().getBinder().getODataEntitySet(new ResWrap<EntitySet>((URI) null, null,
-            getClient().getBinder().getEntitySet(
-                    entitySet, ResourceFactory.entitySetClassForFormat(format == ODataPubFormat.ATOM))));
+            getClient().getBinder().getEntitySet(entitySet)));
     assertEquals(entitySet, written);
   }
 
   @Test
-  public void fromAtom() throws IOException {
+  public void fromAtom() throws Exception {
     read(ODataPubFormat.ATOM);
   }
 
   @Test
-  public void fromJSON() throws IOException {
+  public void fromJSON() throws Exception {
     read(ODataPubFormat.JSON);
   }
 
-  private void ref(final ODataPubFormat format) {
+  private void ref(final ODataPubFormat format) throws ODataDeserializerException {
     final InputStream input = getClass().getResourceAsStream("collectionOfEntityReferences." + getSuffix(format));
     final ODataEntitySet entitySet = getClient().getBinder().getODataEntitySet(
-            getClient().getDeserializer().toEntitySet(input, format));
+            getClient().getDeserializer(format).toEntitySet(input));
     assertNotNull(entitySet);
 
     for (ODataEntity entity : entitySet.getEntities()) {
@@ -79,18 +79,17 @@ public class EntitySetTest extends AbstractTest {
     entitySet.setCount(entitySet.getEntities().size());
 
     final ODataEntitySet written = getClient().getBinder().getODataEntitySet(new ResWrap<EntitySet>((URI) null, null,
-            getClient().getBinder().getEntitySet(
-                    entitySet, ResourceFactory.entitySetClassForFormat(format == ODataPubFormat.ATOM))));
+            getClient().getBinder().getEntitySet(entitySet)));
     assertEquals(entitySet, written);
   }
 
   @Test
-  public void atomRef() {
+  public void atomRef() throws Exception {
     ref(ODataPubFormat.ATOM);
   }
 
   @Test
-  public void jsonRef() {
+  public void jsonRef() throws Exception {
     ref(ODataPubFormat.JSON);
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 0fc3495..38cbd8d 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
@@ -26,6 +26,7 @@ import static org.junit.Assert.assertTrue;
 import java.io.InputStream;
 import java.net.URI;
 import java.util.Iterator;
+
 import org.apache.olingo.client.api.v4.EdmEnabledODataClient;
 import org.apache.olingo.client.api.v4.ODataClient;
 import org.apache.olingo.client.core.AbstractTest;
@@ -43,9 +44,9 @@ 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.core.edm.primitivetype.EdmDateTimeOffset;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmDuration;
-import org.apache.olingo.commons.core.op.ResourceFactory;
 import org.junit.Test;
 
 public class EntityTest extends AbstractTest {
@@ -76,10 +77,10 @@ public class EntityTest extends AbstractTest {
     };
   }
 
-  private void singleton(final ODataPubFormat format) {
+  private void singleton(final ODataPubFormat format) throws ODataDeserializerException {
     final InputStream input = getClass().getResourceAsStream("VipCustomer." + getSuffix(format));
     final ODataEntity entity = getClient().getBinder().getODataEntity(
-            getClient().getDeserializer().toEntity(input, format));
+            getClient().getDeserializer(format).toEntity(input));
     assertNotNull(entity);
 
     assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString());
@@ -120,25 +121,24 @@ public class EntityTest extends AbstractTest {
     // operations won't get serialized
     entity.getOperations().clear();
     final ODataEntity written = getClient().getBinder().getODataEntity(
-            new ResWrap<Entity>((URI) null, null, getClient().getBinder().
-                    getEntity(entity, ResourceFactory.entityClassForFormat(format == ODataPubFormat.ATOM))));
+            new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
     assertEquals(entity, written);
   }
 
   @Test
-  public void atomSingleton() {
+  public void atomSingleton() throws Exception {
     singleton(ODataPubFormat.ATOM);
   }
 
   @Test
-  public void jsonSingleton() {
+  public void jsonSingleton() throws Exception {
     singleton(ODataPubFormat.JSON_FULL_METADATA);
   }
 
-  private void withEnums(final ODataPubFormat format) {
+  private void withEnums(final ODataPubFormat format) throws ODataDeserializerException {
     final InputStream input = getClass().getResourceAsStream("Products_5." + getSuffix(format));
     final ODataEntity entity = getClient().getBinder().getODataEntity(
-            getClient().getDeserializer().toEntity(input, format));
+            getClient().getDeserializer(format).toEntity(input));
     assertNotNull(entity);
 
     final ODataProperty skinColor = entity.getProperty("SkinColor");
@@ -156,26 +156,25 @@ public class EntityTest extends AbstractTest {
     // operations won't get serialized
     entity.getOperations().clear();
     final ODataEntity written = getClient().getBinder().getODataEntity(
-            new ResWrap<Entity>((URI) null, null, getClient().getBinder().
-                    getEntity(entity, ResourceFactory.entityClassForFormat(format == ODataPubFormat.ATOM))));
+            new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
     assertEquals(entity, written);
   }
 
   @Test
-  public void atomWithEnums() {
+  public void atomWithEnums() throws Exception {
     withEnums(ODataPubFormat.ATOM);
   }
 
   @Test
-  public void jsonWithEnums() {
+  public void jsonWithEnums() throws Exception {
     withEnums(ODataPubFormat.JSON_FULL_METADATA);
   }
 
-  private void withInlineEntitySet(final ODataPubFormat format) {
+  private void withInlineEntitySet(final ODataPubFormat format) throws ODataDeserializerException {
     final InputStream input = getClass().getResourceAsStream(
             "Accounts_101_expand_MyPaymentInstruments." + getSuffix(format));
     final ODataEntity entity = getClient().getBinder().getODataEntity(
-            getClient().getDeserializer().toEntity(input, format));
+            getClient().getDeserializer(format).toEntity(input));
     assertNotNull(entity);
 
     final ODataLink instruments = entity.getNavigationLink("MyPaymentInstruments");
@@ -191,26 +190,25 @@ public class EntityTest extends AbstractTest {
     // operations won't get serialized
     entity.getOperations().clear();
     final ODataEntity written = getClient().getBinder().getODataEntity(
-            new ResWrap<Entity>((URI) null, null, getClient().getBinder().
-                    getEntity(entity, ResourceFactory.entityClassForFormat(format == ODataPubFormat.ATOM))));
+            new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
     assertEquals(entity, written);
   }
 
   @Test
-  public void atomWithInlineEntitySet() {
+  public void atomWithInlineEntitySet() throws Exception {
     withInlineEntitySet(ODataPubFormat.ATOM);
   }
 
   @Test
-  public void jsonWithInlineEntitySet() {
+  public void jsonWithInlineEntitySet() throws Exception {
     withInlineEntitySet(ODataPubFormat.JSON_FULL_METADATA);
   }
 
-  private void mediaEntity(final ODataPubFormat format) {
+  private void mediaEntity(final ODataPubFormat format) throws ODataDeserializerException {
     final InputStream input = getClass().getResourceAsStream(
             "Advertisements_f89dee73-af9f-4cd4-b330-db93c25ff3c7." + getSuffix(format));
     final ODataEntity entity = getClient().getBinder().getODataEntity(
-            getClient().getDeserializer().toEntity(input, format));
+            getClient().getDeserializer(format).toEntity(input));
     assertNotNull(entity);
 
     assertTrue(entity.isMediaEntity());
@@ -218,25 +216,24 @@ public class EntityTest extends AbstractTest {
     assertEquals("\"8zOOKKvgOtptr4gt8IrnapX3jds=\"", entity.getMediaETag());
 
     final ODataEntity written = getClient().getBinder().getODataEntity(
-            new ResWrap<Entity>((URI) null, null, getClient().getBinder().
-                    getEntity(entity, ResourceFactory.entityClassForFormat(format == ODataPubFormat.ATOM))));
+            new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
     assertEquals(entity, written);
   }
 
   @Test
-  public void atomMediaEntity() {
+  public void atomMediaEntity() throws Exception {
     mediaEntity(ODataPubFormat.ATOM);
   }
 
   @Test
-  public void jsonMediaEntity() {
+  public void jsonMediaEntity() throws Exception {
     mediaEntity(ODataPubFormat.JSON_FULL_METADATA);
   }
 
-  private void withStream(final ODataPubFormat format) {
+  private void withStream(final ODataPubFormat format) throws ODataDeserializerException {
     final InputStream input = getClass().getResourceAsStream("PersonDetails_1." + getSuffix(format));
     final ODataEntity entity = getClient().getBinder().getODataEntity(
-            getClient().getDeserializer().toEntity(input, format));
+            getClient().getDeserializer(format).toEntity(input));
     assertNotNull(entity);
 
     assertFalse(entity.isMediaEntity());
@@ -245,49 +242,47 @@ public class EntityTest extends AbstractTest {
     assertNotNull(editMedia);
 
     final ODataEntity written = getClient().getBinder().getODataEntity(
-            new ResWrap<Entity>((URI) null, null, getClient().getBinder().
-                    getEntity(entity, ResourceFactory.entityClassForFormat(format == ODataPubFormat.ATOM))));
+            new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
     assertEquals(entity, written);
   }
 
   @Test
-  public void atomWithStream() {
+  public void atomWithStream() throws Exception {
     withStream(ODataPubFormat.ATOM);
   }
 
   @Test
-  public void jsonWithStream() {
+  public void jsonWithStream() throws Exception {
     withStream(ODataPubFormat.JSON_FULL_METADATA);
   }
 
-  private void ref(final ODataPubFormat format) {
+  private void ref(final ODataPubFormat format) throws ODataDeserializerException {
     final InputStream input = getClass().getResourceAsStream("entityReference." + getSuffix(format));
     final ODataEntity entity = getClient().getBinder().getODataEntity(
-            getClient().getDeserializer().toEntity(input, format));
+            getClient().getDeserializer(format).toEntity(input));
     assertNotNull(entity);
 
     assertNotNull(entity.getId());
 
     final ODataEntity written = getClient().getBinder().getODataEntity(
-            new ResWrap<Entity>((URI) null, null, getClient().getBinder().
-                    getEntity(entity, ResourceFactory.entityClassForFormat(format == ODataPubFormat.ATOM))));
+            new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
     assertEquals(entity, written);
   }
 
   @Test
-  public void atomRef() {
+  public void atomRef() throws Exception {
     ref(ODataPubFormat.ATOM);
   }
 
   @Test
-  public void jsonRef() {
+  public void jsonRef() throws Exception {
     ref(ODataPubFormat.JSON);
   }
 
-  private void complexNavigationProperties(final ODataPubFormat format) {
+  private void complexNavigationProperties(final ODataPubFormat format) throws ODataDeserializerException {
     final InputStream input = getClass().getResourceAsStream("entity.withcomplexnavigation." + getSuffix(format));
     final ODataEntity entity = getClient().getBinder().getODataEntity(
-            getClient().getDeserializer().toEntity(input, format));
+            getClient().getDeserializer(format).toEntity(input));
     assertNotNull(entity);
 
     final ODataLinkedComplexValue addressValue = entity.getProperty("Address").getLinkedComplexValue();
@@ -297,25 +292,24 @@ public class EntityTest extends AbstractTest {
     // ETag is not serialized
     entity.setETag(null);
     final ODataEntity written = getClient().getBinder().getODataEntity(
-            new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity,
-                            ResourceFactory.entityClassForFormat(format == ODataPubFormat.ATOM))));
+            new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
     assertEquals(entity, written);
   }
 
   @Test
-  public void atomComplexNavigationProperties() {
+  public void atomComplexNavigationProperties() throws Exception {
     complexNavigationProperties(ODataPubFormat.ATOM);
   }
 
   @Test
-  public void jsonComplexNavigationProperties() {
+  public void jsonComplexNavigationProperties() throws Exception {
     complexNavigationProperties(ODataPubFormat.JSON);
   }
 
-  private void annotated(final ODataPubFormat format) throws EdmPrimitiveTypeException {
+  private void annotated(final ODataPubFormat format) throws EdmPrimitiveTypeException, ODataDeserializerException {
     final InputStream input = getClass().getResourceAsStream("annotated." + getSuffix(format));
     final ODataEntity entity = getClient().getBinder().getODataEntity(
-            getClient().getDeserializer().toEntity(input, format));
+            getClient().getDeserializer(format).toEntity(input));
     assertNotNull(entity);
 
     assertFalse(entity.getAnnotations().isEmpty());
@@ -343,24 +337,23 @@ public class EntityTest extends AbstractTest {
             annotation.getValue().asLinkedComplex().get("order").getPrimitiveValue().toCastValue(Integer.class), 0);
 
     final ODataEntity written = getClient().getBinder().getODataEntity(
-            new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity,
-                            ResourceFactory.entityClassForFormat(format == ODataPubFormat.ATOM))));
+            new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
     assertEquals(entity, written);
   }
 
   @Test
-  public void atomAnnotated() {
+  public void atomAnnotated() throws Exception {
     complexNavigationProperties(ODataPubFormat.ATOM);
   }
 
   @Test
-  public void jsonAnnotated() {
+  public void jsonAnnotated() throws Exception {
     complexNavigationProperties(ODataPubFormat.JSON);
   }
 
-  private void derived(final ODataClient client, final ODataPubFormat format) {
+  private void derived(final ODataClient client, final ODataPubFormat format) throws ODataDeserializerException {
     final InputStream input = getClass().getResourceAsStream("Customer." + getSuffix(format));    
-    final ODataEntity entity = client.getBinder().getODataEntity(client.getDeserializer().toEntity(input, format));
+    final ODataEntity entity = client.getBinder().getODataEntity(client.getDeserializer(format).toEntity(input));
     assertNotNull(entity);
 
     assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString());
@@ -369,17 +362,17 @@ public class EntityTest extends AbstractTest {
   }
 
   @Test
-  public void derivedFromAtom() {
+  public void derivedFromAtom() throws Exception {
     derived(getClient(), ODataPubFormat.ATOM);
   }
 
   @Test
-  public void derivedFromJSON() {
+  public void derivedFromJSON() throws Exception {
     derived(getEdmEnabledClient(), ODataPubFormat.JSON);
   }
 
   @Test
-  public void derivedFromFullJSON() {
+  public void derivedFromFullJSON() throws Exception {
     derived(getClient(), ODataPubFormat.JSON_FULL_METADATA);
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 c89fa39..b221ade 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,6 +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.client.core.AbstractTest;
 import org.junit.Test;
 
@@ -34,14 +35,14 @@ public class ErrorTest extends AbstractTest {
     return v4Client;
   }
 
-  private ODataError error(final String name, final ODataPubFormat format) {
-    final ODataError error = getClient().getDeserializer().toError(
-            getClass().getResourceAsStream(name + "." + getSuffix(format)), format == ODataPubFormat.ATOM);
+  private ODataError error(final String name, final ODataPubFormat format) throws ODataDeserializerException {
+    final ODataError error = getClient().getDeserializer(format).toError(
+            getClass().getResourceAsStream(name + "." + getSuffix(format)));
     assertNotNull(error);
     return error;
   }
 
-  private void simple(final ODataPubFormat format) {
+  private void simple(final ODataPubFormat format) throws ODataDeserializerException {
     final ODataError error = error("error", format);
     assertEquals("501", error.getCode());
     assertEquals("Unsupported functionality", error.getMessage());
@@ -49,12 +50,12 @@ public class ErrorTest extends AbstractTest {
   }
 
   @Test
-  public void jsonSimple() {
+  public void jsonSimple() throws Exception {
     simple(ODataPubFormat.JSON);
   }
 
   @Test
-  public void atomSimple() {
+  public void atomSimple() throws Exception {
     simple(ODataPubFormat.ATOM);
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java
index 39e7a1e..20967b9 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java
@@ -92,16 +92,16 @@ public class JSONTest extends AbstractTest {
       final Map.Entry<String, JsonNode> field = itor.next();
 
       if (field.getKey().charAt(0) == '#'
-              || field.getKey().endsWith(
-                      getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_TYPE))
-              || field.getKey().endsWith(
-                      getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK))
-              || field.getKey().endsWith(
-                      getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIA_CONTENT_TYPE))
-              || field.getKey().endsWith(
-                      getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_ASSOCIATION_LINK))
-              || field.getKey().endsWith(
-                      getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIA_ETAG))) {
+          || field.getKey().endsWith(
+              getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_TYPE))
+          || field.getKey().endsWith(
+              getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK))
+          || field.getKey().endsWith(
+              getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIA_CONTENT_TYPE))
+          || field.getKey().endsWith(
+              getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_ASSOCIATION_LINK))
+          || field.getKey().endsWith(
+              getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIA_ETAG))) {
 
         toRemove.add(field.getKey());
       } else if (field.getValue().isObject()) {
@@ -120,8 +120,8 @@ public class JSONTest extends AbstractTest {
 
   protected void assertSimilar(final String filename, final String actual) throws Exception {
     final JsonNode expected = OBJECT_MAPPER.readTree(IOUtils.toString(getClass().getResourceAsStream(filename)).
-            replace(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_NAVIGATION_LINK),
-                    Constants.JSON_BIND_LINK_SUFFIX));
+        replace(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_NAVIGATION_LINK),
+            Constants.JSON_BIND_LINK_SUFFIX));
     cleanup((ObjectNode) expected);
     final ObjectNode actualNode = (ObjectNode) OBJECT_MAPPER.readTree(new ByteArrayInputStream(actual.getBytes()));
     cleanup(actualNode);
@@ -130,8 +130,8 @@ public class JSONTest extends AbstractTest {
 
   protected void entitySet(final String filename, final ODataPubFormat format) throws Exception {
     final StringWriter writer = new StringWriter();
-    getClient().getSerializer().entitySet(getClient().getDeserializer().toEntitySet(
-            getClass().getResourceAsStream(filename + "." + getSuffix(format)), format).getPayload(), writer);
+    getClient().getSerializer(format).write(writer, getClient().getDeserializer(format).toEntitySet(
+        getClass().getResourceAsStream(filename + "." + getSuffix(format))).getPayload());
 
     assertSimilar(filename + "." + getSuffix(format), writer.toString());
   }
@@ -144,8 +144,8 @@ public class JSONTest extends AbstractTest {
 
   protected void entity(final String filename, final ODataPubFormat format) throws Exception {
     final StringWriter writer = new StringWriter();
-    getClient().getSerializer().entity(getClient().getDeserializer().toEntity(
-            getClass().getResourceAsStream(filename + "." + getSuffix(format)), format).getPayload(), writer);
+    getClient().getSerializer(format).write(writer, getClient().getDeserializer(format).toEntity(
+        getClass().getResourceAsStream(filename + "." + getSuffix(format))).getPayload());
 
     assertSimilar(filename + "." + getSuffix(format), writer.toString());
   }
@@ -171,9 +171,8 @@ public class JSONTest extends AbstractTest {
 
   protected void property(final String filename, final ODataFormat format) throws Exception {
     final StringWriter writer = new StringWriter();
-    getClient().getSerializer().property(getClient().getDeserializer().
-            toProperty(getClass().getResourceAsStream(filename + "." + getSuffix(format)), format).getPayload(),
-            writer);
+    getClient().getSerializer(format).write(writer, getClient().getDeserializer(format).
+        toProperty(getClass().getResourceAsStream(filename + "." + getSuffix(format))).getPayload());
 
     assertSimilar(filename + "." + getSuffix(format), writer.toString());
   }
@@ -188,13 +187,13 @@ public class JSONTest extends AbstractTest {
 
   @Test
   public void crossjoin() throws Exception {
-    assertNotNull(getClient().getDeserializer().toEntitySet(
-            getClass().getResourceAsStream("crossjoin.json"), ODataPubFormat.JSON_FULL_METADATA));
+    assertNotNull(getClient().getDeserializer(ODataPubFormat.JSON_FULL_METADATA).toEntitySet(
+        getClass().getResourceAsStream("crossjoin.json")));
   }
 
   protected void delta(final String filename, final ODataPubFormat format) throws Exception {
-    final Delta delta = getClient().getDeserializer().toDelta(
-            getClass().getResourceAsStream(filename + "." + getSuffix(format)), format).getPayload();
+    final Delta delta = getClient().getDeserializer(format).toDelta(
+        getClass().getResourceAsStream(filename + "." + getSuffix(format))).getPayload();
     assertNotNull(delta);
     assertNotNull(delta.getDeltaLink());
     assertEquals(5, delta.getCount(), 0);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/MetadataTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/MetadataTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/MetadataTest.java
index 8ca024a..dd69685 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/MetadataTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/MetadataTest.java
@@ -62,6 +62,7 @@ import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.api.edm.annotation.EdmUrlRef;
 import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
+import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmDecimal;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmInt32;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
@@ -137,7 +138,7 @@ public class MetadataTest extends AbstractTest {
 
   @Test
   public void demo() {
-    final XMLMetadata metadata = getClient().getDeserializer().
+    final XMLMetadata metadata = getClient().getDeserializer(ODataFormat.XML).
             toMetadata(getClass().getResourceAsStream("demo-metadata.xml"));
     assertNotNull(metadata);
 
@@ -178,7 +179,7 @@ public class MetadataTest extends AbstractTest {
 
   @Test
   public void multipleSchemas() {
-    final XMLMetadata metadata = getClient().getDeserializer().
+    final XMLMetadata metadata = getClient().getDeserializer(ODataFormat.XML).
             toMetadata(getClass().getResourceAsStream("northwind-metadata.xml"));
     assertNotNull(metadata);
 
@@ -199,7 +200,7 @@ public class MetadataTest extends AbstractTest {
    */
   @Test
   public void fromdoc1() {
-    final XMLMetadata metadata = getClient().getDeserializer().
+    final XMLMetadata metadata = getClient().getDeserializer(ODataFormat.XML).
             toMetadata(getClass().getResourceAsStream("fromdoc1-metadata.xml"));
     assertNotNull(metadata);
 
@@ -270,8 +271,8 @@ public class MetadataTest extends AbstractTest {
    */
   @Test
   public void fromdoc2() {
-    final XMLMetadata metadata = getClient().getDeserializer().
-            toMetadata(getClass().getResourceAsStream("fromdoc2-metadata.xml"));
+    final XMLMetadata metadata = getClient().getDeserializer(ODataFormat.XML)
+            .toMetadata(getClass().getResourceAsStream("fromdoc2-metadata.xml"));
     assertNotNull(metadata);
 
     // Check displayName
@@ -334,7 +335,7 @@ public class MetadataTest extends AbstractTest {
    */
   @Test
   public void fromdoc4() {
-    final XMLMetadata metadata = getClient().getDeserializer().
+    final XMLMetadata metadata = getClient().getDeserializer(ODataFormat.XML).
             toMetadata(getClass().getResourceAsStream("fromdoc4-metadata.xml"));
     assertNotNull(metadata);
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 022496c..1535355 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
@@ -18,21 +18,22 @@
  */
 package org.apache.olingo.client.core.v4;
 
-import java.io.IOException;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
 import java.io.InputStream;
 import java.util.Iterator;
+
 import org.apache.olingo.client.api.v4.ODataClient;
 import org.apache.olingo.client.core.AbstractTest;
 import org.apache.olingo.commons.api.domain.ODataCollectionValue;
 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.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
+import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.api.op.ODataSerializerException;
 import org.junit.Test;
 
 public class PropertyTest extends AbstractTest {
@@ -42,7 +43,7 @@ public class PropertyTest extends AbstractTest {
     return v4Client;
   }
 
-  private void _enum(final ODataFormat format) {
+  private void _enum(final ODataFormat format) throws ODataDeserializerException, ODataSerializerException {
     final InputStream input = getClass().getResourceAsStream("Products_5_SkinColor." + getSuffix(format));
     final ODataProperty property = getClient().getReader().readProperty(input, format);
     assertNotNull(property);
@@ -61,16 +62,16 @@ public class PropertyTest extends AbstractTest {
   }
 
   @Test
-  public void xmlEnum() throws IOException, EdmPrimitiveTypeException {
+  public void xmlEnum() throws Exception {
     _enum(ODataFormat.XML);
   }
 
   @Test
-  public void jsonEnum() throws IOException, EdmPrimitiveTypeException {
+  public void jsonEnum() throws Exception {
     _enum(ODataFormat.JSON);
   }
 
-  private void complex(final ODataFormat format) throws IOException {
+  private void complex(final ODataFormat format) throws ODataDeserializerException, ODataSerializerException {
     final InputStream input = getClass().getResourceAsStream("Employees_3_HomeAddress." + getSuffix(format));
     final ODataProperty property = getClient().getReader().readProperty(input, format);
     assertNotNull(property);
@@ -93,16 +94,16 @@ public class PropertyTest extends AbstractTest {
   }
 
   @Test
-  public void xmlComplex() throws IOException {
+  public void xmlComplex() throws Exception {
     complex(ODataFormat.XML);
   }
 
   @Test
-  public void jsonComplex() throws IOException {
+  public void jsonComplex() throws Exception {
     complex(ODataFormat.JSON);
   }
 
-  private void collection(final ODataFormat format) throws IOException {
+  private void collection(final ODataFormat format) throws ODataDeserializerException, ODataSerializerException {
     final InputStream input = getClass().getResourceAsStream("Products_5_CoverColors." + getSuffix(format));
     final ODataProperty property = getClient().getReader().readProperty(input, format);
     assertNotNull(property);
@@ -127,12 +128,12 @@ public class PropertyTest extends AbstractTest {
   }
 
   @Test
-  public void xmlCollection() throws IOException {
+  public void xmlCollection() throws Exception {
     collection(ODataFormat.XML);
   }
 
   @Test
-  public void jsonCollection() throws IOException {
+  public void jsonCollection() throws Exception {
     collection(ODataFormat.JSON);
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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 f515bdc..403fbcf 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
@@ -23,10 +23,12 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import java.net.URI;
+
 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.client.core.AbstractTest;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.junit.Test;
@@ -42,9 +44,9 @@ public class ServiceDocumentTest extends AbstractTest {
     return format == ODataFormat.XML ? "xml" : "json";
   }
 
-  private ODataServiceDocument parse(final ODataFormat format) {
-    ResWrap<ServiceDocument> service = getClient().getDeserializer().toServiceDocument(
-            getClass().getResourceAsStream("serviceDocument." + getFileExtension(format)), format);
+  private ODataServiceDocument parse(final ODataFormat format) throws ODataDeserializerException {
+    ResWrap<ServiceDocument> service = getClient().getDeserializer(format).toServiceDocument(
+            getClass().getResourceAsStream("serviceDocument." + getFileExtension(format)));
 
     assertEquals(URI.create("http://host/service/$metadata"), service.getContextURL().getURI());
     assertEquals("W/\"MjAxMy0wNS0xM1QxNDo1NFo=\"", service.getMetadataETag());
@@ -62,12 +64,12 @@ public class ServiceDocumentTest extends AbstractTest {
   }
 
   @Test
-  public void json() {
+  public void json() throws Exception {
     parse(ODataFormat.JSON);
   }
 
   @Test
-  public void xml() {
+  public void xml() throws Exception {
     parse(ODataFormat.XML);
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/CommonODataDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/CommonODataDeserializer.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/CommonODataDeserializer.java
deleted file mode 100644
index a0d9a87..0000000
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/CommonODataDeserializer.java
+++ /dev/null
@@ -1,71 +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 java.io.Serializable;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.domain.ODataError;
-import org.apache.olingo.commons.api.data.EntitySet;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
-
-/**
- * Interface for de-serialization.
- */
-public interface CommonODataDeserializer extends Serializable {
-
-  /**
-   * Gets an entity set object from the given InputStream.
-   *
-   * @param input stream to be de-serialized.
-   * @param format Atom or JSON
-   * @return {@link EntitySet} instance.
-   */
-  ResWrap<EntitySet> toEntitySet(InputStream input, ODataPubFormat format);
-
-  /**
-   * Gets an entity object from the given InputStream.
-   *
-   * @param input stream to be de-serialized.
-   * @param format Atom or JSON
-   * @return {@link Entity} instance.
-   */
-  ResWrap<Entity> toEntity(InputStream input, ODataPubFormat format);
-
-  /**
-   * Gets a property object from the given InputStream.
-   *
-   * @param input stream to be de-serialized.
-   * @param format XML or JSON
-   * @return Property instance.
-   */
-  ResWrap<Property> toProperty(InputStream input, ODataFormat format);
-
-  /**
-   * Gets the ODataError object represented by the given InputStream.
-   *
-   * @param input stream to be parsed and de-serialized.
-   * @param isXML 'TRUE' if the error is represented by XML; 'FALSE' otherwise.
-   * @return
-   */
-  ODataError toError(InputStream input, boolean isXML);
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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
new file mode 100755
index 0000000..9b6bd5a
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/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.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/46a34178/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
new file mode 100755
index 0000000..7852a5f
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/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.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/46a34178/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
index c8a02cf..6fc95da 100644
--- 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
@@ -18,83 +18,16 @@
  */
 package org.apache.olingo.commons.api.op;
 
-import java.io.OutputStream;
-import java.io.Serializable;
 import java.io.Writer;
-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.format.ODataFormat;
+
+import org.apache.olingo.commons.api.data.ResWrap;
 
 /**
- * Utility class for serialization.
+ * Interface for serialization.
  */
-public interface ODataSerializer extends Serializable {
-
-  /**
-   * Writes entity set object onto the given stream.
-   *
-   * @param obj object to be streamed.
-   * @param out output stream.
-   */
-  void entitySet(EntitySet obj, OutputStream out);
-
-  /**
-   * Writes entity set object by the given writer.
-   *
-   * @param obj object to be streamed.
-   * @param writer writer.
-   */
-  void entitySet(EntitySet obj, Writer writer);
-
-  /**
-   * Writes entity object onto the given stream.
-   *
-   * @param obj object to be streamed.
-   * @param out output stream.
-   */
-  void entity(Entity obj, OutputStream out);
-
-  /**
-   * Writes entity object by the given writer.
-   *
-   * @param obj object to be streamed.
-   * @param writer writer.
-   */
-  void entity(Entity obj, Writer writer);
-
-  /**
-   * Writes the property object onto the given stream.
-   *
-   * @param property object to be streamed.
-   * @param out output stream.
-   */
-  void property(Property property, OutputStream out);
-
-  /**
-   * Writes the property object by the given writer.
-   *
-   * @param property object to be streamed.
-   * @param writer writer.
-   */
-  void property(Property property, Writer writer);
+public interface ODataSerializer {
 
-  /**
-   * Writes link onto the given stream.
-   *
-   * @param link OData link to be streamed.
-   * @param format streaming format.
-   * @param out output stream.
-   */
-  void link(Link link, ODataFormat format, OutputStream out);
+  public <T> void write(final Writer writer, final T obj) throws ODataSerializerException;
 
-  /**
-   * Writes link by the given writer.
-   *
-   * @param link OData link to be streamed.
-   * @param format streaming format.
-   * @param writer writer.
-   */
-  void link(Link link, ODataFormat format, Writer writer);
+  public <T> void write(final Writer writer, final ResWrap<T> container) throws ODataSerializerException;
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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
new file mode 100755
index 0000000..69b5c3f
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/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.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/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractEntity.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractEntity.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractEntity.java
deleted file mode 100644
index 7bc3fd5..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractEntity.java
+++ /dev/null
@@ -1,193 +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.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-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.domain.ODataOperation;
-
-/**
- * Abstract base for classes implementing an OData entity in Atom and JSON.
- */
-public abstract class AbstractEntity extends AbstractODataObject implements Entity {
-
-  private static final long serialVersionUID = 2127764552600969783L;
-
-  private String eTag;
-
-  private String type;
-
-  private Link readLink;
-
-  private Link editLink;
-
-  private final List<Link> associationLinks = new ArrayList<Link>();
-
-  private final List<Link> navigationLinks = new ArrayList<Link>();
-
-  private final List<Link> mediaEditLinks = new ArrayList<Link>();
-
-  private final List<ODataOperation> operations = new ArrayList<ODataOperation>();
-
-  private final List<Property> properties = new ArrayList<Property>();
-
-  private URI mediaContentSource;
-
-  private String mediaContentType;
-
-  private String mediaETag;
-
-  @Override
-  public String getETag() {
-    return eTag;
-  }
-
-  public void setETag(final String eTag) {
-    this.eTag = eTag;
-  }
-
-  @Override
-  public String getType() {
-    return type;
-  }
-
-  @Override
-  public void setType(final String type) {
-    this.type = type;
-  }
-
-  @Override
-  public Link getSelfLink() {
-    return readLink;
-  }
-
-  @Override
-  public void setSelfLink(final Link readLink) {
-    this.readLink = readLink;
-  }
-
-  @Override
-  public Link getEditLink() {
-    return editLink;
-  }
-
-  @Override
-  public void setEditLink(final Link editLink) {
-    this.editLink = editLink;
-  }
-
-  private Link getOneByTitle(final String name, final List<Link> links) {
-    Link result = null;
-
-    for (Link link : links) {
-      if (name.equals(link.getTitle())) {
-        result = link;
-      }
-    }
-
-    return result;
-  }
-
-  @Override
-  public Link getAssociationLink(final String name) {
-    return getOneByTitle(name, associationLinks);
-  }
-
-  @Override
-  public List<Link> getAssociationLinks() {
-    return associationLinks;
-  }
-
-  @Override
-  public Link getNavigationLink(final String name) {
-    return getOneByTitle(name, navigationLinks);
-  }
-
-  @Override
-  public List<Link> getNavigationLinks() {
-    return navigationLinks;
-  }
-
-  @Override
-  public List<Link> getMediaEditLinks() {
-    return mediaEditLinks;
-  }
-
-  @Override
-  public List<ODataOperation> getOperations() {
-    return operations;
-  }
-
-  @Override
-  public List<Property> getProperties() {
-    return properties;
-  }
-
-  @Override
-  public Property getProperty(final String name) {
-    Property result = null;
-
-    for (Property property : properties) {
-      if (name.equals(property.getName())) {
-        result = property;
-      }
-    }
-
-    return result;
-  }
-
-  @Override
-  public String getMediaContentType() {
-    return this.mediaContentType;
-  }
-
-  @Override
-  public void setMediaContentType(final String mediaContentType) {
-    this.mediaContentType = mediaContentType;
-  }
-
-  @Override
-  public URI getMediaContentSource() {
-    return this.mediaContentSource;
-  }
-
-  @Override
-  public void setMediaContentSource(final URI mediaContentSource) {
-    this.mediaContentSource = mediaContentSource;
-  }
-
-  @Override
-  public String getMediaETag() {
-    return mediaETag;
-  }
-
-  @Override
-  public void setMediaETag(final String eTag) {
-    this.mediaETag = eTag;
-  }
-
-  @Override
-  public boolean isMediaEntity() {
-    return this.mediaContentSource != null;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractEntitySet.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractEntitySet.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractEntitySet.java
deleted file mode 100644
index 510c22a..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractEntitySet.java
+++ /dev/null
@@ -1,74 +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.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
-
-public abstract class AbstractEntitySet extends AbstractODataObject implements EntitySet {
-
-  private static final long serialVersionUID = -9159884750819150969L;
-
-  private Integer count;
-
-  private final List<Entity> entities = new ArrayList<Entity>();
-
-  private URI next;
-
-  private URI deltaLink;
-
-  @Override
-  public void setCount(final Integer count) {
-    this.count = count;
-  }
-
-  @Override
-  public Integer getCount() {
-    return count;
-  }
-
-  @Override
-  public List<Entity> getEntities() {
-    return entities;
-  }
-
-  @Override
-  public void setNext(final URI next) {
-    this.next = next;
-  }
-
-  @Override
-  public URI getNext() {
-    return next;
-  }
-
-  @Override
-  public URI getDeltaLink() {
-    return deltaLink;
-  }
-
-  @Override
-  public void setDeltaLink(final URI deltaLink) {
-    this.deltaLink = deltaLink;
-  }
-
-}


[10/23] [OLINGO-317] Finished DeSerializer refactoring

Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeletedEntityImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeletedEntityImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeletedEntityImpl.java
index 67ab03b..1e2930f 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeletedEntityImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeletedEntityImpl.java
@@ -23,10 +23,7 @@ import org.apache.olingo.commons.api.data.DeletedEntity;
 
 public class DeletedEntityImpl extends AbstractAnnotatedObject implements DeletedEntity {
 
-  private static final long serialVersionUID = 2075093398299488510L;
-
   private URI id;
-
   private Reason reason;
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaLinkImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaLinkImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaLinkImpl.java
index 0834b55..7ed1de6 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaLinkImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaLinkImpl.java
@@ -23,12 +23,8 @@ import org.apache.olingo.commons.api.data.DeltaLink;
 
 public class DeltaLinkImpl extends AbstractAnnotatedObject implements DeltaLink {
 
-  private static final long serialVersionUID = 581329273399308799L;
-
   private URI source;
-
   private String relationship;
-
   private URI target;
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntityImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntityImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntityImpl.java
index 28451a9..003c72d 100755
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntityImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntityImpl.java
@@ -31,20 +31,15 @@ import org.apache.olingo.commons.api.domain.ODataOperation;
  */
 public class EntityImpl extends AbstractODataObject implements Entity {
 
-  private static final long serialVersionUID = 2127764552600969783L;
-
   private String eTag;
 
   private String type;
 
   private Link readLink;
-
   private Link editLink;
 
   private final List<Link> associationLinks = new ArrayList<Link>();
-
   private final List<Link> navigationLinks = new ArrayList<Link>();
-
   private final List<Link> mediaEditLinks = new ArrayList<Link>();
 
   private final List<ODataOperation> operations = new ArrayList<ODataOperation>();
@@ -52,9 +47,7 @@ public class EntityImpl extends AbstractODataObject implements Entity {
   private final List<Property> properties = new ArrayList<Property>();
 
   private URI mediaContentSource;
-
   private String mediaContentType;
-
   private String mediaETag;
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntitySetImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntitySetImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntitySetImpl.java
index 1920809..3a985b4 100755
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntitySetImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntitySetImpl.java
@@ -26,8 +26,6 @@ import org.apache.olingo.commons.api.data.EntitySet;
 
 public class EntitySetImpl extends AbstractODataObject implements EntitySet {
 
-  private static final long serialVersionUID = -9159884750819150969L;
-
   private Integer count;
 
   private final List<Entity> entities = new ArrayList<Entity>();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/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
new file mode 100755
index 0000000..1876b9c
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/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.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/70afb2ac/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
index e067d88..bf1c19e 100755
--- 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
@@ -102,7 +102,7 @@ public class JsonSerializer implements ODataSerializer {
       } else if (obj instanceof Entity) {
         new JSONEntitySerializer(version, serverMode).doContainerSerialize((ResWrap<Entity>) container, json);
       } else if (obj instanceof Property) {
-        new JSONPropertySerializer(version, serverMode).doSerialize((Property) obj, json);
+        new JSONPropertySerializer(version, serverMode).doContainerSerialize((ResWrap<Property>) container, json);
       } else if (obj instanceof Link) {
         link((Link) obj, json);
       }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/LinkImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/LinkImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/LinkImpl.java
index 85acc8f..72e09cf 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/LinkImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/LinkImpl.java
@@ -24,20 +24,12 @@ import org.apache.olingo.commons.api.data.Link;
 
 public class LinkImpl extends AbstractAnnotatedObject implements Link {
 
-  private static final long serialVersionUID = -3449344217160035501L;
-
   private String title;
-
   private String rel;
-
   private String href;
-
   private String type;
-
   private String mediaETag;
-
   private Entity entity;
-
   private EntitySet entitySet;
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java
index 9d9f35c..f98e854 100755
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java
@@ -23,12 +23,8 @@ import org.apache.olingo.commons.api.data.Value;
 
 public class PropertyImpl extends AbstractAnnotatedObject implements Property {
 
-  private static final long serialVersionUID = -7175704800169997060L;
-
   private String name;
-
   private String type;
-
   private Value value;
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/JSONLinkCollectionImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/JSONLinkCollectionImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/JSONLinkCollectionImpl.java
deleted file mode 100644
index edf871b..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/JSONLinkCollectionImpl.java
+++ /dev/null
@@ -1,118 +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.v3;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.olingo.commons.api.data.v3.LinkCollection;
-import org.apache.olingo.commons.core.data.AbstractPayloadObject;
-
-/**
- * Link from an entity, represented via JSON.
- */
-public class JSONLinkCollectionImpl extends AbstractPayloadObject implements LinkCollection {
-
-  private static final long serialVersionUID = -5006368367235783907L;
-
-  /**
-   * JSON link URL representation.
-   */
-  static class JSONLinkURL extends AbstractPayloadObject {
-
-    private static final long serialVersionUID = 5365055617973271468L;
-
-    private URI url;
-
-    public URI getUrl() {
-      return url;
-    }
-
-    public void setUrl(final URI url) {
-      this.url = url;
-    }
-  }
-
-  @JsonProperty(value = "odata.metadata", required = false)
-  private URI metadata;
-
-  @JsonProperty(required = false)
-  private URI url;
-
-  @JsonProperty(value = "value", required = false)
-  private final List<JSONLinkURL> links = new ArrayList<JSONLinkURL>();
-
-  @JsonProperty(value = "odata.nextLink", required = false)
-  private String next;
-
-  /**
-   * Gets the metadata URI.
-   */
-  public URI getMetadata() {
-    return metadata;
-  }
-
-  /**
-   * Sets the metadata URI.
-   *
-   * @param metadata metadata URI.
-   */
-  public void setMetadata(final URI metadata) {
-    this.metadata = metadata;
-  }
-
-  /**
-   * {@inheritDoc }
-   */
-  @JsonIgnore
-  @Override
-  public List<URI> getLinks() {
-    final List<URI> result = new ArrayList<URI>();
-
-    if (this.url == null) {
-      for (JSONLinkURL link : links) {
-        result.add(link.getUrl());
-      }
-    } else {
-      result.add(this.url);
-    }
-
-    return result;
-  }
-
-  /**
-   * {@inheritDoc }
-   */
-  @JsonIgnore
-  @Override
-  public void setNext(final URI next) {
-    this.next = next == null ? null : next.toASCIIString();
-  }
-
-  /**
-   * {@inheritDoc }
-   */
-  @JsonIgnore
-  @Override
-  public URI getNext() {
-    return next == null ? null : URI.create(next);
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/LinkCollectionImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/LinkCollectionImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/LinkCollectionImpl.java
index 3310723..f62b423 100755
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/LinkCollectionImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/LinkCollectionImpl.java
@@ -21,9 +21,11 @@ package org.apache.olingo.commons.core.data.v3;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.List;
+
 import org.apache.olingo.commons.api.data.v3.LinkCollection;
+import org.apache.olingo.commons.core.data.AbstractAnnotatedObject;
 
-public class LinkCollectionImpl implements LinkCollection {
+public class LinkCollectionImpl extends AbstractAnnotatedObject implements LinkCollection {
 
   private final List<URI> links = new ArrayList<URI>();
   private URI next;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/DeltaImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/DeltaImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/DeltaImpl.java
index 021a77d..d507ebe 100755
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/DeltaImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/DeltaImpl.java
@@ -27,12 +27,8 @@ import org.apache.olingo.commons.core.data.EntitySetImpl;
 
 public class DeltaImpl extends EntitySetImpl implements Delta {
 
-  private static final long serialVersionUID = 4576771708961553195L;
-
   private final List<DeletedEntity> deletedEntities = new ArrayList<DeletedEntity>();
-
   private final List<DeltaLink> addedLinks = new ArrayList<DeltaLink>();
-
   private final List<DeltaLink> deletedLinks = new ArrayList<DeltaLink>();
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/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
index a2ef134..548d79d 100644
--- 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
@@ -51,12 +51,12 @@ public abstract class AbstractODataDeserializer {
   protected final ODataServiceVersion version;
   protected final ODataDeserializer deserializer;
 
-  public AbstractODataDeserializer(final ODataServiceVersion version, final Format format) {
+  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, false);
+      deserializer = new JsonDeserializer(version, serverMode);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
index cf9f3f3..acea9f5 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
@@ -18,52 +18,26 @@
  */
 package org.apache.olingo.server.core;
 
-import java.io.IOException;
-import java.net.URI;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
 import org.apache.olingo.commons.api.ODataRuntimeException;
-import org.apache.olingo.commons.api.data.ContextURL;
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.api.http.HttpContentType;
-import org.apache.olingo.commons.api.http.HttpMethod;
 import org.apache.olingo.commons.api.http.HttpHeader;
-import org.apache.olingo.commons.core.data.EntityImpl;
-import org.apache.olingo.commons.core.data.EntitySetImpl;
-import org.apache.olingo.commons.core.data.PrimitiveValueImpl;
-import org.apache.olingo.commons.core.data.PropertyImpl;
-import org.apache.olingo.commons.core.op.InjectableSerializerProvider;
+import org.apache.olingo.commons.api.http.HttpMethod;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
-import org.apache.olingo.server.api.processor.DefaultProcessor;
-import org.apache.olingo.server.api.processor.EntityProcessor;
-import org.apache.olingo.server.api.processor.EntitySetProcessor;
-import org.apache.olingo.server.api.processor.MetadataProcessor;
-import org.apache.olingo.server.api.processor.Processor;
-import org.apache.olingo.server.api.processor.ServiceDocumentProcessor;
-import org.apache.olingo.server.api.serializer.ODataSerializer;
+import org.apache.olingo.server.api.processor.*;
 import org.apache.olingo.server.api.uri.UriInfo;
 import org.apache.olingo.server.api.uri.UriResource;
 import org.apache.olingo.server.api.uri.UriResourceNavigation;
 import org.apache.olingo.server.api.uri.UriResourcePartTyped;
-import org.apache.olingo.server.core.serializer.utils.CircleStreamBuffer;
 import org.apache.olingo.server.core.uri.parser.Parser;
 import org.apache.olingo.server.core.uri.validator.UriValidator;
 
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.databind.InjectableValues;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 public class ODataHandler {
 
@@ -134,39 +108,6 @@ public class ODataHandler {
     UriResource lastPathSegment = uriInfo.getUriResourceParts().get(lastPathSegmentIndex);
     switch (lastPathSegment.getKind()) {
     case entitySet:
-      long time = System.nanoTime();
-      ResWrap<EntitySet> wrap = new ResWrap<EntitySet>(
-          ContextURL.getInstance(URI.create("dummyContextURL")), "dummyMetadataETag",
-          createEntitySet());
-      System.out.println((System.nanoTime() - time) / 1000 + " microseconds");
-      time = System.nanoTime();
-      CircleStreamBuffer buffer = new CircleStreamBuffer();
-      if (false) {
-        ObjectMapper mapper = new ObjectMapper().setSerializationInclusion(Include.NON_NULL);
-        mapper.setInjectableValues(new InjectableValues.Std()
-            .addValue(ODataServiceVersion.class, ODataServiceVersion.V40)
-            .addValue(Boolean.class, Boolean.TRUE));
-        mapper.setSerializerProvider(new InjectableSerializerProvider(mapper.getSerializerProvider(),
-            mapper.getSerializationConfig()
-                .withAttribute(ODataServiceVersion.class, ODataServiceVersion.V40)
-                .withAttribute(Boolean.class, Boolean.TRUE),
-            mapper.getSerializerFactory()));
-        try {
-          mapper.writeValue(buffer.getOutputStream(), wrap);
-        } catch (final IOException e) {}
-        response.setContent(buffer.getInputStream());
-      } else {
-        ODataSerializer serializer = odata.createSerializer(org.apache.olingo.server.api.serializer.ODataFormat.JSON);
-        response.setContent(serializer.entitySet(
-            edm.getEntityContainer(new FullQualifiedName("com.sap.odata.test1", "Container"))
-                .getEntitySet("ESAllPrim"),
-            wrap.getPayload(),
-            ContextURL.getInstance(URI.create("dummyContextURL"))));
-      }
-      System.out.println((System.nanoTime() - time) / 1000 + " microseconds");
-      response.setStatusCode(200);
-      response.setHeader("Content-Type", ContentType.APPLICATION_JSON);
-
       if (((UriResourcePartTyped) lastPathSegment).isCollection()) {
         if (request.getMethod().equals(HttpMethod.GET)) {
           EntitySetProcessor esp = selectProcessor(EntitySetProcessor.class);
@@ -240,34 +181,4 @@ public class ODataHandler {
       }
     }
   }
-
-  protected Entity createEntity() {
-    Entity entity = new EntityImpl();
-    Property property = new PropertyImpl();
-    property.setName("PropertyString");
-    property.setType("String"); //"dummyType");
-    property.setValue(new PrimitiveValueImpl("dummyValue"));
-    entity.getProperties().add(property);
-    Property propertyInt = new PropertyImpl();
-    propertyInt.setName("PropertyInt16");
-    // propertyInt.setType("Edm.Int32");
-    propertyInt.setValue(new PrimitiveValueImpl("042"));
-    entity.getProperties().add(propertyInt);
-    Property propertyGuid = new PropertyImpl();
-    propertyGuid.setName("PropertyGuid");
-    propertyGuid.setType("Edm.Guid");
-    propertyGuid.setValue(new PrimitiveValueImpl(UUID.randomUUID().toString()));
-    entity.getProperties().add(propertyGuid);
-    return entity;
-  }
-
-  protected EntitySet createEntitySet() {
-    EntitySet entitySet = new EntitySetImpl();
-    entitySet.setCount(4242);
-    entitySet.setNext(URI.create("nextLinkURI"));
-    for (int i = 0; i < 1000; i++) {
-      entitySet.getEntities().add(createEntity());
-    }
-    return entitySet;
-  }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/server-tecsvc/pom.xml
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/pom.xml b/lib/server-tecsvc/pom.xml
index 1371a00..3925fbd 100644
--- a/lib/server-tecsvc/pom.xml
+++ b/lib/server-tecsvc/pom.xml
@@ -122,6 +122,17 @@
     </dependency>
 
     <dependency>
+      <groupId>org.apache.olingo</groupId>
+      <artifactId>olingo-commons-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.olingo</groupId>
+      <artifactId>olingo-commons-core</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-simple</artifactId>
       <scope>runtime</scope>
@@ -140,6 +151,11 @@
       <artifactId>commons-io</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.olingo</groupId>
+      <artifactId>core</artifactId>
+      <version>0.1.0-SNAPSHOT</version>
+    </dependency>
   </dependencies>
 
 </project>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java
index ec8a061..9841dd8 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java
@@ -29,6 +29,7 @@ import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.server.api.ODataHttpHandler;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.tecsvc.data.DataProvider;
+import org.apache.olingo.server.tecsvc.processor.SampleJsonProcessor;
 import org.apache.olingo.server.tecsvc.processor.TechnicalProcessor;
 import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
 import org.slf4j.Logger;
@@ -56,8 +57,9 @@ public class TechnicalServlet extends HttpServlet {
 
     ODataHttpHandler handler = odata.createHandler(edm);
     
-    handler.register(new TechnicalProcessor(dataProvider));
-       
+//    handler.register(new TechnicalProcessor(dataProvider));
+    handler.register(new SampleJsonProcessor());
+
     handler.process(req, resp);
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
new file mode 100644
index 0000000..66e863b
--- /dev/null
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.server.tecsvc.processor;
+
+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.Property;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.commons.core.data.EntityImpl;
+import org.apache.olingo.commons.core.data.EntitySetImpl;
+import org.apache.olingo.commons.core.data.PrimitiveValueImpl;
+import org.apache.olingo.commons.core.data.PropertyImpl;
+import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.ODataRequest;
+import org.apache.olingo.server.api.ODataResponse;
+import org.apache.olingo.server.api.processor.EntityProcessor;
+import org.apache.olingo.server.api.processor.EntitySetProcessor;
+import org.apache.olingo.server.api.serializer.ODataFormat;
+import org.apache.olingo.server.api.serializer.ODataSerializer;
+import org.apache.olingo.server.api.uri.UriInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.URI;
+import java.util.UUID;
+
+public class SampleJsonProcessor implements EntitySetProcessor, EntityProcessor {
+    private static final Logger LOG = LoggerFactory.getLogger(SampleJsonProcessor.class);
+
+    private OData odata;
+    private Edm edm;
+
+    @Override
+    public void init(OData odata, Edm edm) {
+      this.odata = odata;
+      this.edm = edm;
+    }
+
+    @Override
+    public void readEntitySet(ODataRequest request, ODataResponse response, UriInfo uriInfo, String format) {
+      long time = System.nanoTime();
+
+      EntitySet entitySet = createEntitySet();
+
+      LOG.info((System.nanoTime() - time) / 1000 + " microseconds");
+      time = System.nanoTime();
+      ODataSerializer serializer = odata.createSerializer(ODataFormat.JSON);
+      response.setContent(serializer.entitySet(
+              edm.getEntityContainer(new FullQualifiedName("com.sap.odata.test1", "Container"))
+                      .getEntitySet("ESAllPrim"),
+              entitySet,
+              ContextURL.getInstance(URI.create("dummyContextURL"))));
+      LOG.info("Finished in " + (System.nanoTime() - time) / 1000 + " microseconds");
+
+      response.setStatusCode(200);
+      response.setHeader("Content-Type", ContentType.APPLICATION_JSON);
+    }
+
+    @Override
+    public void readEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, String format) {
+      long time = System.nanoTime();
+      Entity entity = createEntity();
+
+      LOG.info((System.nanoTime() - time) / 1000 + " microseconds");
+      time = System.nanoTime();
+      ODataSerializer serializer = odata.createSerializer(ODataFormat.JSON);
+      response.setContent(serializer.entity(
+              edm.getEntityContainer(new FullQualifiedName("com.sap.odata.test1", "Container"))
+                      .getEntitySet("ESAllPrim").getEntityType(),
+              entity,
+              ContextURL.getInstance(URI.create("dummyContextURL"))));
+      LOG.info("Finished in " + (System.nanoTime() - time) / 1000 + " microseconds");
+
+      response.setStatusCode(200);
+      response.setHeader("Content-Type", ContentType.APPLICATION_JSON);
+    }
+
+    protected Entity createEntity() {
+      Entity entity = new EntityImpl();
+      Property property = new PropertyImpl();
+      property.setName("PropertyString");
+      property.setType("String"); //"dummyType");
+      property.setValue(new PrimitiveValueImpl("dummyValue"));
+      entity.getProperties().add(property);
+      Property propertyInt = new PropertyImpl();
+      propertyInt.setName("PropertyInt16");
+      // propertyInt.setType("Edm.Int32");
+      propertyInt.setValue(new PrimitiveValueImpl("42"));
+      entity.getProperties().add(propertyInt);
+      Property propertyGuid = new PropertyImpl();
+      propertyGuid.setName("PropertyGuid");
+      propertyGuid.setType("Edm.Guid");
+      propertyGuid.setValue(new PrimitiveValueImpl(UUID.randomUUID().toString()));
+      entity.getProperties().add(propertyGuid);
+      return entity;
+    }
+
+    protected EntitySet createEntitySet() {
+      EntitySet entitySet = new EntitySetImpl();
+      entitySet.setCount(4242);
+      entitySet.setNext(URI.create("nextLinkURI"));
+      for (int i = 0; i < 1000; i++) {
+        entitySet.getEntities().add(createEntity());
+      }
+      return entitySet;
+    }
+  }


[08/23] [OLINGO-317] First presentable state

Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/fit/src/main/java/org/apache/olingo/fit/V4Services.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/V4Services.java b/fit/src/main/java/org/apache/olingo/fit/V4Services.java
index 482c194..81f70ee 100644
--- a/fit/src/main/java/org/apache/olingo/fit/V4Services.java
+++ b/fit/src/main/java/org/apache/olingo/fit/V4Services.java
@@ -18,7 +18,6 @@
  */
 package org.apache.olingo.fit;
 
-import com.fasterxml.jackson.core.type.TypeReference;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
@@ -33,6 +32,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 import java.util.regex.Pattern;
+
 import javax.mail.internet.MimeBodyPart;
 import javax.mail.internet.MimeMultipart;
 import javax.ws.rs.Consumes;
@@ -51,6 +51,7 @@ import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.Status;
 import javax.ws.rs.core.UriInfo;
+
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -60,20 +61,18 @@ import org.apache.cxf.jaxrs.ext.multipart.Attachment;
 import org.apache.cxf.jaxrs.ext.multipart.Multipart;
 import org.apache.cxf.jaxrs.ext.multipart.MultipartBody;
 import org.apache.olingo.commons.api.data.CollectionValue;
-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.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.format.ContentType;
-import org.apache.olingo.commons.core.data.AtomEntityImpl;
-import org.apache.olingo.commons.core.data.AtomEntitySetImpl;
-import org.apache.olingo.commons.core.data.AtomPropertyImpl;
 import org.apache.olingo.commons.core.data.CollectionValueImpl;
+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.JSONEntityImpl;
-import org.apache.olingo.commons.core.data.JSONPropertyImpl;
 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.apache.olingo.fit.metadata.Metadata;
 import org.apache.olingo.fit.methods.PATCH;
@@ -90,18 +89,18 @@ import org.springframework.stereotype.Service;
 
 @Service
 @Path("/V40/Static.svc")
-@InInterceptors(classes = {XHTTPMethodInterceptor.class, ResolvingReferencesInterceptor.class})
+@InInterceptors(classes = { XHTTPMethodInterceptor.class, ResolvingReferencesInterceptor.class })
 public class V4Services extends AbstractServices {
 
   /**
    * CR/LF.
    */
-  protected static final byte[] CRLF = {13, 10};
+  protected static final byte[] CRLF = { 13, 10 };
 
   protected static final Pattern RELENTITY_SELECT_PATTERN = Pattern.compile("^.*\\(\\$select=.*\\)$");
 
   protected static final Pattern CROSSJOIN_PATTERN = Pattern.compile(
-          "^\\$crossjoin\\(.*\\)\\?\\$filter=\\([a-zA-Z/]+ eq [a-zA-Z/]+\\)$");
+      "^\\$crossjoin\\(.*\\)\\?\\$filter=\\([a-zA-Z/]+ eq [a-zA-Z/]+\\)$");
 
   private final Map<String, String> providedAsync = new HashMap<String, String>();
 
@@ -116,18 +115,18 @@ public class V4Services extends AbstractServices {
   @GET
   @Path("/redirect/{name}({id})")
   public Response conformanceRedirect(
-          @Context UriInfo uriInfo,
-          @PathParam("name") String name,
-          @PathParam("id") String id) {
+      @Context UriInfo uriInfo,
+      @PathParam("name") String name,
+      @PathParam("id") String id) {
     return Response.temporaryRedirect(
-            URI.create(uriInfo.getRequestUri().toASCIIString().replace("/redirect", ""))).build();
+        URI.create(uriInfo.getRequestUri().toASCIIString().replace("/redirect", ""))).build();
   }
 
   @GET
   @Path("/$crossjoin({elements:.*})")
   public Response crossjoin(
-          @PathParam("elements") String elements,
-          @QueryParam("$filter") String filter) {
+      @PathParam("elements") String elements,
+      @QueryParam("$filter") String filter) {
 
     try {
       if (CROSSJOIN_PATTERN.matcher("$crossjoin(" + elements + ")?$filter=" + filter).matches()) {
@@ -145,8 +144,8 @@ public class V4Services extends AbstractServices {
   @GET
   @Path("/relatedEntitySelect/{path:.*}")
   public Response relatedEntitySelect(
-          @PathParam("path") String path,
-          @QueryParam("$expand") String expand) {
+      @PathParam("path") String path,
+      @QueryParam("$expand") String expand) {
 
     if (RELENTITY_SELECT_PATTERN.matcher(expand).matches()) {
       return xml.createResponse(null, null, Accept.JSON_FULLMETA);
@@ -180,9 +179,9 @@ public class V4Services extends AbstractServices {
   @POST
   @Path("/async/$batch")
   public Response async(
-          @Context final UriInfo uriInfo,
-          @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
-          final @Multipart MultipartBody attachment) {
+      @Context final UriInfo uriInfo,
+      @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
+      final @Multipart MultipartBody attachment) {
 
     try {
       final ByteArrayOutputStream bos = new ByteArrayOutputStream();
@@ -219,7 +218,7 @@ public class V4Services extends AbstractServices {
       bos.close();
 
       return xml.createAsyncResponse(
-              uriInfo.getRequestUri().toASCIIString().replace("async/$batch", "") + "monitor/" + uuid.toString());
+          uriInfo.getRequestUri().toASCIIString().replace("async/$batch", "") + "monitor/" + uuid.toString());
     } catch (Exception e) {
       return xml.createFaultResponse(Accept.JSON.toString(), e);
     }
@@ -228,9 +227,9 @@ public class V4Services extends AbstractServices {
   @GET
   @Path("/async/{name}")
   public Response async(
-          @Context final UriInfo uriInfo,
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-          @PathParam("name") final String name) {
+      @Context final UriInfo uriInfo,
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+      @PathParam("name") final String name) {
 
     try {
       final Accept acceptType = Accept.parse(accept, version);
@@ -242,8 +241,8 @@ public class V4Services extends AbstractServices {
       final StringBuilder path = new StringBuilder(basePath);
 
       path.append(metadata.getEntitySet(name).isSingleton()
-              ? Constants.get(version, ConstantKey.ENTITY)
-              : Constants.get(version, ConstantKey.FEED));
+          ? Constants.get(version, ConstantKey.ENTITY)
+          : Constants.get(version, ConstantKey.FEED));
 
       final InputStream feed = FSManager.instance(version).readFile(path.toString(), acceptType);
 
@@ -257,7 +256,7 @@ public class V4Services extends AbstractServices {
       providedAsync.put(uuid.toString(), builder.toString());
 
       return xml.createAsyncResponse(
-              uriInfo.getRequestUri().toASCIIString().replaceAll("async/" + name, "") + "monitor/" + uuid.toString());
+          uriInfo.getRequestUri().toASCIIString().replaceAll("async/" + name, "") + "monitor/" + uuid.toString());
     } catch (Exception e) {
       return xml.createFaultResponse(accept, e);
     }
@@ -272,8 +271,8 @@ public class V4Services extends AbstractServices {
 
   @Override
   public InputStream exploreMultipart(
-          final List<Attachment> attachments, final String boundary, final boolean continueOnError)
-          throws IOException {
+      final List<Attachment> attachments, final String boundary, final boolean continueOnError)
+      throws IOException {
 
     final ByteArrayOutputStream bos = new ByteArrayOutputStream();
 
@@ -359,59 +358,59 @@ public class V4Services extends AbstractServices {
   @GET
   @Path("/People/{type:.*}")
   public Response getPeople(
-          @Context UriInfo uriInfo,
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @PathParam("type") final String type,
-          @QueryParam("$top") @DefaultValue(StringUtils.EMPTY) String top,
-          @QueryParam("$skip") @DefaultValue(StringUtils.EMPTY) String skip,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
-          @QueryParam("$inlinecount") @DefaultValue(StringUtils.EMPTY) String count,
-          @QueryParam("$filter") @DefaultValue(StringUtils.EMPTY) String filter,
-          @QueryParam("$search") @DefaultValue(StringUtils.EMPTY) String search,
-          @QueryParam("$orderby") @DefaultValue(StringUtils.EMPTY) String orderby,
-          @QueryParam("$skiptoken") @DefaultValue(StringUtils.EMPTY) String skiptoken) {
+      @Context UriInfo uriInfo,
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+      @PathParam("type") final String type,
+      @QueryParam("$top") @DefaultValue(StringUtils.EMPTY) String top,
+      @QueryParam("$skip") @DefaultValue(StringUtils.EMPTY) String skip,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
+      @QueryParam("$inlinecount") @DefaultValue(StringUtils.EMPTY) String count,
+      @QueryParam("$filter") @DefaultValue(StringUtils.EMPTY) String filter,
+      @QueryParam("$search") @DefaultValue(StringUtils.EMPTY) String search,
+      @QueryParam("$orderby") @DefaultValue(StringUtils.EMPTY) String orderby,
+      @QueryParam("$skiptoken") @DefaultValue(StringUtils.EMPTY) String skiptoken) {
 
     return StringUtils.isBlank(filter) && StringUtils.isBlank(search)
-            ? NumberUtils.isNumber(type)
+        ? NumberUtils.isNumber(type)
             ? super.getEntityInternal(
-                    uriInfo.getRequestUri().toASCIIString(), accept, "People", type, format, null, null, true)
+                uriInfo.getRequestUri().toASCIIString(), accept, "People", type, format, null, null, true)
             : super.getEntitySet(accept, "People", type)
-            : super.getEntitySet(uriInfo, accept, "People", top, skip, format, count, filter, orderby, skiptoken);
+        : super.getEntitySet(uriInfo, accept, "People", top, skip, format, count, filter, orderby, skiptoken);
   }
 
   @GET
   @Path("/Boss")
   public Response getSingletonBoss(
-          @Context UriInfo uriInfo,
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
+      @Context UriInfo uriInfo,
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
 
     return getEntityInternal(
-            uriInfo.getRequestUri().toASCIIString(), accept, "Boss", StringUtils.EMPTY, format, null, null, false);
+        uriInfo.getRequestUri().toASCIIString(), accept, "Boss", StringUtils.EMPTY, format, null, null, false);
   }
 
   @GET
   @Path("/Company")
   public Response getSingletonCompany(
-          @Context UriInfo uriInfo,
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
+      @Context UriInfo uriInfo,
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
 
     return getEntityInternal(
-            uriInfo.getRequestUri().toASCIIString(), accept, "Company", StringUtils.EMPTY, format, null, null, false);
+        uriInfo.getRequestUri().toASCIIString(), accept, "Company", StringUtils.EMPTY, format, null, null, false);
   }
 
   @PATCH
   @Path("/Company")
-  @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
-  @Consumes({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
+  @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON })
+  @Consumes({ MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON })
   public Response patchSingletonCompany(
-          @Context UriInfo uriInfo,
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
-          @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) String prefer,
-          @HeaderParam("If-Match") @DefaultValue(StringUtils.EMPTY) String ifMatch,
-          final String changes) {
+      @Context UriInfo uriInfo,
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+      @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
+      @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) String prefer,
+      @HeaderParam("If-Match") @DefaultValue(StringUtils.EMPTY) String ifMatch,
+      final String changes) {
 
     return super.patchEntity(uriInfo, accept, contentType, prefer, ifMatch, "Company", StringUtils.EMPTY, changes);
   }
@@ -419,11 +418,11 @@ public class V4Services extends AbstractServices {
   @GET
   @Path("/Customers")
   public Response getCustomers(
-          @Context UriInfo uriInfo,
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
-          @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) String prefer,
-          @QueryParam("$deltatoken") @DefaultValue(StringUtils.EMPTY) String deltatoken) {
+      @Context UriInfo uriInfo,
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
+      @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) String prefer,
+      @QueryParam("$deltatoken") @DefaultValue(StringUtils.EMPTY) String deltatoken) {
 
     try {
       final Accept acceptType;
@@ -436,29 +435,29 @@ public class V4Services extends AbstractServices {
       final InputStream output;
       if (StringUtils.isBlank(deltatoken)) {
         final InputStream input = (InputStream) getEntitySet(
-                uriInfo, accept, "Customers", null, null, format, null, null, null, null).getEntity();
-        final AtomEntitySetImpl entitySet = xml.readEntitySet(acceptType, input);
+            uriInfo, accept, "Customers", null, null, format, null, null, null, null).getEntity();
+        final EntitySet entitySet = xml.readEntitySet(acceptType, input);
 
         boolean trackChanges = prefer.contains("odata.track-changes");
         if (trackChanges) {
           entitySet.setDeltaLink(URI.create("Customers?$deltatoken=8015"));
         }
 
-        output = xml.writeEntitySet(acceptType, new ResWrap<AtomEntitySetImpl>(
-                URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + "Customers"),
-                null,
-                entitySet));
+        output = xml.writeEntitySet(acceptType, new ResWrap<EntitySet>(
+            URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + "Customers"),
+            null,
+            entitySet));
       } else {
         output = FSManager.instance(version).readFile("delta", acceptType);
       }
 
       final Response response = xml.createResponse(
-              null,
-              output,
-              null,
-              acceptType);
+          null,
+          output,
+          null,
+          acceptType);
       if (StringUtils.isNotBlank(prefer)) {
-        response.getHeaders().put("Preference-Applied", Collections.<Object>singletonList(prefer));
+        response.getHeaders().put("Preference-Applied", Collections.<Object> singletonList(prefer));
       }
       return response;
     } catch (Exception e) {
@@ -469,8 +468,8 @@ public class V4Services extends AbstractServices {
   @GET
   @Path("/Company/Microsoft.Test.OData.Services.ODataWCFService.GetEmployeesCount{paren:[\\(\\)]*}")
   public Response functionGetEmployeesCount(
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
 
     try {
       final Accept acceptType;
@@ -480,18 +479,18 @@ public class V4Services extends AbstractServices {
         acceptType = Accept.parse(accept, version);
       }
 
-      final AtomPropertyImpl property = new AtomPropertyImpl();
+      final Property property = new PropertyImpl();
       property.setType("Edm.Int32");
       property.setValue(new PrimitiveValueImpl("2"));
-      final ResWrap<AtomPropertyImpl> container = new ResWrap<AtomPropertyImpl>(
-              URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + property.getType()), null,
-              property);
+      final ResWrap<Property> container = new ResWrap<Property>(
+          URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + property.getType()), null,
+          property);
 
       return xml.createResponse(
-              null,
-              xml.writeProperty(acceptType, container),
-              null,
-              acceptType);
+          null,
+          xml.writeProperty(acceptType, container),
+          null,
+          acceptType);
     } catch (Exception e) {
       return xml.createFaultResponse(accept, e);
     }
@@ -500,10 +499,10 @@ public class V4Services extends AbstractServices {
   @POST
   @Path("/Company/Microsoft.Test.OData.Services.ODataWCFService.IncreaseRevenue{paren:[\\(\\)]*}")
   public Response actionIncreaseRevenue(
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
-          final String param) {
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+      @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
+      final String param) {
 
     try {
       final Accept acceptType;
@@ -517,10 +516,10 @@ public class V4Services extends AbstractServices {
       final Entity entry = xml.readEntity(contentTypeValue, IOUtils.toInputStream(param, Constants.ENCODING));
 
       return xml.createResponse(
-              null,
-              xml.writeProperty(acceptType, entry.getProperty("IncreaseValue")),
-              null,
-              acceptType);
+          null,
+          xml.writeProperty(acceptType, entry.getProperty("IncreaseValue")),
+          null,
+          acceptType);
     } catch (Exception e) {
       return xml.createFaultResponse(accept, e);
     }
@@ -529,9 +528,9 @@ public class V4Services extends AbstractServices {
   @GET
   @Path("/Products({entityId})/Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails({param:.*})")
   public Response functionGetProductDetails(
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @PathParam("entityId") String entityId,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+      @PathParam("entityId") String entityId,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
 
     try {
       final Accept acceptType;
@@ -541,31 +540,31 @@ public class V4Services extends AbstractServices {
         acceptType = Accept.parse(accept, version);
       }
 
-      final AtomEntityImpl entry = new AtomEntityImpl();
+      final EntityImpl entry = new EntityImpl();
       entry.setType("Microsoft.Test.OData.Services.ODataWCFService.ProductDetail");
-      final Property productId = new AtomPropertyImpl();
+      final Property productId = new PropertyImpl();
       productId.setName("ProductID");
       productId.setType("Edm.Int32");
       productId.setValue(new PrimitiveValueImpl(entityId));
       entry.getProperties().add(productId);
-      final Property productDetailId = new AtomPropertyImpl();
+      final Property productDetailId = new PropertyImpl();
       productDetailId.setName("ProductDetailID");
       productDetailId.setType("Edm.Int32");
       productDetailId.setValue(new PrimitiveValueImpl("2"));
       entry.getProperties().add(productDetailId);
 
-      final AtomEntitySetImpl feed = new AtomEntitySetImpl();
+      final EntitySetImpl feed = new EntitySetImpl();
       feed.getEntities().add(entry);
 
-      final ResWrap<AtomEntitySetImpl> container = new ResWrap<AtomEntitySetImpl>(
-              URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + "ProductDetail"), null,
-              feed);
+      final ResWrap<EntitySet> container = new ResWrap<EntitySet>(
+          URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + "ProductDetail"), null,
+          feed);
 
       return xml.createResponse(
-              null,
-              xml.writeEntitySet(acceptType, container),
-              null,
-              acceptType);
+          null,
+          xml.writeEntitySet(acceptType, container),
+          null,
+          acceptType);
     } catch (Exception e) {
       return xml.createFaultResponse(accept, e);
     }
@@ -574,10 +573,10 @@ public class V4Services extends AbstractServices {
   @POST
   @Path("/Products({entityId})/Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight{paren:[\\(\\)]*}")
   public Response actionAddAccessRight(
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
-          final String param) {
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+      @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
+      final String param) {
 
     try {
       final Accept acceptType;
@@ -596,15 +595,15 @@ public class V4Services extends AbstractServices {
       final Property property = entry.getProperty("accessRight");
       property.setType("Microsoft.Test.OData.Services.ODataWCFService.AccessLevel");
 
-      final ResWrap<AtomPropertyImpl> result = new ResWrap<AtomPropertyImpl>(
-              URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + property.getType()),
-              null, (AtomPropertyImpl) property);
+      final ResWrap<Property> result = new ResWrap<Property>(
+          URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + property.getType()),
+          null, property);
 
       return xml.createResponse(
-              null,
-              xml.writeProperty(acceptType, result),
-              null,
-              acceptType);
+          null,
+          xml.writeProperty(acceptType, result),
+          null,
+          acceptType);
     } catch (Exception e) {
       return xml.createFaultResponse(accept, e);
     }
@@ -613,12 +612,12 @@ public class V4Services extends AbstractServices {
   @POST
   @Path("/Customers(PersonID={personId})/Microsoft.Test.OData.Services.ODataWCFService.ResetAddress{paren:[\\(\\)]*}")
   public Response actionResetAddress(
-          @Context UriInfo uriInfo,
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @PathParam("personId") String personId,
-          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
-          final String param) {
+      @Context UriInfo uriInfo,
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+      @PathParam("personId") String personId,
+      @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
+      final String param) {
 
     try {
       final Accept contentTypeValue = Accept.parse(contentType, version);
@@ -629,7 +628,7 @@ public class V4Services extends AbstractServices {
       assert entry.getProperty("index") != null;
 
       return getEntityInternal(
-              uriInfo.getRequestUri().toASCIIString(), accept, "Customers", personId, format, null, null, false);
+          uriInfo.getRequestUri().toASCIIString(), accept, "Customers", personId, format, null, null, false);
     } catch (Exception e) {
       return xml.createFaultResponse(accept, e);
     }
@@ -637,26 +636,26 @@ public class V4Services extends AbstractServices {
 
   @GET
   @Path("/ProductDetails(ProductID={productId},ProductDetailID={productDetailId})"
-          + "/Microsoft.Test.OData.Services.ODataWCFService.GetRelatedProduct{paren:[\\(\\)]*}")
+      + "/Microsoft.Test.OData.Services.ODataWCFService.GetRelatedProduct{paren:[\\(\\)]*}")
   public Response functionGetRelatedProduct(
-          @Context UriInfo uriInfo,
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @PathParam("productId") String productId,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
+      @Context UriInfo uriInfo,
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+      @PathParam("productId") String productId,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
 
     return getEntityInternal(
-            uriInfo.getRequestUri().toASCIIString(), accept, "Products", productId, format, null, null, false);
+        uriInfo.getRequestUri().toASCIIString(), accept, "Products", productId, format, null, null, false);
   }
 
   @POST
   @Path("/Accounts({entityId})/Microsoft.Test.OData.Services.ODataWCFService.RefreshDefaultPI{paren:[\\(\\)]*}")
   public Response actionRefreshDefaultPI(
-          @Context UriInfo uriInfo,
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
-          @PathParam("entityId") String entityId,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
-          final String param) {
+      @Context UriInfo uriInfo,
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+      @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
+      @PathParam("entityId") String entityId,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
+      final String param) {
 
     try {
       final Accept contentTypeValue = Accept.parse(contentType, version);
@@ -674,9 +673,9 @@ public class V4Services extends AbstractServices {
   @GET
   @Path("/Accounts({entityId})/Microsoft.Test.OData.Services.ODataWCFService.GetDefaultPI{paren:[\\(\\)]*}")
   public Response functionGetDefaultPI(
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @PathParam("entityId") String entityId,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+      @PathParam("entityId") String entityId,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
 
     return getContainedEntity(accept, entityId, "MyPaymentInstruments", entityId + "901", format);
   }
@@ -684,9 +683,9 @@ public class V4Services extends AbstractServices {
   @GET
   @Path("/Accounts({entityId})/Microsoft.Test.OData.Services.ODataWCFService.GetAccountInfo{paren:[\\(\\)]*}")
   public Response functionGetAccountInfo(
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @PathParam("entityId") String entityId,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+      @PathParam("entityId") String entityId,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
 
     return getPath(accept, "Accounts", entityId, "AccountInfo", format);
   }
@@ -694,9 +693,9 @@ public class V4Services extends AbstractServices {
   @GET
   @Path("/Accounts({entityId})/MyGiftCard/Microsoft.Test.OData.Services.ODataWCFService.GetActualAmount({param:.*})")
   public Response functionGetActualAmount(
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @PathParam("entityId") String entityId,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+      @PathParam("entityId") String entityId,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
 
     try {
       final Accept acceptType;
@@ -706,17 +705,17 @@ public class V4Services extends AbstractServices {
         acceptType = Accept.parse(accept, version);
       }
 
-      final AtomPropertyImpl property = new AtomPropertyImpl();
+      final Property property = new PropertyImpl();
       property.setType("Edm.Double");
       property.setValue(new PrimitiveValueImpl("41.79"));
 
-      final ResWrap<AtomPropertyImpl> container = new ResWrap<AtomPropertyImpl>((URI) null, null, property);
+      final ResWrap<Property> container = new ResWrap<Property>((URI) null, null, property);
 
       return xml.createResponse(
-              null,
-              xml.writeProperty(acceptType, container),
-              null,
-              acceptType);
+          null,
+          xml.writeProperty(acceptType, container),
+          null,
+          acceptType);
     } catch (Exception e) {
       return xml.createFaultResponse(accept, e);
     }
@@ -733,9 +732,9 @@ public class V4Services extends AbstractServices {
   @GET
   @Path("/{path:.*}/$ref")
   public Response getEntityReference(
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @PathParam("path") String path,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+      @PathParam("path") String path,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
 
     try {
       final Map.Entry<Accept, AbstractUtilities> utils = getUtilities(accept, format);
@@ -747,10 +746,10 @@ public class V4Services extends AbstractServices {
       final String filename = Base64.encodeBase64String(path.getBytes("UTF-8"));
 
       return utils.getValue().createResponse(
-              FSManager.instance(version).readFile(Constants.get(version, ConstantKey.REF)
-                      + File.separatorChar + filename, utils.getKey()),
-              null,
-              utils.getKey());
+          FSManager.instance(version).readFile(Constants.get(version, ConstantKey.REF)
+              + File.separatorChar + filename, utils.getKey()),
+          null,
+          utils.getKey());
     } catch (Exception e) {
       LOG.error("Error retrieving entity", e);
       return xml.createFaultResponse(accept, e);
@@ -759,36 +758,36 @@ public class V4Services extends AbstractServices {
 
   @Override
   public Response patchEntity(
-          final UriInfo uriInfo,
-          final String accept,
-          final String contentType,
-          final String prefer,
-          final String ifMatch,
-          final String entitySetName,
-          final String entityId,
-          final String changes) {
+      final UriInfo uriInfo,
+      final String accept,
+      final String contentType,
+      final String prefer,
+      final String ifMatch,
+      final String entitySetName,
+      final String entityId,
+      final String changes) {
 
     final Response response =
-            getEntityInternal(uriInfo.getRequestUri().toASCIIString(),
-                    accept, entitySetName, entityId, accept, StringUtils.EMPTY, StringUtils.EMPTY, false);
+        getEntityInternal(uriInfo.getRequestUri().toASCIIString(),
+            accept, entitySetName, entityId, accept, StringUtils.EMPTY, StringUtils.EMPTY, false);
     return response.getStatus() >= 400
-            ? postNewEntity(uriInfo, accept, contentType, prefer, entitySetName, changes)
-            : super.patchEntity(uriInfo, accept, contentType, prefer, ifMatch, entitySetName, entityId, changes);
+        ? postNewEntity(uriInfo, accept, contentType, prefer, entitySetName, changes)
+        : super.patchEntity(uriInfo, accept, contentType, prefer, ifMatch, entitySetName, entityId, changes);
   }
 
   @Override
   public Response replaceEntity(
-          final UriInfo uriInfo,
-          final String accept,
-          final String contentType,
-          final String prefer,
-          final String entitySetName,
-          final String entityId,
-          final String entity) {
+      final UriInfo uriInfo,
+      final String accept,
+      final String contentType,
+      final String prefer,
+      final String entitySetName,
+      final String entityId,
+      final String entity) {
 
     try {
       getEntityInternal(uriInfo.getRequestUri().toASCIIString(),
-              accept, entitySetName, entityId, accept, StringUtils.EMPTY, StringUtils.EMPTY, false);
+          accept, entitySetName, entityId, accept, StringUtils.EMPTY, StringUtils.EMPTY, false);
       return super.replaceEntity(uriInfo, accept, contentType, prefer, entitySetName, entityId, entity);
     } catch (NotFoundException e) {
       return postNewEntity(uriInfo, accept, contentType, prefer, entitySetName, entityId);
@@ -797,19 +796,19 @@ public class V4Services extends AbstractServices {
 
   private StringBuilder containedPath(final String entityId, final String containedEntitySetName) {
     return new StringBuilder("Accounts").append(File.separatorChar).
-            append(entityId).append(File.separatorChar).
-            append("links").append(File.separatorChar).
-            append(containedEntitySetName);
+        append(entityId).append(File.separatorChar).
+        append("links").append(File.separatorChar).
+        append(containedEntitySetName);
   }
 
   @GET
   @Path("/Accounts({entityId})/{containedEntitySetName}({containedEntityId})")
   public Response getContainedEntity(
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @PathParam("entityId") String entityId,
-          @PathParam("containedEntitySetName") String containedEntitySetName,
-          @PathParam("containedEntityId") String containedEntityId,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+      @PathParam("entityId") String entityId,
+      @PathParam("containedEntitySetName") String containedEntitySetName,
+      @PathParam("containedEntityId") String containedEntityId,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
 
     try {
       final Accept acceptType;
@@ -828,13 +827,13 @@ public class V4Services extends AbstractServices {
       }
       final InputStream entry = FSManager.instance(version).readFile(containedPath.toString(), Accept.ATOM);
 
-      final ResWrap<AtomEntityImpl> container = atomDeserializer.read(entry, AtomEntityImpl.class);
+      final ResWrap<Entity> container = atomDeserializer.toEntity(entry);
 
       return xml.createResponse(
-              null,
-              xml.writeEntity(acceptType, container),
-              null,
-              acceptType);
+          null,
+          xml.writeEntity(acceptType, container),
+          null,
+          acceptType);
     } catch (Exception e) {
       return xml.createFaultResponse(accept, e);
     }
@@ -843,12 +842,12 @@ public class V4Services extends AbstractServices {
   @POST
   @Path("/Accounts({entityId})/{containedEntitySetName:.*}")
   public Response postContainedEntity(
-          @Context UriInfo uriInfo,
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
-          @PathParam("entityId") String entityId,
-          @PathParam("containedEntitySetName") String containedEntitySetName,
-          final String entity) {
+      @Context UriInfo uriInfo,
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+      @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
+      @PathParam("entityId") String entityId,
+      @PathParam("containedEntitySetName") String containedEntitySetName,
+      final String entity) {
 
     try {
       final Accept acceptType = Accept.parse(accept, version);
@@ -858,43 +857,40 @@ public class V4Services extends AbstractServices {
 
       final AbstractUtilities utils = getUtilities(acceptType);
 
-      // 1. parse the entry (from Atom or JSON) into AtomEntryImpl
-      final ResWrap<AtomEntityImpl> entryContainer;
-      final AtomEntityImpl entry;
+      // 1. parse the entry (from Atom or JSON)
+      final ResWrap<Entity> entryContainer;
+      final Entity entry;
       final Accept contentTypeValue = Accept.parse(contentType, version);
       if (Accept.ATOM == contentTypeValue) {
-        entryContainer = atomDeserializer.read(IOUtils.toInputStream(entity, Constants.ENCODING), AtomEntityImpl.class);
+        entryContainer = atomDeserializer.toEntity(IOUtils.toInputStream(entity, Constants.ENCODING));
         entry = entryContainer.getPayload();
       } else {
-        final ResWrap<JSONEntityImpl> jcontainer =
-                mapper.readValue(IOUtils.toInputStream(entity, Constants.ENCODING),
-                        new TypeReference<JSONEntityImpl>() {
-                        });
-
-        entry = dataBinder.toAtomEntity(jcontainer.getPayload());
-
-        entryContainer = new ResWrap<AtomEntityImpl>(
-                jcontainer.getContextURL(),
-                jcontainer.getMetadataETag(),
-                entry);
+        final ResWrap<Entity> jcontainer = jsonDeserializer.toEntity(
+            IOUtils.toInputStream(entity, Constants.ENCODING));
+        entry = jcontainer.getPayload();
+
+        entryContainer = new ResWrap<Entity>(
+            jcontainer.getContextURL(),
+            jcontainer.getMetadataETag(),
+            entry);
       }
 
       final EdmTypeInfo contained = new EdmTypeInfo.Builder().setTypeExpression(metadata.
-              getNavigationProperties("Accounts").get(containedEntitySetName).getType()).build();
+          getNavigationProperties("Accounts").get(containedEntitySetName).getType()).build();
       final String entityKey = getUtilities(contentTypeValue).
-              getDefaultEntryKey(contained.getFullQualifiedName().getName(), entry);
+          getDefaultEntryKey(contained.getFullQualifiedName().getName(), entry);
 
       // 2. Store the new entity
       final String atomEntryRelativePath = containedPath(entityId, containedEntitySetName).
-              append('(').append(entityKey).append(')').toString();
+          append('(').append(entityKey).append(')').toString();
       FSManager.instance(version).putInMemory(
-              utils.writeEntity(Accept.ATOM, entryContainer),
-              FSManager.instance(version).getAbsolutePath(atomEntryRelativePath, Accept.ATOM));
+          utils.writeEntity(Accept.ATOM, entryContainer),
+          FSManager.instance(version).getAbsolutePath(atomEntryRelativePath, Accept.ATOM));
 
       // 3. Update the contained entity set
       final String atomFeedRelativePath = containedPath(entityId, containedEntitySetName).toString();
       final InputStream feedIS = FSManager.instance(version).readFile(atomFeedRelativePath, Accept.ATOM);
-      final ResWrap<AtomEntitySetImpl> feedContainer = atomDeserializer.read(feedIS, AtomEntitySetImpl.class);
+      final ResWrap<EntitySet> feedContainer = atomDeserializer.toEntitySet(feedIS);
       feedContainer.getPayload().getEntities().add(entry);
 
       final ByteArrayOutputStream content = new ByteArrayOutputStream();
@@ -904,16 +900,16 @@ public class V4Services extends AbstractServices {
       writer.close();
 
       FSManager.instance(version).putInMemory(
-              new ByteArrayInputStream(content.toByteArray()),
-              FSManager.instance(version).getAbsolutePath(atomFeedRelativePath, Accept.ATOM));
+          new ByteArrayInputStream(content.toByteArray()),
+          FSManager.instance(version).getAbsolutePath(atomFeedRelativePath, Accept.ATOM));
 
       // Finally, return
       return utils.createResponse(
-              uriInfo.getRequestUri().toASCIIString() + "(" + entityKey + ")",
-              utils.writeEntity(acceptType, entryContainer),
-              null,
-              acceptType,
-              Response.Status.CREATED);
+          uriInfo.getRequestUri().toASCIIString() + "(" + entityKey + ")",
+          utils.writeEntity(acceptType, entryContainer),
+          null,
+          acceptType,
+          Response.Status.CREATED);
     } catch (Exception e) {
       LOG.error("While creating new contained entity", e);
       return xml.createFaultResponse(accept, e);
@@ -923,14 +919,14 @@ public class V4Services extends AbstractServices {
   @PATCH
   @Path("/{entitySetName}({entityId})/{containedEntitySetName}({containedEntityId})")
   public Response patchContainedEntity(
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
-          @PathParam("entitySetName") String entitySetName,
-          @PathParam("entityId") String entityId,
-          @PathParam("containedEntitySetName") String containedEntitySetName,
-          @PathParam("containedEntityId") String containedEntityId,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
-          final String changes) {
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+      @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
+      @PathParam("entitySetName") String entitySetName,
+      @PathParam("entityId") String entityId,
+      @PathParam("containedEntitySetName") String containedEntitySetName,
+      @PathParam("containedEntityId") String containedEntityId,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
+      final String changes) {
 
     try {
       final Accept acceptType;
@@ -950,26 +946,25 @@ public class V4Services extends AbstractServices {
       contentTypeValue = Accept.parse(contentType, version);
 
       final LinkInfo links = xml.readLinks(
-              entitySetName, entityId, containedEntitySetName + "(" + containedEntityId + ")", Accept.ATOM);
+          entitySetName, entityId, containedEntitySetName + "(" + containedEntityId + ")", Accept.ATOM);
 
-      ResWrap<AtomEntityImpl> container = atomDeserializer.read(links.getLinks(), AtomEntityImpl.class);
-      final AtomEntityImpl original = container.getPayload();
+      ResWrap<Entity> container = atomDeserializer.toEntity(links.getLinks());
+      final Entity original = container.getPayload();
 
-      final AtomEntityImpl entryChanges;
+      final Entity entryChanges;
       if (Accept.ATOM == contentTypeValue) {
-        container = atomDeserializer.read(IOUtils.toInputStream(changes, Constants.ENCODING), AtomEntityImpl.class);
+        container = atomDeserializer.toEntity(IOUtils.toInputStream(changes, Constants.ENCODING));
         entryChanges = container.getPayload();
       } else {
         final String entityType = metadata.getEntitySet(entitySetName).getType();
         final String containedType = metadata.getEntityOrComplexType(entityType).
-                getNavigationProperty(containedEntitySetName).getType();
+            getNavigationProperty(containedEntitySetName).getType();
         final EdmTypeInfo typeInfo = new EdmTypeInfo.Builder().setTypeExpression(containedType).build();
 
-        final ResWrap<JSONEntityImpl> jsonContainer = mapper.readValue(
-                IOUtils.toInputStream(changes, Constants.ENCODING), new TypeReference<JSONEntityImpl>() {
-                });
+        final ResWrap<Entity> jsonContainer = jsonDeserializer.toEntity(
+            IOUtils.toInputStream(changes, Constants.ENCODING));
         jsonContainer.getPayload().setType(typeInfo.getFullQualifiedName().toString());
-        entryChanges = dataBinder.toAtomEntity(jsonContainer.getPayload());
+        entryChanges = jsonContainer.getPayload();
       }
 
       for (Property property : entryChanges.getProperties()) {
@@ -980,9 +975,8 @@ public class V4Services extends AbstractServices {
         original.getProperties().add(property);
       }
 
-      FSManager.instance(version).putInMemory(new ResWrap<AtomEntityImpl>((URI) null, null, original),
-              xml.getLinksBasePath(entitySetName, entityId) + containedEntitySetName + "(" + containedEntityId + ")",
-              dataBinder);
+      FSManager.instance(version).putInMemory(new ResWrap<Entity>((URI) null, null, original),
+          xml.getLinksBasePath(entitySetName, entityId) + containedEntitySetName + "(" + containedEntityId + ")");
 
       return xml.createResponse(null, null, acceptType, Response.Status.NO_CONTENT);
     } catch (Exception e) {
@@ -993,26 +987,26 @@ public class V4Services extends AbstractServices {
   @DELETE
   @Path("/Accounts({entityId})/{containedEntitySetName}({containedEntityId})")
   public Response removeContainedEntity(
-          @PathParam("entityId") String entityId,
-          @PathParam("containedEntitySetName") String containedEntitySetName,
-          @PathParam("containedEntityId") String containedEntityId) {
+      @PathParam("entityId") String entityId,
+      @PathParam("containedEntitySetName") String containedEntitySetName,
+      @PathParam("containedEntityId") String containedEntityId) {
 
     try {
       // 1. Fetch the contained entity to be removed
       final InputStream entry = FSManager.instance(version).
-              readFile(containedPath(entityId, containedEntitySetName).
-                      append('(').append(containedEntityId).append(')').toString(), Accept.ATOM);
-      final ResWrap<AtomEntityImpl> container = atomDeserializer.read(entry, AtomEntityImpl.class);
+          readFile(containedPath(entityId, containedEntitySetName).
+              append('(').append(containedEntityId).append(')').toString(), Accept.ATOM);
+      final ResWrap<Entity> container = atomDeserializer.toEntity(entry);
 
       // 2. Remove the contained entity
       final String atomEntryRelativePath = containedPath(entityId, containedEntitySetName).
-              append('(').append(containedEntityId).append(')').toString();
+          append('(').append(containedEntityId).append(')').toString();
       FSManager.instance(version).deleteFile(atomEntryRelativePath);
 
       // 3. Update the contained entity set
       final String atomFeedRelativePath = containedPath(entityId, containedEntitySetName).toString();
       final InputStream feedIS = FSManager.instance(version).readFile(atomFeedRelativePath, Accept.ATOM);
-      final ResWrap<AtomEntitySetImpl> feedContainer = atomDeserializer.read(feedIS, AtomEntitySetImpl.class);
+      final ResWrap<EntitySet> feedContainer = atomDeserializer.toEntitySet(feedIS);
       feedContainer.getPayload().getEntities().remove(container.getPayload());
 
       final ByteArrayOutputStream content = new ByteArrayOutputStream();
@@ -1022,8 +1016,8 @@ public class V4Services extends AbstractServices {
       writer.close();
 
       FSManager.instance(version).putInMemory(
-              new ByteArrayInputStream(content.toByteArray()),
-              FSManager.instance(version).getAbsolutePath(atomFeedRelativePath, Accept.ATOM));
+          new ByteArrayInputStream(content.toByteArray()),
+          FSManager.instance(version).getAbsolutePath(atomFeedRelativePath, Accept.ATOM));
 
       return xml.createResponse(null, null, null, null, Response.Status.NO_CONTENT);
     } catch (Exception e) {
@@ -1034,10 +1028,10 @@ public class V4Services extends AbstractServices {
   @GET
   @Path("/Accounts({entityId})/{containedEntitySetName:.*}")
   public Response getContainedEntitySet(
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @PathParam("entityId") String entityId,
-          @PathParam("containedEntitySetName") String containedEntitySetName,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+      @PathParam("entityId") String entityId,
+      @PathParam("containedEntitySetName") String containedEntitySetName,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
 
     if ("MyGiftCard".equals(containedEntitySetName)) {
       return getContainedEntity(accept, entityId, containedEntitySetName, null, format);
@@ -1062,9 +1056,9 @@ public class V4Services extends AbstractServices {
       }
 
       final InputStream feed = FSManager.instance(version).
-              readFile(containedPath(entityId, containedEntitySetName).toString(), Accept.ATOM);
+          readFile(containedPath(entityId, containedEntitySetName).toString(), Accept.ATOM);
 
-      final ResWrap<AtomEntitySetImpl> container = atomDeserializer.read(feed, AtomEntitySetImpl.class);
+      final ResWrap<EntitySet> container = atomDeserializer.toEntitySet(feed);
 
       if (derivedType != null) {
         final List<Entity> nonMatching = new ArrayList<Entity>();
@@ -1077,10 +1071,10 @@ public class V4Services extends AbstractServices {
       }
 
       return xml.createResponse(
-              null,
-              xml.writeEntitySet(acceptType, container),
-              null,
-              acceptType);
+          null,
+          xml.writeEntitySet(acceptType, container),
+          null,
+          acceptType);
     } catch (Exception e) {
       return xml.createFaultResponse(accept, e);
     }
@@ -1089,8 +1083,8 @@ public class V4Services extends AbstractServices {
   @GET
   @Path("/GetDefaultColor()")
   public Response functionGetDefaultColor(
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
 
     try {
       final Accept acceptType;
@@ -1100,18 +1094,18 @@ public class V4Services extends AbstractServices {
         acceptType = Accept.parse(accept, version);
       }
 
-      final AtomPropertyImpl property = new AtomPropertyImpl();
+      final PropertyImpl property = new PropertyImpl();
       property.setType("Microsoft.Test.OData.Services.ODataWCFService.Color");
       property.setValue(new EnumValueImpl("Red"));
-      final ResWrap<AtomPropertyImpl> container = new ResWrap<AtomPropertyImpl>(
-              URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + property.getType()), null,
-              property);
+      final ResWrap<Property> container = new ResWrap<Property>(
+          URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + property.getType()), null,
+          property);
 
       return xml.createResponse(
-              null,
-              xml.writeProperty(acceptType, container),
-              null,
-              acceptType);
+          null,
+          xml.writeProperty(acceptType, container),
+          null,
+          acceptType);
     } catch (Exception e) {
       return xml.createFaultResponse(accept, e);
     }
@@ -1120,31 +1114,31 @@ public class V4Services extends AbstractServices {
   @GET
   @Path("/GetPerson2({param:.*})")
   public Response functionGetPerson2(
-          @Context UriInfo uriInfo,
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
+      @Context UriInfo uriInfo,
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
 
     return getEntityInternal(
-            uriInfo.getRequestUri().toASCIIString(), accept, "Customers", "1", format, null, null, false);
+        uriInfo.getRequestUri().toASCIIString(), accept, "Customers", "1", format, null, null, false);
   }
 
   @GET
   @Path("/GetPerson({param:.*})")
   public Response functionGetPerson(
-          @Context UriInfo uriInfo,
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
+      @Context UriInfo uriInfo,
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
 
     return getEntityInternal(
-            uriInfo.getRequestUri().toASCIIString(), accept, "Customers", "1", format, null, null, false);
+        uriInfo.getRequestUri().toASCIIString(), accept, "Customers", "1", format, null, null, false);
   }
 
   @GET
   @Path("/GetAllProducts()")
   public Response functionGetAllProducts(
-          @Context UriInfo uriInfo,
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
+      @Context UriInfo uriInfo,
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
 
     return getEntitySet(uriInfo, accept, "Products", null, null, format, null, null, null, null);
   }
@@ -1152,9 +1146,9 @@ public class V4Services extends AbstractServices {
   @GET
   @Path("/GetProductsByAccessLevel({param:.*})")
   public Response functionGetProductsByAccessLevel(
-          @Context UriInfo uriInfo,
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
+      @Context UriInfo uriInfo,
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
 
     try {
       final Accept acceptType;
@@ -1164,7 +1158,7 @@ public class V4Services extends AbstractServices {
         acceptType = Accept.parse(accept, version);
       }
 
-      final AtomPropertyImpl property = new AtomPropertyImpl();
+      final PropertyImpl property = new PropertyImpl();
       property.setType("Collection(String)");
       final CollectionValue value = new CollectionValueImpl();
       value.get().add(new PrimitiveValueImpl("Cheetos"));
@@ -1173,15 +1167,15 @@ public class V4Services extends AbstractServices {
       value.get().add(new PrimitiveValueImpl("Car"));
       value.get().add(new PrimitiveValueImpl("Computer"));
       property.setValue(value);
-      final ResWrap<AtomPropertyImpl> container = new ResWrap<AtomPropertyImpl>(
-              URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + property.getType()), null,
-              property);
+      final ResWrap<Property> container = new ResWrap<Property>(
+          URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + property.getType()), null,
+          property);
 
       return xml.createResponse(
-              null,
-              xml.writeProperty(acceptType, container),
-              null,
-              acceptType);
+          null,
+          xml.writeProperty(acceptType, container),
+          null,
+          acceptType);
     } catch (Exception e) {
       return xml.createFaultResponse(accept, e);
     }
@@ -1190,9 +1184,9 @@ public class V4Services extends AbstractServices {
   @GET
   @Path("/GetBossEmails({param:.*})")
   public Response functionGetBossEmails(
-          @Context UriInfo uriInfo,
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
+      @Context UriInfo uriInfo,
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
 
     try {
       final Accept acceptType;
@@ -1202,21 +1196,21 @@ public class V4Services extends AbstractServices {
         acceptType = Accept.parse(accept, version);
       }
 
-      final AtomPropertyImpl property = new AtomPropertyImpl();
+      final PropertyImpl property = new PropertyImpl();
       property.setType("Collection(Edm.String)");
       final CollectionValue value = new CollectionValueImpl();
       value.get().add(new PrimitiveValueImpl("first@olingo.apache.org"));
       value.get().add(new PrimitiveValueImpl("second@olingo.apache.org"));
       property.setValue(value);
-      final ResWrap<AtomPropertyImpl> container = new ResWrap<AtomPropertyImpl>(
-              URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + property.getType()), null,
-              property);
+      final ResWrap<Property> container = new ResWrap<Property>(
+          URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + property.getType()), null,
+          property);
 
       return xml.createResponse(
-              null,
-              xml.writeProperty(acceptType, container),
-              null,
-              acceptType);
+          null,
+          xml.writeProperty(acceptType, container),
+          null,
+          acceptType);
     } catch (Exception e) {
       return xml.createFaultResponse(accept, e);
     }
@@ -1225,10 +1219,10 @@ public class V4Services extends AbstractServices {
   @POST
   @Path("/Discount()")
   public Response actionDiscount(
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
-          final String param) {
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+      @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
+      final String param) {
 
     try {
       final Accept acceptType;
@@ -1241,14 +1235,12 @@ public class V4Services extends AbstractServices {
       final Accept contentTypeValue = Accept.parse(contentType, version);
       Property property;
       if (contentTypeValue == Accept.ATOM) {
-        final ResWrap<AtomPropertyImpl> paramContainer = atomDeserializer.read(
-                IOUtils.toInputStream(param, Constants.ENCODING), AtomPropertyImpl.class);
+        final ResWrap<Property> paramContainer = atomDeserializer.toProperty(
+            IOUtils.toInputStream(param, Constants.ENCODING));
         property = paramContainer.getPayload();
       } else {
-        final ResWrap<JSONPropertyImpl> paramContainer =
-                mapper.readValue(IOUtils.toInputStream(param, Constants.ENCODING),
-                        new TypeReference<JSONPropertyImpl>() {
-                        });
+        final ResWrap<Property> paramContainer = jsonDeserializer.toProperty(
+            IOUtils.toInputStream(param, Constants.ENCODING));
         property = paramContainer.getPayload();
       }
 
@@ -1267,10 +1259,10 @@ public class V4Services extends AbstractServices {
   @POST
   @Path("/ResetBossAddress()")
   public Response actionResetBossAddress(
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
-          final String param) {
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+      @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
+      final String param) {
 
     try {
       final Accept acceptType;
@@ -1281,22 +1273,22 @@ public class V4Services extends AbstractServices {
       }
 
       final Accept contentTypeValue = Accept.parse(contentType, version);
-      final AtomEntityImpl entity = xml.readEntity(contentTypeValue, IOUtils.toInputStream(param, Constants.ENCODING));
+      final Entity entity = xml.readEntity(contentTypeValue, IOUtils.toInputStream(param, Constants.ENCODING));
 
       assert "Microsoft.Test.OData.Services.ODataWCFService.Address".equals(entity.getType());
       assert entity.getProperty("address").getValue().isComplex();
 
-      final ResWrap<AtomPropertyImpl> result = new ResWrap<AtomPropertyImpl>(
-              URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX)
-                      + "Microsoft.Test.OData.Services.ODataWCFService.Address"),
-              null,
-              (AtomPropertyImpl) entity.getProperty("address"));
+      final ResWrap<Property> result = new ResWrap<Property>(
+          URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX)
+              + "Microsoft.Test.OData.Services.ODataWCFService.Address"),
+          null,
+          entity.getProperty("address"));
 
       return xml.createResponse(
-              null,
-              xml.writeProperty(acceptType, result),
-              null,
-              acceptType);
+          null,
+          xml.writeProperty(acceptType, result),
+          null,
+          acceptType);
     } catch (Exception e) {
       return xml.createFaultResponse(accept, e);
     }
@@ -1305,10 +1297,10 @@ public class V4Services extends AbstractServices {
   @POST
   @Path("/ResetBossEmail()")
   public Response actionResetBossEmail(
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
-          final String param) {
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+      @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
+      final String param) {
 
     try {
       final Accept acceptType;
@@ -1326,10 +1318,10 @@ public class V4Services extends AbstractServices {
       assert entry.getProperty("emails").getValue().isCollection();
 
       return xml.createResponse(
-              null,
-              xml.writeProperty(acceptType, entry.getProperty("emails")),
-              null,
-              acceptType);
+          null,
+          xml.writeProperty(acceptType, entry.getProperty("emails")),
+          null,
+          acceptType);
     } catch (Exception e) {
       return xml.createFaultResponse(accept, e);
     }
@@ -1338,10 +1330,10 @@ public class V4Services extends AbstractServices {
   @POST
   @Path("/Products({productId})/Categories/$ref")
   public Response createLinked(
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
-          final String entity) {
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+      @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
+      final String entity) {
 
     return xml.createResponse(null, null, null, Status.NO_CONTENT);
   }
@@ -1349,10 +1341,10 @@ public class V4Services extends AbstractServices {
   @DELETE
   @Path("/Products({productId})/Categories({categoryId})/$ref")
   public Response deleteLinked(
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
-          final String entity) {
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+      @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
+      final String entity) {
 
     return xml.createResponse(null, null, null, Status.NO_CONTENT);
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/fit/src/main/java/org/apache/olingo/fit/serializer/JSONEntryContainer.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/serializer/JSONEntryContainer.java b/fit/src/main/java/org/apache/olingo/fit/serializer/JSONEntryContainer.java
deleted file mode 100644
index 0d3318d..0000000
--- a/fit/src/main/java/org/apache/olingo/fit/serializer/JSONEntryContainer.java
+++ /dev/null
@@ -1,36 +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.fit.serializer;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import org.apache.olingo.commons.api.data.ContextURL;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.core.data.JSONEntityDeserializer;
-import org.apache.olingo.commons.core.data.JSONEntityImpl;
-import org.apache.olingo.commons.core.data.JSONEntitySerializer;
-
-@JsonDeserialize(using = JSONEntityDeserializer.class)
-@JsonSerialize(using = JSONEntitySerializer.class)
-public class JSONEntryContainer extends ResWrap<JSONEntityImpl> {
-
-  public JSONEntryContainer(final ContextURL contextURL, final String metadataETag, final JSONEntityImpl object) {
-    super(contextURL, metadataETag, object);
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/fit/src/main/java/org/apache/olingo/fit/serializer/JSONFeedContainer.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/serializer/JSONFeedContainer.java b/fit/src/main/java/org/apache/olingo/fit/serializer/JSONFeedContainer.java
deleted file mode 100644
index c641444..0000000
--- a/fit/src/main/java/org/apache/olingo/fit/serializer/JSONFeedContainer.java
+++ /dev/null
@@ -1,36 +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.fit.serializer;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import org.apache.olingo.commons.api.data.ContextURL;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.core.data.JSONEntitySetDeserializer;
-import org.apache.olingo.commons.core.data.JSONEntitySetImpl;
-import org.apache.olingo.commons.core.data.JSONEntitySetSerializer;
-
-@JsonDeserialize(using = JSONEntitySetDeserializer.class)
-@JsonSerialize(using = JSONEntitySetSerializer.class)
-public class JSONFeedContainer extends ResWrap<JSONEntitySetImpl> {
-
-  public JSONFeedContainer(final ContextURL contextURL, final String metadataETag, final JSONEntitySetImpl object) {
-    super(contextURL, metadataETag, object);
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/fit/src/main/java/org/apache/olingo/fit/serializer/JSONPropertyContainer.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/serializer/JSONPropertyContainer.java b/fit/src/main/java/org/apache/olingo/fit/serializer/JSONPropertyContainer.java
deleted file mode 100644
index f642a19..0000000
--- a/fit/src/main/java/org/apache/olingo/fit/serializer/JSONPropertyContainer.java
+++ /dev/null
@@ -1,36 +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.fit.serializer;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import org.apache.olingo.commons.api.data.ContextURL;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.core.data.JSONPropertyDeserializer;
-import org.apache.olingo.commons.core.data.JSONPropertyImpl;
-import org.apache.olingo.commons.core.data.JSONPropertySerializer;
-
-@JsonDeserialize(using = JSONPropertyDeserializer.class)
-@JsonSerialize(using = JSONPropertySerializer.class)
-public class JSONPropertyContainer extends ResWrap<JSONPropertyImpl> {
-
-  public JSONPropertyContainer(final ContextURL contextURL, final String metadataETag, final JSONPropertyImpl object) {
-    super(contextURL, metadataETag, object);
-  }
-}


[02/23] [OLINGO-317] First presentable state

Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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
index 61667ac..00f0d3f 100644
--- 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
@@ -18,12 +18,6 @@
  */
 package org.apache.olingo.commons.core.data;
 
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
 import java.io.IOException;
 import java.net.URI;
 import java.util.ArrayList;
@@ -34,26 +28,35 @@ 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.ResWrap;
+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 AbstractJsonDeserializer<JSONEntityImpl> {
+public class JSONEntityDeserializer extends JsonDeserializer {
+
+  public JSONEntityDeserializer(final ODataServiceVersion version, final boolean serverMode) {
+    super(version, serverMode);
+  }
 
-  @Override
-  protected ResWrap<JSONEntityImpl> doDeserialize(final JsonParser parser, final DeserializationContext ctxt)
-          throws IOException, JsonProcessingException {
+  protected ResWrap<Entity> doDeserialize(final JsonParser parser) throws IOException {
 
     final ObjectNode tree = parser.getCodec().readTree(parser);
 
@@ -61,7 +64,7 @@ public class JSONEntityDeserializer extends AbstractJsonDeserializer<JSONEntityI
       throw new JsonParseException("Expected OData Entity, found EntitySet", parser.getCurrentLocation());
     }
 
-    final JSONEntityImpl entity = new JSONEntityImpl();
+    final EntityImpl entity = new EntityImpl();
 
     final URI contextURL;
     if (tree.hasNonNull(Constants.JSON_CONTEXT)) {
@@ -212,6 +215,6 @@ public class JSONEntityDeserializer extends AbstractJsonDeserializer<JSONEntityI
 
     populate(entity, entity.getProperties(), tree, parser.getCodec());
 
-    return new ResWrap<JSONEntityImpl>(contextURL, metadataETag, entity);
+    return new ResWrap<Entity>(contextURL, metadataETag, entity);
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntityImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntityImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntityImpl.java
deleted file mode 100644
index 57db805..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntityImpl.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.core.data;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
-/**
- * A single entity, represented via JSON.
- */
-@JsonSerialize(using = JSONEntitySerializer.class)
-@JsonDeserialize(using = JSONEntityDeserializer.class)
-public class JSONEntityImpl extends AbstractEntity {
-
-  private static final long serialVersionUID = -5275365545400797758L;
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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
index 8ece3ba..36e7ae1 100644
--- 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
@@ -18,11 +18,9 @@
  */
 package org.apache.olingo.commons.core.data;
 
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.SerializerProvider;
 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;
@@ -34,22 +32,23 @@ 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 AbstractJsonSerializer<JSONEntityImpl> {
+public class JSONEntitySerializer extends JsonSerializer {
 
-  @Override
-  protected void doSerialize(final JSONEntityImpl entity, final JsonGenerator jgen, final SerializerProvider provider)
-          throws IOException, JsonProcessingException {
+  public JSONEntitySerializer(final ODataServiceVersion version, final boolean serverMode) {
+    super(version, serverMode);
+  }
 
-    doContainerSerialize(new ResWrap<JSONEntityImpl>((URI) null, null, entity), jgen, provider);
+  protected void doSerialize(final Entity entity, final JsonGenerator jgen) throws IOException {
+    doContainerSerialize(new ResWrap<Entity>((URI) null, null, entity), jgen);
   }
 
-  @Override
-  protected void doContainerSerialize(
-          final ResWrap<JSONEntityImpl> container, final JsonGenerator jgen, final SerializerProvider provider)
-          throws IOException, JsonProcessingException {
+  protected void doContainerSerialize(final ResWrap<Entity> container, final JsonGenerator jgen)
+      throws IOException {
 
     final Entity entity = container.getPayload();
 
@@ -58,8 +57,8 @@ public class JSONEntitySerializer extends AbstractJsonSerializer<JSONEntityImpl>
     if (serverMode) {
       if (container.getContextURL() != null) {
         jgen.writeStringField(version.compareTo(ODataServiceVersion.V40) >= 0
-                ? Constants.JSON_CONTEXT : Constants.JSON_METADATA,
-                container.getContextURL().getURI().toASCIIString());
+            ? 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());
@@ -72,7 +71,7 @@ public class JSONEntitySerializer extends AbstractJsonSerializer<JSONEntityImpl>
 
     if (StringUtils.isNotBlank(entity.getType())) {
       jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_TYPE),
-              new EdmTypeInfo.Builder().setTypeExpression(entity.getType()).build().external(version));
+          new EdmTypeInfo.Builder().setTypeExpression(entity.getType()).build().external(version));
     }
 
     if (entity.getId() != null) {
@@ -89,11 +88,11 @@ public class JSONEntitySerializer extends AbstractJsonSerializer<JSONEntityImpl>
 
     if (serverMode && entity.getEditLink() != null && StringUtils.isNotBlank(entity.getEditLink().getHref())) {
       jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_EDIT_LINK),
-              entity.getEditLink().getHref());
+          entity.getEditLink().getHref());
 
       if (entity.isMediaEntity()) {
         jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_MEDIAREAD_LINK),
-                entity.getEditLink().getHref() + "/$value");
+            entity.getEditLink().getHref() + "/$value");
       }
     }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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
index 241dcbc..e4cd3ab 100644
--- 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
@@ -18,31 +18,34 @@
  */
 package org.apache.olingo.commons.core.data;
 
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
 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 AbstractJsonDeserializer<JSONEntitySetImpl> {
+public class JSONEntitySetDeserializer extends JsonDeserializer {
+
+  public JSONEntitySetDeserializer(final ODataServiceVersion version, final boolean serverMode) {
+    super(version, serverMode);
+  }
 
-  @Override
-  protected ResWrap<JSONEntitySetImpl> doDeserialize(final JsonParser parser, final DeserializationContext ctxt)
-          throws IOException, JsonProcessingException {
+  protected ResWrap<EntitySet> doDeserialize(final JsonParser parser) throws IOException {
 
     final ObjectNode tree = (ObjectNode) parser.getCodec().readTree(parser);
 
@@ -50,9 +53,9 @@ public class JSONEntitySetDeserializer extends AbstractJsonDeserializer<JSONEnti
       return null;
     }
 
-    final JSONEntitySetImpl entitySet = new JSONEntitySetImpl();
+    final EntitySetImpl entitySet = new EntitySetImpl();
 
-    final URI contextURL;
+    URI contextURL;
     if (tree.hasNonNull(Constants.JSON_CONTEXT)) {
       contextURL = URI.create(tree.get(Constants.JSON_CONTEXT).textValue());
       tree.remove(Constants.JSON_CONTEXT);
@@ -88,11 +91,10 @@ public class JSONEntitySetDeserializer extends AbstractJsonDeserializer<JSONEnti
     }
 
     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(
-                itor.next().traverse(parser.getCodec()).<ResWrap<JSONEntityImpl>>readValueAs(
-                        new TypeReference<JSONEntityImpl>() {
-                        }).getPayload());
+            entityDeserializer.doDeserialize(itor.next().traverse(parser.getCodec())).getPayload());
       }
       tree.remove(Constants.VALUE);
     }
@@ -109,6 +111,6 @@ public class JSONEntitySetDeserializer extends AbstractJsonDeserializer<JSONEnti
       }
     }
 
-    return new ResWrap<JSONEntitySetImpl>(contextURL, metadataETag, entitySet);
+    return new ResWrap<EntitySet>(contextURL, metadataETag, entitySet);
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetImpl.java
deleted file mode 100644
index dac67cd..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetImpl.java
+++ /dev/null
@@ -1,35 +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.annotation.JsonDeserialize;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
-/**
- * List of entries, represented via JSON.
- *
- * @see JSONEntry
- */
-@JsonDeserialize(using = JSONEntitySetDeserializer.class)
-@JsonSerialize(using = JSONEntitySetSerializer.class)
-public class JSONEntitySetImpl extends AbstractEntitySet {
-
-  private static final long serialVersionUID = -3576372289800799417L;
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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
index 40eb8e6..1670259 100644
--- 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
@@ -18,48 +18,47 @@
  */
 package org.apache.olingo.commons.core.data;
 
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.SerializerProvider;
 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.ResWrap;
 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;
 
-public class JSONEntitySetSerializer extends AbstractJsonSerializer<JSONEntitySetImpl> {
+import com.fasterxml.jackson.core.JsonGenerator;
 
-  @Override
-  protected void doSerialize(
-          final JSONEntitySetImpl entitySet, final JsonGenerator jgen, final SerializerProvider provider)
-          throws IOException, JsonProcessingException {
+public class JSONEntitySetSerializer extends JsonSerializer {
 
-    doContainerSerialize(new ResWrap<JSONEntitySetImpl>((URI) null, null, entitySet), jgen, provider);
+  public JSONEntitySetSerializer(final ODataServiceVersion version, final boolean serverMode) {
+    super(version, serverMode);
   }
 
-  @Override
-  protected void doContainerSerialize(
-          final ResWrap<JSONEntitySetImpl> container, final JsonGenerator jgen, final SerializerProvider provider)
-          throws IOException, JsonProcessingException {
+  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 JSONEntitySetImpl entitySet = container.getPayload();
+    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());
+            ? 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());
+            Constants.JSON_METADATA_ETAG,
+            container.getMetadataETag());
       }
     }
 
@@ -67,15 +66,15 @@ public class JSONEntitySetSerializer extends AbstractJsonSerializer<JSONEntitySe
       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());
+        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());
+            entitySet.getNext().toASCIIString());
       }
       if (entitySet.getDeltaLink() != null) {
         jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_DELTA_LINK),
-                entitySet.getDeltaLink().toASCIIString());
+            entitySet.getDeltaLink().toASCIIString());
       }
     }
 
@@ -84,10 +83,12 @@ public class JSONEntitySetSerializer extends AbstractJsonSerializer<JSONEntitySe
     }
 
     jgen.writeArrayFieldStart(Constants.VALUE);
+    final JSONEntitySerializer entitySerializer = new JSONEntitySerializer(version, serverMode);
     for (Entity entity : entitySet.getEntities()) {
-      jgen.writeObject(entity);
+      entitySerializer.doSerialize(entity, jgen);
     }
-
     jgen.writeEndArray();
+
+    jgen.writeEndObject();
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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
index 36818a9..1803c10 100644
--- 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
@@ -18,28 +18,29 @@
  */
 package org.apache.olingo.commons.core.data;
 
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
 import java.io.IOException;
-import java.net.URI;
 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.data.ResWrap;
+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 AbstractJsonDeserializer<JSONODataErrorImpl> {
+public class JSONODataErrorDeserializer extends JsonDeserializer {
+
+  public JSONODataErrorDeserializer(final ODataServiceVersion version, final boolean serverMode) {
+    super(version, serverMode);
+  }
 
-  @Override
-  protected ResWrap<JSONODataErrorImpl> doDeserialize(final JsonParser parser, final DeserializationContext ctxt)
-          throws IOException, JsonProcessingException {
+  protected ODataError doDeserialize(final JsonParser parser) throws IOException {
 
-    final JSONODataErrorImpl error = new JSONODataErrorImpl();
+    final ODataErrorImpl error = new ODataErrorImpl();
 
     final ObjectNode tree = parser.getCodec().readTree(parser);
     if (tree.has(jsonError)) {
@@ -60,11 +61,12 @@ public class JSONODataErrorDeserializer extends AbstractJsonDeserializer<JSONODa
         error.setTarget(errorNode.get(Constants.ERROR_TARGET).textValue());
       }
       if (errorNode.hasNonNull(Constants.ERROR_DETAILS)) {
-        final List<ODataErrorDetail> details = new ArrayList<ODataErrorDetail>();
-        for (final Iterator<JsonNode> itor = errorNode.get(Constants.ERROR_DETAILS).iterator(); itor.hasNext();) {
-          details.add(itor.next().traverse(parser.getCodec()).<ResWrap<JSONODataErrorDetailImpl>>readValueAs(
-                  new TypeReference<JSONODataErrorDetailImpl>() {
-                  }).getPayload());
+        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);
@@ -79,6 +81,6 @@ public class JSONODataErrorDeserializer extends AbstractJsonDeserializer<JSONODa
       }
     }
 
-    return new ResWrap<JSONODataErrorImpl>((URI) null, null, error);
+    return error;
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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
index 38ea043..6fe51ce 100644
--- 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
@@ -18,23 +18,26 @@
  */
 package org.apache.olingo.commons.core.data;
 
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
 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 AbstractJsonDeserializer<JSONODataErrorDetailImpl> {
+public class JSONODataErrorDetailDeserializer extends JsonDeserializer {
+
+  public JSONODataErrorDetailDeserializer(final ODataServiceVersion version, final boolean serverMode) {
+    super(version, serverMode);
+  }
 
-  @Override
-  protected ResWrap<JSONODataErrorDetailImpl> doDeserialize(
-          final JsonParser parser, final DeserializationContext ctxt)
-          throws IOException, JsonProcessingException {
+  protected ResWrap<ODataErrorDetail> doDeserialize(final JsonParser parser) throws IOException {
 
-    final JSONODataErrorDetailImpl error = new JSONODataErrorDetailImpl();
+    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());
@@ -51,6 +54,6 @@ public class JSONODataErrorDetailDeserializer extends AbstractJsonDeserializer<J
       error.setTarget(errorNode.get(Constants.ERROR_TARGET).textValue());
     }
 
-    return new ResWrap<JSONODataErrorDetailImpl>((URI) null, null, error);
+    return new ResWrap<ODataErrorDetail>((URI) null, null, error);
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDetailImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDetailImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDetailImpl.java
deleted file mode 100644
index 49f3159..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDetailImpl.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.data;
-
-import org.apache.olingo.commons.api.domain.ODataErrorDetail;
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-
-/*
- * JSONODataErrorDetailImpl, using the JSONODataErrorDetailDeserializer similar to JSONODataErrorImpl's.
- */
-@JsonDeserialize(using = JSONODataErrorDetailDeserializer.class)
-public class JSONODataErrorDetailImpl implements ODataErrorDetail {
-
-  private String code;
-
-  private String message;
-
-  private String target;
-
-  @Override
-  public String getCode() {
-    return code;
-  }
-
-  public void setCode(final String code) {
-    this.code = code;
-  }
-
-  @Override
-  public String getMessage() {
-    return message;
-  }
-
-  public void setMessage(final String message) {
-    this.message = message;
-  }
-
-  @Override
-  public String getTarget() {
-    return target;
-  }
-
-  public void setTarget(final String target) {
-    this.target = target;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorImpl.java
deleted file mode 100644
index c455d2d..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorImpl.java
+++ /dev/null
@@ -1,26 +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.annotation.JsonDeserialize;
-
-@JsonDeserialize(using = JSONODataErrorDeserializer.class)
-public class JSONODataErrorImpl extends AbstractODataError {
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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
index ea2a9df..465250a 100644
--- 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
@@ -18,37 +18,39 @@
  */
 package org.apache.olingo.commons.core.data;
 
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
 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>JSONPropertyImpl</tt>.
- *
- * @see JSONPropertyImpl
+ * Parse JSON string into <tt>Property</tt>.
  */
-public class JSONPropertyDeserializer extends AbstractJsonDeserializer<JSONPropertyImpl> {
+public class JSONPropertyDeserializer extends JsonDeserializer {
+
+  public JSONPropertyDeserializer(final ODataServiceVersion version, final boolean serverMode) {
+    super(version, serverMode);
+  }
 
-  @Override
-  protected ResWrap<JSONPropertyImpl> doDeserialize(final JsonParser parser, final DeserializationContext ctxt)
-          throws IOException, JsonProcessingException {
+  protected ResWrap<Property> doDeserialize(final JsonParser parser) throws IOException {
 
     final ObjectNode tree = (ObjectNode) parser.getCodec().readTree(parser);
 
     final String metadataETag;
     final URI contextURL;
-    final JSONPropertyImpl property = new JSONPropertyImpl();
+    final PropertyImpl property = new PropertyImpl();
 
     if (tree.hasNonNull(Constants.JSON_METADATA_ETAG)) {
       metadataETag = tree.get(Constants.JSON_METADATA_ETAG).textValue();
@@ -97,6 +99,6 @@ public class JSONPropertyDeserializer extends AbstractJsonDeserializer<JSONPrope
       }
     }
 
-    return new ResWrap<JSONPropertyImpl>(contextURL, metadataETag, property);
+    return new ResWrap<Property>(contextURL, metadataETag, property);
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertyImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertyImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertyImpl.java
deleted file mode 100644
index 1018666..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertyImpl.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.core.data;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
-/**
- * A single property (primitive, complex or collection) represented via JSON.
- */
-@JsonSerialize(using = JSONPropertySerializer.class)
-@JsonDeserialize(using = JSONPropertyDeserializer.class)
-public class JSONPropertyImpl extends AbstractProperty {
-
-  private static final long serialVersionUID = 553414431536637434L;
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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
index 1a7b908..1a82a3b 100644
--- 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
@@ -18,37 +18,34 @@
  */
 package org.apache.olingo.commons.core.data;
 
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.SerializerProvider;
 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.ResWrap;
 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>JSONPropertyImpl</tt>.
- *
- * @see JSONPropertyImpl
+ * Writes out JSON string from <tt>PropertyImpl</tt>.
  */
-public class JSONPropertySerializer extends AbstractJsonSerializer<JSONPropertyImpl> {
+public class JSONPropertySerializer extends JsonSerializer {
 
-  @Override
-  protected void doSerialize(final JSONPropertyImpl property, final JsonGenerator jgen,
-          final SerializerProvider provider) throws IOException, JsonProcessingException {
+  public JSONPropertySerializer(final ODataServiceVersion version, final boolean serverMode) {
+    super(version, serverMode);
+  }
 
-    doContainerSerialize(new ResWrap<JSONPropertyImpl>((URI) null, null, property), jgen, provider);
+  protected void doSerialize(final Property property, final JsonGenerator jgen) throws IOException {
+    doContainerSerialize(new ResWrap<Property>((URI) null, null, property), jgen);
   }
 
-  @Override
-  protected void doContainerSerialize(
-          final ResWrap<JSONPropertyImpl> container, final JsonGenerator jgen, final SerializerProvider provider)
-          throws IOException, JsonProcessingException {
+  protected void doContainerSerialize(final ResWrap<Property> container, final JsonGenerator jgen)
+          throws IOException {
 
     final Property property = container.getPayload();
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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
new file mode 100755
index 0000000..0ecd7f3
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JsonDeserializer.java
@@ -0,0 +1,463 @@
+/*
+ * 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/46a34178/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
new file mode 100755
index 0000000..e067d88
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JsonSerializer.java
@@ -0,0 +1,315 @@
+/*
+ * 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).doSerialize((Property) obj, 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/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataErrorDetailImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataErrorDetailImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataErrorDetailImpl.java
new file mode 100755
index 0000000..3367080
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataErrorDetailImpl.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.core.data;
+
+import org.apache.olingo.commons.api.domain.ODataErrorDetail;
+
+public class ODataErrorDetailImpl implements ODataErrorDetail {
+
+  private String code;
+
+  private String message;
+
+  private String target;
+
+  @Override
+  public String getCode() {
+    return code;
+  }
+
+  public void setCode(final String code) {
+    this.code = code;
+  }
+
+  @Override
+  public String getMessage() {
+    return message;
+  }
+
+  public void setMessage(final String message) {
+    this.message = message;
+  }
+
+  @Override
+  public String getTarget() {
+    return target;
+  }
+
+  public void setTarget(final String target) {
+    this.target = target;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataErrorImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataErrorImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataErrorImpl.java
new file mode 100755
index 0000000..e766ae3
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataErrorImpl.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.core.data;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.olingo.commons.api.domain.ODataError;
+import org.apache.olingo.commons.api.domain.ODataErrorDetail;
+
+/**
+ * Example:
+ * <tt>
+ * {
+ * "error": { "code": "501", "message": "Unsupported functionality", "target": "query", "details": [ { "code": "301",
+ * "target": "$search", "message": "$search query option not supported" } ], "innererror": { "trace": [...], "context":
+ * {...} } } }
+ * </tt>.
+ */
+public class ODataErrorImpl implements ODataError {
+
+  private String code;
+
+  private String message;
+
+  private String target;
+
+  private List<ODataErrorDetail> details;
+
+  private Map<String, String> innerError = new LinkedHashMap<String, String>();
+
+  @Override
+  public String getCode() {
+    return code;
+  }
+
+  public void setCode(final String code) {
+    this.code = code;
+  }
+
+  @Override
+  public String getMessage() {
+    return message;
+  }
+
+  public void setMessage(final String message) {
+    this.message = message;
+  }
+
+  @Override
+  public String getTarget() {
+    return target;
+  }
+
+  public void setTarget(final String target) {
+    this.target = target;
+  }
+
+  @Override
+  public List<ODataErrorDetail> getDetails() {
+    return details;
+  }
+
+  public void setDetails(final List<ODataErrorDetail> detail) {
+    this.details = detail;
+  }
+
+  @Override
+  public Map<String, String> getInnerError() {
+    return innerError;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataJacksonDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataJacksonDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataJacksonDeserializer.java
deleted file mode 100644
index a6a75b8..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataJacksonDeserializer.java
+++ /dev/null
@@ -1,98 +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.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonDeserializer;
-
-import java.io.IOException;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-
-public abstract class ODataJacksonDeserializer<T> extends JsonDeserializer<T> {
-
-  protected ODataServiceVersion version;
-
-  protected 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;
-
-  protected abstract T doDeserialize(JsonParser jp, DeserializationContext ctxt)
-          throws IOException, JsonProcessingException;
-
-  protected String getJSONAnnotation(final String string) {
-    return StringUtils.prependIfMissing(string, "@");
-  }
-
-  @Override
-  public T deserialize(final JsonParser jp, final DeserializationContext ctxt)
-          throws IOException, JsonProcessingException {
-
-    version = (ODataServiceVersion) ctxt.findInjectableValue(ODataServiceVersion.class.getName(), null, null);
-    serverMode = (Boolean) ctxt.findInjectableValue(Boolean.class.getName(), null, null);
-
-    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);
-
-    return doDeserialize(jp, ctxt);
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataJacksonSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataJacksonSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataJacksonSerializer.java
deleted file mode 100644
index 944fb51..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataJacksonSerializer.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.data;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonSerializer;
-import com.fasterxml.jackson.databind.SerializerProvider;
-
-import java.io.IOException;
-import org.apache.olingo.commons.api.data.ResWrap;
-
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-
-public abstract class ODataJacksonSerializer<T> extends JsonSerializer<T> {
-
-  protected ODataServiceVersion version;
-
-  protected boolean serverMode;
-
-  protected abstract void doSerialize(T value, JsonGenerator jgen, SerializerProvider provider)
-          throws IOException, JsonProcessingException;
-
-  protected abstract void doContainerSerialize(ResWrap<T> value, JsonGenerator jgen, SerializerProvider provider)
-          throws IOException, JsonProcessingException;
-
-  @Override
-  @SuppressWarnings("unchecked")
-  public void serialize(final T value, final JsonGenerator jgen, final SerializerProvider provider)
-          throws IOException, JsonProcessingException {
-
-    version = (ODataServiceVersion) provider.getAttribute(ODataServiceVersion.class);
-    serverMode = (Boolean) provider.getAttribute(Boolean.class);
-
-    if (value instanceof ResWrap) {
-      doContainerSerialize((ResWrap) value, jgen, provider);
-    } else {
-      doSerialize(value, jgen, provider);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java
new file mode 100755
index 0000000..9d9f35c
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.core.data;
+
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.Value;
+
+public class PropertyImpl extends AbstractAnnotatedObject implements Property {
+
+  private static final long serialVersionUID = -7175704800169997060L;
+
+  private String name;
+
+  private String type;
+
+  private Value value;
+
+  @Override
+  public String getName() {
+    return name;
+  }
+
+  @Override
+  public void setName(final String name) {
+    this.name = name;
+  }
+
+  @Override
+  public String getType() {
+    return type;
+  }
+
+  @Override
+  public void setType(final String type) {
+    this.type = type;
+  }
+
+  @Override
+  public Value getValue() {
+    return value;
+  }
+
+  @Override
+  public void setValue(final Value value) {
+    this.value = value;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/XMLODataErrorImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/XMLODataErrorImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/XMLODataErrorImpl.java
deleted file mode 100644
index 36cb682..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/XMLODataErrorImpl.java
+++ /dev/null
@@ -1,23 +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;
-
-public class XMLODataErrorImpl extends AbstractODataError {
-
-}


[14/23] [OLINGO-317] Rename and move of some packages and classes

Posted by ch...@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();
+  }
+}


[23/23] git commit: [OLINGO-327] make client supports shorter operation name in url (not protocol standard)

Posted by ch...@apache.org.
[OLINGO-327] make client supports shorter operation name in url (not protocol standard)


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

Branch: refs/heads/clientjune
Commit: f40643f92ecb43b2a135fc413eba318801ae8744
Parents: 1e8ad44
Author: challenh <ch...@microsoft.com>
Authored: Tue Jun 24 12:52:27 2014 +0800
Committer: challenh <ch...@microsoft.com>
Committed: Tue Jun 24 12:52:27 2014 +0800

----------------------------------------------------------------------
 .../commons/OperationInvocationHandler.java     |  5 +++--
 .../olingo/client/api/CommonConfiguration.java  | 23 ++++++++++++++++++++
 .../client/core/AbstractConfiguration.java      | 12 ++++++++++
 3 files changed, 38 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f40643f9/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java
index b561619..d68efb1 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java
@@ -161,6 +161,7 @@ final class OperationInvocationHandler extends AbstractInvocationHandler impleme
     if (boundOp == null) {
       boundOp = entity.getOperation(new FullQualifiedName(targetFQN.getNamespace(), operation.name()).toString());
     }
+    boolean useOperationFQN = this.getClient().getConfiguration().isUseUrlOperationFQN();
     if (boundOp == null) {
     	// json minimal/none metadata doesn't return operations for entity, so here try creating it from Edm: 
     	EdmAction action = this.getClient().getEdm(null).getBoundAction(
@@ -170,7 +171,7 @@ final class OperationInvocationHandler extends AbstractInvocationHandler impleme
     		boundOp.setMetadataAnchor(action.getFullQualifiedName().toString());
     		boundOp.setTitle(boundOp.getMetadataAnchor());
     		boundOp.setTarget(URI.create(entity.getEditLink().toString() + "/" 
-                  + action.getFullQualifiedName().toString()));
+                  + (useOperationFQN ? action.getFullQualifiedName().toString() : operation.name())));
     	}
     }
     if (boundOp == null) {
@@ -182,7 +183,7 @@ final class OperationInvocationHandler extends AbstractInvocationHandler impleme
     		boundOp.setMetadataAnchor(func.getFullQualifiedName().toString());
     		boundOp.setTitle(boundOp.getMetadataAnchor());
     		boundOp.setTarget(URI.create(entity.getEditLink().toString() + "/" 
-                  + func.getFullQualifiedName().toString()));
+                  + (useOperationFQN ? func.getFullQualifiedName().toString() : operation.name())));
     	}
     }
     if (boundOp == null) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f40643f9/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonConfiguration.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonConfiguration.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonConfiguration.java
index 46f12b3..7a25d8e 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonConfiguration.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonConfiguration.java
@@ -216,6 +216,29 @@ public interface CommonConfiguration extends Serializable {
   boolean isAddressingDerivedTypes() ;
 
   /**
+   * Sets whether operation name in request URI should be fully qualified name, which is required by OData V4 protocol,
+   * but some service may still choose to support shorter name.
+   * <br/>
+   * Example: http://host/service/Customers(2)/NS1.Model.IncreaseSalary VS 
+   * http://host/service/Customers(2)/IncreaseSalary
+   *
+   * @param value 'TRUE' to use this feature.
+   */  
+  void setUseUrlOperationFQN(final boolean value);
+  
+  /**
+   * Sets whether operation name in request URI should be fully qualified name, which is required by OData V4 protocol,
+   * but some service may still choose to support shorter name.
+   * <br/>
+   * Example: http://host/service/Customers(2)/NS1.Model.IncreaseSalary VS 
+   * http://host/service/Customers(2)/IncreaseSalary
+   *
+   * @return whether whether operation name in request URI should be fully qualified name.
+   * segment.
+   */
+  boolean isUseUrlOperationFQN() ;
+
+  /**
    * Sets whether query URIs in request should contain fully qualified type name.
    * - OData Intermediate Conformance Level:
    * MUST support casting to a derived type according to [OData-URL] if derived types are present in the model.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f40643f9/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractConfiguration.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractConfiguration.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractConfiguration.java
index 888452a..a314dd4 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractConfiguration.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractConfiguration.java
@@ -54,6 +54,8 @@ public abstract class AbstractConfiguration implements CommonConfiguration {
   
   private static final String ADDRESS_DERIVED_TYPE = "addressDerivedType";
 
+  private static final String USE_OPERATION_FQN_IN_URL = "useOperationFqnInUrl";
+
   private static final String GZIP_COMPRESSION = "gzipCompression";
 
   private static final String CHUNKING = "chunking";
@@ -225,6 +227,16 @@ public abstract class AbstractConfiguration implements CommonConfiguration {
   }
   
   @Override
+  public boolean isUseUrlOperationFQN() {
+    return (Boolean) getProperty(USE_OPERATION_FQN_IN_URL, true);
+  }
+
+  @Override
+  public void setUseUrlOperationFQN(final boolean value) {
+    setProperty(USE_OPERATION_FQN_IN_URL, value);
+  }
+  
+  @Override
   public ExecutorService getExecutor() {
     return executor;
   }


[03/23] [OLINGO-317] First presentable state

Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonDeserializer.java
deleted file mode 100644
index 133c916..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonDeserializer.java
+++ /dev/null
@@ -1,372 +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.ObjectCodec;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import java.io.IOException;
-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.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.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.core.edm.EdmTypeInfo;
-
-abstract class AbstractJsonDeserializer<T> extends ODataJacksonDeserializer<ResWrap<T>> {
-
-  protected final Pattern CUSTOM_ANNOTATION = Pattern.compile("(.+)@(.+)\\.(.+)");
-
-  private JSONGeoValueDeserializer geoDeserializer;
-
-  private JSONGeoValueDeserializer getGeoDeserializer() {
-    if (geoDeserializer == null) {
-      geoDeserializer = new JSONGeoValueDeserializer(version);
-    }
-    return geoDeserializer;
-  }
-
-  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);
-
-      if (inline instanceof ObjectNode) {
-        link.setType(ODataLinkType.ENTITY_NAVIGATION.toString());
-
-        link.setInlineEntity(inline.traverse(codec).<ResWrap<JSONEntityImpl>>readValueAs(
-                new TypeReference<JSONEntityImpl>() {
-                }).getPayload());
-      }
-
-      if (inline instanceof ArrayNode) {
-        link.setType(ODataLinkType.ENTITY_SET_NAVIGATION.toString());
-
-        final JSONEntitySetImpl entitySet = new JSONEntitySetImpl();
-        final Iterator<JsonNode> entries = ((ArrayNode) inline).elements();
-        while (entries.hasNext()) {
-          entitySet.getEntities().add(entries.next().traverse(codec).<ResWrap<JSONEntityImpl>>readValuesAs(
-                  new TypeReference<JSONEntityImpl>() {
-                  }).next().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 JSONPropertyImpl property = new JSONPropertyImpl();
-        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));
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonSerializer.java
deleted file mode 100644
index 1713a7c..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonSerializer.java
+++ /dev/null
@@ -1,248 +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.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.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.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.core.edm.EdmTypeInfo;
-
-abstract class AbstractJsonSerializer<T> extends ODataJacksonSerializer<T> {
-
-  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();
-
-  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.writeObjectField(link.getTitle(), link.getInlineEntity());
-      } else if (link.getInlineEntitySet() != null) {
-        jgen.writeArrayFieldStart(link.getTitle());
-        for (Entity subEntry : link.getInlineEntitySet().getEntities()) {
-          jgen.writeObject(subEntry);
-        }
-        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 JSONEntityImpl) {
-      for (Link link : ((JSONEntityImpl) 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.writeObjectField(link.getTitle(), link.getInlineEntity());
-      } else if (link.getInlineEntitySet() != null) {
-        jgen.writeArrayFieldStart(link.getTitle());
-        for (Entity subEntry : link.getInlineEntitySet().getEntities()) {
-          jgen.writeObject(subEntry);
-        }
-        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/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractODataError.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractODataError.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractODataError.java
deleted file mode 100644
index 1e9cf51..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractODataError.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.data;
-
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.olingo.commons.api.domain.ODataError;
-import org.apache.olingo.commons.api.domain.ODataErrorDetail;
-
-/**
- * Example:
- * <tt>
- * {
- * "error": { "code": "501", "message": "Unsupported functionality", "target": "query", "details": [ { "code": "301",
- * "target": "$search", "message": "$search query option not supported" } ], "innererror": { "trace": [...], "context":
- * {...} } } }
- * </tt>.
- */
-public abstract class AbstractODataError implements ODataError {
-
-  private String code;
-
-  private String message;
-
-  private String target;
-
-  private List<ODataErrorDetail> details;
-
-  private Map<String, String> innerError = new LinkedHashMap<String, String>();
-
-  @Override
-  public String getCode() {
-    return code;
-  }
-
-  public void setCode(final String code) {
-    this.code = code;
-  }
-
-  @Override
-  public String getMessage() {
-    return message;
-  }
-
-  public void setMessage(final String message) {
-    this.message = message;
-  }
-
-  @Override
-  public String getTarget() {
-    return target;
-  }
-
-  public void setTarget(final String target) {
-    this.target = target;
-  }
-
-  @Override
-  public List<ODataErrorDetail> getDetails() {
-    return details;
-  }
-
-  public void setDetails(final List<ODataErrorDetail> detail) {
-    this.details = detail;
-  }
-
-  @Override
-  public Map<String, String> getInnerError() {
-    return innerError;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractProperty.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractProperty.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractProperty.java
deleted file mode 100644
index 2363c0b..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractProperty.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.data;
-
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.data.Value;
-
-public abstract class AbstractProperty extends AbstractAnnotatedObject implements Property {
-
-  private static final long serialVersionUID = -7175704800169997060L;
-
-  private String name;
-
-  private String type;
-
-  private Value value;
-
-  @Override
-  public String getName() {
-    return name;
-  }
-
-  @Override
-  public void setName(final String name) {
-    this.name = name;
-  }
-
-  @Override
-  public String getType() {
-    return type;
-  }
-
-  @Override
-  public void setType(final String type) {
-    this.type = type;
-  }
-
-  @Override
-  public Value getValue() {
-    return value;
-  }
-
-  @Override
-  public void setValue(final Value value) {
-    this.value = value;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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
index 51a5465..dec0028 100644
--- 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
@@ -18,8 +18,6 @@
  */
 package org.apache.olingo.commons.core.data;
 
-import com.fasterxml.aalto.stax.InputFactoryImpl;
-import org.apache.olingo.commons.core.data.v4.AtomDeltaImpl;
 import java.io.InputStream;
 import java.net.URI;
 import java.text.ParseException;
@@ -27,6 +25,7 @@ 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;
@@ -34,25 +33,35 @@ 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.core.data.v3.XMLLinkCollectionImpl;
+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;
 
-public class AtomDeserializer extends AbstractAtomDealer {
+import com.fasterxml.aalto.stax.InputFactoryImpl;
+
+public class AtomDeserializer extends AbstractAtomDealer implements ODataDeserializer {
 
   protected static final XMLInputFactory FACTORY = new InputFactoryImpl();
 
@@ -68,7 +77,7 @@ public class AtomDeserializer extends AbstractAtomDealer {
   }
 
   private Value fromPrimitive(final XMLEventReader reader, final StartElement start,
-          final EdmTypeInfo typeInfo) throws XMLStreamException {
+      final EdmTypeInfo typeInfo) throws XMLStreamException {
 
     Value value = null;
 
@@ -78,12 +87,12 @@ public class AtomDeserializer extends AbstractAtomDealer {
 
       if (event.isStartElement() && typeInfo != null && typeInfo.getPrimitiveTypeKind().isGeospatial()) {
         final EdmPrimitiveTypeKind geoType = EdmPrimitiveTypeKind.valueOfFQN(
-                version, typeInfo.getFullQualifiedName().toString());
+            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())) {
+          && (typeInfo == null || !typeInfo.getPrimitiveTypeKind().isGeospatial())) {
 
         value = new PrimitiveValueImpl(event.asCharacters().getData());
       }
@@ -97,7 +106,7 @@ public class AtomDeserializer extends AbstractAtomDealer {
   }
 
   private Value fromComplexOrEnum(final XMLEventReader reader, final StartElement start)
-          throws XMLStreamException {
+      throws XMLStreamException {
 
     Value value = null;
 
@@ -108,8 +117,8 @@ public class AtomDeserializer extends AbstractAtomDealer {
       if (event.isStartElement()) {
         if (value == null) {
           value = version.compareTo(ODataServiceVersion.V40) < 0
-                  ? new ComplexValueImpl()
-                  : new LinkedComplexValueImpl();
+              ? new ComplexValueImpl()
+              : new LinkedComplexValueImpl();
         }
 
         if (Constants.QNAME_ATOM_ELEM_LINK.equals(event.asStartElement().getName())) {
@@ -132,12 +141,12 @@ public class AtomDeserializer extends AbstractAtomDealer {
           }
 
           if (link.getRel().startsWith(
-                  version.getNamespaceMap().get(ODataServiceVersion.NAVIGATION_LINK_REL))) {
+              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))) {
+              version.getNamespaceMap().get(ODataServiceVersion.ASSOCIATION_LINK_REL))) {
 
             value.asLinkedComplex().getAssociationLinks().add(link);
           }
@@ -159,13 +168,13 @@ public class AtomDeserializer extends AbstractAtomDealer {
   }
 
   private CollectionValue fromCollection(final XMLEventReader reader, final StartElement start,
-          final EdmTypeInfo typeInfo) throws XMLStreamException {
+      final EdmTypeInfo typeInfo) throws XMLStreamException {
 
     final CollectionValueImpl value = new CollectionValueImpl();
 
     final EdmTypeInfo type = typeInfo == null
-            ? null
-            : new EdmTypeInfo.Builder().setTypeExpression(typeInfo.getFullQualifiedName().toString()).build();
+        ? null
+        : new EdmTypeInfo.Builder().setTypeExpression(typeInfo.getFullQualifiedName().toString()).build();
 
     boolean foundEndProperty = false;
     while (reader.hasNext() && !foundEndProperty) {
@@ -173,16 +182,16 @@ public class AtomDeserializer extends AbstractAtomDealer {
 
       if (event.isStartElement()) {
         switch (guessPropertyType(reader, typeInfo)) {
-          case COMPLEX:
-          case ENUM:
-            value.get().add(fromComplexOrEnum(reader, event.asStartElement()));
-            break;
+        case COMPLEX:
+        case ENUM:
+          value.get().add(fromComplexOrEnum(reader, event.asStartElement()));
+          break;
 
-          case PRIMITIVE:
-            value.get().add(fromPrimitive(reader, event.asStartElement(), type));
-            break;
+        case PRIMITIVE:
+          value.get().add(fromPrimitive(reader, event.asStartElement(), type));
+          break;
 
-          default:
+        default:
           // do not add null or empty values
         }
       }
@@ -196,7 +205,7 @@ public class AtomDeserializer extends AbstractAtomDealer {
   }
 
   private ODataPropertyType guessPropertyType(final XMLEventReader reader, final EdmTypeInfo typeInfo)
-          throws XMLStreamException {
+      throws XMLStreamException {
 
     XMLEvent child = null;
     while (reader.hasNext() && child == null) {
@@ -211,8 +220,8 @@ public class AtomDeserializer extends AbstractAtomDealer {
     final ODataPropertyType type;
     if (child == null) {
       type = typeInfo == null || typeInfo.isPrimitiveType()
-              ? ODataPropertyType.PRIMITIVE
-              : ODataPropertyType.ENUM;
+          ? ODataPropertyType.PRIMITIVE
+          : ODataPropertyType.ENUM;
     } else {
       if (child.isStartElement()) {
         if (Constants.NS_GML.equals(child.asStartElement().getName().getNamespaceURI())) {
@@ -224,8 +233,8 @@ public class AtomDeserializer extends AbstractAtomDealer {
         }
       } else if (child.isCharacters()) {
         type = typeInfo == null || typeInfo.isPrimitiveType()
-                ? ODataPropertyType.PRIMITIVE
-                : ODataPropertyType.ENUM;
+            ? ODataPropertyType.PRIMITIVE
+            : ODataPropertyType.ENUM;
       } else {
         type = ODataPropertyType.EMPTY;
       }
@@ -234,10 +243,10 @@ public class AtomDeserializer extends AbstractAtomDealer {
     return type;
   }
 
-  private AtomPropertyImpl property(final XMLEventReader reader, final StartElement start)
-          throws XMLStreamException {
+  private Property property(final XMLEventReader reader, final StartElement start)
+      throws XMLStreamException {
 
-    final AtomPropertyImpl property = new AtomPropertyImpl();
+    final PropertyImpl property = new PropertyImpl();
 
     if (ODataServiceVersion.V40 == version && propertyValueQName.equals(start.getName())) {
       // retrieve name from context
@@ -255,7 +264,7 @@ public class AtomDeserializer extends AbstractAtomDealer {
   }
 
   private void valuable(final Valuable valuable, final XMLEventReader reader, final StartElement start)
-          throws XMLStreamException {
+      throws XMLStreamException {
 
     final Attribute nullAttr = start.getAttributeByName(this.nullQName);
 
@@ -265,41 +274,41 @@ public class AtomDeserializer extends AbstractAtomDealer {
       final String typeAttrValue = typeAttr == null ? null : typeAttr.getValue();
 
       final EdmTypeInfo typeInfo = StringUtils.isBlank(typeAttrValue)
-              ? null
-              : new EdmTypeInfo.Builder().setTypeExpression(typeAttrValue).build();
+          ? null
+          : new EdmTypeInfo.Builder().setTypeExpression(typeAttrValue).build();
 
       if (typeInfo != null) {
         valuable.setType(typeInfo.internal());
       }
 
       final ODataPropertyType propType = typeInfo == null
-              ? guessPropertyType(reader, typeInfo)
-              : typeInfo.isCollection()
+          ? guessPropertyType(reader, typeInfo)
+          : typeInfo.isCollection()
               ? ODataPropertyType.COLLECTION
               : typeInfo.isPrimitiveType()
-              ? ODataPropertyType.PRIMITIVE
-              : ODataPropertyType.COMPLEX;
+                  ? 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 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);
+      case EMPTY:
+      default:
+        value = new PrimitiveValueImpl(StringUtils.EMPTY);
       }
     } else {
       value = new NullValueImpl();
@@ -308,10 +317,15 @@ public class AtomDeserializer extends AbstractAtomDealer {
     valuable.setValue(value);
   }
 
-  private ResWrap<AtomPropertyImpl> property(final InputStream input) throws XMLStreamException {
-    final XMLEventReader reader = getReader(input);
-    final StartElement start = skipBeforeFirstStartElement(reader);
-    return getContainer(start, property(reader, start));
+  @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 {
@@ -330,7 +344,7 @@ public class AtomDeserializer extends AbstractAtomDealer {
   }
 
   private void common(final XMLEventReader reader, final StartElement start,
-          final AbstractODataObject object, final String key) throws XMLStreamException {
+      final AbstractODataObject object, final String key) throws XMLStreamException {
 
     boolean foundEndElement = false;
     while (reader.hasNext() && !foundEndElement) {
@@ -351,7 +365,7 @@ public class AtomDeserializer extends AbstractAtomDealer {
   }
 
   private void inline(final XMLEventReader reader, final StartElement start, final LinkImpl link)
-          throws XMLStreamException {
+      throws XMLStreamException {
 
     boolean foundEndElement = false;
     while (reader.hasNext() && !foundEndElement) {
@@ -387,17 +401,17 @@ public class AtomDeserializer extends AbstractAtomDealer {
     }
   }
 
-  private ResWrap<AtomDeltaImpl> delta(final InputStream input) throws XMLStreamException {
+  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 AtomDeltaImpl delta(final XMLEventReader reader, final StartElement start) throws XMLStreamException {
+  private Delta delta(final XMLEventReader reader, final StartElement start) throws XMLStreamException {
     if (!Constants.QNAME_ATOM_ELEM_FEED.equals(start.getName())) {
       return null;
     }
-    final AtomDeltaImpl delta = new AtomDeltaImpl();
+    final DeltaImpl delta = new DeltaImpl();
     final Attribute xmlBase = start.getAttributeByName(Constants.QNAME_ATTR_XML_BASE);
     if (xmlBase != null) {
       delta.setBaseURI(xmlBase.getValue());
@@ -449,7 +463,7 @@ public class AtomDeserializer extends AbstractAtomDealer {
 
           delta.getDeletedEntities().add(deletedEntity);
         } else if (linkQName.equals(event.asStartElement().getName())
-                || deletedLinkQName.equals(event.asStartElement().getName())) {
+            || deletedLinkQName.equals(event.asStartElement().getName())) {
 
           final DeltaLinkImpl link = new DeltaLinkImpl();
 
@@ -458,7 +472,7 @@ public class AtomDeserializer extends AbstractAtomDealer {
             link.setSource(URI.create(source.getValue()));
           }
           final Attribute relationship =
-                  event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_RELATIONSHIP));
+              event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_RELATIONSHIP));
           if (relationship != null) {
             link.setRelationship(relationship.getValue());
           }
@@ -483,16 +497,16 @@ public class AtomDeserializer extends AbstractAtomDealer {
     return delta;
   }
 
-  private ResWrap<XMLLinkCollectionImpl> linkCollection(final InputStream input) throws XMLStreamException {
+  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 XMLLinkCollectionImpl linkCollection(final XMLEventReader reader, final StartElement start)
-          throws XMLStreamException {
+  private LinkCollection linkCollection(final XMLEventReader reader, final StartElement start)
+      throws XMLStreamException {
 
-    final XMLLinkCollectionImpl linkCollection = new XMLLinkCollectionImpl();
+    final LinkCollectionImpl linkCollection = new LinkCollectionImpl();
 
     boolean isURI = false;
     boolean isNext = false;
@@ -517,8 +531,8 @@ public class AtomDeserializer extends AbstractAtomDealer {
     return linkCollection;
   }
 
-  private void properties(final XMLEventReader reader, final StartElement start, final AtomEntityImpl entity)
-          throws XMLStreamException {
+  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>>();
 
@@ -529,7 +543,7 @@ public class AtomDeserializer extends AbstractAtomDealer {
       if (event.isStartElement()) {
         if (annotationQName.equals(event.asStartElement().getName())) {
           final String target = event.asStartElement().
-                  getAttributeByName(QName.valueOf(Constants.ATTR_TARGET)).getValue();
+              getAttributeByName(QName.valueOf(Constants.ATTR_TARGET)).getValue();
           if (!annotations.containsKey(target)) {
             annotations.put(target, new ArrayList<Annotation>());
           }
@@ -552,7 +566,7 @@ public class AtomDeserializer extends AbstractAtomDealer {
   }
 
   private Annotation annotation(final XMLEventReader reader, final StartElement start)
-          throws XMLStreamException {
+      throws XMLStreamException {
 
     final Annotation annotation = new AnnotationImpl();
 
@@ -562,8 +576,8 @@ public class AtomDeserializer extends AbstractAtomDealer {
     return annotation;
   }
 
-  private AtomEntityImpl entityRef(final StartElement start) throws XMLStreamException {
-    final AtomEntityImpl entity = new AtomEntityImpl();
+  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) {
@@ -573,12 +587,12 @@ public class AtomDeserializer extends AbstractAtomDealer {
     return entity;
   }
 
-  private AtomEntityImpl entity(final XMLEventReader reader, final StartElement start) throws XMLStreamException {
-    final AtomEntityImpl 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 AtomEntityImpl();
+      entity = new EntityImpl();
       final Attribute xmlBase = start.getAttributeByName(Constants.QNAME_ATTR_XML_BASE);
       if (xmlBase != null) {
         entity.setBaseURI(xmlBase.getValue());
@@ -636,16 +650,16 @@ public class AtomDeserializer extends AbstractAtomDealer {
                 entity.setMediaETag(mediaETag.getValue());
               }
             } else if (link.getRel().startsWith(
-                    version.getNamespaceMap().get(ODataServiceVersion.NAVIGATION_LINK_REL))) {
-              
+                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))) {
+                version.getNamespaceMap().get(ODataServiceVersion.ASSOCIATION_LINK_REL))) {
 
               entity.getAssociationLinks().add(link);
             } else if (link.getRel().startsWith(
-                    version.getNamespaceMap().get(ODataServiceVersion.MEDIA_EDIT_LINK_REL))) {
+                version.getNamespaceMap().get(ODataServiceVersion.MEDIA_EDIT_LINK_REL))) {
 
               final Attribute metag = event.asStartElement().getAttributeByName(etagQName);
               if (metag != null) {
@@ -656,7 +670,7 @@ public class AtomDeserializer extends AbstractAtomDealer {
           } else if (actionQName.equals(event.asStartElement().getName())) {
             final ODataOperation operation = new ODataOperation();
             final Attribute metadata =
-                    event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_METADATA));
+                event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_METADATA));
             if (metadata != null) {
               operation.setMetadataAnchor(metadata.getValue());
             }
@@ -699,14 +713,19 @@ public class AtomDeserializer extends AbstractAtomDealer {
     return entity;
   }
 
-  private ResWrap<AtomEntityImpl> entity(final InputStream input) throws XMLStreamException {
-    final XMLEventReader reader = getReader(input);
-    final StartElement start = skipBeforeFirstStartElement(reader);
-    return getContainer(start, entity(reader, start));
+  @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 {
+      throws XMLStreamException {
 
     boolean foundEndElement = false;
     while (reader.hasNext() && !foundEndElement) {
@@ -722,11 +741,11 @@ public class AtomDeserializer extends AbstractAtomDealer {
     }
   }
 
-  private AtomEntitySetImpl entitySet(final XMLEventReader reader, final StartElement start) throws XMLStreamException {
+  private EntitySet entitySet(final XMLEventReader reader, final StartElement start) throws XMLStreamException {
     if (!Constants.QNAME_ATOM_ELEM_FEED.equals(start.getName())) {
       return null;
     }
-    final AtomEntitySetImpl entitySet = new AtomEntitySetImpl();
+    final EntitySetImpl entitySet = new EntitySetImpl();
     final Attribute xmlBase = start.getAttributeByName(Constants.QNAME_ATTR_XML_BASE);
     if (xmlBase != null) {
       entitySet.setBaseURI(xmlBase.getValue());
@@ -779,14 +798,19 @@ public class AtomDeserializer extends AbstractAtomDealer {
     return entitySet;
   }
 
-  private ResWrap<AtomEntitySetImpl> entitySet(final InputStream input) throws XMLStreamException {
-    final XMLEventReader reader = getReader(input);
-    final StartElement start = skipBeforeFirstStartElement(reader);
-    return getContainer(start, entitySet(reader, start));
+  @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 XMLODataErrorImpl error(final XMLEventReader reader, final StartElement start) throws XMLStreamException {
-    final XMLODataErrorImpl error = new XMLODataErrorImpl();
+  private ODataError error(final XMLEventReader reader, final StartElement start) throws XMLStreamException {
+    final ODataErrorImpl error = new ODataErrorImpl();
 
     boolean setCode = false;
     boolean codeSet = false;
@@ -835,10 +859,15 @@ public class AtomDeserializer extends AbstractAtomDealer {
     return error;
   }
 
-  private ResWrap<XMLODataErrorImpl> error(final InputStream input) throws XMLStreamException {
-    final XMLEventReader reader = getReader(input);
-    final StartElement start = skipBeforeFirstStartElement(reader);
-    return getContainer(start, error(reader, start));
+  @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) {
@@ -846,28 +875,8 @@ public class AtomDeserializer extends AbstractAtomDealer {
     final Attribute metadataETag = start.getAttributeByName(metadataEtagQName);
 
     return new ResWrap<T>(
-            context == null ? null : URI.create(context.getValue()),
-            metadataETag == null ? null : metadataETag.getValue(),
-            object);
-  }
-
-  @SuppressWarnings("unchecked")
-  public <T, V extends T> ResWrap<T> read(final InputStream input, final Class<V> reference)
-          throws XMLStreamException {
-
-    if (XMLODataErrorImpl.class.equals(reference)) {
-      return (ResWrap<T>) error(input);
-    } else if (AtomEntitySetImpl.class.equals(reference)) {
-      return (ResWrap<T>) entitySet(input);
-    } else if (AtomEntityImpl.class.equals(reference)) {
-      return (ResWrap<T>) entity(input);
-    } else if (AtomPropertyImpl.class.equals(reference)) {
-      return (ResWrap<T>) property(input);
-    } else if (XMLLinkCollectionImpl.class.equals(reference)) {
-      return (ResWrap<T>) linkCollection(input);
-    } else if (AtomDeltaImpl.class.equals(reference)) {
-      return (ResWrap<T>) delta(input);
-    }
-    return null;
+        context == null ? null : URI.create(context.getValue()),
+        metadataETag == null ? null : metadataETag.getValue(),
+        object);
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomEntityImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomEntityImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomEntityImpl.java
deleted file mode 100644
index 6c7fb13..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomEntityImpl.java
+++ /dev/null
@@ -1,25 +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;
-
-public class AtomEntityImpl extends AbstractEntity {
-
-  private static final long serialVersionUID = 6973729343868293279L;
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomEntitySetImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomEntitySetImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomEntitySetImpl.java
deleted file mode 100644
index 397b18e..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomEntitySetImpl.java
+++ /dev/null
@@ -1,28 +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;
-
-/**
- * List of entries, represented via Atom.
- */
-public class AtomEntitySetImpl extends AbstractEntitySet {
-
-  private static final long serialVersionUID = 5466590540021319153L;
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomPropertyImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomPropertyImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomPropertyImpl.java
deleted file mode 100644
index e0018bc..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomPropertyImpl.java
+++ /dev/null
@@ -1,25 +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;
-
-public class AtomPropertyImpl extends AbstractProperty {
-
-  private static final long serialVersionUID = 48748492242474814L;
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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
index 200a4bf..3d4eae6 100644
--- 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
@@ -18,31 +18,36 @@
  */
 package org.apache.olingo.commons.core.data;
 
-import com.fasterxml.aalto.stax.OutputFactoryImpl;
 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.ResWrap;
 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;
 
-public class AtomSerializer extends AbstractAtomDealer {
+import com.fasterxml.aalto.stax.OutputFactoryImpl;
+
+public class AtomSerializer extends AbstractAtomDealer implements ODataSerializer {
 
   private static final XMLOutputFactory FACTORY = new OutputFactoryImpl();
 
@@ -64,10 +69,10 @@ public class AtomSerializer extends AbstractAtomDealer {
     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));
+            version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES));
       } else {
         writer.writeStartElement(Constants.PREFIX_METADATA, Constants.ELEM_ELEMENT,
-                version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA));
+            version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA));
       }
       value(writer, item);
       writer.writeEndElement();
@@ -91,14 +96,14 @@ public class AtomSerializer extends AbstractAtomDealer {
   }
 
   public void property(final XMLStreamWriter writer, final Property property, final boolean standalone)
-          throws XMLStreamException {
+      throws XMLStreamException {
 
     if (version.compareTo(ODataServiceVersion.V40) >= 0 && standalone) {
       writer.writeStartElement(Constants.PREFIX_METADATA, Constants.VALUE,
-              version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES));
+          version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES));
     } else {
       writer.writeStartElement(Constants.PREFIX_DATASERVICES, property.getName(),
-              version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES));
+          version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES));
     }
 
     if (standalone) {
@@ -109,13 +114,13 @@ public class AtomSerializer extends AbstractAtomDealer {
       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));
+            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());
+          Constants.ATTR_NULL, Boolean.TRUE.toString());
     } else {
       value(writer, property.getValue());
       if (property.getValue().isLinkedComplex()) {
@@ -174,7 +179,7 @@ public class AtomSerializer extends AbstractAtomDealer {
 
       if (link.getInlineEntity() != null || link.getInlineEntitySet() != null) {
         writer.writeStartElement(Constants.PREFIX_METADATA, Constants.ATOM_ELEM_INLINE,
-                version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA));
+            version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA));
 
         if (link.getInlineEntity() != null) {
           writer.writeStartElement(Constants.ATOM_ELEM_ENTRY);
@@ -214,10 +219,10 @@ public class AtomSerializer extends AbstractAtomDealer {
   }
 
   private void annotation(final XMLStreamWriter writer, final Annotation annotation, final String target)
-          throws XMLStreamException {
+      throws XMLStreamException {
 
     writer.writeStartElement(Constants.PREFIX_METADATA, Constants.ANNOTATION,
-            version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA));
+        version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA));
 
     writer.writeAttribute(Constants.ATOM_ATTR_TERM, annotation.getTerm());
 
@@ -229,13 +234,13 @@ public class AtomSerializer extends AbstractAtomDealer {
       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));
+            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());
+          Constants.ATTR_NULL, Boolean.TRUE.toString());
     } else {
       value(writer, annotation.getValue());
     }
@@ -250,8 +255,8 @@ public class AtomSerializer extends AbstractAtomDealer {
 
     if (serverMode && StringUtils.isNotBlank(entity.getETag())) {
       writer.writeAttribute(
-              version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA),
-              Constants.ATOM_ATTR_ETAG, entity.getETag());
+          version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA),
+          Constants.ATOM_ATTR_ETAG, entity.getETag());
     }
 
     if (entity.getId() != null) {
@@ -264,7 +269,7 @@ public class AtomSerializer extends AbstractAtomDealer {
     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));
+          new EdmTypeInfo.Builder().setTypeExpression(entity.getType()).build().external(version));
     }
     writer.writeEndElement();
 
@@ -289,7 +294,7 @@ public class AtomSerializer extends AbstractAtomDealer {
     if (serverMode) {
       for (ODataOperation operation : entity.getOperations()) {
         writer.writeStartElement(
-                version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ELEM_ACTION);
+            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());
@@ -384,7 +389,7 @@ public class AtomSerializer extends AbstractAtomDealer {
 
     if (entitySet.getCount() != null) {
       writer.writeStartElement(
-              version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ELEM_COUNT);
+          version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ELEM_COUNT);
       writer.writeCharacters(Integer.toString(entitySet.getCount()));
       writer.writeEndElement();
     }
@@ -416,14 +421,14 @@ public class AtomSerializer extends AbstractAtomDealer {
         next.setRel(Constants.NEXT_LINK_REL);
         next.setHref(entitySet.getNext().toASCIIString());
 
-        links(writer, Collections.<Link>singletonList(next));
+        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));
+        links(writer, Collections.<Link> singletonList(next));
       }
     }
   }
@@ -472,56 +477,64 @@ public class AtomSerializer extends AbstractAtomDealer {
     writer.flush();
   }
 
-  public <T> void write(final Writer writer, final T obj) throws XMLStreamException {
-    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);
+  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 XMLStreamException {
+  public <T> void write(final Writer writer, final ResWrap<T> container) throws ODataSerializerException {
     final T obj = container == null ? null : container.getPayload();
 
-    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);
+    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 {
+      final XMLStreamWriter writer, final ResWrap<T> container) throws XMLStreamException {
 
     if (container.getContextURL() != null) {
       String base = container.getContextURL().getServiceRoot().toASCIIString();
-      if (container.getPayload() instanceof AtomEntitySetImpl) {
-        ((AtomEntitySetImpl) container.getPayload()).setBaseURI(base);
+      if (container.getPayload() instanceof EntitySet) {
+        ((EntitySetImpl) container.getPayload()).setBaseURI(base);
       }
-      if (container.getPayload() instanceof AtomEntityImpl) {
-        ((AtomEntityImpl) 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());
+          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());
+          version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA),
+          Constants.ATOM_ATTR_METADATAETAG,
+          container.getMetadataETag());
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntityImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntityImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntityImpl.java
new file mode 100755
index 0000000..28451a9
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntityImpl.java
@@ -0,0 +1,193 @@
+/*
+ * 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.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+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.domain.ODataOperation;
+
+/**
+ * Class implementing an OData entity.
+ */
+public class EntityImpl extends AbstractODataObject implements Entity {
+
+  private static final long serialVersionUID = 2127764552600969783L;
+
+  private String eTag;
+
+  private String type;
+
+  private Link readLink;
+
+  private Link editLink;
+
+  private final List<Link> associationLinks = new ArrayList<Link>();
+
+  private final List<Link> navigationLinks = new ArrayList<Link>();
+
+  private final List<Link> mediaEditLinks = new ArrayList<Link>();
+
+  private final List<ODataOperation> operations = new ArrayList<ODataOperation>();
+
+  private final List<Property> properties = new ArrayList<Property>();
+
+  private URI mediaContentSource;
+
+  private String mediaContentType;
+
+  private String mediaETag;
+
+  @Override
+  public String getETag() {
+    return eTag;
+  }
+
+  public void setETag(final String eTag) {
+    this.eTag = eTag;
+  }
+
+  @Override
+  public String getType() {
+    return type;
+  }
+
+  @Override
+  public void setType(final String type) {
+    this.type = type;
+  }
+
+  @Override
+  public Link getSelfLink() {
+    return readLink;
+  }
+
+  @Override
+  public void setSelfLink(final Link readLink) {
+    this.readLink = readLink;
+  }
+
+  @Override
+  public Link getEditLink() {
+    return editLink;
+  }
+
+  @Override
+  public void setEditLink(final Link editLink) {
+    this.editLink = editLink;
+  }
+
+  private Link getOneByTitle(final String name, final List<Link> links) {
+    Link result = null;
+
+    for (Link link : links) {
+      if (name.equals(link.getTitle())) {
+        result = link;
+      }
+    }
+
+    return result;
+  }
+
+  @Override
+  public Link getAssociationLink(final String name) {
+    return getOneByTitle(name, associationLinks);
+  }
+
+  @Override
+  public List<Link> getAssociationLinks() {
+    return associationLinks;
+  }
+
+  @Override
+  public Link getNavigationLink(final String name) {
+    return getOneByTitle(name, navigationLinks);
+  }
+
+  @Override
+  public List<Link> getNavigationLinks() {
+    return navigationLinks;
+  }
+
+  @Override
+  public List<Link> getMediaEditLinks() {
+    return mediaEditLinks;
+  }
+
+  @Override
+  public List<ODataOperation> getOperations() {
+    return operations;
+  }
+
+  @Override
+  public List<Property> getProperties() {
+    return properties;
+  }
+
+  @Override
+  public Property getProperty(final String name) {
+    Property result = null;
+
+    for (Property property : properties) {
+      if (name.equals(property.getName())) {
+        result = property;
+      }
+    }
+
+    return result;
+  }
+
+  @Override
+  public String getMediaContentType() {
+    return this.mediaContentType;
+  }
+
+  @Override
+  public void setMediaContentType(final String mediaContentType) {
+    this.mediaContentType = mediaContentType;
+  }
+
+  @Override
+  public URI getMediaContentSource() {
+    return this.mediaContentSource;
+  }
+
+  @Override
+  public void setMediaContentSource(final URI mediaContentSource) {
+    this.mediaContentSource = mediaContentSource;
+  }
+
+  @Override
+  public String getMediaETag() {
+    return mediaETag;
+  }
+
+  @Override
+  public void setMediaETag(final String eTag) {
+    this.mediaETag = eTag;
+  }
+
+  @Override
+  public boolean isMediaEntity() {
+    return this.mediaContentSource != null;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntitySetImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntitySetImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntitySetImpl.java
new file mode 100755
index 0000000..1920809
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntitySetImpl.java
@@ -0,0 +1,74 @@
+/*
+ * 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.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
+
+public class EntitySetImpl extends AbstractODataObject implements EntitySet {
+
+  private static final long serialVersionUID = -9159884750819150969L;
+
+  private Integer count;
+
+  private final List<Entity> entities = new ArrayList<Entity>();
+
+  private URI next;
+
+  private URI deltaLink;
+
+  @Override
+  public void setCount(final Integer count) {
+    this.count = count;
+  }
+
+  @Override
+  public Integer getCount() {
+    return count;
+  }
+
+  @Override
+  public List<Entity> getEntities() {
+    return entities;
+  }
+
+  @Override
+  public void setNext(final URI next) {
+    this.next = next;
+  }
+
+  @Override
+  public URI getNext() {
+    return next;
+  }
+
+  @Override
+  public URI getDeltaLink() {
+    return deltaLink;
+  }
+
+  @Override
+  public void setDeltaLink(final URI deltaLink) {
+    this.deltaLink = deltaLink;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/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
index f712e74..9ca82f1 100644
--- 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
@@ -18,37 +18,40 @@
  */
 package org.apache.olingo.commons.core.data;
 
-import org.apache.olingo.commons.core.data.v4.JSONDeltaImpl;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
 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;
 
-public class JSONDeltaDeserializer extends AbstractJsonDeserializer<JSONDeltaImpl> {
+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;
 
-  @Override
-  protected ResWrap<JSONDeltaImpl> doDeserialize(final JsonParser parser, final DeserializationContext ctxt)
-          throws IOException, JsonProcessingException {
+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 JSONDeltaImpl delta = new JSONDeltaImpl();
+    final DeltaImpl delta = new DeltaImpl();
 
-    final URI contextURL;
-    if (tree.hasNonNull(Constants.JSON_CONTEXT)) {
-      contextURL = URI.create(tree.get(Constants.JSON_CONTEXT).textValue());
-    } else {
-      contextURL = null;
-    }
+    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));
     }
@@ -64,17 +67,15 @@ public class JSONDeltaDeserializer extends AbstractJsonDeserializer<JSONDeltaImp
     }
 
     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;
+            ? ContextURL.getInstance(URI.create(item.get(Constants.JSON_CONTEXT).textValue())) : null;
         item.remove(Constants.JSON_CONTEXT);
 
         if (itemContextURL == null || itemContextURL.isEntity()) {
-          final ResWrap<JSONEntityImpl> entity = item.traverse(parser.getCodec()).
-                  readValueAs(new TypeReference<JSONEntityImpl>() {
-                  });
-          delta.getEntities().add(entity.getPayload());
+          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()) {
@@ -85,7 +86,15 @@ public class JSONDeltaDeserializer extends AbstractJsonDeserializer<JSONDeltaImp
       }
     }
 
-    return new ResWrap<JSONDeltaImpl>(contextURL, null, delta);
+    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);
+    }
+  }
 }