olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chall...@apache.org
Subject [07/23] [OLINGO-317] First presentable state
Date Tue, 24 Jun 2014 04:57:32 GMT
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.


Mime
View raw message