You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by fm...@apache.org on 2014/07/16 11:27:05 UTC

[42/58] [abbrv] Providing some refactoring in order to avoid multi-request retrieving entity info

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6587302a/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 fc19379..3181705 100644
--- a/fit/src/main/java/org/apache/olingo/fit/V4Services.java
+++ b/fit/src/main/java/org/apache/olingo/fit/V4Services.java
@@ -63,6 +63,7 @@ import org.apache.cxf.jaxrs.ext.multipart.Multipart;
 import org.apache.cxf.jaxrs.ext.multipart.MultipartBody;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.data.ValueType;
@@ -70,6 +71,7 @@ import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.core.data.EntityImpl;
 import org.apache.olingo.commons.core.data.EntitySetImpl;
+import org.apache.olingo.commons.core.data.LinkImpl;
 import org.apache.olingo.commons.core.data.PropertyImpl;
 import org.apache.olingo.commons.core.edm.EdmTypeInfo;
 import org.apache.olingo.fit.metadata.Metadata;
@@ -87,18 +89,18 @@ import org.springframework.stereotype.Service;
 
 @Service
 @Path("/V40/Static.svc")
-@InInterceptors(classes = { XHTTPMethodInterceptor.class, ResolvingReferencesInterceptor.class })
+@InInterceptors(classes = {XHTTPMethodInterceptor.class, ResolvingReferencesInterceptor.class})
 public class V4Services extends AbstractServices {
 
   /**
    * CR/LF.
    */
-  protected static final byte[] CRLF = { 13, 10 };
+  protected static final byte[] CRLF = {13, 10};
 
   protected static final Pattern RELENTITY_SELECT_PATTERN = Pattern.compile("^.*\\(\\$select=.*\\)$");
 
   protected static final Pattern CROSSJOIN_PATTERN = Pattern.compile(
-      "^\\$crossjoin\\(.*\\)\\?\\$filter=\\([a-zA-Z/]+ eq [a-zA-Z/]+\\)$");
+          "^\\$crossjoin\\(.*\\)\\?\\$filter=\\([a-zA-Z/]+ eq [a-zA-Z/]+\\)$");
 
   private final Map<String, String> providedAsync = new HashMap<String, String>();
 
