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/02 15:29:55 UTC

[3/3] git commit: [OLINGO-230] Implementation completed

[OLINGO-230] Implementation completed


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

Branch: refs/heads/master
Commit: 16d3b0288690595f36f5c8ae25249ca0e4f8a96a
Parents: 6ae704d
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Wed Apr 2 15:29:34 2014 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Wed Apr 2 15:29:34 2014 +0200

----------------------------------------------------------------------
 .../olingo/client/api/op/v4/ODataBinder.java    |   2 +
 .../communication/request/ODataRequestImpl.java |   4 +-
 .../edm/AbstractEdmServiceMetadataImpl.java     |   2 +-
 .../client/core/op/AbstractODataBinder.java     | 127 +++++-----
 .../client/core/op/impl/v3/ODataBinderImpl.java |  10 +-
 .../client/core/op/impl/v4/ODataBinderImpl.java |  53 +++-
 .../apache/olingo/client/core/uri/URIUtils.java |  14 +-
 .../olingo/client/core/v4/EntityTest.java       |  28 +++
 .../apache/olingo/client/core/v4/JSONTest.java  |   5 +-
 .../olingo/client/core/v4/atom_cleanup.xsl      |   3 +-
 .../olingo/client/core/v4/entity.full.json      |  22 --
 .../core/v4/entity.withcomplexnavigation.json   |  22 ++
 .../core/v4/entity.withcomplexnavigation.xml    |  62 +++++
 .../apache/olingo/commons/api/data/Entry.java   |  16 +-
 .../apache/olingo/commons/api/data/Linked.java  |  38 +++
 .../commons/api/data/LinkedComplexValue.java    |  24 ++
 .../apache/olingo/commons/api/data/Value.java   |   4 +
 .../commons/api/domain/CommonODataEntity.java   |  76 ++----
 .../olingo/commons/api/domain/ODataLinked.java  |  70 ++++++
 .../api/domain/v4/ODataLinkedComplexValue.java  |  26 ++
 .../api/domain/v4/ODataObjectFactory.java       |   2 +
 .../commons/api/domain/v4/ODataProperty.java    |   7 +
 .../commons/api/domain/v4/ODataValue.java       |  14 ++
 .../commons/core/data/AbstractAtomDealer.java   |   2 +-
 .../core/data/AbstractJsonDeserializer.java     | 111 ++++++++-
 .../core/data/AbstractJsonSerializer.java       |  57 +++++
 .../olingo/commons/core/data/AbstractValue.java |  11 +
 .../commons/core/data/AtomDeserializer.java     | 245 ++++++++++++++++++-
 .../core/data/AtomPropertyDeserializer.java     | 240 ------------------
 .../core/data/AtomPropertySerializer.java       | 116 ---------
 .../commons/core/data/AtomSerializer.java       |  92 ++++++-
 .../core/data/JSONEntryDeserializer.java        |  74 +-----
 .../commons/core/data/JSONEntrySerializer.java  |  56 +----
 .../core/data/JSONPropertyDeserializer.java     |   2 +-
 .../core/data/LinkedComplexValueImpl.java       |  47 ++++
 .../domain/v4/ODataCollectionValueImpl.java     |  11 +
 .../core/domain/v4/ODataComplexValueImpl.java   |  86 ++++++-
 .../core/domain/v4/ODataEnumValueImpl.java      |  10 +
 .../core/domain/v4/ODataObjectFactoryImpl.java  |   6 +
 .../core/domain/v4/ODataPrimitiveValueImpl.java |  11 +
 .../core/domain/v4/ODataPropertyImpl.java       |  16 +-
 41 files changed, 1149 insertions(+), 675 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16d3b028/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataBinder.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataBinder.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataBinder.java
