olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject [9/9] git commit: [OLINGO-317] First presentable state
Date Mon, 09 Jun 2014 12:47:27 GMT
[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/Olingo-317_DeSerializerRefactoring
Commit: 46a34178253d4a9d106d4d728f8ad812db05592a
Parents: 0e84b4c
Author: mibo <mibo@mirb.de>
Authored: Mon Jun 9 14:43:34 2014 +0200
Committer: mibo <mibo@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);


Mime
View raw message