@@ -113,18 +115,18 @@ public class V4Services extends AbstractServices {
   @GET
   @Path("/redirect/{name}({id})")
   public Response conformanceRedirect(
-      @Context final UriInfo uriInfo,
-      @PathParam("name") final String name,
-      @PathParam("id") final String id) {
+          @Context final UriInfo uriInfo,
+          @PathParam("name") final String name,
+          @PathParam("id") final String id) {
     return Response.temporaryRedirect(
-        URI.create(uriInfo.getRequestUri().toASCIIString().replace("/redirect", ""))).build();
+            URI.create(uriInfo.getRequestUri().toASCIIString().replace("/redirect", ""))).build();
   }
 
   @GET
   @Path("/$crossjoin({elements:.*})")
   public Response crossjoin(
-      @PathParam("elements") final String elements,
-      @QueryParam("$filter") final String filter) {
+          @PathParam("elements") final String elements,
+          @QueryParam("$filter") final String filter) {
 
     try {
       if (CROSSJOIN_PATTERN.matcher("$crossjoin(" + elements + ")?$filter=" + filter).matches()) {
@@ -142,8 +144,8 @@ public class V4Services extends AbstractServices {
   @GET
   @Path("/relatedEntitySelect/{path:.*}")
   public Response relatedEntitySelect(
-      @PathParam("path") final String path,
-      @QueryParam("$expand") final String expand) {
+          @PathParam("path") final String path,
+          @QueryParam("$expand") final String expand) {
 
     if (RELENTITY_SELECT_PATTERN.matcher(expand).matches()) {
       return xml.createResponse(null, null, Accept.JSON_FULLMETA);
@@ -177,9 +179,9 @@ public class V4Services extends AbstractServices {
   @POST
   @Path("/async/$batch")
   public Response async(
-      @Context final UriInfo uriInfo,
-      @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
-      final @Multipart MultipartBody attachment) {
+          @Context final UriInfo uriInfo,
+          @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
+          final @Multipart MultipartBody attachment) {
 
     try {
       final ByteArrayOutputStream bos = new ByteArrayOutputStream();
@@ -216,7 +218,7 @@ public class V4Services extends AbstractServices {
       bos.close();
 
       return xml.createAsyncResponse(
-          uriInfo.getRequestUri().toASCIIString().replace("async/$batch", "") + "monitor/" + uuid.toString());
+              uriInfo.getRequestUri().toASCIIString().replace("async/$batch", "") + "monitor/" + uuid.toString());
     } catch (Exception e) {
       return xml.createFaultResponse(Accept.JSON.toString(), e);
     }
@@ -225,9 +227,9 @@ public class V4Services extends AbstractServices {
   @GET
   @Path("/async/{name}")
   public Response async(
-      @Context final UriInfo uriInfo,
-      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-      @PathParam("name") final String name) {
+          @Context final UriInfo uriInfo,
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+          @PathParam("name") final String name) {
 
     try {
       final Accept acceptType = Accept.parse(accept, version);
@@ -239,8 +241,8 @@ public class V4Services extends AbstractServices {
       final StringBuilder path = new StringBuilder(basePath);
 
       path.append(metadata.getEntitySet(name).isSingleton()
-          ? Constants.get(version, ConstantKey.ENTITY)
-          : Constants.get(version, ConstantKey.FEED));
+              ? Constants.get(version, ConstantKey.ENTITY)
+              : Constants.get(version, ConstantKey.FEED));
 
       final InputStream feed = FSManager.instance(version).readFile(path.toString(), acceptType);
 
@@ -254,7 +256,7 @@ public class V4Services extends AbstractServices {
       providedAsync.put(uuid.toString(), builder.toString());
 
       return xml.createAsyncResponse(
-          uriInfo.getRequestUri().toASCIIString().replaceAll("async/" + name, "") + "monitor/" + uuid.toString());
+              uriInfo.getRequestUri().toASCIIString().replaceAll("async/" + name, "") + "monitor/" + uuid.toString());
     } catch (Exception e) {
       return xml.createFaultResponse(accept, e);
     }
@@ -269,8 +271,8 @@ public class V4Services extends AbstractServices {
 
   @Override
   public InputStream exploreMultipart(
-      final List<Attachment> attachments, final String boundary, final boolean continueOnError)
-      throws IOException {
+          final List<Attachment> attachments, final String boundary, final boolean continueOnError)
+          throws IOException {
 
     final ByteArrayOutputStream bos = new ByteArrayOutputStream();
 
@@ -356,59 +358,59 @@ public class V4Services extends AbstractServices {
   @GET
   @Path("/People/{type:.*}")
   public Response getPeople(
-      @Context final UriInfo uriInfo,
-      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-      @PathParam("type") final String type,
-      @QueryParam("$top") @DefaultValue(StringUtils.EMPTY) final String top,
-      @QueryParam("$skip") @DefaultValue(StringUtils.EMPTY) final String skip,
-      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
-      @QueryParam("$inlinecount") @DefaultValue(StringUtils.EMPTY) final String count,
-      @QueryParam("$filter") @DefaultValue(StringUtils.EMPTY) final String filter,
-      @QueryParam("$search") @DefaultValue(StringUtils.EMPTY) final String search,
-      @QueryParam("$orderby") @DefaultValue(StringUtils.EMPTY) final String orderby,
-      @QueryParam("$skiptoken") @DefaultValue(StringUtils.EMPTY) final String skiptoken) {
+          @Context final UriInfo uriInfo,
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+          @PathParam("type") final String type,
+          @QueryParam("$top") @DefaultValue(StringUtils.EMPTY) final String top,
+          @QueryParam("$skip") @DefaultValue(StringUtils.EMPTY) final String skip,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+          @QueryParam("$inlinecount") @DefaultValue(StringUtils.EMPTY) final String count,
+          @QueryParam("$filter") @DefaultValue(StringUtils.EMPTY) final String filter,
+          @QueryParam("$search") @DefaultValue(StringUtils.EMPTY) final String search,
+          @QueryParam("$orderby") @DefaultValue(StringUtils.EMPTY) final String orderby,
+          @QueryParam("$skiptoken") @DefaultValue(StringUtils.EMPTY) final String skiptoken) {
 
     return StringUtils.isBlank(filter) && StringUtils.isBlank(search)
-        ? NumberUtils.isNumber(type)
+            ? NumberUtils.isNumber(type)
             ? super.getEntityInternal(
-                uriInfo.getRequestUri().toASCIIString(), accept, "People", type, format, null, null)
+            uriInfo.getRequestUri().toASCIIString(), accept, "People", type, format, null, null)
             : super.getEntitySet(accept, "People", type)
-        : super.getEntitySet(uriInfo, accept, "People", top, skip, format, count, filter, orderby, skiptoken);
+            : super.getEntitySet(uriInfo, accept, "People", top, skip, format, count, filter, orderby, skiptoken);
   }
 
   @GET
   @Path("/Boss")
   public Response getSingletonBoss(
-      @Context final UriInfo uriInfo,
-      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+          @Context final UriInfo uriInfo,
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
 
     return getEntityInternal(
-        uriInfo.getRequestUri().toASCIIString(), accept, "Boss", StringUtils.EMPTY, format, null, null);
+            uriInfo.getRequestUri().toASCIIString(), accept, "Boss", StringUtils.EMPTY, format, null, null);
   }
 
   @GET
   @Path("/Company")
   public Response getSingletonCompany(
-      @Context final UriInfo uriInfo,
-      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+          @Context final UriInfo uriInfo,
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
 
     return getEntityInternal(
-        uriInfo.getRequestUri().toASCIIString(), accept, "Company", StringUtils.EMPTY, format, null, null);
+            uriInfo.getRequestUri().toASCIIString(), accept, "Company", StringUtils.EMPTY, format, null, null);
   }
 
   @PATCH
   @Path("/Company")
-  @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON })
-  @Consumes({ MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON })
+  @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
+  @Consumes({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
   public Response patchSingletonCompany(
-      @Context final UriInfo uriInfo,
-      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-      @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
-      @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
-      @HeaderParam("If-Match") @DefaultValue(StringUtils.EMPTY) final String ifMatch,
-      final String changes) {
+          @Context final UriInfo uriInfo,
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
+          @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
+          @HeaderParam("If-Match") @DefaultValue(StringUtils.EMPTY) final String ifMatch,
+          final String changes) {
 
     return super.patchEntity(uriInfo, accept, contentType, prefer, ifMatch, "Company", StringUtils.EMPTY, changes);
   }
@@ -416,11 +418,11 @@ public class V4Services extends AbstractServices {
   @GET
   @Path("/Customers")
   public Response getCustomers(
-      @Context final UriInfo uriInfo,
-      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
-      @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
-      @QueryParam("$deltatoken") @DefaultValue(StringUtils.EMPTY) final String deltatoken) {
+          @Context final UriInfo uriInfo,
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+          @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
+          @QueryParam("$deltatoken") @DefaultValue(StringUtils.EMPTY) final String deltatoken) {
 
     try {
       final Accept acceptType;
@@ -433,7 +435,7 @@ public class V4Services extends AbstractServices {
       final InputStream output;
       if (StringUtils.isBlank(deltatoken)) {
         final InputStream input = (InputStream) getEntitySet(
-            uriInfo, accept, "Customers", null, null, format, null, null, null, null).getEntity();
+                uriInfo, accept, "Customers", null, null, format, null, null, null, null).getEntity();
         final EntitySet entitySet = xml.readEntitySet(acceptType, input);
 
         boolean trackChanges = prefer.contains("odata.track-changes");
@@ -442,20 +444,20 @@ public class V4Services extends AbstractServices {
         }
 
         output = xml.writeEntitySet(acceptType, new ResWrap<EntitySet>(
-            URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + "Customers"),
-            null,
-            entitySet));
+                URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + "Customers"),
+                null,
+                entitySet));
       } else {
         output = FSManager.instance(version).readFile("delta", acceptType);
       }
 
       final Response response = xml.createResponse(
-          null,
-          output,
-          null,
-          acceptType);
+              null,
+              output,
+              null,
+              acceptType);
       if (StringUtils.isNotBlank(prefer)) {
-        response.getHeaders().put("Preference-Applied", Collections.<Object> singletonList(prefer));
+        response.getHeaders().put("Preference-Applied", Collections.<Object>singletonList(prefer));
       }
       return response;
     } catch (Exception e) {
@@ -466,8 +468,8 @@ public class V4Services extends AbstractServices {
   @GET
   @Path("/Company/Microsoft.Test.OData.Services.ODataWCFService.GetEmployeesCount{paren:[\\(\\)]*}")
   public Response functionGetEmployeesCount(
-      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
 
     try {
       final Accept acceptType;
@@ -481,14 +483,14 @@ public class V4Services extends AbstractServices {
       property.setType("Edm.Int32");
       property.setValue(ValueType.PRIMITIVE, 2);
       final ResWrap<Property> container = new ResWrap<Property>(
-          URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + property.getType()), null,
-          property);
+              URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + property.getType()), null,
+              property);
 
       return xml.createResponse(
-          null,
-          xml.writeProperty(acceptType, container),
-          null,
-          acceptType);
+              null,
+              xml.writeProperty(acceptType, container),
+              null,
+              acceptType);
     } catch (Exception e) {
       return xml.createFaultResponse(accept, e);
     }
@@ -497,10 +499,10 @@ public class V4Services extends AbstractServices {
   @POST
   @Path("/Company/Microsoft.Test.OData.Services.ODataWCFService.IncreaseRevenue{paren:[\\(\\)]*}")
   public Response actionIncreaseRevenue(
-      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-      @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
-      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
-      final String param) {
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+          final String param) {
 
     try {
       final Accept acceptType;
@@ -514,10 +516,10 @@ public class V4Services extends AbstractServices {
       final Entity entry = xml.readEntity(contentTypeValue, IOUtils.toInputStream(param, Constants.ENCODING));
 
       return xml.createResponse(
-          null,
-          xml.writeProperty(acceptType, entry.getProperty("IncreaseValue")),
-          null,
-          acceptType);
+              null,
+              xml.writeProperty(acceptType, entry.getProperty("IncreaseValue")),
+              null,
+              acceptType);
     } catch (Exception e) {
       return xml.createFaultResponse(accept, e);
     }
@@ -526,9 +528,9 @@ public class V4Services extends AbstractServices {
   @GET
   @Path("/Products({entityId})/Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails({param:.*})")
   public Response functionGetProductDetails(
-      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-      @PathParam("entityId") final String entityId,
-      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+          @PathParam("entityId") final String entityId,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
 
     try {
       final Accept acceptType;
@@ -551,18 +553,25 @@ public class V4Services extends AbstractServices {
       productDetailId.setValue(ValueType.PRIMITIVE, 2);
       entry.getProperties().add(productDetailId);
 
+      final Link link = new LinkImpl();
+      link.setRel("edit");
+      link.setHref(URI.create(
+              Constants.get(version, ConstantKey.DEFAULT_SERVICE_URL) 
+              + "ProductDetails(ProductID=6,ProductDetailID=1)").toASCIIString());
+      entry.setEditLink(link);
+
       final EntitySetImpl feed = new EntitySetImpl();
       feed.getEntities().add(entry);
 
       final ResWrap<EntitySet> container = new ResWrap<EntitySet>(
-          URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + "ProductDetail"), null,
-          feed);
+              URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + "ProductDetail"), null,
+              feed);
 
       return xml.createResponse(
-          null,
-          xml.writeEntitySet(acceptType, container),
-          null,
-          acceptType);
+              null,
+              xml.writeEntitySet(acceptType, container),
+              null,
+              acceptType);
     } catch (Exception e) {
       return xml.createFaultResponse(accept, e);
     }
@@ -571,10 +580,10 @@ public class V4Services extends AbstractServices {
   @POST
   @Path("/Products({entityId})/Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight{paren:[\\(\\)]*}")
   public Response actionAddAccessRight(
-      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-      @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
-      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
-      final String param) {
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+          final String param) {
 
     try {
       final Accept acceptType;
@@ -594,28 +603,28 @@ public class V4Services extends AbstractServices {
       property.setType("Microsoft.Test.OData.Services.ODataWCFService.AccessLevel");
 
       final ResWrap<Property> result = new ResWrap<Property>(
-          URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + property.getType()),
-          null, property);
+              URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + property.getType()),
+              null, property);
 
       return xml.createResponse(
-          null,
-          xml.writeProperty(acceptType, result),
-          null,
-          acceptType);
+              null,
+              xml.writeProperty(acceptType, result),
+              null,
+              acceptType);
     } catch (Exception e) {
       return xml.createFaultResponse(accept, e);
     }
   }
 
   @POST
-  @Path("/Customers(PersonID={personId})/Microsoft.Test.OData.Services.ODataWCFService.ResetAddress{paren:[\\(\\)]*}")
+  @Path("/Customers({personId})/Microsoft.Test.OData.Services.ODataWCFService.ResetAddress{paren:[\\(\\)]*}")
   public Response actionResetAddress(
-      @Context final UriInfo uriInfo,
-      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-      @PathParam("personId") final String personId,
-      @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
-      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
-      final String param) {
+          @Context final UriInfo uriInfo,
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+          @PathParam("personId") final String personId,
+          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+          final String param) {
 
     try {
       final Accept contentTypeValue = Accept.parse(contentType, version);
@@ -626,7 +635,7 @@ public class V4Services extends AbstractServices {
       assert entry.getProperty("index") != null;
 
       return getEntityInternal(
-          uriInfo.getRequestUri().toASCIIString(), accept, "Customers", personId, format, null, null);
+              uriInfo.getRequestUri().toASCIIString(), accept, "Customers", personId, format, null, null);
     } catch (Exception e) {
       return xml.createFaultResponse(accept, e);
     }
@@ -634,26 +643,26 @@ public class V4Services extends AbstractServices {
 
   @GET
   @Path("/ProductDetails(ProductID={productId},ProductDetailID={productDetailId})"
-      + "/Microsoft.Test.OData.Services.ODataWCFService.GetRelatedProduct{paren:[\\(\\)]*}")
+          + "/Microsoft.Test.OData.Services.ODataWCFService.GetRelatedProduct{paren:[\\(\\)]*}")
   public Response functionGetRelatedProduct(
-      @Context final UriInfo uriInfo,
-      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-      @PathParam("productId") final String productId,
-      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+          @Context final UriInfo uriInfo,
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+          @PathParam("productId") final String productId,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
 
     return getEntityInternal(
-        uriInfo.getRequestUri().toASCIIString(), accept, "Products", productId, format, null, null);
+            uriInfo.getRequestUri().toASCIIString(), accept, "Products", productId, format, null, null);
   }
 
   @POST
   @Path("/Accounts({entityId})/Microsoft.Test.OData.Services.ODataWCFService.RefreshDefaultPI{paren:[\\(\\)]*}")
   public Response actionRefreshDefaultPI(
-      @Context final UriInfo uriInfo,
-      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-      @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
-      @PathParam("entityId") final String entityId,
-      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
-      final String param) {
+          @Context final UriInfo uriInfo,
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
+          @PathParam("entityId") final String entityId,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+          final String param) {
 
     try {
       final Accept contentTypeValue = Accept.parse(contentType, version);
@@ -671,9 +680,9 @@ public class V4Services extends AbstractServices {
   @GET
   @Path("/Accounts({entityId})/Microsoft.Test.OData.Services.ODataWCFService.GetDefaultPI{paren:[\\(\\)]*}")
   public Response functionGetDefaultPI(
-      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-      @PathParam("entityId") final String entityId,
-      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+          @PathParam("entityId") final String entityId,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
 
     return getContainedEntity(accept, entityId, "MyPaymentInstruments", entityId + "901", format);
   }
@@ -681,9 +690,9 @@ public class V4Services extends AbstractServices {
   @GET
   @Path("/Accounts({entityId})/Microsoft.Test.OData.Services.ODataWCFService.GetAccountInfo{paren:[\\(\\)]*}")
   public Response functionGetAccountInfo(
-      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-      @PathParam("entityId") final String entityId,
-      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+          @PathParam("entityId") final String entityId,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
 
     return getPath(accept, "Accounts", entityId, "AccountInfo", format);
   }
@@ -691,9 +700,9 @@ public class V4Services extends AbstractServices {
   @GET
   @Path("/Accounts({entityId})/MyGiftCard/Microsoft.Test.OData.Services.ODataWCFService.GetActualAmount({param:.*})")
   public Response functionGetActualAmount(
-      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-      @PathParam("entityId") final String entityId,
-      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+          @PathParam("entityId") final String entityId,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
 
     try {
       final Accept acceptType;
@@ -710,10 +719,10 @@ public class V4Services extends AbstractServices {
       final ResWrap<Property> container = new ResWrap<Property>((URI) null, null, property);
 
       return xml.createResponse(
-          null,
-          xml.writeProperty(acceptType, container),
-          null,
-          acceptType);
+              null,
+              xml.writeProperty(acceptType, container),
+              null,
+              acceptType);
     } catch (Exception e) {
       return xml.createFaultResponse(accept, e);
     }
@@ -721,7 +730,7 @@ public class V4Services extends AbstractServices {
 
   /**
    * Retrieve entity reference sample.
-   * 
+   *
    * @param accept Accept header.
    * @param path path.
    * @param format format query option.
@@ -730,9 +739,9 @@ public class V4Services extends AbstractServices {
   @GET
   @Path("/{path:.*}/$ref")
   public Response getEntityReference(
-      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-      @PathParam("path") final String path,
-      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+          @PathParam("path") final String path,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
 
     try {
       final Map.Entry<Accept, AbstractUtilities> utils = getUtilities(accept, format);
@@ -744,10 +753,10 @@ public class V4Services extends AbstractServices {
       final String filename = Base64.encodeBase64String(path.getBytes("UTF-8"));
 
       return utils.getValue().createResponse(
-          FSManager.instance(version).readFile(Constants.get(version, ConstantKey.REF)
+              FSManager.instance(version).readFile(Constants.get(version, ConstantKey.REF)
               + File.separatorChar + filename, utils.getKey()),
-          null,
-          utils.getKey());
+              null,
+              utils.getKey());
     } catch (Exception e) {
       LOG.error("Error retrieving entity", e);
       return xml.createFaultResponse(accept, e);
@@ -756,36 +765,36 @@ public class V4Services extends AbstractServices {
 
   @Override
   public Response patchEntity(
-      final UriInfo uriInfo,
-      final String accept,
-      final String contentType,
-      final String prefer,
-      final String ifMatch,
-      final String entitySetName,
-      final String entityId,
-      final String changes) {
+          final UriInfo uriInfo,
+          final String accept,
+          final String contentType,
+          final String prefer,
+          final String ifMatch,
+          final String entitySetName,
+          final String entityId,
+          final String changes) {
 
     final Response response =
-        getEntityInternal(uriInfo.getRequestUri().toASCIIString(),
+            getEntityInternal(uriInfo.getRequestUri().toASCIIString(),
             accept, entitySetName, entityId, accept, StringUtils.EMPTY, StringUtils.EMPTY);
     return response.getStatus() >= 400
-        ? postNewEntity(uriInfo, accept, contentType, prefer, entitySetName, changes)
-        : super.patchEntity(uriInfo, accept, contentType, prefer, ifMatch, entitySetName, entityId, changes);
+            ? postNewEntity(uriInfo, accept, contentType, prefer, entitySetName, changes)
+            : super.patchEntity(uriInfo, accept, contentType, prefer, ifMatch, entitySetName, entityId, changes);
   }
 
   @Override
   public Response replaceEntity(
-      final UriInfo uriInfo,
-      final String accept,
-      final String contentType,
-      final String prefer,
-      final String entitySetName,
-      final String entityId,
-      final String entity) {
+          final UriInfo uriInfo,
+          final String accept,
+          final String contentType,
+          final String prefer,
+          final String entitySetName,
+          final String entityId,
+          final String entity) {
 
     try {
       getEntityInternal(uriInfo.getRequestUri().toASCIIString(),
-          accept, entitySetName, entityId, accept, StringUtils.EMPTY, StringUtils.EMPTY);
+              accept, entitySetName, entityId, accept, StringUtils.EMPTY, StringUtils.EMPTY);
       return super.replaceEntity(uriInfo, accept, contentType, prefer, entitySetName, entityId, entity);
     } catch (NotFoundException e) {
       return postNewEntity(uriInfo, accept, contentType, prefer, entitySetName, entityId);
@@ -794,19 +803,19 @@ public class V4Services extends AbstractServices {
 
   private StringBuilder containedPath(final String entityId, final String containedEntitySetName) {
     return new StringBuilder("Accounts").append(File.separatorChar).
-        append(entityId).append(File.separatorChar).
-        append("links").append(File.separatorChar).
-        append(containedEntitySetName);
+            append(entityId).append(File.separatorChar).
+            append("links").append(File.separatorChar).
+            append(containedEntitySetName);
   }
 
   @GET
   @Path("/Accounts({entityId})/{containedEntitySetName}({containedEntityId})")
   public Response getContainedEntity(
-      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-      @PathParam("entityId") final String entityId,
-      @PathParam("containedEntitySetName") final String containedEntitySetName,
-      @PathParam("containedEntityId") final String containedEntityId,
-      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+          @PathParam("entityId") final String entityId,
+          @PathParam("containedEntitySetName") final String containedEntitySetName,
+          @PathParam("containedEntityId") final String containedEntityId,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
 
     try {
       final Accept acceptType;
@@ -828,10 +837,10 @@ public class V4Services extends AbstractServices {
       final ResWrap<Entity> container = atomDeserializer.toEntity(entry);
 
       return xml.createResponse(
-          null,
-          xml.writeEntity(acceptType, container),
-          null,
-          acceptType);
+              null,
+              xml.writeEntity(acceptType, container),
+              null,
+              acceptType);
     } catch (Exception e) {
       return xml.createFaultResponse(accept, e);
     }
@@ -840,12 +849,12 @@ public class V4Services extends AbstractServices {
   @POST
   @Path("/Accounts({entityId})/{containedEntitySetName:.*}")
   public Response postContainedEntity(
-      @Context final UriInfo uriInfo,
-      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-      @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
-      @PathParam("entityId") final String entityId,
-      @PathParam("containedEntitySetName") final String containedEntitySetName,
-      final String entity) {
+          @Context final UriInfo uriInfo,
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
+          @PathParam("entityId") final String entityId,
+          @PathParam("containedEntitySetName") final String containedEntitySetName,
+          final String entity) {
 
     try {
       final Accept acceptType = Accept.parse(accept, version);
@@ -864,26 +873,26 @@ public class V4Services extends AbstractServices {
         entry = entryContainer.getPayload();
       } else {
         final ResWrap<Entity> jcontainer = jsonDeserializer.toEntity(
-            IOUtils.toInputStream(entity, Constants.ENCODING));
+                IOUtils.toInputStream(entity, Constants.ENCODING));
         entry = jcontainer.getPayload();
 
         entryContainer = new ResWrap<Entity>(
-            jcontainer.getContextURL(),
-            jcontainer.getMetadataETag(),
-            entry);
+                jcontainer.getContextURL(),
+                jcontainer.getMetadataETag(),
+                entry);
       }
 
       final EdmTypeInfo contained = new EdmTypeInfo.Builder().setTypeExpression(metadata.
-          getNavigationProperties("Accounts").get(containedEntitySetName).getType()).build();
+              getNavigationProperties("Accounts").get(containedEntitySetName).getType()).build();
       final String entityKey = getUtilities(contentTypeValue).
-          getDefaultEntryKey(contained.getFullQualifiedName().getName(), entry);
+              getDefaultEntryKey(contained.getFullQualifiedName().getName(), entry);
 
       // 2. Store the new entity
       final String atomEntryRelativePath = containedPath(entityId, containedEntitySetName).
-          append('(').append(entityKey).append(')').toString();
+              append('(').append(entityKey).append(')').toString();
       FSManager.instance(version).putInMemory(
-          utils.writeEntity(Accept.ATOM, entryContainer),
-          FSManager.instance(version).getAbsolutePath(atomEntryRelativePath, Accept.ATOM));
+              utils.writeEntity(Accept.ATOM, entryContainer),
+              FSManager.instance(version).getAbsolutePath(atomEntryRelativePath, Accept.ATOM));
 
       // 3. Update the contained entity set
       final String atomFeedRelativePath = containedPath(entityId, containedEntitySetName).toString();
@@ -898,16 +907,16 @@ public class V4Services extends AbstractServices {
       writer.close();
 
       FSManager.instance(version).putInMemory(
-          new ByteArrayInputStream(content.toByteArray()),
-          FSManager.instance(version).getAbsolutePath(atomFeedRelativePath, Accept.ATOM));
+              new ByteArrayInputStream(content.toByteArray()),
+              FSManager.instance(version).getAbsolutePath(atomFeedRelativePath, Accept.ATOM));
 
       // Finally, return
       return utils.createResponse(
-          uriInfo.getRequestUri().toASCIIString() + "(" + entityKey + ")",
-          utils.writeEntity(acceptType, entryContainer),
-          null,
-          acceptType,
-          Response.Status.CREATED);
+              uriInfo.getRequestUri().toASCIIString() + "(" + entityKey + ")",
+              utils.writeEntity(acceptType, entryContainer),
+              null,
+              acceptType,
+              Response.Status.CREATED);
     } catch (Exception e) {
       LOG.error("While creating new contained entity", e);
       return xml.createFaultResponse(accept, e);
@@ -917,14 +926,14 @@ public class V4Services extends AbstractServices {
   @PATCH
   @Path("/{entitySetName}({entityId})/{containedEntitySetName}({containedEntityId})")
   public Response patchContainedEntity(
-      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-      @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
-      @PathParam("entitySetName") final String entitySetName,
-      @PathParam("entityId") final String entityId,
-      @PathParam("containedEntitySetName") final String containedEntitySetName,
-      @PathParam("containedEntityId") final String containedEntityId,
-      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
-      final String changes) {
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
+          @PathParam("entitySetName") final String entitySetName,
+          @PathParam("entityId") final String entityId,
+          @PathParam("containedEntitySetName") final String containedEntitySetName,
+          @PathParam("containedEntityId") final String containedEntityId,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+          final String changes) {
 
     try {
       final Accept acceptType;
@@ -944,7 +953,7 @@ public class V4Services extends AbstractServices {
       contentTypeValue = Accept.parse(contentType, version);
 
       final LinkInfo links = xml.readLinks(
-          entitySetName, entityId, containedEntitySetName + "(" + containedEntityId + ")", Accept.ATOM);
+              entitySetName, entityId, containedEntitySetName + "(" + containedEntityId + ")", Accept.ATOM);
 
       ResWrap<Entity> container = atomDeserializer.toEntity(links.getLinks());
       final Entity original = container.getPayload();
@@ -956,11 +965,11 @@ public class V4Services extends AbstractServices {
       } else {
         final String entityType = metadata.getEntitySet(entitySetName).getType();
         final String containedType = metadata.getEntityOrComplexType(entityType).
-            getNavigationProperty(containedEntitySetName).getType();
+                getNavigationProperty(containedEntitySetName).getType();
         final EdmTypeInfo typeInfo = new EdmTypeInfo.Builder().setTypeExpression(containedType).build();
 
         final ResWrap<Entity> jsonContainer = jsonDeserializer.toEntity(
-            IOUtils.toInputStream(changes, Constants.ENCODING));
+                IOUtils.toInputStream(changes, Constants.ENCODING));
         jsonContainer.getPayload().setType(typeInfo.getFullQualifiedName().toString());
         entryChanges = jsonContainer.getPayload();
       }
@@ -974,7 +983,7 @@ public class V4Services extends AbstractServices {
       }
 
       FSManager.instance(version).putInMemory(new ResWrap<Entity>((URI) null, null, original),
-          xml.getLinksBasePath(entitySetName, entityId) + containedEntitySetName + "(" + containedEntityId + ")");
+              xml.getLinksBasePath(entitySetName, entityId) + containedEntitySetName + "(" + containedEntityId + ")");
 
       return xml.createResponse(null, null, acceptType, Response.Status.NO_CONTENT);
     } catch (Exception e) {
@@ -985,20 +994,20 @@ public class V4Services extends AbstractServices {
   @DELETE
   @Path("/Accounts({entityId})/{containedEntitySetName}({containedEntityId})")
   public Response removeContainedEntity(
-      @PathParam("entityId") final String entityId,
-      @PathParam("containedEntitySetName") final String containedEntitySetName,
-      @PathParam("containedEntityId") final String containedEntityId) {
+          @PathParam("entityId") final String entityId,
+          @PathParam("containedEntitySetName") final String containedEntitySetName,
+          @PathParam("containedEntityId") final String containedEntityId) {
 
     try {
       // 1. Fetch the contained entity to be removed
       final InputStream entry = FSManager.instance(version).
-          readFile(containedPath(entityId, containedEntitySetName).
+              readFile(containedPath(entityId, containedEntitySetName).
               append('(').append(containedEntityId).append(')').toString(), Accept.ATOM);
       final ResWrap<Entity> container = atomDeserializer.toEntity(entry);
 
       // 2. Remove the contained entity
       final String atomEntryRelativePath = containedPath(entityId, containedEntitySetName).
-          append('(').append(containedEntityId).append(')').toString();
+              append('(').append(containedEntityId).append(')').toString();
       FSManager.instance(version).deleteFile(atomEntryRelativePath);
 
       // 3. Update the contained entity set
@@ -1014,8 +1023,8 @@ public class V4Services extends AbstractServices {
       writer.close();
 
       FSManager.instance(version).putInMemory(
-          new ByteArrayInputStream(content.toByteArray()),
-          FSManager.instance(version).getAbsolutePath(atomFeedRelativePath, Accept.ATOM));
+              new ByteArrayInputStream(content.toByteArray()),
+              FSManager.instance(version).getAbsolutePath(atomFeedRelativePath, Accept.ATOM));
 
       return xml.createResponse(null, null, null, null, Response.Status.NO_CONTENT);
     } catch (Exception e) {
@@ -1026,10 +1035,10 @@ public class V4Services extends AbstractServices {
   @GET
   @Path("/Accounts({entityId})/{containedEntitySetName:.*}")
   public Response getContainedEntitySet(
-      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-      @PathParam("entityId") final String entityId,
-      @PathParam("containedEntitySetName") String containedEntitySetName,
-      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+          @PathParam("entityId") final String entityId,
+          @PathParam("containedEntitySetName") String containedEntitySetName,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
 
     if ("MyGiftCard".equals(containedEntitySetName)) {
       return getContainedEntity(accept, entityId, containedEntitySetName, null, format);
@@ -1054,7 +1063,7 @@ public class V4Services extends AbstractServices {
       }
 
       final InputStream feed = FSManager.instance(version).
-          readFile(containedPath(entityId, containedEntitySetName).toString(), Accept.ATOM);
+              readFile(containedPath(entityId, containedEntitySetName).toString(), Accept.ATOM);
 
       final ResWrap<EntitySet> container = atomDeserializer.toEntitySet(feed);
 
@@ -1069,10 +1078,10 @@ public class V4Services extends AbstractServices {
       }
 
       return xml.createResponse(
-          null,
-          xml.writeEntitySet(acceptType, container),
-          null,
-          acceptType);
+              null,
+              xml.writeEntitySet(acceptType, container),
+              null,
+              acceptType);
     } catch (Exception e) {
       return xml.createFaultResponse(accept, e);
     }
@@ -1081,8 +1090,8 @@ public class V4Services extends AbstractServices {
   @GET
   @Path("/GetDefaultColor()")
   public Response functionGetDefaultColor(
-      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
 
     try {
       final Accept acceptType;
@@ -1096,14 +1105,14 @@ public class V4Services extends AbstractServices {
       property.setType("Microsoft.Test.OData.Services.ODataWCFService.Color");
       property.setValue(ValueType.ENUM, "Red");
       final ResWrap<Property> container = new ResWrap<Property>(
-          URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + property.getType()), null,
-          property);
+              URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + property.getType()), null,
+              property);
 
       return xml.createResponse(
-          null,
-          xml.writeProperty(acceptType, container),
-          null,
-          acceptType);
+              null,
+              xml.writeProperty(acceptType, container),
+              null,
+              acceptType);
     } catch (Exception e) {
       return xml.createFaultResponse(accept, e);
     }
@@ -1112,31 +1121,31 @@ public class V4Services extends AbstractServices {
   @GET
   @Path("/GetPerson2({param:.*})")
   public Response functionGetPerson2(
-      @Context final UriInfo uriInfo,
-      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+          @Context final UriInfo uriInfo,
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
 
     return getEntityInternal(
-        uriInfo.getRequestUri().toASCIIString(), accept, "Customers", "1", format, null, null);
+            uriInfo.getRequestUri().toASCIIString(), accept, "Customers", "1", format, null, null);
   }
 
   @GET
   @Path("/GetPerson({param:.*})")
   public Response functionGetPerson(
-      @Context final UriInfo uriInfo,
-      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+          @Context final UriInfo uriInfo,
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
 
     return getEntityInternal(
-        uriInfo.getRequestUri().toASCIIString(), accept, "Customers", "1", format, null, null);
+            uriInfo.getRequestUri().toASCIIString(), accept, "Customers", "1", format, null, null);
   }
 
   @GET
   @Path("/GetAllProducts()")
   public Response functionGetAllProducts(
-      @Context final UriInfo uriInfo,
-      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+          @Context final UriInfo uriInfo,
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
 
     return getEntitySet(uriInfo, accept, "Products", null, null, format, null, null, null, null);
   }
@@ -1144,9 +1153,9 @@ public class V4Services extends AbstractServices {
   @GET
   @Path("/GetProductsByAccessLevel({param:.*})")
   public Response functionGetProductsByAccessLevel(
-      @Context final UriInfo uriInfo,
-      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+          @Context final UriInfo uriInfo,
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
 
     try {
       final Accept acceptType;
@@ -1161,14 +1170,14 @@ public class V4Services extends AbstractServices {
       final List<String> value = Arrays.asList("Cheetos", "Mushrooms", "Apple", "Car", "Computer");
       property.setValue(ValueType.COLLECTION_PRIMITIVE, value);
       final ResWrap<Property> container = new ResWrap<Property>(
-          URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + property.getType()), null,
-          property);
+              URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + property.getType()), null,
+              property);
 
       return xml.createResponse(
-          null,
-          xml.writeProperty(acceptType, container),
-          null,
-          acceptType);
+              null,
+              xml.writeProperty(acceptType, container),
+              null,
+              acceptType);
     } catch (Exception e) {
       return xml.createFaultResponse(accept, e);
     }
@@ -1177,9 +1186,9 @@ public class V4Services extends AbstractServices {
   @GET
   @Path("/GetBossEmails({param:.*})")
   public Response functionGetBossEmails(
-      @Context final UriInfo uriInfo,
-      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+          @Context final UriInfo uriInfo,
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
 
     try {
       final Accept acceptType;
@@ -1192,10 +1201,10 @@ public class V4Services extends AbstractServices {
       final PropertyImpl property = new PropertyImpl();
       property.setType("Collection(Edm.String)");
       property.setValue(ValueType.COLLECTION_PRIMITIVE,
-          Arrays.asList("first@olingo.apache.org", "second@olingo.apache.org"));
+              Arrays.asList("first@olingo.apache.org", "second@olingo.apache.org"));
       final ResWrap<Property> container = new ResWrap<Property>(
-          URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + property.getType()), null,
-          property);
+              URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + property.getType()), null,
+              property);
 
       return xml.createResponse(null, xml.writeProperty(acceptType, container), null, acceptType);
     } catch (Exception e) {
@@ -1206,10 +1215,10 @@ public class V4Services extends AbstractServices {
   @POST
   @Path("/Discount()")
   public Response actionDiscount(
-      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-      @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
-      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
-      final String param) {
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+          final String param) {
 
     try {
       final Accept acceptType;
@@ -1223,11 +1232,11 @@ public class V4Services extends AbstractServices {
       Property property;
       if (contentTypeValue == Accept.ATOM) {
         final ResWrap<Property> paramContainer = atomDeserializer.toProperty(
-            IOUtils.toInputStream(param, Constants.ENCODING));
+                IOUtils.toInputStream(param, Constants.ENCODING));
         property = paramContainer.getPayload();
       } else {
         final ResWrap<Property> paramContainer = jsonDeserializer.toProperty(
-            IOUtils.toInputStream(param, Constants.ENCODING));
+                IOUtils.toInputStream(param, Constants.ENCODING));
         property = paramContainer.getPayload();
       }
 
@@ -1246,10 +1255,10 @@ public class V4Services extends AbstractServices {
   @POST
   @Path("/ResetBossAddress()")
   public Response actionResetBossAddress(
-      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-      @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
-      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
-      final String param) {
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+          final String param) {
 
     try {
       final Accept acceptType;
@@ -1266,16 +1275,16 @@ public class V4Services extends AbstractServices {
       assert entity.getProperty("address").isComplex();
 
       final ResWrap<Property> result = new ResWrap<Property>(
-          URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX)
+              URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX)
               + "Microsoft.Test.OData.Services.ODataWCFService.Address"),
-          null,
-          entity.getProperty("address"));
+              null,
+              entity.getProperty("address"));
 
       return xml.createResponse(
-          null,
-          xml.writeProperty(acceptType, result),
-          null,
-          acceptType);
+              null,
+              xml.writeProperty(acceptType, result),
+              null,
+              acceptType);
     } catch (Exception e) {
       return xml.createFaultResponse(accept, e);
     }
@@ -1284,10 +1293,10 @@ public class V4Services extends AbstractServices {
   @POST
   @Path("/ResetBossEmail()")
   public Response actionResetBossEmail(
-      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-      @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
-      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
-      final String param) {
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+          final String param) {
 
     try {
       final Accept acceptType;
@@ -1305,10 +1314,10 @@ public class V4Services extends AbstractServices {
       assert entry.getProperty("emails").isCollection();
 
       return xml.createResponse(
-          null,
-          xml.writeProperty(acceptType, entry.getProperty("emails")),
-          null,
-          acceptType);
+              null,
+              xml.writeProperty(acceptType, entry.getProperty("emails")),
+              null,
+              acceptType);
     } catch (Exception e) {
       return xml.createFaultResponse(accept, e);
     }
@@ -1317,10 +1326,10 @@ public class V4Services extends AbstractServices {
   @POST
   @Path("/Products({productId})/Categories/$ref")
   public Response createLinked(
-      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-      @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
-      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
-      final String entity) {
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+          final String entity) {
 
     return xml.createResponse(null, null, null, Status.NO_CONTENT);
   }
@@ -1328,10 +1337,10 @@ public class V4Services extends AbstractServices {
   @DELETE
   @Path("/Products({productId})/Categories({categoryId})/$ref")
   public Response deleteLinked(
-      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-      @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
-      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
-      final String entity) {
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+          final String entity) {
 
     return xml.createResponse(null, null, null, Status.NO_CONTENT);
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6587302a/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java b/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java
index fba674b..ea467c4 100644
--- a/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java
@@ -448,7 +448,7 @@ public class XMLUtilities extends AbstractUtilities {
     XMLEventWriter writer = getEventWriter(bos);
 
     final String editLinkElement = String.format("<link rel=\"edit\" title=\"%s\" href=\"%s\" />", title, href);
-    System.out.println("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA replace with " + editLinkElement);
+    
     try {
       // check edit link existence
       extractElement(reader, writer, Collections.<String>singletonList(Constants.get(version, ConstantKey.LINK)),

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6587302a/fit/src/main/resources/V40/Accounts/101/links/MyPaymentInstruments(101901).xml
----------------------------------------------------------------------
diff --git a/fit/src/main/resources/V40/Accounts/101/links/MyPaymentInstruments(101901).xml b/fit/src/main/resources/V40/Accounts/101/links/MyPaymentInstruments(101901).xml
index b4bf571..7bae727 100644
--- a/fit/src/main/resources/V40/Accounts/101/links/MyPaymentInstruments(101901).xml
+++ b/fit/src/main/resources/V40/Accounts/101/links/MyPaymentInstruments(101901).xml
@@ -21,6 +21,7 @@
 -->
 <entry xml:base="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://docs.oasis-open.org/odata/ns/data" xmlns:m="http://docs.oasis-open.org/odata/ns/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml" m:context="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/$metadata#Accounts(101)/MyPaymentInstruments/$entity">
   <category term="#Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument" scheme="http://docs.oasis-open.org/odata/ns/scheme"/>
+  <link rel="edit" href="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(101)/MyPaymentInstruments(101901)"/>
   <link rel="http://docs.oasis-open.org/odata/ns/related/TheStoredPI" type="application/atom+xml;type=entry" title="TheStoredPI" href="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(101)/MyPaymentInstruments(101901)/TheStoredPI"/>
   <link rel="http://docs.oasis-open.org/odata/ns/related/BillingStatements" type="application/atom+xml;type=feed" title="BillingStatements" href="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(101)/MyPaymentInstruments(101901)/BillingStatements"/>
   <link rel="http://docs.oasis-open.org/odata/ns/related/BackupStoredPI" type="application/atom+xml;type=entry" title="BackupStoredPI" href="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(101)/MyPaymentInstruments(101901)/BackupStoredPI"/>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6587302a/fit/src/main/resources/V40/Accounts/101/links/MyPaymentInstruments(101902).xml
----------------------------------------------------------------------
diff --git a/fit/src/main/resources/V40/Accounts/101/links/MyPaymentInstruments(101902).xml b/fit/src/main/resources/V40/Accounts/101/links/MyPaymentInstruments(101902).xml
index 78397c9..1d967ed 100644
--- a/fit/src/main/resources/V40/Accounts/101/links/MyPaymentInstruments(101902).xml
+++ b/fit/src/main/resources/V40/Accounts/101/links/MyPaymentInstruments(101902).xml
@@ -21,6 +21,7 @@
 -->
 <entry xml:base="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://docs.oasis-open.org/odata/ns/data" xmlns:m="http://docs.oasis-open.org/odata/ns/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml" m:context="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/$metadata#Accounts(101)/MyPaymentInstruments/$entity">
   <category term="#Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument" scheme="http://docs.oasis-open.org/odata/ns/scheme"/>
+  <link rel="edit" href="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(101)/MyPaymentInstruments(101902)"/>
   <link rel="http://docs.oasis-open.org/odata/ns/related/TheStoredPI" type="application/atom+xml;type=entry" title="TheStoredPI" href="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(101)/MyPaymentInstruments(101902)/TheStoredPI"/>
   <link rel="http://docs.oasis-open.org/odata/ns/related/BillingStatements" type="application/atom+xml;type=feed" title="BillingStatements" href="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(101)/MyPaymentInstruments(101902)/BillingStatements"/>
   <link rel="http://docs.oasis-open.org/odata/ns/related/BackupStoredPI" type="application/atom+xml;type=entry" title="BackupStoredPI" href="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(101)/MyPaymentInstruments(101902)/BackupStoredPI"/>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6587302a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AbstractTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AbstractTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AbstractTestITCase.java
index cf19a12..bbf077f 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AbstractTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AbstractTestITCase.java
@@ -139,7 +139,7 @@ public abstract class AbstractTestITCase {
   }
 
   protected Customer readCustomer(final DefaultContainer container, final int id) {
-    final Customer customer = container.getCustomer().get(id);
+    final Customer customer = container.getCustomer().get(id).load();
     assertNotNull(customer);
     assertEquals(Integer.valueOf(id), customer.getCustomerId());
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6587302a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AsyncTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AsyncTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AsyncTestITCase.java
index 951e499..bd593e1 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AsyncTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AsyncTestITCase.java
@@ -94,7 +94,7 @@ public class AsyncTestITCase extends AbstractTestITCase {
       }
     };
 
-    assertEquals("AsyncTest#updateEntity " + random, futureProd.get().getDescription());
+    assertEquals("AsyncTest#updateEntity " + random, futureProd.get().load().getDescription());
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6587302a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/ContextTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/ContextTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/ContextTestITCase.java
index 9caab38..405e741 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/ContextTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/ContextTestITCase.java
@@ -22,7 +22,6 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -59,9 +58,9 @@ public class ContextTestITCase extends AbstractTestITCase {
     final Customer customer2 = container.getCustomer().newCustomer();
 
     final EntityInvocationHandler source1 =
-        (EntityInvocationHandler) Proxy.getInvocationHandler(customer1);
+            (EntityInvocationHandler) Proxy.getInvocationHandler(customer1);
     final EntityInvocationHandler source2 =
-        (EntityInvocationHandler) Proxy.getInvocationHandler(customer2);
+            (EntityInvocationHandler) Proxy.getInvocationHandler(customer2);
 
     assertTrue(containerFactory.getContext().entityContext().isAttached(source1));
     assertTrue(containerFactory.getContext().entityContext().isAttached(source2));
@@ -82,11 +81,11 @@ public class ContextTestITCase extends AbstractTestITCase {
     final Customer customer3 = container.getCustomer().get(-10);
 
     final EntityInvocationHandler source1 =
-        (EntityInvocationHandler) Proxy.getInvocationHandler(customer1);
+            (EntityInvocationHandler) Proxy.getInvocationHandler(customer1);
     final EntityInvocationHandler source2 =
-        (EntityInvocationHandler) Proxy.getInvocationHandler(customer2);
+            (EntityInvocationHandler) Proxy.getInvocationHandler(customer2);
     final EntityInvocationHandler source3 =
-        (EntityInvocationHandler) Proxy.getInvocationHandler(customer3);
+            (EntityInvocationHandler) Proxy.getInvocationHandler(customer3);
 
     assertFalse(containerFactory.getContext().entityContext().isAttached(source1));
     assertFalse(containerFactory.getContext().entityContext().isAttached(source2));
@@ -130,9 +129,9 @@ public class ContextTestITCase extends AbstractTestITCase {
     assertNotNull(customer.getInfo());
 
     final EntityInvocationHandler source =
-        (EntityInvocationHandler) Proxy.getInvocationHandler(customer);
+            (EntityInvocationHandler) Proxy.getInvocationHandler(customer);
     final EntityInvocationHandler target =
-        (EntityInvocationHandler) Proxy.getInvocationHandler(customerInfo);
+            (EntityInvocationHandler) Proxy.getInvocationHandler(customerInfo);
 
     assertTrue(containerFactory.getContext().entityContext().isAttached(source));
     assertEquals(AttachedEntityStatus.NEW, containerFactory.getContext().entityContext().getStatus(source));
@@ -150,7 +149,7 @@ public class ContextTestITCase extends AbstractTestITCase {
   @Test
   public void linkSourceExisting() {
     final Customer customer = container.getCustomer().get(-10);
-    ;
+
     final CustomerInfo customerInfo = container.getCustomerInfo().newCustomerInfo();
 
     customer.setInfo(customerInfo);
@@ -158,9 +157,9 @@ public class ContextTestITCase extends AbstractTestITCase {
     assertNotNull(customer.getInfo());
 
     final EntityInvocationHandler source =
-        (EntityInvocationHandler) Proxy.getInvocationHandler(customer);
+            (EntityInvocationHandler) Proxy.getInvocationHandler(customer);
     final EntityInvocationHandler target =
-        (EntityInvocationHandler) Proxy.getInvocationHandler(customerInfo);
+            (EntityInvocationHandler) Proxy.getInvocationHandler(customerInfo);
 
     assertTrue(containerFactory.getContext().entityContext().isAttached(source));
     assertEquals(AttachedEntityStatus.CHANGED, containerFactory.getContext().entityContext().getStatus(source));
@@ -185,9 +184,9 @@ public class ContextTestITCase extends AbstractTestITCase {
     assertNotNull(customer.getInfo());
 
     final EntityInvocationHandler source =
-        (EntityInvocationHandler) Proxy.getInvocationHandler(customer);
+            (EntityInvocationHandler) Proxy.getInvocationHandler(customer);
     final EntityInvocationHandler target =
-        (EntityInvocationHandler) Proxy.getInvocationHandler(customerInfo);
+            (EntityInvocationHandler) Proxy.getInvocationHandler(customerInfo);
 
     assertTrue(containerFactory.getContext().entityContext().isAttached(source));
     assertEquals(AttachedEntityStatus.CHANGED, containerFactory.getContext().entityContext().getStatus(source));
@@ -235,7 +234,7 @@ public class ContextTestITCase extends AbstractTestITCase {
 
     for (Order order : toBeLinked) {
       assertFalse(containerFactory.getContext().entityContext().
-          isAttached((EntityInvocationHandler) Proxy.getInvocationHandler(order)));
+              isAttached((EntityInvocationHandler) Proxy.getInvocationHandler(order)));
     }
   }
 
@@ -250,7 +249,7 @@ public class ContextTestITCase extends AbstractTestITCase {
     cd.setAlternativeNames(Arrays.asList("alternative1", "alternative2"));
 
     final ContactDetails bcd = customer.factory().newBackupContactInfo();
-    customer.setBackupContactInfo(Collections.<ContactDetails> singletonList(bcd));
+    customer.setBackupContactInfo(Collections.<ContactDetails>singletonList(bcd));
 
     bcd.setAlternativeNames(Arrays.asList("alternative3", "alternative4"));
 
@@ -273,7 +272,7 @@ public class ContextTestITCase extends AbstractTestITCase {
 
   @Test
   public void readEntityInTheContext() {
-    CustomerInfo customerInfo = container.getCustomerInfo().get(16);
+    CustomerInfo customerInfo = container.getCustomerInfo().get(16).load();
     customerInfo.setInformation("some other info ...");
 
     assertEquals("some other info ...", customerInfo.getInformation());
@@ -288,7 +287,7 @@ public class ContextTestITCase extends AbstractTestITCase {
 
   @Test
   public void readAllWithEntityInTheContext() {
-    CustomerInfo customerInfo = container.getCustomerInfo().get(16);
+    CustomerInfo customerInfo = container.getCustomerInfo().get(16).load();
     customerInfo.setInformation("some other info ...");
 
     assertEquals("some other info ...", customerInfo.getInformation());
@@ -343,7 +342,12 @@ public class ContextTestITCase extends AbstractTestITCase {
 
     container.flush();
     assertFalse(containerFactory.getContext().entityContext().isAttached(handler));
-    assertNull(container.getLogin().get("customer"));
+
+    try {
+      container.getLogin().get("customer").load();
+      fail();
+    } catch (IllegalArgumentException e) {
+    }
   }
 
   @Test
@@ -374,62 +378,62 @@ public class ContextTestITCase extends AbstractTestITCase {
 
     final ContactDetails cd = customer.factory().newPrimaryContactInfo();
     cd.setAlternativeNames(Arrays.asList("alternative1", "alternative2"));
-    cd.setEmailBag(Collections.<String> singleton("myemail@mydomain.org"));
-    cd.setMobilePhoneBag(Collections.<Phone> emptySet());
+    cd.setEmailBag(Collections.<String>singleton("myemail@mydomain.org"));
+    cd.setMobilePhoneBag(Collections.<Phone>emptySet());
 
     final ContactDetails bcd = customer.factory().newBackupContactInfo();
     bcd.setAlternativeNames(Arrays.asList("alternative3", "alternative4"));
-    bcd.setEmailBag(Collections.<String> emptySet());
-    bcd.setMobilePhoneBag(Collections.<Phone> emptySet());
+    bcd.setEmailBag(Collections.<String>emptySet());
+    bcd.setMobilePhoneBag(Collections.<Phone>emptySet());
 
     customer.setPrimaryContactInfo(cd);
-    customer.setBackupContactInfo(Collections.<ContactDetails> singletonList(bcd));
+    customer.setBackupContactInfo(Collections.<ContactDetails>singletonList(bcd));
 
     assertTrue(containerFactory.getContext().entityContext().
-        isAttached((EntityInvocationHandler) Proxy.getInvocationHandler(customerInfo)));
+            isAttached((EntityInvocationHandler) Proxy.getInvocationHandler(customerInfo)));
     assertTrue(containerFactory.getContext().entityContext().
-        isAttached((EntityInvocationHandler) Proxy.getInvocationHandler(customer)));
+            isAttached((EntityInvocationHandler) Proxy.getInvocationHandler(customer)));
     for (Order linked : toBeLinked) {
       assertTrue(containerFactory.getContext().entityContext().
-          isAttached((EntityInvocationHandler) Proxy.getInvocationHandler(linked)));
+              isAttached((EntityInvocationHandler) Proxy.getInvocationHandler(linked)));
     }
 
     container.flush();
 
     assertFalse(containerFactory.getContext().entityContext().
-        isAttached((EntityInvocationHandler) Proxy.getInvocationHandler(customerInfo)));
+            isAttached((EntityInvocationHandler) Proxy.getInvocationHandler(customerInfo)));
     assertFalse(containerFactory.getContext().entityContext().
-        isAttached((EntityInvocationHandler) Proxy.getInvocationHandler(customer)));
+            isAttached((EntityInvocationHandler) Proxy.getInvocationHandler(customer)));
     for (Order linked : toBeLinked) {
       assertFalse(containerFactory.getContext().entityContext().
-          isAttached((EntityInvocationHandler) Proxy.getInvocationHandler(linked)));
+              isAttached((EntityInvocationHandler) Proxy.getInvocationHandler(linked)));
     }
 
-    assertEquals("some new info ...", container.getCustomerInfo().get(16).getInformation());
+    assertEquals("some new info ...", container.getCustomerInfo().get(16).load().getInformation());
 
     container.getOrder().delete(toBeLinked);
     container.getCustomer().delete(customer.getCustomerId());
 
     assertTrue(containerFactory.getContext().entityContext().
-        isAttached((EntityInvocationHandler) Proxy.getInvocationHandler(customer)));
+            isAttached((EntityInvocationHandler) Proxy.getInvocationHandler(customer)));
     for (Order linked : toBeLinked) {
       assertTrue(containerFactory.getContext().entityContext().
-          isAttached((EntityInvocationHandler) Proxy.getInvocationHandler(linked)));
+              isAttached((EntityInvocationHandler) Proxy.getInvocationHandler(linked)));
     }
 
     container.flush();
 
     assertFalse(containerFactory.getContext().entityContext().
-        isAttached((EntityInvocationHandler) Proxy.getInvocationHandler(customer)));
+            isAttached((EntityInvocationHandler) Proxy.getInvocationHandler(customer)));
     for (Order linked : toBeLinked) {
       assertFalse(containerFactory.getContext().entityContext().
-          isAttached((EntityInvocationHandler) Proxy.getInvocationHandler(linked)));
+              isAttached((EntityInvocationHandler) Proxy.getInvocationHandler(linked)));
     }
   }
 
   private void checkUnlink(
-      final String sourceName,
-      final EntityInvocationHandler source) {
+          final String sourceName,
+          final EntityInvocationHandler source) {
 
     boolean found = false;
     for (Map.Entry<NavigationProperty, Object> property : source.getLinkChanges().entrySet()) {
@@ -441,10 +445,10 @@ public class ContextTestITCase extends AbstractTestITCase {
   }
 
   private void checkLink(
-      final String sourceName,
-      final EntityInvocationHandler source,
-      final EntityInvocationHandler target,
-      final boolean isCollection) {
+          final String sourceName,
+          final EntityInvocationHandler source,
+          final EntityInvocationHandler target,
+          final boolean isCollection) {
 
     boolean found = false;
     for (Map.Entry<NavigationProperty, Object> property : source.getLinkChanges().entrySet()) {
@@ -458,7 +462,7 @@ public class ContextTestITCase extends AbstractTestITCase {
           }
         } else {
           found = target.equals(
-              (EntityInvocationHandler) Proxy.getInvocationHandler(property.getValue()));
+                  (EntityInvocationHandler) Proxy.getInvocationHandler(property.getValue()));
         }
       }
     }
@@ -466,11 +470,11 @@ public class ContextTestITCase extends AbstractTestITCase {
   }
 
   private void checkUnidirectional(
-      final String sourceName,
-      final EntityInvocationHandler source,
-      final String targetName,
-      final EntityInvocationHandler target,
-      final boolean isCollection) {
+          final String sourceName,
+          final EntityInvocationHandler source,
+          final String targetName,
+          final EntityInvocationHandler target,
+          final boolean isCollection) {
 
     checkLink(sourceName, source, target, isCollection);
     checkUnlink(targetName, target);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6587302a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/EntityCreateTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/EntityCreateTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/EntityCreateTestITCase.java
index 766db4f..211ced3 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/EntityCreateTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/EntityCreateTestITCase.java
@@ -18,6 +18,7 @@
  */
 package org.apache.olingo.fit.proxy.v3;
 
+import static org.apache.olingo.fit.proxy.v3.AbstractTestITCase.container;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
@@ -30,6 +31,7 @@ import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.service
 import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.MessageKey;
 import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.Order;
 import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.OrderCollection;
+import static org.junit.Assert.fail;
 //CHECKSTYLE:ON (Maven checkstyle)
 import org.junit.Test;
 
@@ -55,18 +57,24 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
     assertNull(actual);
 
     containerFactory.getContext().detachAll();
-    actual = container.getCustomer().get(id);
-    assertNotNull(actual);
+    actual = container.getCustomer().get(id).load();
 
     container.getCustomer().delete(actual.getCustomerId());
     container.flush();
 
-    actual = container.getCustomer().get(id);
-    assertNull(actual);
+    try {
+      container.getCustomer().get(id).load();
+      fail();
+    } catch (IllegalArgumentException e) {
+    }
 
     containerFactory.getContext().detachAll();
-    actual = container.getCustomer().get(id);
-    assertNull(actual);
+
+    try {
+      container.getCustomer().get(id).load();
+      fail();
+    } catch (IllegalArgumentException e) {
+    }
   }
 
   @Test
@@ -82,23 +90,30 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
 
     container.flush();
 
-    Employee actual = container.getPerson().get(id, Employee.class);
+    Employee actual = container.getPerson().get(id, Employee.class).load();
     assertNotNull(actual);
     assertEquals(id, actual.getPersonId());
 
     containerFactory.getContext().detachAll();
-    actual = container.getPerson().get(id, Employee.class);
+    actual = container.getPerson().get(id, Employee.class).load();
     assertNotNull(actual);
 
     container.getPerson().delete(actual.getPersonId());
     container.flush();
 
-    actual = container.getPerson().get(id, Employee.class);
-    assertNull(actual);
+    try {
+      container.getPerson().get(id, Employee.class).load();
+      fail();
+    } catch (IllegalArgumentException e) {
+    }
 
     containerFactory.getContext().detachAll();
-    actual = container.getPerson().get(id, Employee.class);
-    assertNull(actual);
+
+    try {
+      container.getPerson().get(id, Employee.class).load();
+      fail();
+    } catch (IllegalArgumentException e) {
+    }
   }
 
   @Test
@@ -117,8 +132,11 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
     container.getCustomer().delete(actual.getCustomerId());
     container.flush();
 
-    actual = container.getCustomer().get(id);
-    assertNull(actual);
+    try {
+      container.getCustomer().get(id).load();
+      fail();
+    } catch (IllegalArgumentException e) {
+    }
   }
 
   @Test
@@ -156,8 +174,11 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
     container.getOrder().delete(actual.getOrders());
     container.flush();
 
-    order = container.getOrder().get(id);
-    assertNull(order);
+    try {
+      container.getOrder().get(id).load();
+      fail();
+    } catch (IllegalArgumentException e) {
+    }
 
     actual = readCustomer(container, id);
     assertTrue(actual.getOrders().isEmpty());
@@ -165,8 +186,11 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
     container.getCustomer().delete(actual.getCustomerId());
     container.flush();
 
-    actual = container.getCustomer().get(id);
-    assertNull(actual);
+    try {
+      container.getCustomer().get(id).load();
+      fail();
+    } catch (IllegalArgumentException e) {
+    }
   }
 
   @Test
@@ -185,7 +209,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
     key.setFromUsername("fromusername");
     key.setMessageId(100);
 
-    message = container.getMessage().get(key);
+    message = container.getMessage().get(key).load();
     assertNotNull(message);
     assertEquals(Integer.valueOf(100), message.getMessageId());
     assertEquals("fromusername", message.getFromUsername());
@@ -196,6 +220,10 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
     container.getMessage().delete(key);
     container.flush();
 
-    assertNull(container.getMessage().get(key));
+    try {
+      container.getMessage().get(key).load();
+      fail();
+    } catch (IllegalArgumentException e) {
+    }
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6587302a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/EntityRetrieveTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/EntityRetrieveTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/EntityRetrieveTestITCase.java
index 2c95dcf..eb75c79 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/EntityRetrieveTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/EntityRetrieveTestITCase.java
@@ -25,6 +25,7 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import java.lang.reflect.Proxy;
+import java.sql.Timestamp;
 import java.util.Calendar;
 import java.util.Collection;
 
@@ -116,8 +117,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
 
   @Test
   public void navigate() {
-    final Order order = getContainer().getOrder().get(-9);
-    assertNotNull(order);
+    final Order order = getContainer().getOrder().get(-9).load();
     assertEquals(-9, order.getOrderId(), 0);
 
     final ConcurrencyInfo concurrency = order.getConcurrency();
@@ -126,13 +126,13 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
     actual.clear();
     actual.set(2012, 1, 12, 11, 32, 50);
     actual.set(Calendar.MILLISECOND, 507);
-    assertEquals(actual.getTimeInMillis(), concurrency.getQueriedDateTime().getTimeInMillis());
+    assertEquals(actual.getTimeInMillis(), concurrency.getQueriedDateTime().getTime());
     assertEquals(78, order.getCustomerId(), 0);
   }
 
   @Test
   public void withGeospatial() {
-    final AllSpatialTypes allSpatialTypes = getContainer().getAllGeoTypesSet().get(-10);
+    final AllSpatialTypes allSpatialTypes = getContainer().getAllGeoTypesSet().get(-10).load();
     assertNotNull(allSpatialTypes);
     assertEquals(-10, allSpatialTypes.getId(), 0);
 
@@ -167,12 +167,12 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
 
   @Test
   public void withActions() {
-    final ComputerDetail computerDetail = getContainer().getComputerDetail().get(-10);
+    final ComputerDetail computerDetail = getContainer().getComputerDetail().get(-10).load();
     assertEquals(-10, computerDetail.getComputerDetailId(), 0);
 
     try {
       assertNotNull(computerDetail.operations().getClass().getMethod(
-          "resetComputerDetailsSpecifications", Collection.class, Calendar.class));
+          "resetComputerDetailsSpecifications", Collection.class, Timestamp.class));
     } catch (Exception e) {
       fail();
     }
@@ -184,14 +184,13 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
     messageKey.setFromUsername("1");
     messageKey.setMessageId(-10);
 
-    final Message message = getContainer().getMessage().get(messageKey);
-    assertNotNull(message);
+    final Message message = getContainer().getMessage().get(messageKey).load();
     assertEquals("1", message.getFromUsername());
   }
 
   @Test
   public void checkForETag() {
-    Product product = getContainer().getProduct().get(-10);
+    Product product = getContainer().getProduct().get(-10).load();
     assertTrue(StringUtils.isNotBlank(
         ((EntityInvocationHandler) Proxy.getInvocationHandler(product)).getETag()));
   }