index f51c798..d2805bb 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataBinder.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataBinder.java
@@ -43,4 +43,6 @@ public interface ODataBinder extends CommonODataBinder {
 
   @Override
   ODataProperty getODataProperty(Property property);
+
+  ODataProperty getODataProperty(Property property, URI base);
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16d3b028/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/ODataRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/ODataRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/ODataRequestImpl.java
index 12696a6..9d38461 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/ODataRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/ODataRequestImpl.java
@@ -47,7 +47,6 @@ import org.apache.olingo.client.api.http.HttpClientException;
 import org.apache.olingo.client.api.http.HttpMethod;
 import org.apache.olingo.client.core.communication.header.ODataHeadersImpl;
 import org.apache.olingo.commons.api.domain.ODataError;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.api.format.ODataMediaFormat;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
 import org.apache.olingo.commons.api.format.ODataValueFormat;
@@ -389,8 +388,9 @@ public class ODataRequestImpl<T extends Format> implements ODataRequest {
     }
 
     // Add header for KeyAsSegment management
-    if (odataClient.getServiceVersion() == ODataServiceVersion.V30
+    if (odataClient.getConfiguration() instanceof Configuration
             && ((Configuration) odataClient.getConfiguration()).isKeyAsSegment()) {
+
       addCustomHeader(
               HeaderName.dataServiceUrlConventions.toString(),
               new ODataPreferences(odataClient.getServiceVersion()).keyAsSegment());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16d3b028/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/AbstractEdmServiceMetadataImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/AbstractEdmServiceMetadataImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/AbstractEdmServiceMetadataImpl.java
index 12463d3..020a09a 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/AbstractEdmServiceMetadataImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/AbstractEdmServiceMetadataImpl.java
@@ -49,7 +49,7 @@ public abstract class AbstractEdmServiceMetadataImpl implements EdmServiceMetada
   public static EdmServiceMetadata getInstance(final ODataServiceVersion version,
           final List<? extends Schema> xmlSchemas) {
 
-    return version == ODataServiceVersion.V30
+    return version.compareTo(ODataServiceVersion.V40) < 0
             ? new org.apache.olingo.client.core.edm.v3.EdmServiceMetadataImpl(xmlSchemas)
             : new org.apache.olingo.client.core.edm.v4.EdmServiceMetadataImpl(xmlSchemas);
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16d3b028/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 c9b6b0e..71e08bb 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
@@ -21,6 +21,7 @@ package org.apache.olingo.client.core.op;
 import java.io.StringWriter;
 import java.net.URI;
 import java.util.Iterator;
+import java.util.List;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.olingo.client.api.CommonODataClient;
 import org.apache.olingo.client.api.data.ServiceDocument;
@@ -31,6 +32,7 @@ import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.data.Entry;
 import org.apache.olingo.commons.api.data.Feed;
 import org.apache.olingo.commons.api.data.Link;
+import org.apache.olingo.commons.api.data.Linked;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.Value;
 import org.apache.olingo.commons.api.domain.ODataCollectionValue;
@@ -43,6 +45,7 @@ import org.apache.olingo.commons.api.domain.ODataLink;
 import org.apache.olingo.commons.api.domain.ODataOperation;
 import org.apache.olingo.commons.api.domain.CommonODataProperty;
 import org.apache.olingo.commons.api.domain.ODataLinkType;
+import org.apache.olingo.commons.api.domain.ODataLinked;
 import org.apache.olingo.commons.api.domain.ODataServiceDocument;
 import org.apache.olingo.commons.api.domain.ODataValue;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
@@ -112,6 +115,30 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
     return getEntry(entity, reference, true);
   }
 
+  protected void links(final ODataLinked odataLinked, final Linked linked, final Class<? extends Entry> reference) {
+    // -------------------------------------------------------------
+    // Append navigation links (handling inline entry / feed as well)
+    // -------------------------------------------------------------
+    // handle navigation links
+    for (ODataLink link : odataLinked.getNavigationLinks()) {
+      // append link 
+      LOG.debug("Append navigation link\n{}", link);
+      linked.getNavigationLinks().add(getLink(link,
+              ResourceFactory.formatForEntryClass(reference) == ODataPubFormat.ATOM));
+    }
+    // -------------------------------------------------------------
+
+    // -------------------------------------------------------------
+    // Append association links
+    // -------------------------------------------------------------
+    for (ODataLink link : odataLinked.getAssociationLinks()) {
+      LOG.debug("Append association link\n{}", link);
+      linked.getAssociationLinks().add(getLink(link,
+              ResourceFactory.formatForEntryClass(reference) == ODataPubFormat.ATOM));
+    }
+    // -------------------------------------------------------------
+  }
+
   @Override
   public Entry getEntry(final CommonODataEntity entity, final Class<? extends Entry> reference, final boolean setType) {
     final Entry entry = ResourceFactory.newEntry(reference);
@@ -139,17 +166,7 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
     }
     // -------------------------------------------------------------
 
-    // -------------------------------------------------------------
-    // Append navigation links (handling inline entry / feed as well)
-    // -------------------------------------------------------------
-    // handle navigation links
-    for (ODataLink link : entity.getNavigationLinks()) {
-      // append link 
-      LOG.debug("Append navigation link\n{}", link);
-      entry.getNavigationLinks().add(getLink(link,
-              ResourceFactory.formatForEntryClass(reference) == ODataPubFormat.ATOM));
-    }
-    // -------------------------------------------------------------
+    links(entity, entry, reference);
 
     // -------------------------------------------------------------
     // Append edit-media links
@@ -161,16 +178,6 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
     }
     // -------------------------------------------------------------
 
-    // -------------------------------------------------------------
-    // Append association links
-    // -------------------------------------------------------------
-    for (ODataLink link : entity.getAssociationLinks()) {
-      LOG.debug("Append association link\n{}", link);
-      entry.getAssociationLinks().add(getLink(link,
-              ResourceFactory.formatForEntryClass(reference) == ODataPubFormat.ATOM));
-    }
-    // -------------------------------------------------------------
-
     if (entity.isMediaEntity()) {
       entry.setMediaContentSource(entity.getMediaContentSource());
       entry.setMediaContentType(entity.getMediaContentType());
@@ -278,6 +285,34 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
     return getODataEntity(resource, null);
   }
 
+  protected void odataLinks(final Linked linked, final ODataLinked odataLinked, final URI base) {
+    for (Link link : linked.getNavigationLinks()) {
+      final Entry inlineEntry = link.getInlineEntry();
+      final Feed inlineFeed = link.getInlineFeed();
+
+      if (inlineEntry == null && inlineFeed == null) {
+        final ODataLinkType linkType = link.getType() == null
+                ? ODataLinkType.ENTITY_NAVIGATION
+                : ODataLinkType.fromString(client.getServiceVersion(), link.getRel(), link.getType());
+        odataLinked.addLink(linkType == ODataLinkType.ENTITY_NAVIGATION
+                ? client.getObjectFactory().newEntityNavigationLink(link.getTitle(), base, link.getHref())
+                : client.getObjectFactory().newEntitySetNavigationLink(link.getTitle(), base, link.getHref()));
+      } else if (inlineEntry != null) {
+        odataLinked.addLink(client.getObjectFactory().newInlineEntity(
+                link.getTitle(), base, link.getHref(),
+                getODataEntity(inlineEntry,
+                        inlineEntry.getBaseURI() == null ? base : inlineEntry.getBaseURI())));
+      } else {
+        odataLinked.addLink(client.getObjectFactory().newInlineEntitySet(
+                link.getTitle(), base, link.getHref(),
+                getODataEntitySet(inlineFeed,
+                        inlineFeed.getBaseURI() == null ? base : inlineFeed.getBaseURI())));
+      }
+    }
+  }
+
+  protected abstract void copyProperties(List<Property> src, CommonODataEntity dst, final URI base);
+
   @Override
   public CommonODataEntity getODataEntity(final Entry resource, final URI defaultBaseURI) {
     if (LOG.isDebugEnabled()) {
@@ -292,7 +327,7 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
     final CommonODataEntity entity = resource.getSelfLink() == null
             ? client.getObjectFactory().newEntity(resource.getType())
             : client.getObjectFactory().newEntity(resource.getType(),
-            URIUtils.getURI(base, resource.getSelfLink().getHref()));
+                    URIUtils.getURI(base, resource.getSelfLink().getHref()));
 
     if (StringUtils.isNotBlank(resource.getETag())) {
       entity.setETag(resource.getETag());
@@ -306,29 +341,7 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
       entity.addLink(client.getObjectFactory().newAssociationLink(link.getTitle(), base, link.getHref()));
     }
 
-    for (Link link : resource.getNavigationLinks()) {
-      final Entry inlineEntry = link.getInlineEntry();
-      final Feed inlineFeed = link.getInlineFeed();
-
-      if (inlineEntry == null && inlineFeed == null) {
-        final ODataLinkType linkType = link.getType() == null
-                ? ODataLinkType.ENTITY_NAVIGATION
-                : ODataLinkType.fromString(client.getServiceVersion(), link.getRel(), link.getType());
-        entity.addLink(linkType == ODataLinkType.ENTITY_NAVIGATION
-                ? client.getObjectFactory().newEntityNavigationLink(link.getTitle(), base, link.getHref())
-                : client.getObjectFactory().newEntitySetNavigationLink(link.getTitle(), base, link.getHref()));
-      } else if (inlineEntry != null) {
-        entity.addLink(client.getObjectFactory().newInlineEntity(
-                link.getTitle(), base, link.getHref(),
-                getODataEntity(inlineEntry,
-                inlineEntry.getBaseURI() == null ? base : inlineEntry.getBaseURI())));
-      } else {
-        entity.addLink(client.getObjectFactory().newInlineEntitySet(
-                link.getTitle(), base, link.getHref(),
-                getODataEntitySet(inlineFeed,
-                inlineFeed.getBaseURI() == null ? base : inlineFeed.getBaseURI())));
-      }
-    }
+    odataLinks(resource, entity, base);
 
     for (Link link : resource.getMediaEditLinks()) {
       entity.addLink(client.getObjectFactory().newMediaEditLink(link.getTitle(), base, link.getHref()));
@@ -346,14 +359,12 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
       entity.setMediaETag(resource.getMediaETag());
     }
 
-    for (Property property : resource.getProperties()) {
-      add(entity, getODataProperty(property));
-    }
+    copyProperties(resource.getProperties(), entity, base);
 
     return entity;
   }
 
-  protected ODataValue getODataValue(final Property resource) {
+  protected ODataValue getODataValue(final Property resource, final URI base) {
     ODataValue value = null;
 
     final EdmTypeInfo typeInfo = resource.getType() == null
@@ -363,18 +374,18 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
       value = client.getObjectFactory().newPrimitiveValueBuilder().
               setText(resource.getValue().asPrimitive().get()).
               setType(typeInfo == null
-              ? null
-              : EdmPrimitiveTypeKind.valueOfFQN(
-              client.getServiceVersion(), typeInfo.getFullQualifiedName().toString())).build();
+                      ? null
+                      : EdmPrimitiveTypeKind.valueOfFQN(
+                              client.getServiceVersion(), typeInfo.getFullQualifiedName().toString())).build();
     } else if (resource.getValue().isGeospatial()) {
       value = client.getObjectFactory().newPrimitiveValueBuilder().
               setValue(resource.getValue().asGeospatial().get()).
               setType(typeInfo == null
-              || EdmPrimitiveTypeKind.Geography.getFullQualifiedName().equals(typeInfo.getFullQualifiedName())
-              || EdmPrimitiveTypeKind.Geometry.getFullQualifiedName().equals(typeInfo.getFullQualifiedName())
-              ? resource.getValue().asGeospatial().get().getEdmPrimitiveTypeKind()
-              : EdmPrimitiveTypeKind.valueOfFQN(
-              client.getServiceVersion(), typeInfo.getFullQualifiedName().toString())).build();
+                      || EdmPrimitiveTypeKind.Geography.getFullQualifiedName().equals(typeInfo.getFullQualifiedName())
+                      || EdmPrimitiveTypeKind.Geometry.getFullQualifiedName().equals(typeInfo.getFullQualifiedName())
+                      ? resource.getValue().asGeospatial().get().getEdmPrimitiveTypeKind()
+                      : EdmPrimitiveTypeKind.valueOfFQN(
+                              client.getServiceVersion(), typeInfo.getFullQualifiedName().toString())).build();
     } else if (resource.getValue().isComplex()) {
       value = client.getObjectFactory().newComplexValue(typeInfo == null
               ? null : typeInfo.getFullQualifiedName().toString());
@@ -389,7 +400,7 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
       for (Value _value : resource.getValue().asCollection().get()) {
         final JSONPropertyImpl fake = new JSONPropertyImpl();
         fake.setValue(_value);
-        value.asCollection().add(getODataValue(fake));
+        value.asCollection().add(getODataValue(fake, base));
       }
     }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16d3b028/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java
index 50deadd..ab973d3 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java
@@ -19,6 +19,7 @@
 package org.apache.olingo.client.core.op.impl.v3;
 
 import java.net.URI;
+import java.util.List;
 import org.apache.olingo.commons.api.data.v3.LinkCollection;
 import org.apache.olingo.client.api.domain.v3.ODataLinkCollection;
 import org.apache.olingo.client.api.op.v3.ODataBinder;
@@ -86,6 +87,13 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
   }
 
   @Override
