You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by il...@apache.org on 2014/04/29 10:59:36 UTC

[1/2] git commit: [OLINGO-259] Some refinements

Repository: olingo-odata4
Updated Branches:
  refs/heads/master 639941c00 -> 6c7aef90e


[OLINGO-259] Some refinements


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

Branch: refs/heads/master
Commit: e26d55d5bcd94038b9505db4a84007a97d0d9422
Parents: e8ac1c7
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Tue Apr 29 10:49:36 2014 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Tue Apr 29 10:49:36 2014 +0200

----------------------------------------------------------------------
 .../org/apache/olingo/fit/AbstractServices.java |  6 +-
 .../java/org/apache/olingo/fit/V4Services.java  | 78 +++++++++++++-------
 .../olingo/fit/utils/AbstractUtilities.java     | 29 ++++++--
 .../org/apache/olingo/fit/utils/Commons.java    |  5 +-
 .../client/core/op/AbstractODataBinder.java     |  2 +-
 .../client/core/op/impl/v4/ODataBinderImpl.java | 37 +++++++---
 .../core/op/impl/v4/ODataDeserializerImpl.java  |  4 +-
 .../client/core/it/v4/DeltaTestITCase.java      | 28 ++++---
 .../apache/olingo/client/core/v3/JSONTest.java  |  3 +
 .../olingo/client/core/v3/atom_cleanup.xsl      |  2 +-
 .../olingo/commons/api/data/DeletedEntity.java  | 36 ---------
 .../apache/olingo/commons/api/data/Delta.java   | 22 ++----
 .../olingo/commons/api/data/DeltaLink.java      | 36 ---------
 .../olingo/commons/api/data/EntitySet.java      | 14 ++++
 .../api/domain/v4/ODataDeletedEntity.java       | 36 +++++++++
 .../commons/api/domain/v4/ODataDelta.java       | 23 +-----
 .../commons/api/domain/v4/ODataDeltaLink.java   | 36 +++++++++
 .../commons/api/domain/v4/ODataEntitySet.java   | 14 ++++
 .../olingo/commons/core/data/AbstractDelta.java | 65 ----------------
 .../commons/core/data/AbstractEntitySet.java    | 13 ++++
 .../olingo/commons/core/data/AtomDeltaImpl.java | 25 -------
 .../commons/core/data/AtomDeserializer.java     | 27 +++++--
 .../commons/core/data/AtomSerializer.java       | 21 ++++--
 .../commons/core/data/DeletedEntityImpl.java    | 50 -------------
 .../olingo/commons/core/data/DeltaLinkImpl.java | 64 ----------------
 .../core/data/JSONDeltaDeserializer.java        |  9 ++-
 .../olingo/commons/core/data/JSONDeltaImpl.java | 28 -------
 .../core/data/JSONEntitySetDeserializer.java    |  3 +
 .../core/data/JSONEntitySetSerializer.java      | 12 ++-
 .../commons/core/data/v4/AbstractDelta.java     | 52 +++++++++++++
 .../commons/core/data/v4/AtomDeltaImpl.java     | 25 +++++++
 .../commons/core/data/v4/JSONDeltaImpl.java     | 29 ++++++++
 .../core/domain/v4/ODataDeletedEntityImpl.java  | 51 +++++++++++++
 .../commons/core/domain/v4/ODataDeltaImpl.java  | 28 ++-----
 .../core/domain/v4/ODataDeltaLinkImpl.java      | 65 ++++++++++++++++
 .../core/domain/v4/ODataEntitySetImpl.java      | 11 +++
 36 files changed, 547 insertions(+), 442 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/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 202d118..e43a37b 100644