+  protected void copyProperties(final List<Property> src, final CommonODataEntity dst, final URI base) {
+    for (Property property : src) {
+      add(dst, getODataProperty(property));
+    }
+  }
+
+  @Override
   public ODataEntity getODataEntity(final Entry resource) {
     return (ODataEntity) super.getODataEntity(resource);
   }
@@ -97,7 +105,7 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
 
   @Override
   public ODataProperty getODataProperty(final Property property) {
-    return new ODataPropertyImpl(property.getName(), getODataValue(property));
+    return new ODataPropertyImpl(property.getName(), getODataValue(property, null));
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16d3b028/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 226d8b8..adce2ee 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java
@@ -19,6 +19,7 @@
 package org.apache.olingo.client.core.op.impl.v4;
 
 import java.net.URI;
+import java.util.List;
 import org.apache.olingo.client.api.data.ServiceDocument;
 import org.apache.olingo.client.api.data.ServiceDocumentItem;
 import org.apache.olingo.client.api.op.v4.ODataBinder;
@@ -27,6 +28,7 @@ import org.apache.olingo.client.core.op.AbstractODataBinder;
 import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.commons.api.data.Entry;
 import org.apache.olingo.commons.api.data.Feed;
+import org.apache.olingo.commons.api.data.LinkedComplexValue;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.Value;
 import org.apache.olingo.commons.api.domain.CommonODataEntity;
@@ -36,8 +38,10 @@ import org.apache.olingo.commons.api.domain.ODataServiceDocument;
 import org.apache.olingo.commons.api.domain.ODataValue;
 import org.apache.olingo.commons.api.domain.v4.ODataEntity;
 import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
+import org.apache.olingo.commons.api.domain.v4.ODataLinkedComplexValue;
 import org.apache.olingo.commons.api.domain.v4.ODataProperty;
 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;
 import org.apache.olingo.commons.core.edm.EdmTypeInfo;
 import org.apache.olingo.commons.core.op.ResourceFactory;
@@ -125,6 +129,19 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
               ((org.apache.olingo.commons.api.domain.v4.ODataValue) value).asEnum().getValue());
     } else {
       valueResource = super.getValue(value, reference, setType);
+
+      if (value instanceof org.apache.olingo.commons.api.domain.v4.ODataValue
+              && ((org.apache.olingo.commons.api.domain.v4.ODataValue) value).isLinkedComplex()) {
+
+        final LinkedComplexValue lcValueResource = new LinkedComplexValueImpl();
+        lcValueResource.get().addAll(valueResource.asComplex().get());
+
+        final ODataLinkedComplexValue linked =
+                ((org.apache.olingo.commons.api.domain.v4.ODataValue) value).asLinkedComplex();
+        links(linked, lcValueResource, reference);
+
+        valueResource = lcValueResource;
+      }
     }
     return valueResource;
   }
@@ -140,6 +157,13 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
   }
 
   @Override
+  protected void copyProperties(final List<Property> src, final CommonODataEntity dst, final URI base) {
+    for (Property property : src) {
+      add(dst, getODataProperty(property, base));
+    }
+  }
+
+  @Override
   public ODataEntity getODataEntity(final Entry resource) {
     return (ODataEntity) super.getODataEntity(resource);
   }
@@ -153,21 +177,38 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
 
   @Override
   public ODataProperty getODataProperty(final Property property) {
-    return new ODataPropertyImpl(property.getName(), getODataValue(property));
+    return getODataProperty(property, null);
   }
 
   @Override