--- a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
+++ b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
@@ -489,7 +489,7 @@ public abstract class AbstractServices {
 
       final InputStream res = getUtilities(acceptType).addOrReplaceEntity(entityId, entitySetName,
               IOUtils.toInputStream(entity, Constants.ENCODING),
-              xml.readEntry(acceptType, IOUtils.toInputStream(entity, Constants.ENCODING)));
+              xml.readEntity(acceptType, IOUtils.toInputStream(entity, Constants.ENCODING)));
 
       final ResWrap<AtomEntityImpl> cres;
       if (acceptType == Accept.ATOM) {
@@ -640,7 +640,7 @@ public abstract class AbstractServices {
       } else {
         response = xml.createResponse(
                 location,
-                xml.writeEntry(acceptType, result),
+                xml.writeEntity(acceptType, result),
                 null,
                 acceptType,
                 Response.Status.CREATED);
@@ -1077,7 +1077,7 @@ public abstract class AbstractServices {
 
       return xml.createResponse(
               location,
-              xml.writeEntry(utils.getKey(), container),
+              xml.writeEntity(utils.getKey(), container),
               Commons.getETag(entityInfo.getKey(), version),
               utils.getKey());
     } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/fit/src/main/java/org/apache/olingo/fit/V4Services.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/V4Services.java b/fit/src/main/java/org/apache/olingo/fit/V4Services.java
index 40111ee..72dd00e 100644
--- a/fit/src/main/java/org/apache/olingo/fit/V4Services.java
+++ b/fit/src/main/java/org/apache/olingo/fit/V4Services.java
@@ -26,6 +26,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStreamWriter;
 import java.net.URI;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -242,9 +243,9 @@ public class V4Services extends AbstractServices {
   }
 
   @Override
-  protected void setInlineCount(final EntitySet feed, final String count) {
+  protected void setInlineCount(final EntitySet entitySet, final String count) {
     if ("true".equals(count)) {
-      feed.setCount(feed.getEntities().size());
+      entitySet.setCount(entitySet.getEntities().size());
     }
   }
 
@@ -252,6 +253,7 @@ public class V4Services extends AbstractServices {
   public InputStream exploreMultipart(
           final List<Attachment> attachments, final String boundary, final boolean continueOnError)
           throws IOException {
+
     final ByteArrayOutputStream bos = new ByteArrayOutputStream();
 
     Response res = null;
@@ -346,31 +348,51 @@ public class V4Services extends AbstractServices {
 
   @GET
   @Path("/Customers")
-  public Response getEntitySet(
+  public Response getCustomers(
           @Context UriInfo uriInfo,
           @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
           @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
+          @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) String prefer,
           @QueryParam("$deltatoken") @DefaultValue(StringUtils.EMPTY) String deltatoken) {
 
-    if (StringUtils.isBlank(deltatoken)) {
-      return getEntitySet(uriInfo, accept, "Customers", null, null, format, null, null, null, null);
-    } else {
-      try {
-        final Accept acceptType;
-        if (StringUtils.isNotBlank(format)) {
-          acceptType = Accept.valueOf(format.toUpperCase());
-        } else {
-          acceptType = Accept.parse(accept, version);
+    try {
+      final Accept acceptType;
+      if (StringUtils.isNotBlank(format)) {
+        acceptType = Accept.valueOf(format.toUpperCase());
+      } else {
+        acceptType = Accept.parse(accept, version);
+      }
+
+      final InputStream output;
+      if (StringUtils.isBlank(deltatoken)) {
+        final InputStream input = (InputStream) getEntitySet(
+                uriInfo, accept, "Customers", null, null, format, null, null, null, null).getEntity();
+        final AtomEntitySetImpl entitySet = xml.readEntitySet(acceptType, input);
+
+        boolean trackChanges = prefer.contains("odata.track-changes");
+        if (trackChanges) {
+          entitySet.setDeltaLink(URI.create("Customers?$deltatoken=8015"));
         }
 
-        return xml.createResponse(
-                null,
-                FSManager.instance(version).readFile("delta", acceptType),
+        output = xml.writeEntitySet(acceptType, new ResWrap<AtomEntitySetImpl>(
+                URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + "Customers"),
                 null,
-                acceptType);
-      } catch (Exception e) {
-        return xml.createFaultResponse(accept, e);
+                entitySet));
+      } else {
+        output = FSManager.instance(version).readFile("delta", acceptType);
       }
+
+      final Response response = xml.createResponse(
+              null,
+              output,
+              null,
+              acceptType);
+      if (StringUtils.isNotBlank(prefer)) {
+        response.getHeaders().put("Preference-Applied", Collections.<Object>singletonList(prefer));
+      }
+      return response;
+    } catch (Exception e) {
+      return xml.createFaultResponse(accept, e);
     }
   }
 
@@ -422,7 +444,7 @@ public class V4Services extends AbstractServices {
       }
 
       final Accept contentTypeValue = Accept.parse(contentType, version);
-      final Entity entry = xml.readEntry(contentTypeValue, IOUtils.toInputStream(param, Constants.ENCODING));
+      final Entity entry = xml.readEntity(contentTypeValue, IOUtils.toInputStream(param, Constants.ENCODING));
 
       return xml.createResponse(
               null,
@@ -471,7 +493,7 @@ public class V4Services extends AbstractServices {
 
       return xml.createResponse(
               null,
-              xml.writeFeed(acceptType, container),
+              xml.writeEntitySet(acceptType, container),
               null,
               acceptType);
     } catch (Exception e) {
@@ -496,7 +518,7 @@ public class V4Services extends AbstractServices {
       }
 
       final Accept contentTypeValue = Accept.parse(contentType, version);
-      final Entity entry = xml.readEntry(contentTypeValue, IOUtils.toInputStream(param, Constants.ENCODING));
+      final Entity entry = xml.readEntity(contentTypeValue, IOUtils.toInputStream(param, Constants.ENCODING));
 
       assert 1 == entry.getProperties().size();
       assert entry.getProperty("accessRight") != null;
@@ -525,7 +547,7 @@ public class V4Services extends AbstractServices {
 
     try {
       final Accept contentTypeValue = Accept.parse(contentType, version);
-      final Entity entry = xml.readEntry(contentTypeValue, IOUtils.toInputStream(param, Constants.ENCODING));
+      final Entity entry = xml.readEntity(contentTypeValue, IOUtils.toInputStream(param, Constants.ENCODING));
 
       assert 2 == entry.getProperties().size();
       assert entry.getProperty("addresses") != null;
@@ -562,7 +584,7 @@ public class V4Services extends AbstractServices {
 
     try {
       final Accept contentTypeValue = Accept.parse(contentType, version);
-      final Entity entry = xml.readEntry(contentTypeValue, IOUtils.toInputStream(param, Constants.ENCODING));
+      final Entity entry = xml.readEntity(contentTypeValue, IOUtils.toInputStream(param, Constants.ENCODING));
 
       assert 1 == entry.getProperties().size();
       assert entry.getProperty("newDate") != null;
@@ -733,7 +755,7 @@ public class V4Services extends AbstractServices {
 
       return xml.createResponse(
               null,
-              xml.writeEntry(acceptType, container),
+              xml.writeEntity(acceptType, container),
               null,
               acceptType);
     } catch (Exception e) {
@@ -789,7 +811,7 @@ public class V4Services extends AbstractServices {
       final String atomEntryRelativePath = containedPath(entityId, containedEntitySetName).
               append('(').append(entityKey).append(')').toString();
       FSManager.instance(version).putInMemory(
-              utils.writeEntry(Accept.ATOM, entryContainer),
+              utils.writeEntity(Accept.ATOM, entryContainer),
               FSManager.instance(version).getAbsolutePath(atomEntryRelativePath, Accept.ATOM));
 
       // 3. Update the contained entity set
@@ -811,7 +833,7 @@ public class V4Services extends AbstractServices {
       // Finally, return
       return utils.createResponse(
               uriInfo.getRequestUri().toASCIIString() + "(" + entityKey + ")",
-              utils.writeEntry(acceptType, entryContainer),
+              utils.writeEntity(acceptType, entryContainer),
               null,
               acceptType,
               Response.Status.CREATED);
@@ -961,7 +983,7 @@ public class V4Services extends AbstractServices {
 
       return xml.createResponse(
               null,
-              xml.writeFeed(acceptType, container),
+              xml.writeEntitySet(acceptType, container),
               null,
               acceptType);
     } catch (Exception e) {
@@ -1207,7 +1229,7 @@ public class V4Services extends AbstractServices {
       }
 
       final Accept contentTypeValue = Accept.parse(contentType, version);
-      final Entity entry = xml.readEntry(contentTypeValue, IOUtils.toInputStream(param, Constants.ENCODING));
+      final Entity entry = xml.readEntity(contentTypeValue, IOUtils.toInputStream(param, Constants.ENCODING));
 
       assert 1 == entry.getProperties().size();
       assert "Collection(Edm.String)".equals(entry.getProperty("emails").getType());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/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 57e2049..770f97c 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
@@ -53,6 +53,7 @@ import org.apache.olingo.commons.core.data.AtomEntitySetImpl;
 import org.apache.olingo.commons.core.data.AtomPropertyImpl;
 import org.apache.olingo.commons.core.data.AtomSerializer;
 import org.apache.olingo.commons.core.data.JSONEntityImpl;
+import org.apache.olingo.commons.core.data.JSONEntitySetImpl;
 import org.apache.olingo.commons.core.data.JSONPropertyImpl;
 import org.apache.olingo.fit.UnsupportedMediaTypeException;
 import org.apache.olingo.fit.metadata.Metadata;
@@ -540,7 +541,25 @@ public abstract class AbstractUtilities {
     return builder.build();
   }
 
-  public InputStream writeFeed(final Accept accept, final ResWrap<AtomEntitySetImpl> container)
+  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 InputStream writeEntitySet(final Accept accept, final ResWrap<AtomEntitySetImpl> container)
           throws XMLStreamException, IOException {
 
     final StringWriter writer = new StringWriter();
@@ -557,7 +576,7 @@ public abstract class AbstractUtilities {
     return IOUtils.toInputStream(writer.toString(), Constants.ENCODING);
   }
 
-  public AtomEntityImpl readEntry(final Accept accept, final InputStream entity)
+  public AtomEntityImpl readEntity(final Accept accept, final InputStream entity)
           throws XMLStreamException, IOException {
 
     final AtomEntityImpl entry;
@@ -575,7 +594,7 @@ public abstract class AbstractUtilities {
     return entry;
   }
 
-  public InputStream writeEntry(final Accept accept, final ResWrap<AtomEntityImpl> container)
+  public InputStream writeEntity(final Accept accept, final ResWrap<AtomEntityImpl> container)
           throws XMLStreamException, IOException {
 
     final StringWriter writer = new StringWriter();
@@ -832,10 +851,10 @@ public abstract class AbstractUtilities {
     InputStream stream = fsManager.readFile(basePath + Constants.get(version, ConstantKey.ENTITY), acceptType);
     stream = replaceProperty(stream, changes, path, justValue);
 
-    final AtomEntityImpl entry = readEntry(acceptType, stream);
+    final AtomEntityImpl entry = readEntity(acceptType, stream);
     final ResWrap<AtomEntityImpl> container = new ResWrap<AtomEntityImpl>((URI) null, null, entry);
 
-    fsManager.putInMemory(writeEntry(Accept.ATOM, container),
+    fsManager.putInMemory(writeEntity(Accept.ATOM, container),
             fsManager.getAbsolutePath(basePath + Constants.get(version, ConstantKey.ENTITY), Accept.ATOM));
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/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 af15f2d..c6d055d 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
@@ -19,6 +19,8 @@
 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;
@@ -262,7 +264,8 @@ public abstract class Commons {
       IOUtils.copy(is, bos);
       IOUtils.closeQuietly(is);
 
-      final ObjectMapper mapper = new ObjectMapper();
+      final ObjectMapper mapper = new ObjectMapper(
+              new JsonFactory().configure(JsonParser.Feature.ALLOW_NUMERIC_LEADING_ZEROS, true));
       final JsonNode node =
               changeFormat((ObjectNode) mapper.readTree(new ByteArrayInputStream(bos.toByteArray())), version, target);
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
index 3107e8e..125cca4 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
@@ -114,7 +114,7 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
     if (next != null) {
       entitySet.setNext(next);
     }
-
+    
     for (CommonODataEntity entity : odataEntitySet.getEntities()) {
       entitySet.getEntities().add(getEntity(entity, ResourceFactory.entityClassForEntitySet(reference)));
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java
index 64ae222..6c7c888 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java
@@ -26,9 +26,9 @@ import org.apache.olingo.client.api.v4.EdmEnabledODataClient;
 import org.apache.olingo.client.api.v4.ODataClient;
 import org.apache.olingo.client.core.op.AbstractODataBinder;
 import org.apache.olingo.client.core.uri.URIUtils;
-import org.apache.olingo.commons.api.data.DeletedEntity;
+import org.apache.olingo.commons.api.domain.v4.ODataDeletedEntity;
 import org.apache.olingo.commons.api.data.Delta;
-import org.apache.olingo.commons.api.data.DeltaLink;
+import org.apache.olingo.commons.api.domain.v4.ODataDeltaLink;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntitySet;
 import org.apache.olingo.commons.api.data.LinkedComplexValue;
@@ -46,8 +46,8 @@ import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
 import org.apache.olingo.commons.api.domain.v4.ODataLinkedComplexValue;
 import org.apache.olingo.commons.api.domain.v4.ODataProperty;
 import org.apache.olingo.commons.api.edm.EdmComplexType;
-import org.apache.olingo.commons.core.data.DeletedEntityImpl;
-import org.apache.olingo.commons.core.data.DeltaLinkImpl;
+import org.apache.olingo.commons.core.domain.v4.ODataDeletedEntityImpl;
+import org.apache.olingo.commons.core.domain.v4.ODataDeltaLinkImpl;
 import org.apache.olingo.commons.core.data.EnumValueImpl;
 import org.apache.olingo.commons.core.data.LinkedComplexValueImpl;
 import org.apache.olingo.commons.core.domain.v4.ODataPropertyImpl;
@@ -96,6 +96,13 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
   }
 
   @Override
+  public EntitySet getEntitySet(final CommonODataEntitySet odataEntitySet, final Class<? extends EntitySet> reference) {
+    final EntitySet entitySet = super.getEntitySet(odataEntitySet, reference);
+    entitySet.setDeltaLink(((ODataEntitySet) odataEntitySet).getDeltaLink());
+    return entitySet;
+  }
+
+  @Override
   public Entity getEntity(final CommonODataEntity odataEntity, final Class<? extends Entity> reference) {
     final Entity entity = super.getEntity(odataEntity, reference);
     entity.setId(((ODataEntity) odataEntity).getReference());
@@ -152,7 +159,15 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
 
   @Override
   public ODataEntitySet getODataEntitySet(final ResWrap<EntitySet> resource) {
-    return (ODataEntitySet) super.getODataEntitySet(resource);
+    final ODataEntitySet entitySet = (ODataEntitySet) super.getODataEntitySet(resource);
+
+    if (resource.getPayload().getDeltaLink() != null) {
+      final URI base = resource.getContextURL() == null
+              ? resource.getPayload().getBaseURI() : resource.getContextURL().getServiceRoot();
+      entitySet.setDeltaLink(URIUtils.getURI(base, resource.getPayload().getDeltaLink()));
+    }
+
+    return entitySet;
   }
 
   @Override
@@ -225,24 +240,24 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
       add(delta, getODataEntity(
               new ResWrap<Entity>(resource.getContextURL(), resource.getMetadataETag(), entityResource)));
     }
-    for (DeletedEntity deletedEntity : resource.getPayload().getDeletedEntities()) {
-      final DeletedEntityImpl impl = new DeletedEntityImpl();
+    for (ODataDeletedEntity deletedEntity : resource.getPayload().getDeletedEntities()) {
+      final ODataDeletedEntityImpl impl = new ODataDeletedEntityImpl();
       impl.setId(URIUtils.getURI(base, deletedEntity.getId()));
       impl.setReason(deletedEntity.getReason());
 
       delta.getDeletedEntities().add(impl);
     }
 
-    for (DeltaLink link : resource.getPayload().getAddedLinks()) {
-      final DeltaLinkImpl impl = new DeltaLinkImpl();
+    for (ODataDeltaLink link : resource.getPayload().getAddedLinks()) {
+      final ODataDeltaLinkImpl impl = new ODataDeltaLinkImpl();
       impl.setRelationship(link.getRelationship());
       impl.setSource(URIUtils.getURI(base, link.getSource()));
       impl.setTarget(URIUtils.getURI(base, link.getTarget()));
 
       delta.getAddedLinks().add(impl);
     }
-    for (DeltaLink link : resource.getPayload().getDeletedLinks()) {
-      final DeltaLinkImpl impl = new DeltaLinkImpl();
+    for (ODataDeltaLink link : resource.getPayload().getDeletedLinks()) {
+      final ODataDeltaLinkImpl impl = new ODataDeltaLinkImpl();
       impl.setRelationship(link.getRelationship());
       impl.setSource(URIUtils.getURI(base, link.getSource()));
       impl.setTarget(URIUtils.getURI(base, link.getTarget()));

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataDeserializerImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataDeserializerImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataDeserializerImpl.java
index ae7d5cd..0e0f72c 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataDeserializerImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataDeserializerImpl.java
@@ -33,8 +33,8 @@ import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.core.op.AbstractODataDeserializer;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.core.data.AtomDeltaImpl;
-import org.apache.olingo.commons.core.data.JSONDeltaImpl;
+import org.apache.olingo.commons.core.data.v4.AtomDeltaImpl;
+import org.apache.olingo.commons.core.data.v4.JSONDeltaImpl;
 
 public class ODataDeserializerImpl extends AbstractODataDeserializer implements ODataDeserializer {
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/DeltaTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/DeltaTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/DeltaTestITCase.java
index f0f8fca..49dc262 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/DeltaTestITCase.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/DeltaTestITCase.java
@@ -18,24 +18,35 @@
  */
 package org.apache.olingo.client.core.it.v4;
 
-import java.net.URI;
+import org.apache.olingo.client.api.communication.header.ODataPreferences;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
 import org.apache.olingo.client.api.communication.request.retrieve.v4.ODataDeltaRequest;
 import org.apache.olingo.commons.api.domain.v4.ODataDelta;
+import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
 import org.apache.olingo.commons.api.domain.v4.ODataProperty;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
 import org.junit.Test;
 
 public class DeltaTestITCase extends AbstractTestITCase {
 
   private void parse(final ODataPubFormat format) {
-    final URI deltaLink = URI.create(testStaticServiceRootURL + "/Customers?$expand=Orders&$deltatoken=565656");
-    final ODataDeltaRequest req = client.getRetrieveRequestFactory().getDeltaRequest(deltaLink);
-    req.setFormat(format);
+    final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().getEntitySetRequest(
+            client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customers").build());
+    req.setPrefer(client.newPreferences().trackChanges());
+    
+    final ODataEntitySet customers = req.execute().getBody();
+    assertNotNull(customers);
+    assertNotNull(customers.getDeltaLink());
 
-    final ODataDelta delta = req.execute().getBody();
+    final ODataDeltaRequest deltaReq = client.getRetrieveRequestFactory().getDeltaRequest(customers.getDeltaLink());
+    deltaReq.setFormat(format);
+
+    final ODataDelta delta = deltaReq.execute().getBody();
     assertNotNull(delta);
 
     assertNotNull(delta.getDeltaLink());
@@ -73,6 +84,5 @@ public class DeltaTestITCase extends AbstractTestITCase {
   @Test
   public void jsonParse() {
     parse(ODataPubFormat.JSON);
-
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/JSONTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/JSONTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/JSONTest.java
index 1434008..ccc458c 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/JSONTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/JSONTest.java
@@ -70,6 +70,9 @@ public class JSONTest extends AtomTest {
     if (node.has(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIA_CONTENT_TYPE))) {
       node.remove(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIA_CONTENT_TYPE));
     }
+    if (node.has(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_NEXT_LINK))) {
+      node.remove(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_NEXT_LINK));
+    }
     final List<String> toRemove = new ArrayList<String>();
     for (final Iterator<Map.Entry<String, JsonNode>> itor = node.fields(); itor.hasNext();) {
       final Map.Entry<String, JsonNode> field = itor.next();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/lib/client-core/src/test/resources/org/apache/olingo/client/core/v3/atom_cleanup.xsl
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v3/atom_cleanup.xsl b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v3/atom_cleanup.xsl
index a518fcb..49900e7 100644
--- a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v3/atom_cleanup.xsl
+++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v3/atom_cleanup.xsl
@@ -34,7 +34,7 @@
       </title>
     </xsl:if>
   </xsl:template>
-  <xsl:template match="atom:link[@rel = 'self' or @rel = 'edit' or @rel = 'edit-media']"/>
+  <xsl:template match="atom:link[@rel = 'self' or @rel = 'edit' or @rel = 'edit-media' or @rel = 'next']"/>
   
   <xsl:template match="m:action"/>
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeletedEntity.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeletedEntity.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeletedEntity.java
deleted file mode 100644
index 49ef737..0000000
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeletedEntity.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.api.data;
-
-import java.net.URI;
-
-public interface DeletedEntity {
-
-  enum Reason {
-
-    deleted,
-    changed;
-
-  }
-
-  URI getId();
-
-  Reason getReason();
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Delta.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Delta.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Delta.java
index 066033a..2b80220 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Delta.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Delta.java
@@ -18,28 +18,16 @@
  */
 package org.apache.olingo.commons.api.data;
 
-import java.net.URI;
+import org.apache.olingo.commons.api.domain.v4.ODataDeletedEntity;
+import org.apache.olingo.commons.api.domain.v4.ODataDeltaLink;
 import java.util.List;
 
 public interface Delta extends EntitySet {
 
-  List<DeletedEntity> getDeletedEntities();
+  List<ODataDeletedEntity> getDeletedEntities();
 
-  List<DeltaLink> getAddedLinks();
+  List<ODataDeltaLink> getAddedLinks();
 
-  List<DeltaLink> getDeletedLinks();
+  List<ODataDeltaLink> getDeletedLinks();
 
-  /**
-   * Gets delta link if exists.
-   *
-   * @return delta link if exists; null otherwise.
-   */
-  URI getDeltaLink();
-
-  /**
-   * Sets delta link.
-   *
-   * @param deltaLink delta link.
-   */
-  void setDeltaLink(URI deltaLink);
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeltaLink.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeltaLink.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeltaLink.java
deleted file mode 100644
index a280165..0000000
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeltaLink.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.api.data;
-
-import java.net.URI;
-
-public interface DeltaLink {
-
-  URI getSource();
-
-  void setSource(URI source);
-
-  String getRelationship();
-
-  void setRelationship(String relationship);
-
-  URI getTarget();
-
-  void setTarget(URI target);
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EntitySet.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EntitySet.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EntitySet.java
index 0812acf..ce798a9 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EntitySet.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EntitySet.java
@@ -71,4 +71,18 @@ public interface EntitySet {
    * @param next next link.
    */
   void setNext(URI next);
+
+  /**
+   * Gets delta link if exists.
+   *
+   * @return delta link if exists; null otherwise.
+   */
+  URI getDeltaLink();
+
+  /**
+   * Sets delta link.
+   *
+   * @param deltaLink delta link.
+   */
+  void setDeltaLink(URI deltaLink);
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataDeletedEntity.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataDeletedEntity.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataDeletedEntity.java
new file mode 100644
index 0000000..fcb6b40
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataDeletedEntity.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.api.domain.v4;
+
+import java.net.URI;
+
+public interface ODataDeletedEntity {
+
+  enum Reason {
+
+    deleted,
+    changed;
+
+  }
+
+  URI getId();
+
+  Reason getReason();
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataDelta.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataDelta.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataDelta.java
index f6b0b4f..14219be 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataDelta.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataDelta.java
@@ -18,31 +18,14 @@
  */
 package org.apache.olingo.commons.api.domain.v4;
 
-import java.net.URI;
 import java.util.List;
-import org.apache.olingo.commons.api.data.DeletedEntity;
-import org.apache.olingo.commons.api.data.DeltaLink;
 
 public interface ODataDelta extends ODataEntitySet {
 
-  List<DeletedEntity> getDeletedEntities();
+  List<ODataDeletedEntity> getDeletedEntities();
 
-  List<DeltaLink> getAddedLinks();
+  List<ODataDeltaLink> getAddedLinks();
 
-  List<DeltaLink> getDeletedLinks();
-
-  /**
-   * Gets delta link if exists.
-   *
-   * @return delta link if exists; null otherwise.
-   */
-  URI getDeltaLink();
-
-  /**
-   * Sets delta link.
-   *
-   * @param deltaLink delta link.
-   */
-  void setDeltaLink(URI deltaLink);
+  List<ODataDeltaLink> getDeletedLinks();
 
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataDeltaLink.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataDeltaLink.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataDeltaLink.java
new file mode 100644
index 0000000..d42e2d6
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataDeltaLink.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.api.domain.v4;
+
+import java.net.URI;
+
+public interface ODataDeltaLink {
+
+  URI getSource();
+
+  void setSource(URI source);
+
+  String getRelationship();
+
+  void setRelationship(String relationship);
+
+  URI getTarget();
+
+  void setTarget(URI target);
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataEntitySet.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataEntitySet.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataEntitySet.java
index 97ac192..cd06f44 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataEntitySet.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataEntitySet.java
@@ -18,6 +18,7 @@
  */
 package org.apache.olingo.commons.api.domain.v4;
 
+import java.net.URI;
 import java.util.List;
 import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
 
@@ -26,4 +27,17 @@ public interface ODataEntitySet extends CommonODataEntitySet {
   @Override
   List<ODataEntity> getEntities();
 
+  /**
+   * Gets delta link if exists.
+   *
+   * @return delta link if exists; null otherwise.
+   */
+  URI getDeltaLink();
+
+  /**
+   * Sets delta link.
+   *
+   * @param deltaLink delta link.
+   */
+  void setDeltaLink(URI deltaLink);
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractDelta.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractDelta.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractDelta.java
deleted file mode 100644
index 73a65b7..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractDelta.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.data;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.olingo.commons.api.data.DeletedEntity;
-import org.apache.olingo.commons.api.data.Delta;
-import org.apache.olingo.commons.api.data.DeltaLink;
-
-public abstract class AbstractDelta extends AbstractEntitySet implements Delta {
-
-  private static final long serialVersionUID = 4576771708961553195L;
-
-  private final List<DeletedEntity> deletedEntities = new ArrayList<DeletedEntity>();
-
-  private final List<DeltaLink> addedLinks = new ArrayList<DeltaLink>();
-
-  private final List<DeltaLink> deletedLinks = new ArrayList<DeltaLink>();
-
-  private URI deltaLink;
-
-  @Override
-  public List<DeletedEntity> getDeletedEntities() {
-    return deletedEntities;
-  }
-
-  @Override
-  public List<DeltaLink> getAddedLinks() {
-    return addedLinks;
-  }
-
-  @Override
-  public List<DeltaLink> getDeletedLinks() {
-    return deletedLinks;
-  }
-
-  @Override
-  public URI getDeltaLink() {
-    return deltaLink;
-  }
-
-  @Override
-  public void setDeltaLink(final URI deltaLink) {
-    this.deltaLink = deltaLink;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractEntitySet.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractEntitySet.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractEntitySet.java
index b640812..510c22a 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractEntitySet.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractEntitySet.java
@@ -34,6 +34,8 @@ public abstract class AbstractEntitySet extends AbstractODataObject implements E
 
   private URI next;
 
+  private URI deltaLink;
+
   @Override
   public void setCount(final Integer count) {
     this.count = count;
@@ -58,4 +60,15 @@ public abstract class AbstractEntitySet extends AbstractODataObject implements E
   public URI getNext() {
     return next;
   }
+
+  @Override
+  public URI getDeltaLink() {
+    return deltaLink;
+  }
+
+  @Override
+  public void setDeltaLink(final URI deltaLink) {
+    this.deltaLink = deltaLink;
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomDeltaImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomDeltaImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomDeltaImpl.java
deleted file mode 100644
index 165299b..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomDeltaImpl.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.data;
-
-public class AtomDeltaImpl extends AbstractDelta {
-
-  private static final long serialVersionUID = -730729098008847535L;
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomDeserializer.java
index fdbfb48..cd1852a 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomDeserializer.java
@@ -18,6 +18,9 @@
  */
 package org.apache.olingo.commons.core.data;
 
+import org.apache.olingo.commons.core.data.v4.AtomDeltaImpl;
+import org.apache.olingo.commons.core.domain.v4.ODataDeltaLinkImpl;
+import org.apache.olingo.commons.core.domain.v4.ODataDeletedEntityImpl;
 import java.io.InputStream;
 import java.net.URI;
 import java.text.ParseException;
@@ -31,7 +34,7 @@ import javax.xml.stream.events.XMLEvent;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.data.CollectionValue;
-import org.apache.olingo.commons.api.data.DeletedEntity.Reason;
+import org.apache.olingo.commons.api.domain.v4.ODataDeletedEntity.Reason;
 import org.apache.olingo.commons.api.data.EntitySet;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.data.Value;
@@ -417,7 +420,7 @@ public class AtomDeserializer extends AbstractAtomDealer {
         } else if (Constants.QNAME_ATOM_ELEM_ENTRY.equals(event.asStartElement().getName())) {
           delta.getEntities().add(entity(reader, event.asStartElement()));
         } else if (deletedEntryQName.equals(event.asStartElement().getName())) {
-          final DeletedEntityImpl deletedEntity = new DeletedEntityImpl();
+          final ODataDeletedEntityImpl deletedEntity = new ODataDeletedEntityImpl();
 
           final Attribute ref = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REF));
           if (ref != null) {
@@ -432,13 +435,13 @@ public class AtomDeserializer extends AbstractAtomDealer {
         } else if (linkQName.equals(event.asStartElement().getName())
                 || deletedLinkQName.equals(event.asStartElement().getName())) {
 
-          final DeltaLinkImpl link = new DeltaLinkImpl();
+          final ODataDeltaLinkImpl link = new ODataDeltaLinkImpl();
 
           final Attribute source = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_SOURCE));
           if (source != null) {
             link.setSource(URI.create(source.getValue()));
           }
-          final Attribute relationship = 
+          final Attribute relationship =
                   event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_RELATIONSHIP));
           if (relationship != null) {
             link.setRelationship(relationship.getValue());
@@ -699,10 +702,18 @@ public class AtomDeserializer extends AbstractAtomDealer {
           common(reader, event.asStartElement(), entitySet, "updated");
         } else if (Constants.QNAME_ATOM_ELEM_LINK.equals(event.asStartElement().getName())) {
           final Attribute rel = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REL));
-          if (rel != null && Constants.NEXT_LINK_REL.equals(rel.getValue())) {
-            final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
-            if (href != null) {
-              entitySet.setNext(URI.create(href.getValue()));
+          if (rel != null) {
+            if (Constants.NEXT_LINK_REL.equals(rel.getValue())) {
+              final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
+              if (href != null) {
+                entitySet.setNext(URI.create(href.getValue()));
+              }
+            }
+            if (Constants.DELTA_LINK_REL.equals(rel.getValue())) {
+              final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
+              if (href != null) {
+                entitySet.setDeltaLink(URI.create(href.getValue()));
+              }
             }
           }
         } else if (Constants.QNAME_ATOM_ELEM_ENTRY.equals(event.asStartElement().getName())) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomSerializer.java
index 279e3fe..68782d4 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomSerializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomSerializer.java
@@ -256,7 +256,7 @@ public class AtomSerializer extends AbstractAtomDealer {
     if (serverMode) {
       for (ODataOperation operation : entity.getOperations()) {
         writer.writeStartElement(
-                version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ELEM_ACTION);        
+                version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ELEM_ACTION);
         writer.writeAttribute(Constants.ATTR_METADATA, operation.getMetadataAnchor());
         writer.writeAttribute(Constants.ATTR_TITLE, operation.getTitle());
         writer.writeAttribute(Constants.ATTR_TARGET, operation.getTarget().toASCIIString());
@@ -373,12 +373,21 @@ public class AtomSerializer extends AbstractAtomDealer {
       }
     }
 
-    if (entitySet.getNext() != null) {
-      final LinkImpl next = new LinkImpl();
-      next.setRel(Constants.NEXT_LINK_REL);
-      next.setHref(entitySet.getNext().toASCIIString());
+    if (serverMode) {
+      if (entitySet.getNext() != null) {
+        final LinkImpl next = new LinkImpl();
+        next.setRel(Constants.NEXT_LINK_REL);
+        next.setHref(entitySet.getNext().toASCIIString());
+
+        links(writer, Collections.<Link>singletonList(next));
+      }
+      if (entitySet.getDeltaLink() != null) {
+        final LinkImpl next = new LinkImpl();
+        next.setRel(Constants.DELTA_LINK_REL);
+        next.setHref(entitySet.getDeltaLink().toASCIIString());
 
-      links(writer, Collections.<Link>singletonList(next));
+        links(writer, Collections.<Link>singletonList(next));
+      }
     }
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeletedEntityImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeletedEntityImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeletedEntityImpl.java
deleted file mode 100644
index d3cbdf5..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeletedEntityImpl.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.data;
-
-import java.net.URI;
-import org.apache.olingo.commons.api.data.DeletedEntity;
-
-public class DeletedEntityImpl extends AbstractPayloadObject implements DeletedEntity {
-
-  private static final long serialVersionUID = -3841730551749114664L;
-
-  private URI id;
-
-  private Reason reason;
-
-  @Override
-  public URI getId() {
-    return id;
-  }
-
-  public void setId(final URI id) {
-    this.id = id;
-  }
-
-  @Override
-  public Reason getReason() {
-    return reason;
-  }
-
-  public void setReason(final Reason reason) {
-    this.reason = reason;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaLinkImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaLinkImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaLinkImpl.java
deleted file mode 100644
index 972c6c6..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaLinkImpl.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.data;
-
-import java.net.URI;
-import org.apache.olingo.commons.api.data.DeltaLink;
-
-public class DeltaLinkImpl extends AbstractPayloadObject implements DeltaLink {
-
-  private static final long serialVersionUID = -6686550836508873044L;
-
-  private URI source;
-
-  private String relationship;
-
-  private URI target;
-
-  @Override
-  public URI getSource() {
-    return source;
-  }
-
-  @Override
-  public void setSource(final URI source) {
-    this.source = source;
-  }
-
-  @Override
-  public String getRelationship() {
-    return relationship;
-  }
-
-  @Override
-  public void setRelationship(String relationship) {
-    this.relationship = relationship;
-  }
-
-  @Override
-  public URI getTarget() {
-    return target;
-  }
-
-  @Override
-  public void setTarget(URI target) {
-    this.target = target;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONDeltaDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONDeltaDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONDeltaDeserializer.java
index a141111..6b7f121 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONDeltaDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONDeltaDeserializer.java
@@ -18,6 +18,9 @@
  */
 package org.apache.olingo.commons.core.data;
 
+import org.apache.olingo.commons.core.data.v4.JSONDeltaImpl;
+import org.apache.olingo.commons.core.domain.v4.ODataDeltaLinkImpl;
+import org.apache.olingo.commons.core.domain.v4.ODataDeletedEntityImpl;
 import com.fasterxml.jackson.core.JsonParser;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.core.type.TypeReference;
@@ -76,13 +79,13 @@ public class JSONDeltaDeserializer extends AbstractJsonDeserializer<JSONDeltaImp
           delta.getEntities().add(entity.getPayload());
         } else if (itemContextURL.isDeltaDeletedEntity()) {
           delta.getDeletedEntities().
-                  add(parser.getCodec().treeToValue(item, DeletedEntityImpl.class));
+                  add(parser.getCodec().treeToValue(item, ODataDeletedEntityImpl.class));
         } else if (itemContextURL.isDeltaLink()) {
           delta.getAddedLinks().
-                  add(parser.getCodec().treeToValue(item, DeltaLinkImpl.class));
+                  add(parser.getCodec().treeToValue(item, ODataDeltaLinkImpl.class));
         } else if (itemContextURL.isDeltaDeletedLink()) {
           delta.getDeletedLinks().
-                  add(parser.getCodec().treeToValue(item, DeltaLinkImpl.class));
+                  add(parser.getCodec().treeToValue(item, ODataDeltaLinkImpl.class));
         }
       }
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONDeltaImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONDeltaImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONDeltaImpl.java
deleted file mode 100644
index d684069..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONDeltaImpl.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.data;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-
-@JsonDeserialize(using = JSONDeltaDeserializer.class)
-public class JSONDeltaImpl extends AbstractDelta {
-
-  private static final long serialVersionUID = -7948494801560470246L;
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetDeserializer.java
index 044e269..df5d40a 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetDeserializer.java
@@ -78,6 +78,9 @@ public class JSONEntitySetDeserializer extends AbstractJsonDeserializer<JSONEnti
     if (tree.hasNonNull(jsonNextLink)) {
       entitySet.setNext(URI.create(tree.get(jsonNextLink).textValue()));
     }
+    if (tree.hasNonNull(jsonDeltaLink)) {
+      entitySet.setDeltaLink(URI.create(tree.get(jsonDeltaLink).textValue()));
+    }
 
     if (tree.hasNonNull(Constants.VALUE)) {
       for (final Iterator<JsonNode> itor = tree.get(Constants.VALUE).iterator(); itor.hasNext();) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetSerializer.java
index 1e16fa8..f3195ab 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetSerializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetSerializer.java
@@ -67,9 +67,15 @@ public class JSONEntitySetSerializer extends AbstractJsonSerializer<JSONEntitySe
     }
     jgen.writeNumberField(version.getJSONMap().get(ODataServiceVersion.JSON_COUNT),
             entitySet.getCount() == null ? entitySet.getEntities().size() : entitySet.getCount());
-    if (entitySet.getNext() != null) {
-      jgen.writeStringField(
-              version.getJSONMap().get(ODataServiceVersion.JSON_NEXT_LINK), entitySet.getNext().toASCIIString());
+    if (serverMode) {
+      if (entitySet.getNext() != null) {
+        jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_NEXT_LINK),
+                entitySet.getNext().toASCIIString());
+      }
+      if (entitySet.getDeltaLink() != null) {
+        jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_DELTA_LINK),
+                entitySet.getDeltaLink().toASCIIString());
+      }
     }
 
     jgen.writeArrayFieldStart(Constants.VALUE);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/AbstractDelta.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/AbstractDelta.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/AbstractDelta.java
new file mode 100644
index 0000000..c2df46c
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/AbstractDelta.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.core.data.v4;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.olingo.commons.api.domain.v4.ODataDeletedEntity;
+import org.apache.olingo.commons.api.data.Delta;
+import org.apache.olingo.commons.api.domain.v4.ODataDeltaLink;
+import org.apache.olingo.commons.core.data.AbstractEntitySet;
+
+public abstract class AbstractDelta extends AbstractEntitySet implements Delta {
+
+  private static final long serialVersionUID = 4576771708961553195L;
+
+  private final List<ODataDeletedEntity> deletedEntities = new ArrayList<ODataDeletedEntity>();
+
+  private final List<ODataDeltaLink> addedLinks = new ArrayList<ODataDeltaLink>();
+
+  private final List<ODataDeltaLink> deletedLinks = new ArrayList<ODataDeltaLink>();
+
+  @Override
+  public List<ODataDeletedEntity> getDeletedEntities() {
+    return deletedEntities;
+  }
+
+  @Override
+  public List<ODataDeltaLink> getAddedLinks() {
+    return addedLinks;
+  }
+
+  @Override
+  public List<ODataDeltaLink> getDeletedLinks() {
+    return deletedLinks;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/AtomDeltaImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/AtomDeltaImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/AtomDeltaImpl.java
new file mode 100644
index 0000000..d2f85b2
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/AtomDeltaImpl.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.core.data.v4;
+
+public class AtomDeltaImpl extends AbstractDelta {
+
+  private static final long serialVersionUID = -730729098008847535L;
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/JSONDeltaImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/JSONDeltaImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/JSONDeltaImpl.java
new file mode 100644
index 0000000..7b60d5f
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/JSONDeltaImpl.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.core.data.v4;
+
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import org.apache.olingo.commons.core.data.JSONDeltaDeserializer;
+
+@JsonDeserialize(using = JSONDeltaDeserializer.class)
+public class JSONDeltaImpl extends AbstractDelta {
+
+  private static final long serialVersionUID = -7948494801560470246L;
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataDeletedEntityImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataDeletedEntityImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataDeletedEntityImpl.java
new file mode 100644
index 0000000..23bfdf5
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataDeletedEntityImpl.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.core.domain.v4;
+
+import java.net.URI;
+import org.apache.olingo.commons.api.domain.v4.ODataDeletedEntity;
+import org.apache.olingo.commons.core.data.AbstractPayloadObject;
+
+public class ODataDeletedEntityImpl extends AbstractPayloadObject implements ODataDeletedEntity {
+
+  private static final long serialVersionUID = -3841730551749114664L;
+
+  private URI id;
+
+  private Reason reason;
+
+  @Override
+  public URI getId() {
+    return id;
+  }
+
+  public void setId(final URI id) {
+    this.id = id;
+  }
+
+  @Override
+  public Reason getReason() {
+    return reason;
+  }
+
+  public void setReason(final Reason reason) {
+    this.reason = reason;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataDeltaImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataDeltaImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataDeltaImpl.java
index b226be8..8aeeaf9 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataDeltaImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataDeltaImpl.java
@@ -21,21 +21,19 @@ package org.apache.olingo.commons.core.domain.v4;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.List;
-import org.apache.olingo.commons.api.data.DeletedEntity;
-import org.apache.olingo.commons.api.data.DeltaLink;
+import org.apache.olingo.commons.api.domain.v4.ODataDeletedEntity;
+import org.apache.olingo.commons.api.domain.v4.ODataDeltaLink;
 import org.apache.olingo.commons.api.domain.v4.ODataDelta;
 
 public class ODataDeltaImpl extends ODataEntitySetImpl implements ODataDelta {
 
   private static final long serialVersionUID = -418357452933455313L;
 
-  private URI deltaLink;
+  private final List<ODataDeletedEntity> deletedEntities = new ArrayList<ODataDeletedEntity>();
 
-  private final List<DeletedEntity> deletedEntities = new ArrayList<DeletedEntity>();
+  private final List<ODataDeltaLink> addedLinks = new ArrayList<ODataDeltaLink>();
 
-  private final List<DeltaLink> addedLinks = new ArrayList<DeltaLink>();
-
-  private final List<DeltaLink> deletedLinks = new ArrayList<DeltaLink>();
+  private final List<ODataDeltaLink> deletedLinks = new ArrayList<ODataDeltaLink>();
 
   public ODataDeltaImpl() {
     super();
@@ -46,28 +44,18 @@ public class ODataDeltaImpl extends ODataEntitySetImpl implements ODataDelta {
   }
 
   @Override
-  public List<DeletedEntity> getDeletedEntities() {
+  public List<ODataDeletedEntity> getDeletedEntities() {
     return deletedEntities;
   }
 
   @Override
-  public List<DeltaLink> getAddedLinks() {
+  public List<ODataDeltaLink> getAddedLinks() {
     return addedLinks;
   }
 
   @Override
-  public List<DeltaLink> getDeletedLinks() {
+  public List<ODataDeltaLink> getDeletedLinks() {
     return deletedLinks;
   }
 
-  @Override
-  public URI getDeltaLink() {
-    return deltaLink;
-  }
-
-  @Override
-  public void setDeltaLink(final URI deltaLink) {
-    this.deltaLink = deltaLink;
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataDeltaLinkImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataDeltaLinkImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataDeltaLinkImpl.java
new file mode 100644
index 0000000..0c549ac
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataDeltaLinkImpl.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.core.domain.v4;
+
+import java.net.URI;
+import org.apache.olingo.commons.api.domain.v4.ODataDeltaLink;
+import org.apache.olingo.commons.core.data.AbstractPayloadObject;
+
+public class ODataDeltaLinkImpl extends AbstractPayloadObject implements ODataDeltaLink {
+
+  private static final long serialVersionUID = -6686550836508873044L;
+
+  private URI source;
+
+  private String relationship;
+
+  private URI target;
+
+  @Override
+  public URI getSource() {
+    return source;
+  }
+
+  @Override
+  public void setSource(final URI source) {
+    this.source = source;
+  }
+
+  @Override
+  public String getRelationship() {
+    return relationship;
+  }
+
+  @Override
+  public void setRelationship(String relationship) {
+    this.relationship = relationship;
+  }
+
+  @Override
+  public URI getTarget() {
+    return target;
+  }
+
+  @Override
+  public void setTarget(URI target) {
+    this.target = target;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e26d55d5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataEntitySetImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataEntitySetImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataEntitySetImpl.java
index cbc5a04..81a795b 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataEntitySetImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataEntitySetImpl.java
@@ -31,6 +31,8 @@ public class ODataEntitySetImpl extends AbstractODataEntitySet implements ODataE
 
   private final List<ODataEntity> entities = new ArrayList<ODataEntity>();
 
+  private URI deltaLink;
+
   public ODataEntitySetImpl() {
   }
 
@@ -48,4 +50,13 @@ public class ODataEntitySetImpl extends AbstractODataEntitySet implements ODataE
     return entities;
   }
 
+  @Override
+  public URI getDeltaLink() {
+    return deltaLink;
+  }
+
+  @Override
+  public void setDeltaLink(final URI deltaLink) {
+    this.deltaLink = deltaLink;
+  }
 }


[2/2] git commit: Merge from master

Posted by il...@apache.org.
Merge from master


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

Branch: refs/heads/master
Commit: 6c7aef90eae4eaf93ca948fe70ddd59bd20275ba
Parents: e26d55d 639941c
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Tue Apr 29 10:59:19 2014 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Tue Apr 29 10:59:19 2014 +0200

----------------------------------------------------------------------
 fit/pom.xml                                     |  14 ---
 .../org/apache/olingo/fit/AbstractServices.java | 117 ++++++++++++-------
 .../java/org/apache/olingo/fit/V3OpenType.java  |   3 +-
 .../java/org/apache/olingo/fit/V4OpenType.java  |   2 +-
 .../apache/olingo/fit/metadata/Metadata.java    |  50 +++++---
 .../olingo/fit/utils/AbstractUtilities.java     |  64 +++++-----
 .../org/apache/olingo/fit/utils/Commons.java    |   6 +-
 .../apache/olingo/fit/utils/ConstantKey.java    |   3 +
 .../org/apache/olingo/fit/utils/Constants.java  |  12 ++
 .../org/apache/olingo/fit/utils/XMLElement.java |   5 +-
 .../olingo/fit/utils/XMLEventReaderWrapper.java |  29 ++---
 .../apache/olingo/fit/utils/XMLUtilities.java   |  73 ++++++------
 fit/src/main/resources/V30/openTypeMetadata.xml |   2 +-
 .../client/core/it/v4/PropertyTestITCase.java   |  57 ++++++++-
 14 files changed, 268 insertions(+), 169 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6c7aef90/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
----------------------------------------------------------------------
diff --cc fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
index e43a37b,5ce5790..f3be7ce
--- a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
+++ b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
@@@ -1142,26 -1144,50 +1144,50 @@@ public abstract class AbstractServices 
            final String changes,
            final boolean justValue) {
  
+     // if the given path is not about any link then search for property
+     LOG.info("Retrieve property {}", path);
+ 
      try {
-       Accept acceptType = null;
-       if (StringUtils.isNotBlank(format)) {
-         acceptType = Accept.valueOf(format.toUpperCase());
-       } else if (StringUtils.isNotBlank(accept)) {
-         acceptType = Accept.parse(accept, version, null);
+       final FSManager fsManager = FSManager.instance(version);
+ 
+       final String basePath = Commons.getEntityBasePath(entitySetName, entityId);
 -      final ResWrap<AtomEntityImpl> container = xml.readContainerEntry(Accept.ATOM,
++      final ResWrap<AtomEntityImpl> container = xml.readContainerEntity(Accept.ATOM,
+               fsManager.readFile(basePath + Constants.get(version, ConstantKey.ENTITY), Accept.ATOM));
+ 
+       final AtomEntityImpl entry = container.getPayload();
+ 
+       Property toBeReplaced = null;
+       for (String element : path.split("/")) {
+         if (toBeReplaced == null) {
+           toBeReplaced = entry.getProperty(element.trim());
+         } else {
+           ComplexValue value = toBeReplaced.getValue().asComplex();
+           for (Property field : value.get()) {
+             if (field.getName().equalsIgnoreCase(element)) {
+               toBeReplaced = field;
+             }
+           }
+         }
        }
  
-       // if the given path is not about any link then search for property
-       LOG.info("Retrieve property {}", path);
+       if (toBeReplaced == null) {
+         throw new NotFoundException();
+       }
  
-       final AbstractUtilities utils = getUtilities(acceptType);
+       if (justValue) {
+         // just for primitive values
+         toBeReplaced.setValue(new PrimitiveValueImpl(changes));
+       } else {
+         final AtomPropertyImpl pchanges = xml.readProperty(
+                 Accept.parse(contentType, version),
+                 IOUtils.toInputStream(changes, Constants.ENCODING),
+                 entry.getType());
  
-       utils.replaceProperty(
-               entitySetName,
-               entityId,
-               IOUtils.toInputStream(changes, Constants.ENCODING),
-               Arrays.asList(path.split("/")),
-               acceptType,
-               justValue);
+         toBeReplaced.setValue(pchanges.getValue());
+       }
+ 
 -      fsManager.putInMemory(xml.writeEntry(Accept.ATOM, container),
++      fsManager.putInMemory(xml.writeEntity(Accept.ATOM, container),
+               fsManager.getAbsolutePath(basePath + Constants.get(version, ConstantKey.ENTITY), Accept.ATOM));
  
        final Response response;
        if ("return-content".equalsIgnoreCase(prefer)) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6c7aef90/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java
----------------------------------------------------------------------
diff --cc fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java
index 770f97c,2882784..f202fc4
--- a/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java
@@@ -576,25 -556,32 +575,32 @@@ public abstract class AbstractUtilitie
      return IOUtils.toInputStream(writer.toString(), Constants.ENCODING);
    }
  
-   public AtomEntityImpl readEntity(final Accept accept, final InputStream entity)
 -  public ResWrap<AtomEntityImpl> readContainerEntry(final Accept accept, final InputStream entity)
++  public ResWrap<AtomEntityImpl> readContainerEntity(final Accept accept, final InputStream entity)
            throws XMLStreamException, IOException {
- 
-     final AtomEntityImpl entry;
+     final ResWrap<AtomEntityImpl> container;
  
      if (accept == Accept.ATOM || accept == Accept.XML) {
-       final ResWrap<AtomEntityImpl> container = atomDeserializer.read(entity, AtomEntityImpl.class);
-       entry = container.getPayload();
+       container = atomDeserializer.read(entity, AtomEntityImpl.class);
      } else {
-       final ResWrap<JSONEntityImpl> container =
+       final ResWrap<JSONEntityImpl> jcontainer =
                mapper.readValue(entity, new TypeReference<JSONEntityImpl>() {
 -      });
 +              });
-       entry = dataBinder.toAtomEntity(container.getPayload());
+       container = new ResWrap<AtomEntityImpl>(
+               jcontainer.getContextURL(),
+               jcontainer.getMetadataETag(),
+               dataBinder.toAtomEntity(jcontainer.getPayload()));
      }
  
-     return entry;
+     return container;
+   }
+ 
 -  public AtomEntityImpl readEntry(final Accept accept, final InputStream entity)
++  public AtomEntityImpl readEntity(final Accept accept, final InputStream entity)
+           throws XMLStreamException, IOException {
 -    return readContainerEntry(accept, entity).getPayload();
+ 
++    return readContainerEntity(accept, entity).getPayload();
    }
  
 -  public InputStream writeEntry(final Accept accept, final ResWrap<AtomEntityImpl> container)
 +  public InputStream writeEntity(final Accept accept, final ResWrap<AtomEntityImpl> container)
            throws XMLStreamException, IOException {
  
      final StringWriter writer = new StringWriter();
@@@ -624,6 -611,23 +630,23 @@@
      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 InputStream writeProperty(final Accept accept, final ResWrap<AtomPropertyImpl> container)
            throws XMLStreamException, IOException {
  

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6c7aef90/fit/src/main/java/org/apache/olingo/fit/utils/Commons.java
----------------------------------------------------------------------