-  protected ODataValue getODataValue(final Property resource) {
+  public ODataProperty getODataProperty(final Property property, final URI base) {
+    return new ODataPropertyImpl(property.getName(), getODataValue(property, base));
+  }
+
+  @Override
+  protected ODataValue getODataValue(final Property resource, final URI base) {
+    final EdmTypeInfo typeInfo = resource.getType() == null
+            ? null
+            : new EdmTypeInfo.Builder().setTypeExpression(resource.getType()).build();
+
     ODataValue value;
     if (resource.getValue().isEnum()) {
-      final EdmTypeInfo typeInfo = resource.getType() == null
-              ? null
-              : new EdmTypeInfo.Builder().setTypeExpression(resource.getType()).build();
       value = ((ODataClient) client).getObjectFactory().newEnumValue(
               typeInfo == null ? null : typeInfo.getFullQualifiedName().toString(),
               resource.getValue().asEnum().get());
+    } else if (resource.getValue().isLinkedComplex()) {
+      final ODataLinkedComplexValue lcValue = ((ODataClient) client).getObjectFactory().
+              newLinkedComplexValue(typeInfo == null ? null : typeInfo.getFullQualifiedName().toString());
+
+      for (Property property : resource.getValue().asComplex().get()) {
+        lcValue.add(getODataProperty(property));
+      }
+
+      odataLinks(resource.getValue().asLinkedComplex(), lcValue, base);
+
+      value = lcValue;
     } else {
-      value = super.getODataValue(resource);
+      value = super.getODataValue(resource, base);
     }
 
     return value;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16d3b028/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java
index 17cfcd0..94eccf5 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java
@@ -161,7 +161,7 @@ public final class URIUtils {
 
   private static String prefix(final ODataServiceVersion version, final EdmPrimitiveTypeKind typeKind) {
     String result = StringUtils.EMPTY;
-    if (version == ODataServiceVersion.V30) {
+    if (version.compareTo(ODataServiceVersion.V40) < 0) {
       switch (typeKind) {
         case Guid:
           result = "guid'";
@@ -188,7 +188,7 @@ public final class URIUtils {
 
   private static String suffix(final ODataServiceVersion version, final EdmPrimitiveTypeKind typeKind) {
     String result = StringUtils.EMPTY;
-    if (version == ODataServiceVersion.V30) {
+    if (version.compareTo(ODataServiceVersion.V40) < 0) {
       switch (typeKind) {
         case Guid:
         case DateTime:
@@ -222,7 +222,7 @@ public final class URIUtils {
   private static String timestamp(final ODataServiceVersion version, final Timestamp timestamp)
           throws UnsupportedEncodingException, EdmPrimitiveTypeException {
 
-    return version == ODataServiceVersion.V30
+    return version.compareTo(ODataServiceVersion.V40) < 0
             ? prefix(version, EdmPrimitiveTypeKind.DateTime)
             + URLEncoder.encode(EdmDateTime.getInstance().
                     valueToString(timestamp, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null),
@@ -238,7 +238,7 @@ public final class URIUtils {
 
     String result;
     if (calendar.get(Calendar.ZONE_OFFSET) == 0) {
-      if (version == ODataServiceVersion.V30) {
+      if (version.compareTo(ODataServiceVersion.V40) < 0) {
         result = prefix(version, EdmPrimitiveTypeKind.DateTime)
                 + URLEncoder.encode(EdmDateTime.getInstance().
                         valueToString(calendar, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null),
@@ -271,7 +271,7 @@ public final class URIUtils {
   private static String duration(final ODataServiceVersion version, final Duration duration)
           throws UnsupportedEncodingException, EdmPrimitiveTypeException {
 
-    return version == ODataServiceVersion.V30
+    return version.compareTo(ODataServiceVersion.V40) < 0
             ? EdmTime.getInstance().toUriLiteral(URLEncoder.encode(EdmTime.getInstance().
                             valueToString(duration, null, null,
                                     Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), Constants.UTF8))
@@ -308,7 +308,7 @@ public final class URIUtils {
     try {
       if (obj == null) {
         value = Constants.ATTR_NULL;
-      } else if (version == ODataServiceVersion.V40 && obj instanceof Collection) {
+      } else if (version.compareTo(ODataServiceVersion.V40) >= 0 && obj instanceof Collection) {
         final StringBuffer buffer = new StringBuffer("[");
         for (@SuppressWarnings("unchecked")
                 final Iterator<Object> itor = ((Collection<Object>) obj).iterator(); itor.hasNext();) {
@@ -320,7 +320,7 @@ public final class URIUtils {
         buffer.append(']');
 
         value = buffer.toString();
-      } else if (version == ODataServiceVersion.V40 && obj instanceof Map) {
+      } else if (version.compareTo(ODataServiceVersion.V40) >= 0 && obj instanceof Map) {
         final StringBuffer buffer = new StringBuffer("{");
         for (@SuppressWarnings("unchecked")
                 final Iterator<Map.Entry<Object, Object>> itor =

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16d3b028/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
index 5b8f586..8717c3c 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
@@ -31,6 +31,7 @@ import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
 import org.apache.olingo.commons.api.domain.ODataLink;
 import org.apache.olingo.commons.api.domain.ODataLinkType;
 import org.apache.olingo.commons.api.domain.v4.ODataEntity;
+import org.apache.olingo.commons.api.domain.v4.ODataLinkedComplexValue;
 import org.apache.olingo.commons.api.domain.v4.ODataProperty;
 import org.apache.olingo.commons.api.domain.v4.ODataValue;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
@@ -247,4 +248,31 @@ public class EntityTest extends AbstractTest {
   public void jsonRef() {
     ref(ODataPubFormat.JSON);
   }
+
+  private void complexNavigationProperties(final ODataPubFormat format) {
+    final InputStream input = getClass().getResourceAsStream("entity.withcomplexnavigation." + getSuffix(format));
+    final ODataEntity entity = getClient().getBinder().getODataEntity(
+            getClient().getDeserializer().toEntry(input, format).getObject());
+    assertNotNull(entity);
+
+    final ODataLinkedComplexValue addressValue = entity.getProperty("Address").getLinkedComplexValue();
+    assertNotNull(addressValue);
+    assertNotNull(addressValue.getNavigationLink("Country"));
+
+    // ETag is not serialized
+    entity.setETag(null);
+    final ODataEntity written = getClient().getBinder().getODataEntity(getClient().getBinder().
+            getEntry(entity, ResourceFactory.entryClassForFormat(format == ODataPubFormat.ATOM)));
+    assertEquals(entity, written);
+  }
+
+  @Test
+  public void atomComplexNavigationProperties() {
+    complexNavigationProperties(ODataPubFormat.ATOM);
+  }
+
+  @Test
+  public void jsonComplexNavigationProperties() {
+    complexNavigationProperties(ODataPubFormat.JSON);
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16d3b028/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java
index 791c1c7..8bd3245 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java
@@ -58,6 +58,9 @@ public class JSONTest extends AbstractTest {
     if (node.has(Constants.JSON_CONTEXT)) {
       node.remove(Constants.JSON_CONTEXT);
     }
+    if (node.has(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_ETAG))) {
+      node.remove(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_ETAG));
+    }
     if (node.has(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_TYPE))) {
       node.remove(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_TYPE));
     }
@@ -140,7 +143,6 @@ public class JSONTest extends AbstractTest {
   @Test
   public void additionalEntries() throws Exception {
     entry("entity.minimal", getODataPubFormat());
-//    entry("entity.full", getODataPubFormat());
     entry("entity.primitive", getODataPubFormat());
     entry("entity.complex", getODataPubFormat());
     entry("entity.collection.primitive", getODataPubFormat());
@@ -153,6 +155,7 @@ public class JSONTest extends AbstractTest {
     entry("VipCustomer", getODataPubFormat());
     entry("Advertisements_f89dee73-af9f-4cd4-b330-db93c25ff3c7", getODataPubFormat());
     entry("entityReference", getODataPubFormat());
+    entry("entity.withcomplexnavigation", getODataPubFormat());
   }
 
   protected void property(final String filename, final ODataFormat format) throws Exception {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16d3b028/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/atom_cleanup.xsl
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/atom_cleanup.xsl b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/atom_cleanup.xsl
index ed30201..f80a315 100644
--- a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/atom_cleanup.xsl
+++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/atom_cleanup.xsl
@@ -27,6 +27,7 @@
 
   <xsl:template match="atom:updated"/>
   <xsl:template match="atom:author"/>
+  <xsl:template match="atom:summary"/>
   <xsl:template match="atom:title">
     <xsl:if test="string-length(.) &gt; 0">
       <title type="{@type}">
@@ -38,7 +39,7 @@
   
   <xsl:template match="m:action"/>
 
-  <xsl:template match="@*[name() = 'm:etag' or name() = 'm:context']"/>
+  <xsl:template match="@*[name() = 'm:etag' or name() = 'm:context' or name() = 'm:metadata-etag']"/>
 
   <xsl:template match="node()|@*">
     <xsl:copy>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16d3b028/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.full.json
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.full.json b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.full.json
deleted file mode 100644
index bcd1dba..0000000
--- a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.full.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
-  "@odata.context": "http://host/service/$metadata#Customers/$entity",
-  "@odata.id": "Customers('ALFKI')",
-  "@odata.etag": "W/\"MjAxMy0wNS0yN1QxMTo1OFo=\"",
-  "@odata.editLink": "Customers('ALFKI')",
-  "ID": "ALFKI",
-  "CompanyName": "Alfreds Futterkiste",
-  "ContactName": "Maria Anders",
-  "ContactTitle": "Sales Representative",
-  "Phone": "030-0074321",
-  "Fax": "030-0076545",
-  "Address": {
-    "Street": "Obere Str. 57",
-    "City": "Berlin",
-    "Region": null,
-    "PostalCode": "D-12209",
-    "Country@odata.associationLink": "Customers('ALFKI')/Address/Country/$ref",
-    "Country@odata.navigationLink": "Customers('ALFKI')/Address/Country"
-  },
-  "Orders@odata.associationLink": "Customers('ALFKI')/Orders/$ref",
-  "Orders@odata.navigationLink": "Customers('ALFKI')/Orders"
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16d3b028/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.withcomplexnavigation.json
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.withcomplexnavigation.json b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.withcomplexnavigation.json
new file mode 100644
index 0000000..bcd1dba
--- /dev/null
+++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.withcomplexnavigation.json
@@ -0,0 +1,22 @@
+{
+  "@odata.context": "http://host/service/$metadata#Customers/$entity",
+  "@odata.id": "Customers('ALFKI')",
+  "@odata.etag": "W/\"MjAxMy0wNS0yN1QxMTo1OFo=\"",
+  "@odata.editLink": "Customers('ALFKI')",
+  "ID": "ALFKI",
+  "CompanyName": "Alfreds Futterkiste",
+  "ContactName": "Maria Anders",
+  "ContactTitle": "Sales Representative",
+  "Phone": "030-0074321",
+  "Fax": "030-0076545",
+  "Address": {
+    "Street": "Obere Str. 57",
+    "City": "Berlin",
+    "Region": null,
+    "PostalCode": "D-12209",
+    "Country@odata.associationLink": "Customers('ALFKI')/Address/Country/$ref",
+    "Country@odata.navigationLink": "Customers('ALFKI')/Address/Country"
+  },
+  "Orders@odata.associationLink": "Customers('ALFKI')/Orders/$ref",
+  "Orders@odata.navigationLink": "Customers('ALFKI')/Orders"
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16d3b028/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.withcomplexnavigation.xml
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.withcomplexnavigation.xml b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.withcomplexnavigation.xml
new file mode 100644
index 0000000..1a4e0cc
--- /dev/null
+++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.withcomplexnavigation.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+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.
+-->
+<entry xmlns="http://www.w3.org/2005/Atom"
+       xmlns:m="http://docs.oasis-open.org/odata/ns/metadata"
+       xmlns:d="http://docs.oasis-open.org/odata/ns/data"
+       xml:base="http://host/service/"
+       m:context="$metadata#Customers/$entity"
+       m:metadata-etag="W/&quot;MjAxMy0wNS0xM1QxNDo1NFo=&quot;">
+  <id>http://host/service/$metadata#Customers('ALFKI')</id>
+  <title/>
+  <summary/>
+  <updated>2012-03-30T07:11:05Z</updated>
+  <author>
+    <name/>
+  </author>
+  <link rel="edit" title="Customer" href="Customers('ALFKI')"/>
+  <link rel="http://docs.oasis-open.org/odata/ns/related/Orders"
+        type="application/atom+xml;type=feed"
+        title="Orders" href="Customers('ALFKI')/Orders"/>
+  <link rel="http://docs.oasis-open.org/odata/ns/related/Supplier"
+        type="application/atom+xml;type=entry"
+        title="Supplier" href="Customers('ALFKI')/Supplier"/>
+  <category term="#ODataDemo.Customer"
+            scheme="http://docs.oasis-open.org/odata/ns/scheme"/>
+  <content type="application/xml">
+    <m:properties>
+      <d:ID>ALFKI</d:ID>
+      <d:CompanyName>Alfreds Futterkiste</d:CompanyName>
+      <d:ContactName>Maria Anders</d:ContactName>
+      <d:ContactTitle>Sales Representative</d:ContactTitle>
+      <d:Phone>030-0074321</d:Phone>
+      <d:Fax>030-0076545</d:Fax>
+      <d:Address>
+        <d:Street>Obere Str. 57</d:Street>
+        <d:City>Berlin</d:City>
+        <d:Region m:null="true"/>
+        <d:PostalCode>D-12209</d:PostalCode>
+        <link rel="http://docs.oasis-open.org/odata/ns/related/Country"
+              type="application/atom+xml;type=entry"
+              title="Country"
+              href="Customers('ALFKI')/Address/Country"/>
+      </d:Address>
+    </m:properties>
+  </content>
+</entry>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16d3b028/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Entry.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Entry.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Entry.java
index 5e24e8a..d82005e 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Entry.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Entry.java
@@ -22,7 +22,7 @@ import org.apache.olingo.commons.api.domain.ODataOperation;
 import java.net.URI;
 import java.util.List;
 
-public interface Entry {
+public interface Entry extends Linked {
 
   /**
    * Gets ETag.
@@ -95,20 +95,6 @@ public interface Entry {
   void setEditLink(Link editLink);
 
   /**
-   * Gets association links.
-   *
-   * @return association links.
-   */
-  List<Link> getAssociationLinks();
-
-  /**
-   * Gets navigation links.
-   *
-   * @return links.
-   */
-  List<Link> getNavigationLinks();
-
-  /**
    * Gets media entity links.
    *
    * @return links.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16d3b028/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Linked.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Linked.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Linked.java
new file mode 100644
index 0000000..b5c7db7
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Linked.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.api.data;
+
+import java.util.List;
+
+public interface Linked {
+
+  /**
+   * Gets association links.
+   *
+   * @return association links.
+   */
+  List<Link> getAssociationLinks();
+
+  /**
+   * Gets navigation links.
+   *
+   * @return links.
+   */
+  List<Link> getNavigationLinks();
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16d3b028/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/LinkedComplexValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/LinkedComplexValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/LinkedComplexValue.java
new file mode 100644
index 0000000..13cb72c
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/LinkedComplexValue.java
@@ -0,0 +1,24 @@
+/*
+ * 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;
+
+public interface LinkedComplexValue extends ComplexValue, Linked {
+  
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16d3b028/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Value.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Value.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Value.java
index b02f1ba..08a420d 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Value.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Value.java
@@ -30,6 +30,8 @@ public interface Value {
 
   boolean isComplex();
 
+  boolean isLinkedComplex();
+
   boolean isCollection();
 
   Object get();
@@ -44,5 +46,7 @@ public interface Value {
 
   ComplexValue asComplex();
 
+  LinkedComplexValue asLinkedComplex();
+
   CollectionValue asCollection();
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16d3b028/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataEntity.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataEntity.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataEntity.java
index 6d832c8..7827c68 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataEntity.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataEntity.java
@@ -24,13 +24,27 @@ import java.util.List;
 /**
  * OData entity.
  */
-public interface CommonODataEntity extends ODataInvokeResult {
+public interface CommonODataEntity extends ODataLinked, ODataInvokeResult {
 
   String getName();
 
   URI getLink();
 
   /**
+   * Returns OData entity edit link.
+   *
+   * @return entity edit link.
+   */
+  URI getEditLink();
+
+  /**
+   * Sets OData entity edit link.
+   *
+   * @param editLink edit link.
+   */
+  void setEditLink(URI editLink);
+
+  /**
    * Gets ETag.
    *
    * @return ETag.
@@ -75,52 +89,6 @@ public interface CommonODataEntity extends ODataInvokeResult {
   List<? extends CommonODataProperty> getProperties();
 
   /**
-   * Puts the given link into one of available lists, based on its type.
-   *
-   * @param link to be added
-   * @return <tt>true</tt> if the given link was added in one of available lists
-   */
-  boolean addLink(ODataLink link);
-
-  /**
-   * Removes the given link from any list (association, navigation, edit-media).
-   *
-   * @param link to be removed
-   * @return <tt>true</tt> if the given link was contained in one of available lists
-   */
-  boolean removeLink(ODataLink link);
-
-  /**
-   * Gets association link with given name, if available, otherwise <tt>null</tt>.
-   *
-   * @param name candidate link name
-   * @return association link with given name, if available, otherwise <tt>null</tt>
-   */
-  ODataLink getAssociationLink(String name);
-
-  /**
-   * Returns all entity association links.
-   *
-   * @return OData entity links.
-   */
-  List<ODataLink> getAssociationLinks();
-
-  /**
-   * Gets navigation link with given name, if available, otherwise <tt>null</tt>.
-   *
-   * @param name candidate link name
-   * @return navigation link with given name, if available, otherwise <tt>null</tt>
-   */
-  ODataLink getNavigationLink(String name);
-
-  /**
-   * Returns all entity navigation links (including inline entities / feeds).
-   *
-   * @return OData entity links.
-   */
-  List<ODataLink> getNavigationLinks();
-
-  /**
    * Gets media-edit link with given name, if available, otherwise <tt>null</tt>.
    *
    * @param name candidate link name
@@ -136,20 +104,6 @@ public interface CommonODataEntity extends ODataInvokeResult {
   List<ODataLink> getEditMediaLinks();
 
   /**
-   * Returns OData entity edit link.
-   *
-   * @return entity edit link.
-   */
-  URI getEditLink();
-
-  /**
-   * Sets OData entity edit link.
-   *
-   * @param editLink edit link.
-   */
-  void setEditLink(URI editLink);
-
-  /**
    * TRUE if read-only entity.
    *
    * @return TRUE if read-only; FALSE otherwise.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16d3b028/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinked.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinked.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinked.java
new file mode 100644
index 0000000..0dd5462
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinked.java
@@ -0,0 +1,70 @@
+/*
+ * 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;
+
+import java.util.List;
+
+public interface ODataLinked {
+
+  /**
+   * Puts the given link into one of available lists, based on its type.
+   *
+   * @param link to be added
+   * @return <tt>true</tt> if the given link was added in one of available lists
+   */
+  boolean addLink(ODataLink link);
+
+  /**
+   * Removes the given link from any list (association, navigation, edit-media).
+   *
+   * @param link to be removed
+   * @return <tt>true</tt> if the given link was contained in one of available lists
+   */
+  boolean removeLink(ODataLink link);
+
+  /**
+   * Gets association link with given name, if available, otherwise <tt>null</tt>.
+   *
+   * @param name candidate link name
+   * @return association link with given name, if available, otherwise <tt>null</tt>
+   */
+  ODataLink getAssociationLink(String name);
+
+  /**
+   * Returns all entity association links.
+   *
+   * @return OData entity links.
+   */
+  List<ODataLink> getAssociationLinks();
+
+  /**
+   * Gets navigation link with given name, if available, otherwise <tt>null</tt>.
+   *
+   * @param name candidate link name
+   * @return navigation link with given name, if available, otherwise <tt>null</tt>
+   */
+  ODataLink getNavigationLink(String name);
+
+  /**
+   * Returns all entity navigation links (including inline entities / feeds).
+   *
+   * @return OData entity links.
+   */
+  List<ODataLink> getNavigationLinks();
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16d3b028/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataLinkedComplexValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataLinkedComplexValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataLinkedComplexValue.java
new file mode 100644
index 0000000..a54be59
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataLinkedComplexValue.java
@@ -0,0 +1,26 @@
+/*
+ * 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 org.apache.olingo.commons.api.domain.ODataComplexValue;
+import org.apache.olingo.commons.api.domain.ODataLinked;
+
+public interface ODataLinkedComplexValue extends ODataValue, ODataLinked, ODataComplexValue<ODataProperty> {
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16d3b028/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataObjectFactory.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataObjectFactory.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataObjectFactory.java
index 67adf57..b493392 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataObjectFactory.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataObjectFactory.java
@@ -44,6 +44,8 @@ public interface ODataObjectFactory extends CommonODataObjectFactory {
   @Override
   ODataComplexValue<ODataProperty> newComplexValue(String typeName);
 
+  ODataLinkedComplexValue newLinkedComplexValue(String typeName);
+
   @Override
   ODataCollectionValue<ODataValue> newCollectionValue(String typeName);
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16d3b028/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataProperty.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataProperty.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataProperty.java
index 4666e6e..4031486 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataProperty.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataProperty.java
@@ -37,6 +37,13 @@ public interface ODataProperty extends CommonODataProperty {
    * @return complex value if exists; null otherwise.
    */
   ODataComplexValue<ODataProperty> getComplexValue();
+  
+  /**
+   * Gets complex value with link information (if available).
+   *
+   * @return complex value if exists; null otherwise.
+   */
+  ODataLinkedComplexValue getLinkedComplexValue();
 
   /**
    * Checks if has enum value.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16d3b028/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataValue.java
index 1535e10..a8f5dff 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataValue.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataValue.java
@@ -21,6 +21,20 @@ package org.apache.olingo.commons.api.domain.v4;
 public interface ODataValue extends org.apache.olingo.commons.api.domain.ODataValue {
 
   /**
+   * Check is is a linked complex value.
+   *
+   * @return 'TRUE' if linked complex; 'FALSE' otherwise.
+   */
+  boolean isLinkedComplex();
+
+  /**
+   * Casts to complex value with link information (if available).
+   *
+   * @return complex value with link information.
+   */
+  ODataLinkedComplexValue asLinkedComplex();
+
+  /**
    * Check is is an enum value.
    *
    * @return 'TRUE' if enum; 'FALSE' otherwise.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16d3b028/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractAtomDealer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractAtomDealer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractAtomDealer.java
index f4944d6..f571c66 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractAtomDealer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractAtomDealer.java
@@ -81,7 +81,7 @@ abstract class AbstractAtomDealer {
             new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.PROPERTIES);
     this.typeQName = new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATTR_TYPE);
     this.nullQName = new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATTR_NULL);
-    this.elementQName = version == ODataServiceVersion.V30
+    this.elementQName = version.compareTo(ODataServiceVersion.V40) < 0
             ? new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES), Constants.ELEM_ELEMENT)
             : new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ELEM_ELEMENT);
     this.countQName =

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16d3b028/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonDeserializer.java
index 6731259..59712e5 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonDeserializer.java
@@ -18,17 +18,26 @@
  */
 package org.apache.olingo.commons.core.data;
 
+import com.fasterxml.jackson.core.ObjectCodec;
+import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ArrayNode;
 import com.fasterxml.jackson.databind.node.ObjectNode;
+import java.io.IOException;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Set;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.olingo.commons.api.data.CollectionValue;
 import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.Container;
+import org.apache.olingo.commons.api.data.Linked;
 import org.apache.olingo.commons.api.data.Value;
+import org.apache.olingo.commons.api.domain.ODataLinkType;
 import org.apache.olingo.commons.api.domain.ODataPropertyType;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.core.edm.EdmTypeInfo;
 
 abstract class AbstractJsonDeserializer<T> extends ODataJacksonDeserializer<Container<T>> {
@@ -42,6 +51,76 @@ abstract class AbstractJsonDeserializer<T> extends ODataJacksonDeserializer<Cont
     return geoDeserializer;
   }
 
+  protected String getTitle(final Map.Entry<String, JsonNode> entry) {
+    return entry.getKey().substring(0, entry.getKey().indexOf('@'));
+  }
+
+  protected String setInline(final String name, final String suffix, final JsonNode tree,
+          final ObjectCodec codec, final LinkImpl link) throws IOException {
+
+    final String entryNamePrefix = name.substring(0, name.indexOf(suffix));
+    if (tree.has(entryNamePrefix)) {
+      final JsonNode inline = tree.path(entryNamePrefix);
+
+      if (inline instanceof ObjectNode) {
+        link.setType(ODataLinkType.ENTITY_NAVIGATION.toString());
+
+        link.setInlineEntry(inline.traverse(codec).<Container<JSONEntryImpl>>readValueAs(
+                new TypeReference<JSONEntryImpl>() {
+                }).getObject());
+      }
+
+      if (inline instanceof ArrayNode) {
+        link.setType(ODataLinkType.ENTITY_SET_NAVIGATION.toString());
+
+        final JSONFeedImpl feed = new JSONFeedImpl();
+        final Iterator<JsonNode> entries = ((ArrayNode) inline).elements();
+        while (entries.hasNext()) {
+          feed.getEntries().add(entries.next().traverse(codec).<Container<JSONEntryImpl>>readValuesAs(
+                  new TypeReference<JSONEntryImpl>() {
+                  }).next().getObject());
+        }
+
+        link.setInlineFeed(feed);
+      }
+    }
+    return entryNamePrefix;
+  }
+
+  protected void links(final Map.Entry<String, JsonNode> field, final Linked linked, final Set<String> toRemove,
+          final JsonNode tree, final ObjectCodec codec) throws IOException {
+
+    if (field.getKey().endsWith(jsonNavigationLink)) {
+      final LinkImpl link = new LinkImpl();
+      link.setTitle(getTitle(field));
+      link.setRel(version.getNamespaceMap().get(ODataServiceVersion.NAVIGATION_LINK_REL) + getTitle(field));
+
+      if (field.getValue().isValueNode()) {
+        link.setHref(field.getValue().textValue());
+        link.setType(ODataLinkType.ENTITY_NAVIGATION.toString());
+      }
+      // NOTE: this should be expected to happen, but it isn't - at least up to OData 4.0
+        /* if (field.getValue().isArray()) {
+       * link.setHref(field.getValue().asText());
+       * link.setType(ODataLinkType.ENTITY_SET_NAVIGATION.toString());
+       * } */
+
+      linked.getNavigationLinks().add(link);
+
+      toRemove.add(field.getKey());
+      toRemove.add(setInline(field.getKey(), jsonNavigationLink, tree, codec, link));
+    } else if (field.getKey().endsWith(jsonAssociationLink)) {
+      final LinkImpl link = new LinkImpl();
+      link.setTitle(getTitle(field));
+      link.setRel(version.getNamespaceMap().get(ODataServiceVersion.ASSOCIATION_LINK_REL) + getTitle(field));
+      link.setHref(field.getValue().textValue());
+      link.setType(ODataLinkType.ASSOCIATION.toString());
+      linked.getAssociationLinks().add(link);
+
+      toRemove.add(field.getKey());
+    }
+  }
+
   protected EdmPrimitiveTypeKind getPrimitiveType(final JsonNode node) {
     EdmPrimitiveTypeKind result = EdmPrimitiveTypeKind.String;
 
@@ -88,8 +167,20 @@ abstract class AbstractJsonDeserializer<T> extends ODataJacksonDeserializer<Cont
     return value;
   }
 
-  private ComplexValue fromComplex(final JsonNode node) {
-    final ComplexValue value = new ComplexValueImpl();
+  private ComplexValue fromComplex(final ObjectNode node, final ObjectCodec codec) throws IOException {
+    final ComplexValue value = version.compareTo(ODataServiceVersion.V40) < 0
+            ? new ComplexValueImpl()
+            : new LinkedComplexValueImpl();
+
+    if (value.isLinkedComplex()) {
+      final Set<String> toRemove = new HashSet<String>();
+      for (final Iterator<Map.Entry<String, JsonNode>> itor = node.fields(); itor.hasNext();) {
+        final Map.Entry<String, JsonNode> field = itor.next();
+
+        links(field, value.asLinkedComplex(), toRemove, node, codec);
+      }
+      node.remove(toRemove);
+    }
 
     String type = null;
     for (final Iterator<Map.Entry<String, JsonNode>> itor = node.fields(); itor.hasNext();) {
@@ -103,7 +194,7 @@ abstract class AbstractJsonDeserializer<T> extends ODataJacksonDeserializer<Cont
         property.setType(type);
         type = null;
 
-        value(property, field.getValue());
+        value(property, field.getValue(), codec);
         value.get().add(property);
       }
     }
@@ -111,7 +202,9 @@ abstract class AbstractJsonDeserializer<T> extends ODataJacksonDeserializer<Cont
     return value;
   }
 
-  private CollectionValue fromCollection(final Iterator<JsonNode> nodeItor, final EdmTypeInfo typeInfo) {
+  private CollectionValue fromCollection(final Iterator<JsonNode> nodeItor, final EdmTypeInfo typeInfo,
+          final ObjectCodec codec) throws IOException {
+
     final CollectionValueImpl value = new CollectionValueImpl();
 
     final EdmTypeInfo type = typeInfo == null
@@ -131,14 +224,16 @@ abstract class AbstractJsonDeserializer<T> extends ODataJacksonDeserializer<Cont
         if (child.has(jsonType)) {
           ((ObjectNode) child).remove(jsonType);
         }
-        value.get().add(fromComplex(child));
+        value.get().add(fromComplex((ObjectNode) child, codec));
       }
     }
 
     return value;
   }
 
-  protected void value(final JSONPropertyImpl property, final JsonNode node) {
+  protected void value(final JSONPropertyImpl property, final JsonNode node, final ObjectCodec codec)
+          throws IOException {
+
     final EdmTypeInfo typeInfo = StringUtils.isBlank(property.getType())
             ? null
             : new EdmTypeInfo.Builder().setTypeExpression(property.getType()).build();
@@ -155,7 +250,7 @@ abstract class AbstractJsonDeserializer<T> extends ODataJacksonDeserializer<Cont
 
     switch (propType) {
       case COLLECTION:
-        property.setValue(fromCollection(node.elements(), typeInfo));
+        property.setValue(fromCollection(node.elements(), typeInfo, codec));
         break;
 
       case COMPLEX:
@@ -163,7 +258,7 @@ abstract class AbstractJsonDeserializer<T> extends ODataJacksonDeserializer<Cont
           property.setType(node.get(jsonType).asText());
           ((ObjectNode) node).remove(jsonType);
         }
-        property.setValue(fromComplex(node));
+        property.setValue(fromComplex((ObjectNode) node, codec));
         break;
 
       case ENUM:

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16d3b028/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonSerializer.java
index dede6aa..76451d1 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonSerializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonSerializer.java
@@ -20,12 +20,22 @@ package org.apache.olingo.commons.core.data;
 
 import com.fasterxml.jackson.core.JsonGenerator;
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.lang3.BooleanUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.math.NumberUtils;
+import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.data.CollectionValue;
+import org.apache.olingo.commons.api.data.Entry;
+import org.apache.olingo.commons.api.data.Link;
+import org.apache.olingo.commons.api.data.Linked;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.Value;
+import org.apache.olingo.commons.api.domain.ODataLinkType;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.core.edm.EdmTypeInfo;
 
@@ -39,6 +49,50 @@ abstract class AbstractJsonSerializer<T> extends ODataJacksonSerializer<T> {
 
   private final JSONGeoValueSerializer geoSerializer = new JSONGeoValueSerializer();
 
+  protected void links(final Linked linked, final JsonGenerator jgen) throws IOException {
+    final Map<String, List<String>> entitySetLinks = new HashMap<String, List<String>>();
+    for (Link link : linked.getNavigationLinks()) {
+      ODataLinkType type = null;
+      try {
+        type = ODataLinkType.fromString(version, link.getRel(), link.getType());
+      } catch (IllegalArgumentException e) {
+        // ignore   
+      }
+
+      if (type == ODataLinkType.ENTITY_SET_NAVIGATION) {
+        final List<String> uris;
+        if (entitySetLinks.containsKey(link.getTitle())) {
+          uris = entitySetLinks.get(link.getTitle());
+        } else {
+          uris = new ArrayList<String>();
+          entitySetLinks.put(link.getTitle(), uris);
+        }
+        uris.add(link.getHref());
+      } else {
+        if (StringUtils.isNotBlank(link.getHref())) {
+          jgen.writeStringField(link.getTitle() + Constants.JSON_BIND_LINK_SUFFIX, link.getHref());
+        }
+      }
+
+      if (link.getInlineEntry() != null) {
+        jgen.writeObjectField(link.getTitle(), link.getInlineEntry());
+      } else if (link.getInlineFeed() != null) {
+        jgen.writeArrayFieldStart(link.getTitle());
+        for (Entry subEntry : link.getInlineFeed().getEntries()) {
+          jgen.writeObject(subEntry);
+        }
+        jgen.writeEndArray();
+      }
+    }
+    for (Map.Entry<String, List<String>> entitySetLink : entitySetLinks.entrySet()) {
+      jgen.writeArrayFieldStart(entitySetLink.getKey() + Constants.JSON_BIND_LINK_SUFFIX);
+      for (String uri : entitySetLink.getValue()) {
+        jgen.writeString(uri);
+      }
+      jgen.writeEndArray();
+    }
+  }
+
   private void collection(final JsonGenerator jgen, final String itemType, final CollectionValue value)
           throws IOException {
 
@@ -85,6 +139,9 @@ abstract class AbstractJsonSerializer<T> extends ODataJacksonSerializer<T> {
       for (Property property : value.asComplex().get()) {
         property(jgen, property, property.getName());
       }
+      if (value.isLinkedComplex()) {
+        links(value.asLinkedComplex(), jgen);
+      }
       jgen.writeEndObject();
     }
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16d3b028/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValue.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValue.java
index 629592f..2d91ffd 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValue.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValue.java
@@ -26,6 +26,7 @@ import org.apache.olingo.commons.api.data.CollectionValue;
 import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.EnumValue;
 import org.apache.olingo.commons.api.data.GeospatialValue;
+import org.apache.olingo.commons.api.data.LinkedComplexValue;
 import org.apache.olingo.commons.api.data.NullValue;
 import org.apache.olingo.commons.api.data.PrimitiveValue;
 import org.apache.olingo.commons.api.data.Value;
@@ -58,6 +59,11 @@ public abstract class AbstractValue implements Value {
   }
 
   @Override
+  public boolean isLinkedComplex() {
+    return false;
+  }
+
+  @Override
   public boolean isCollection() {
     return false;
   }
@@ -88,6 +94,11 @@ public abstract class AbstractValue implements Value {
   }
 
   @Override
+  public LinkedComplexValue asLinkedComplex() {
+    return isLinkedComplex() ? (LinkedComplexValue) this : null;
+  }
+
+  @Override
   public CollectionValue asCollection() {
     return isCollection() ? (CollectionValue) this : null;
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16d3b028/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 c748f59..1ead6cb 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
@@ -29,27 +29,264 @@ import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.events.Attribute;
 import javax.xml.stream.events.StartElement;
 import javax.xml.stream.events.XMLEvent;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.CollectionValue;
+import org.apache.olingo.commons.api.data.Value;
 import org.apache.olingo.commons.api.domain.ODataOperation;
+import org.apache.olingo.commons.api.domain.ODataPropertyType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.core.data.v3.XMLLinkCollectionImpl;
+import org.apache.olingo.commons.core.edm.EdmTypeInfo;
 
 public class AtomDeserializer extends AbstractAtomDealer {
 
   private static final XMLInputFactory FACTORY = XMLInputFactory.newInstance();
 
-  private final AtomPropertyDeserializer propDeserializer;
+  private final AtomGeoValueDeserializer geoDeserializer;
 
   public AtomDeserializer(final ODataServiceVersion version) {
     super(version);
-    this.propDeserializer = new AtomPropertyDeserializer(version);
+    this.geoDeserializer = new AtomGeoValueDeserializer();
+  }
+
+  private Value fromPrimitive(final XMLEventReader reader, final StartElement start,
+          final EdmTypeInfo typeInfo) throws XMLStreamException {
+
+    Value value = null;
+
+    boolean foundEndProperty = false;
+    while (reader.hasNext() && !foundEndProperty) {
+      final XMLEvent event = reader.nextEvent();
+
+      if (event.isStartElement() && typeInfo != null && typeInfo.getPrimitiveTypeKind().isGeospatial()) {
+        final EdmPrimitiveTypeKind geoType = EdmPrimitiveTypeKind.valueOfFQN(
+                version, typeInfo.getFullQualifiedName().toString());
+        value = new GeospatialValueImpl(this.geoDeserializer.deserialize(reader, event.asStartElement(), geoType));
+      }
+
+      if (event.isCharacters() && !event.asCharacters().isWhiteSpace()
+              && (typeInfo == null || !typeInfo.getPrimitiveTypeKind().isGeospatial())) {
+
+        value = new PrimitiveValueImpl(event.asCharacters().getData());
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndProperty = true;
+      }
+    }
+
+    return value == null ? new PrimitiveValueImpl(StringUtils.EMPTY) : value;
+  }
+
+  private Value fromComplexOrEnum(final XMLEventReader reader, final StartElement start)
+          throws XMLStreamException {
+
+    Value value = null;
+
+    boolean foundEndProperty = false;
+    while (reader.hasNext() && !foundEndProperty) {
+      final XMLEvent event = reader.nextEvent();
+
+      if (event.isStartElement()) {
+        if (value == null) {
+          value = version.compareTo(ODataServiceVersion.V40) < 0
+                  ? new ComplexValueImpl()
+                  : new LinkedComplexValueImpl();
+        }
+
+        if (Constants.QNAME_ATOM_ELEM_LINK.equals(event.asStartElement().getName())) {
+          final LinkImpl link = new LinkImpl();
+          final Attribute rel = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REL));
+          if (rel != null) {
+            link.setRel(rel.getValue());
+          }
+          final Attribute title = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TITLE));
+          if (title != null) {
+            link.setTitle(title.getValue());
+          }
+          final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
+          if (href != null) {
+            link.setHref(href.getValue());
+          }
+          final Attribute type = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TYPE));
+          if (type != null) {
+            link.setType(type.getValue());
+          }
+
+          if (link.getRel().startsWith(
+                  version.getNamespaceMap().get(ODataServiceVersion.NAVIGATION_LINK_REL))) {
+
+            value.asLinkedComplex().getNavigationLinks().add(link);
+            inline(reader, event.asStartElement(), link);
+          } else if (link.getRel().startsWith(
+                  version.getNamespaceMap().get(ODataServiceVersion.ASSOCIATION_LINK_REL))) {
+
+            value.asLinkedComplex().getAssociationLinks().add(link);
+          }
+        } else {
+          value.asComplex().get().add(property(reader, event.asStartElement()));
+        }
+      }
+
+      if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
+        value = new EnumValueImpl(event.asCharacters().getData());
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndProperty = true;
+      }
+    }
+
+    return value;
+  }
+
+  private CollectionValue fromCollection(final XMLEventReader reader, final StartElement start,
+          final EdmTypeInfo typeInfo) throws XMLStreamException {
+
+    final CollectionValueImpl value = new CollectionValueImpl();
+
+    final EdmTypeInfo type = typeInfo == null
+            ? null
+            : new EdmTypeInfo.Builder().setTypeExpression(typeInfo.getFullQualifiedName().toString()).build();
+
+    boolean foundEndProperty = false;
+    while (reader.hasNext() && !foundEndProperty) {
+      final XMLEvent event = reader.nextEvent();
+
+      if (event.isStartElement()) {
+        switch (guessPropertyType(reader, typeInfo)) {
+          case COMPLEX:
+          case ENUM:
+            value.get().add(fromComplexOrEnum(reader, event.asStartElement()));
+            break;
+
+          case PRIMITIVE:
+            value.get().add(fromPrimitive(reader, event.asStartElement(), type));
+            break;
+
+          default:
+          // do not add null or empty values
+        }
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndProperty = true;
+      }
+    }
+
+    return value;
+  }
+
+  private ODataPropertyType guessPropertyType(final XMLEventReader reader, final EdmTypeInfo typeInfo)
+          throws XMLStreamException {
+
+    XMLEvent child = null;
+    while (reader.hasNext() && child == null) {
+      final XMLEvent event = reader.peek();
+      if (event.isCharacters() && event.asCharacters().isWhiteSpace()) {
+        reader.nextEvent();
+      } else {
+        child = event;
+      }
+    }
+
+    final ODataPropertyType type;
+    if (child == null) {
+      type = typeInfo == null || typeInfo.isPrimitiveType()
+              ? ODataPropertyType.PRIMITIVE
+              : ODataPropertyType.ENUM;
+    } else {
+      if (child.isStartElement()) {
+        if (Constants.NS_GML.equals(child.asStartElement().getName().getNamespaceURI())) {
+          type = ODataPropertyType.PRIMITIVE;
+        } else if (elementQName.equals(child.asStartElement().getName())) {
+          type = ODataPropertyType.COLLECTION;
+        } else {
+          type = ODataPropertyType.COMPLEX;
+        }
+      } else if (child.isCharacters()) {
+        type = typeInfo == null || typeInfo.isPrimitiveType()
+                ? ODataPropertyType.PRIMITIVE
+                : ODataPropertyType.ENUM;
+      } else {
+        type = ODataPropertyType.EMPTY;
+      }
+    }
+
+    return type;
+  }
+
+  private AtomPropertyImpl property(final XMLEventReader reader, final StartElement start)
+          throws XMLStreamException {
+
+    final AtomPropertyImpl property = new AtomPropertyImpl();
+
+    if (ODataServiceVersion.V40 == version && v4PropertyValueQName.equals(start.getName())) {
+      // retrieve name from context
+      final Attribute context = start.getAttributeByName(contextQName);
+      if (context != null) {
+        property.setName(StringUtils.substringAfterLast(context.getValue(), "/"));
+      }
+    } else {
+      property.setName(start.getName().getLocalPart());
+    }
+
+    final Attribute nullAttr = start.getAttributeByName(this.nullQName);
+
+    Value value;
+    if (nullAttr == null) {
+      final Attribute typeAttr = start.getAttributeByName(this.typeQName);
+      final String typeAttrValue = typeAttr == null ? null : typeAttr.getValue();
+
+      final EdmTypeInfo typeInfo = StringUtils.isBlank(typeAttrValue)
+              ? null
+              : new EdmTypeInfo.Builder().setTypeExpression(typeAttrValue).build();
+
+      if (typeInfo != null) {
+        property.setType(typeInfo.getTypeExpression());
+      }
+
+      final ODataPropertyType propType = typeInfo == null
+              ? guessPropertyType(reader, typeInfo)
+              : typeInfo.isCollection()
+              ? ODataPropertyType.COLLECTION
+              : typeInfo.isPrimitiveType()
+              ? ODataPropertyType.PRIMITIVE
+              : ODataPropertyType.COMPLEX;
+
+      switch (propType) {
+        case COLLECTION:
+          value = fromCollection(reader, start, typeInfo);
+          break;
+
+        case COMPLEX:
+          value = fromComplexOrEnum(reader, start);
+          break;
+
+        case PRIMITIVE:
+          value = fromPrimitive(reader, start, typeInfo);
+          break;
+
+        case EMPTY:
+        default:
+          value = new PrimitiveValueImpl(StringUtils.EMPTY);
+      }
+    } else {
+      value = new NullValueImpl();
+    }
+
+    property.setValue(value);
+
+    return property;
   }
 
   private Container<AtomPropertyImpl> property(final InputStream input) throws XMLStreamException {
     final XMLEventReader reader = FACTORY.createXMLEventReader(input);
     final StartElement start = skipBeforeFirstStartElement(reader);
-    return getContainer(start, propDeserializer.deserialize(reader, start));
+    return getContainer(start, property(reader, start));
   }
 
   private StartElement skipBeforeFirstStartElement(final XMLEventReader reader) throws XMLStreamException {
@@ -162,7 +399,7 @@ public class AtomDeserializer extends AbstractAtomDealer {
       final XMLEvent event = reader.nextEvent();
 
       if (event.isStartElement()) {
-        entry.getProperties().add(propDeserializer.deserialize(reader, event.asStartElement()));
+        entry.getProperties().add(property(reader, event.asStartElement()));
       }
 
       if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {