olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [2/2] git commit: [OLINGO-244] Implementation and IT provided
Date Mon, 14 Apr 2014 12:12:03 GMT
[OLINGO-244] Implementation and IT provided


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

Branch: refs/heads/master
Commit: d5e29b02075bf60dfcf733e9c41e691ba348ece7
Parents: 1585f2d
Author: Francesco Chicchiriccò <ilgrosso@apache.org>
Authored: Mon Apr 14 14:11:43 2014 +0200
Committer: Francesco Chicchiriccò <ilgrosso@apache.org>
Committed: Mon Apr 14 14:11:43 2014 +0200

----------------------------------------------------------------------
 .../org/apache/olingo/fit/AbstractServices.java | 224 +-----------------
 .../org/apache/olingo/fit/V3KeyAsSegment.java   |  12 +-
 .../java/org/apache/olingo/fit/V3Services.java  | 226 +++++++++++++++++++
 .../java/org/apache/olingo/fit/V4Services.java  |  38 ++++
 .../org/apache/olingo/fit/utils/Accept.java     |  24 +-
 .../olingo/client/api/CommonODataClient.java    |   5 +-
 .../request/cud/CommonCUDRequestFactory.java    |  41 +---
 .../request/cud/CommonUpdateType.java           |  31 +++
 .../request/cud/ODataLinkCreateRequest.java     |  29 ---
 .../request/cud/ODataLinkUpdateRequest.java     |  29 ---
 .../communication/request/cud/UpdateType.java   |  31 ---
 .../request/cud/v3/CUDRequestFactory.java       |  29 ++-
 .../request/cud/v3/ODataLinkCreateRequest.java  |  29 +++
 .../request/cud/v3/ODataLinkUpdateRequest.java  |  29 +++
 .../request/cud/v3/UpdateType.java              |   3 +-
 .../request/cud/v4/CUDRequestFactory.java       |  15 +-
 .../request/cud/v4/UpdateType.java              |   3 +-
 .../olingo/client/api/v3/ODataClient.java       |   3 +-
 .../olingo/client/api/v4/ODataClient.java       |   3 +-
 .../olingo/client/core/AbstractODataClient.java |   3 +-
 .../request/cud/AbstractCUDRequestFactory.java  |  40 +---
 .../cud/ODataEntityUpdateRequestImpl.java       |   2 +-
 .../request/cud/ODataLinkCreateRequestImpl.java | 108 ---------
 .../request/cud/ODataLinkUpdateRequestImpl.java | 111 ---------
 .../request/cud/v3/CUDRequestFactoryImpl.java   |  28 ++-
 .../cud/v3/ODataLinkCreateRequestImpl.java      | 108 +++++++++
 .../cud/v3/ODataLinkUpdateRequestImpl.java      | 111 +++++++++
 .../request/cud/v4/CUDRequestFactoryImpl.java   |  15 +-
 .../olingo/client/core/v3/ODataClientImpl.java  |   4 +-
 .../olingo/client/core/v4/ODataClientImpl.java  |   4 +-
 .../client/core/it/v3/AbstractTestITCase.java   |   2 +-
 .../client/core/it/v3/LinkTestITCase.java       |   5 +-
 .../core/it/v4/EntityUpdateTestITCase.java      |  82 +++++++
 .../edm/primitivetype/EdmDateTimeOffset.java    |   7 +-
 34 files changed, 806 insertions(+), 628 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d5e29b02/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
index 2cff9e1..01a5326 100644
--- a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
+++ b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
@@ -216,13 +216,14 @@ public abstract class AbstractServices {
   @Consumes({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
   public Response mergeEntity(
           @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
           @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) String prefer,
           @HeaderParam("If-Match") @DefaultValue(StringUtils.EMPTY) String ifMatch,
           @PathParam("entitySetName") String entitySetName,
           @PathParam("entityId") String entityId,
           final String changes) {
 
-    return patchEntity(accept, prefer, ifMatch, entitySetName, entityId, changes);
+    return patchEntity(accept, contentType, prefer, ifMatch, entitySetName, entityId, changes);
   }
 
   @PATCH
@@ -231,6 +232,7 @@ public abstract class AbstractServices {
   @Consumes({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
   public Response patchEntity(
           @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
           @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) String prefer,
           @HeaderParam("If-Match") @DefaultValue(StringUtils.EMPTY) String ifMatch,
           @PathParam("entitySetName") String entitySetName,
@@ -245,7 +247,7 @@ public abstract class AbstractServices {
       }
 
       final AbstractUtilities util = acceptType == Accept.ATOM ? xml : json;
-      InputStream res =
+      final InputStream res =
               util.patchEntity(entitySetName, entityId, IOUtils.toInputStream(changes), acceptType, ifMatch);
 
       final FITAtomDeserializer atomDeserializer = Commons.getAtomDeserializer(version);
@@ -294,6 +296,7 @@ public abstract class AbstractServices {
   @Consumes({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
   public Response replaceEntity(
           @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
           @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) String prefer,
           @PathParam("entitySetName") String entitySetName,
           @PathParam("entityId") String entityId,
@@ -782,7 +785,7 @@ public abstract class AbstractServices {
       final Map.Entry<String, InputStream> entityInfo =
               utils.getValue().readEntity(entitySetName, entityId, Accept.ATOM);
 
-      InputStream entity = entityInfo.getValue();
+      final InputStream entity = entityInfo.getValue();
 
       final FITAtomDeserializer atomDeserializer = Commons.getAtomDeserializer(version);
       final AtomSerializer atomSerializer = Commons.getAtomSerializer(version);
@@ -1356,219 +1359,6 @@ public abstract class AbstractServices {
   }
 
   /**
-   * Retrieve links sample.
-   *
-   * @param accept Accept header.
-   * @param entitySetName Entity set name.
-   * @param entityId entity id.
-   * @param linkName link name.
-   * @param format format query option.
-   * @return links.
-   */
-  @GET
-  @Path("/{entitySetName}({entityId})/$links/{linkName}")
-  public Response getLinks(
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @PathParam("entitySetName") String entitySetName,
-          @PathParam("entityId") String entityId,
-          @PathParam("linkName") String linkName,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
-    try {
-      final Accept acceptType;
-      if (StringUtils.isNotBlank(format)) {
-        acceptType = Accept.valueOf(format.toUpperCase());
-      } else {
-        acceptType = Accept.parse(accept, version);
-      }
-
-      if (acceptType == Accept.ATOM) {
-        throw new UnsupportedMediaTypeException("Unsupported media type");
-      }
-
-      final LinkInfo links = xml.readLinks(entitySetName, entityId, linkName, acceptType);
-
-      return xml.createResponse(
-              links.getLinks(),
-              links.getEtag(),
-              acceptType);
-    } catch (Exception e) {
-      return xml.createFaultResponse(accept, e);
-    }
-  }
-
-  @POST
-  @Path("/{entitySetName}({entityId})/$links/{linkName}")
-  public Response postLink(
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
-          @PathParam("entitySetName") String entitySetName,
-          @PathParam("entityId") String entityId,
-          @PathParam("linkName") String linkName,
-          String link,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
-    try {
-      final Accept acceptType;
-      if (StringUtils.isNotBlank(format)) {
-        acceptType = Accept.valueOf(format.toUpperCase());
-      } else {
-        acceptType = Accept.parse(accept, version);
-      }
-
-      if (acceptType == Accept.ATOM) {
-        throw new UnsupportedMediaTypeException("Unsupported media type");
-      }
-
-      final Accept content;
-      if (StringUtils.isNotBlank(contentType)) {
-        content = Accept.parse(contentType, version);
-      } else {
-        content = acceptType;
-      }
-
-      final AbstractUtilities utils = getUtilities(acceptType);
-
-      final List<String> links;
-      if (content == Accept.XML || content == Accept.TEXT || content == Accept.ATOM) {
-        links = xml.extractLinkURIs(IOUtils.toInputStream(link)).getValue();
-      } else {
-        links = json.extractLinkURIs(IOUtils.toInputStream(link)).getValue();
-      }
-
-      utils.putLinksInMemory(
-              Commons.getEntityBasePath(entitySetName, entityId),
-              entitySetName,
-              entityId,
-              linkName,
-              links);
-
-      return xml.createResponse(null, null, null, Response.Status.NO_CONTENT);
-    } catch (Exception e) {
-      return xml.createFaultResponse(accept, e);
-    }
-  }
-
-  @MERGE
-  @Path("/{entitySetName}({entityId})/$links/{linkName}")
-  public Response mergeLink(
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
-          @PathParam("entitySetName") String entitySetName,
-          @PathParam("entityId") String entityId,
-          @PathParam("linkName") String linkName,
-          String link,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
-    return putLink(accept, contentType, entitySetName, entityId, linkName, link, format);
-  }
-
-  @PATCH
-  @Path("/{entitySetName}({entityId})/$links/{linkName}")
-  public Response patchLink(
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
-          @PathParam("entitySetName") String entitySetName,
-          @PathParam("entityId") String entityId,
-          @PathParam("linkName") String linkName,
-          String link,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
-    return putLink(accept, contentType, entitySetName, entityId, linkName, link, format);
-  }
-
-  @PUT
-  @Path("/{entitySetName}({entityId})/$links/{linkName}")
-  public Response putLink(
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
-          @PathParam("entitySetName") String entitySetName,
-          @PathParam("entityId") String entityId,
-          @PathParam("linkName") String linkName,
-          String link,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
-    try {
-      final Accept acceptType;
-      if (StringUtils.isNotBlank(format)) {
-        acceptType = Accept.valueOf(format.toUpperCase());
-      } else {
-        acceptType = Accept.parse(accept, version);
-      }
-
-      if (acceptType == Accept.ATOM) {
-        throw new UnsupportedMediaTypeException("Unsupported media type");
-      }
-
-      final Accept content;
-      if (StringUtils.isNotBlank(contentType)) {
-        content = Accept.parse(contentType, version);
-      } else {
-        content = acceptType;
-      }
-
-      final AbstractUtilities utils = getUtilities(acceptType);
-
-      final List<String> links;
-      if (content == Accept.XML || content == Accept.TEXT || content == Accept.ATOM) {
-        links = xml.extractLinkURIs(IOUtils.toInputStream(link)).getValue();
-      } else {
-        links = json.extractLinkURIs(IOUtils.toInputStream(link)).getValue();
-      }
-
-      utils.putLinksInMemory(
-              Commons.getEntityBasePath(entitySetName, entityId),
-              entitySetName,
-              linkName,
-              links);
-
-      return xml.createResponse(null, null, null, Response.Status.NO_CONTENT);
-    } catch (Exception e) {
-      return xml.createFaultResponse(accept, e);
-    }
-  }
-
-  @DELETE
-  @Path("/{entitySetName}({entityId})/$links/{linkName}({linkId})")
-  public Response deleteLink(
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
-          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
-          @PathParam("entitySetName") String entitySetName,
-          @PathParam("entityId") String entityId,
-          @PathParam("linkName") String linkName,
-          @PathParam("linkId") String linkId,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
-    try {
-      final Accept acceptType;
-      if (StringUtils.isNotBlank(format)) {
-        acceptType = Accept.valueOf(format.toUpperCase());
-      } else {
-        acceptType = Accept.parse(accept, version);
-      }
-
-      if (acceptType == Accept.ATOM) {
-        throw new UnsupportedMediaTypeException("Unsupported media type");
-      }
-
-      final AbstractUtilities utils = getUtilities(acceptType);
-
-      final Map.Entry<String, List<String>> currents = json.extractLinkURIs(utils.readLinks(
-              entitySetName, entityId, linkName, Accept.JSON_FULLMETA).getLinks());
-
-      final Map.Entry<String, List<String>> toBeRemoved = json.extractLinkURIs(utils.readLinks(
-              entitySetName, entityId, linkName + "(" + linkId + ")", Accept.JSON_FULLMETA).getLinks());
-
-      final List<String> remains = currents.getValue();
-      remains.removeAll(toBeRemoved.getValue());
-
-      utils.putLinksInMemory(
-              Commons.getEntityBasePath(entitySetName, entityId),
-              entitySetName,
-              linkName,
-              remains);
-
-      return xml.createResponse(null, null, null, Response.Status.NO_CONTENT);
-    } catch (Exception e) {
-      return xml.createFaultResponse(accept, e);
-    }
-  }
-
-  /**
    * Count sample.
    *
    * @param accept Accept header.
@@ -1609,7 +1399,7 @@ public abstract class AbstractServices {
     return new AbstractMap.SimpleEntry<Accept, AbstractUtilities>(acceptType, getUtilities(acceptType));
   }
 
-  private AbstractUtilities getUtilities(final Accept accept) {
+  protected AbstractUtilities getUtilities(final Accept accept) {
     final AbstractUtilities utils;
     if (accept == Accept.XML || accept == Accept.TEXT || accept == Accept.ATOM) {
       utils = xml;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d5e29b02/fit/src/main/java/org/apache/olingo/fit/V3KeyAsSegment.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/V3KeyAsSegment.java b/fit/src/main/java/org/apache/olingo/fit/V3KeyAsSegment.java
index 0939115..01572ab 100644
--- a/fit/src/main/java/org/apache/olingo/fit/V3KeyAsSegment.java
+++ b/fit/src/main/java/org/apache/olingo/fit/V3KeyAsSegment.java
@@ -105,13 +105,15 @@ public class V3KeyAsSegment {
   @Consumes({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
   public Response mergeEntity(
           @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
           @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) String prefer,
           @HeaderParam("If-Match") @DefaultValue(StringUtils.EMPTY) String ifMatch,
           @PathParam("entitySetName") String entitySetName,
           @PathParam("entityId") String entityId,
           final String changes) {
 
-    return replaceServiceName(services.patchEntity(accept, prefer, ifMatch, entitySetName, entityId, changes));
+    return replaceServiceName(
+            services.patchEntity(accept, contentType, prefer, ifMatch, entitySetName, entityId, changes));
   }
 
   @PATCH
@@ -120,13 +122,15 @@ public class V3KeyAsSegment {
   @Consumes({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
   public Response patchEntity(
           @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
           @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) String prefer,
           @HeaderParam("If-Match") @DefaultValue(StringUtils.EMPTY) String ifMatch,
           @PathParam("entitySetName") String entitySetName,
           @PathParam("entityId") String entityId,
           final String changes) {
 
-    return replaceServiceName(services.patchEntity(accept, prefer, ifMatch, entitySetName, entityId, changes));
+    return replaceServiceName(
+            services.patchEntity(accept, contentType, prefer, ifMatch, entitySetName, entityId, changes));
   }
 
   @PUT
@@ -135,12 +139,14 @@ public class V3KeyAsSegment {
   @Consumes({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
   public Response putNewEntity(
           @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
           @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) String prefer,
           @PathParam("entitySetName") String entitySetName,
           @PathParam("entityId") String entityId,
           final String entity) {
 
-    return replaceServiceName(services.replaceEntity(accept, prefer, entitySetName, entityId, entity));
+    return replaceServiceName(
+            services.replaceEntity(accept, contentType, prefer, entitySetName, entityId, entity));
   }
 
   @POST

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d5e29b02/fit/src/main/java/org/apache/olingo/fit/V3Services.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/V3Services.java b/fit/src/main/java/org/apache/olingo/fit/V3Services.java
index 24b7ff6..9963684 100644
--- a/fit/src/main/java/org/apache/olingo/fit/V3Services.java
+++ b/fit/src/main/java/org/apache/olingo/fit/V3Services.java
@@ -19,23 +19,35 @@
 package org.apache.olingo.fit;
 
 import java.io.InputStream;
+import java.util.List;
+import java.util.Map;
+import javax.ws.rs.DELETE;
 import javax.ws.rs.DefaultValue;
 import javax.ws.rs.GET;
 import javax.ws.rs.HeaderParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
 import org.apache.olingo.fit.utils.XHTTPMethodInterceptor;
 import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
+import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.cxf.interceptor.InInterceptors;
 import org.apache.olingo.commons.api.data.Feed;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.fit.methods.MERGE;
+import org.apache.olingo.fit.methods.PATCH;
+import org.apache.olingo.fit.utils.AbstractUtilities;
 import org.apache.olingo.fit.utils.Accept;
+import org.apache.olingo.fit.utils.Commons;
 import org.apache.olingo.fit.utils.ConstantKey;
 import org.apache.olingo.fit.utils.Constants;
 import org.apache.olingo.fit.utils.FSManager;
+import org.apache.olingo.fit.utils.LinkInfo;
 import org.springframework.stereotype.Service;
 
 @Service
@@ -94,4 +106,218 @@ public class V3Services extends AbstractServices {
       feed.setCount(feed.getEntries().size());
     }
   }
+
+  /**
+   * Retrieve links sample.
+   *
+   * @param accept Accept header.
+   * @param entitySetName Entity set name.
+   * @param entityId entity id.
+   * @param linkName link name.
+   * @param format format query option.
+   * @return links.
+   */
+  @GET
+  @Path("/{entitySetName}({entityId})/$links/{linkName}")
+  public Response getLinks(
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+          @PathParam("entitySetName") String entitySetName,
+          @PathParam("entityId") String entityId,
+          @PathParam("linkName") String linkName,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
+    try {
+      final Accept acceptType;
+      if (StringUtils.isNotBlank(format)) {
+        acceptType = Accept.valueOf(format.toUpperCase());
+      } else {
+        acceptType = Accept.parse(accept, version);
+      }
+
+      if (acceptType == Accept.ATOM) {
+        throw new UnsupportedMediaTypeException("Unsupported media type");
+      }
+
+      final LinkInfo links = xml.readLinks(entitySetName, entityId, linkName, acceptType);
+
+      return xml.createResponse(
+              links.getLinks(),
+              links.getEtag(),
+              acceptType);
+    } catch (Exception e) {
+      return xml.createFaultResponse(accept, e);
+    }
+  }
+
+  @POST
+  @Path("/{entitySetName}({entityId})/$links/{linkName}")
+  public Response postLink(
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
+          @PathParam("entitySetName") String entitySetName,
+          @PathParam("entityId") String entityId,
+          @PathParam("linkName") String linkName,
+          String link,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
+    try {
+      final Accept acceptType;
+      if (StringUtils.isNotBlank(format)) {
+        acceptType = Accept.valueOf(format.toUpperCase());
+      } else {
+        acceptType = Accept.parse(accept, version);
+      }
+
+      if (acceptType == Accept.ATOM) {
+        throw new UnsupportedMediaTypeException("Unsupported media type");
+      }
+
+      final Accept content;
+      if (StringUtils.isNotBlank(contentType)) {
+        content = Accept.parse(contentType, version);
+      } else {
+        content = acceptType;
+      }
+
+      final AbstractUtilities utils = getUtilities(acceptType);
+
+      final List<String> links;
+      if (content == Accept.XML || content == Accept.TEXT || content == Accept.ATOM) {
+        links = xml.extractLinkURIs(IOUtils.toInputStream(link)).getValue();
+      } else {
+        links = json.extractLinkURIs(IOUtils.toInputStream(link)).getValue();
+      }
+
+      utils.putLinksInMemory(
+              Commons.getEntityBasePath(entitySetName, entityId),
+              entitySetName,
+              entityId,
+              linkName,
+              links);
+
+      return xml.createResponse(null, null, null, Response.Status.NO_CONTENT);
+    } catch (Exception e) {
+      return xml.createFaultResponse(accept, e);
+    }
+  }
+
+  @MERGE
+  @Path("/{entitySetName}({entityId})/$links/{linkName}")
+  public Response mergeLink(
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
+          @PathParam("entitySetName") String entitySetName,
+          @PathParam("entityId") String entityId,
+          @PathParam("linkName") String linkName,
+          String link,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
+    return putLink(accept, contentType, entitySetName, entityId, linkName, link, format);
+  }
+
+  @PATCH
+  @Path("/{entitySetName}({entityId})/$links/{linkName}")
+  public Response patchLink(
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
+          @PathParam("entitySetName") String entitySetName,
+          @PathParam("entityId") String entityId,
+          @PathParam("linkName") String linkName,
+          String link,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
+    return putLink(accept, contentType, entitySetName, entityId, linkName, link, format);
+  }
+
+  @PUT
+  @Path("/{entitySetName}({entityId})/$links/{linkName}")
+  public Response putLink(
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
+          @PathParam("entitySetName") String entitySetName,
+          @PathParam("entityId") String entityId,
+          @PathParam("linkName") String linkName,
+          String link,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
+    try {
+      final Accept acceptType;
+      if (StringUtils.isNotBlank(format)) {
+        acceptType = Accept.valueOf(format.toUpperCase());
+      } else {
+        acceptType = Accept.parse(accept, version);
+      }
+
+      if (acceptType == Accept.ATOM) {
+        throw new UnsupportedMediaTypeException("Unsupported media type");
+      }
+
+      final Accept content;
+      if (StringUtils.isNotBlank(contentType)) {
+        content = Accept.parse(contentType, version);
+      } else {
+        content = acceptType;
+      }
+
+      final AbstractUtilities utils = getUtilities(acceptType);
+
+      final List<String> links;
+      if (content == Accept.XML || content == Accept.TEXT || content == Accept.ATOM) {
+        links = xml.extractLinkURIs(IOUtils.toInputStream(link)).getValue();
+      } else {
+        links = json.extractLinkURIs(IOUtils.toInputStream(link)).getValue();
+      }
+
+      utils.putLinksInMemory(
+              Commons.getEntityBasePath(entitySetName, entityId),
+              entitySetName,
+              linkName,
+              links);
+
+      return xml.createResponse(null, null, null, Response.Status.NO_CONTENT);
+    } catch (Exception e) {
+      return xml.createFaultResponse(accept, e);
+    }
+  }
+
+  @DELETE
+  @Path("/{entitySetName}({entityId})/$links/{linkName}({linkId})")
+  public Response deleteLink(
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
+          @PathParam("entitySetName") String entitySetName,
+          @PathParam("entityId") String entityId,
+          @PathParam("linkName") String linkName,
+          @PathParam("linkId") String linkId,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
+    try {
+      final Accept acceptType;
+      if (StringUtils.isNotBlank(format)) {
+        acceptType = Accept.valueOf(format.toUpperCase());
+      } else {
+        acceptType = Accept.parse(accept, version);
+      }
+
+      if (acceptType == Accept.ATOM) {
+        throw new UnsupportedMediaTypeException("Unsupported media type");
+      }
+
+      final AbstractUtilities utils = getUtilities(acceptType);
+
+      final Map.Entry<String, List<String>> currents = json.extractLinkURIs(utils.readLinks(
+              entitySetName, entityId, linkName, Accept.JSON_FULLMETA).getLinks());
+
+      final Map.Entry<String, List<String>> toBeRemoved = json.extractLinkURIs(utils.readLinks(
+              entitySetName, entityId, linkName + "(" + linkId + ")", Accept.JSON_FULLMETA).getLinks());
+
+      final List<String> remains = currents.getValue();
+      remains.removeAll(toBeRemoved.getValue());
+
+      utils.putLinksInMemory(
+              Commons.getEntityBasePath(entitySetName, entityId),
+              entitySetName,
+              linkName,
+              remains);
+
+      return xml.createResponse(null, null, null, Response.Status.NO_CONTENT);
+    } catch (Exception e) {
+      return xml.createFaultResponse(accept, e);
+    }
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d5e29b02/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 a879f77..28fbebd 100644
--- a/fit/src/main/java/org/apache/olingo/fit/V4Services.java
+++ b/fit/src/main/java/org/apache/olingo/fit/V4Services.java
@@ -18,8 +18,11 @@
  */
 package org.apache.olingo.fit;
 
+import javax.ws.rs.NotFoundException;
 import org.apache.olingo.fit.utils.XHTTPMethodInterceptor;
 import javax.ws.rs.Path;
+import javax.ws.rs.core.Response;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.cxf.interceptor.InInterceptors;
 import org.apache.olingo.commons.api.data.Feed;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
@@ -41,4 +44,39 @@ public class V4Services extends AbstractServices {
       feed.setCount(feed.getEntries().size());
     }
   }
+
+  @Override
+  public Response patchEntity(
+          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(accept, entitySetName, entityId, accept, StringUtils.EMPTY, StringUtils.EMPTY, false);
+    return response.getStatus() >= 400
+            ? postNewEntity(accept, contentType, prefer, entitySetName, changes)
+            : super.patchEntity(accept, contentType, prefer, ifMatch, entitySetName, entityId, changes);
+  }
+
+  @Override
+  public Response replaceEntity(
+          final String accept,
+          final String contentType,
+          final String prefer,
+          final String entitySetName,
+          final String entityId,
+          final String entity) {
+
+    try {
+      getEntityInternal(accept, entitySetName, entityId, accept, StringUtils.EMPTY, StringUtils.EMPTY, false);
+      return super.replaceEntity(accept, contentType, prefer, entitySetName, entityId, entity);
+    } catch (NotFoundException e) {
+      return postNewEntity(accept, contentType, prefer, entitySetName, entityId);
+    }
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d5e29b02/fit/src/main/java/org/apache/olingo/fit/utils/Accept.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/Accept.java b/fit/src/main/java/org/apache/olingo/fit/utils/Accept.java
index cac8e0b..053a52d 100644
--- a/fit/src/main/java/org/apache/olingo/fit/utils/Accept.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/Accept.java
@@ -30,11 +30,11 @@ public enum Accept {
   XML(ContentType.APPLICATION_XML.getMimeType(), ".xml"),
   ATOM(ContentType.APPLICATION_ATOM_XML.getMimeType(), ".xml"),
   JSON(ContentType.APPLICATION_JSON.getMimeType() + ";odata=minimalmetadata",
-  ContentType.APPLICATION_JSON.getMimeType() + ";odata.metadata=minimal", ".full.json"),
+          ContentType.APPLICATION_JSON.getMimeType() + ";odata.metadata=minimal", ".full.json"),
   JSON_NOMETA(ContentType.APPLICATION_JSON.getMimeType() + ";odata=nometadata",
-  ContentType.APPLICATION_JSON.getMimeType() + ";odata.metadata=none", ".full.json"),
+          ContentType.APPLICATION_JSON.getMimeType() + ";odata.metadata=none", ".full.json"),
   JSON_FULLMETA(ContentType.APPLICATION_JSON.getMimeType() + ";odata=fullmetadata",
-  ContentType.APPLICATION_JSON.getMimeType() + ";odata.metadata=full", ".full.json");
+          ContentType.APPLICATION_JSON.getMimeType() + ";odata.metadata=full", ".full.json");
 
   private final String contentTypeV3;
 
@@ -78,20 +78,22 @@ public enum Accept {
   public static Accept parse(final String contentType, final ODataServiceVersion version, final Accept def) {
     if (StringUtils.isBlank(contentType) || allTypesPattern.matcher(contentType).matches()) {
       return def;
-    } else if (JSON_NOMETA.toString(version).equals(contentType)) {
+    } else if (contentType.startsWith(JSON_NOMETA.toString(version))) {
       return JSON_NOMETA;
-    } else if (JSON.toString(version).equals(contentType) || "application/json".equals(contentType)) {
-      return JSON;
-    } else if (JSON_FULLMETA.toString(version).equals(contentType)) {
+    } else if (contentType.startsWith(JSON_FULLMETA.toString(version))) {
       return JSON_FULLMETA;
-    } else if (XML.toString(version).equals(contentType)) {
+    } else if (contentType.startsWith(JSON.toString(version))
+            || contentType.startsWith(ContentType.APPLICATION_JSON.getMimeType())) {
+
+      return JSON;
+    } else if (contentType.startsWith(XML.toString(version))) {
       return XML;
-    } else if (ATOM.toString(version).equals(contentType)) {
+    } else if (contentType.startsWith(ATOM.toString(version))) {
       return ATOM;
-    } else if (TEXT.toString(version).equals(contentType)) {
+    } else if (contentType.startsWith(TEXT.toString(version))) {
       return TEXT;
     } else {
       throw new UnsupportedMediaTypeException("Unsupported media type");
     }
   }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d5e29b02/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java
index ed0910a..dbc44d8 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java
@@ -21,6 +21,7 @@ package org.apache.olingo.client.api;
 import org.apache.olingo.client.api.communication.header.ODataHeaders;
 import org.apache.olingo.client.api.communication.request.batch.CommonBatchRequestFactory;
 import org.apache.olingo.client.api.communication.request.cud.CommonCUDRequestFactory;
+import org.apache.olingo.client.api.communication.request.cud.CommonUpdateType;
 import org.apache.olingo.client.api.communication.request.invoke.CommonInvokeRequestFactory;
 import org.apache.olingo.client.api.communication.request.retrieve.CommonRetrieveRequestFactory;
 import org.apache.olingo.client.api.communication.request.streamed.CommonStreamedRequestFactory;
@@ -34,7 +35,7 @@ import org.apache.olingo.client.api.uri.CommonURIBuilder;
 import org.apache.olingo.client.api.uri.CommonFilterFactory;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 
-public interface CommonODataClient {
+public interface CommonODataClient<UT extends CommonUpdateType> {
 
   ODataServiceVersion getServiceVersion();
 
@@ -60,7 +61,7 @@ public interface CommonODataClient {
 
   CommonRetrieveRequestFactory getRetrieveRequestFactory();
 
-  CommonCUDRequestFactory getCUDRequestFactory();
+  CommonCUDRequestFactory<UT> getCUDRequestFactory();
 
   CommonStreamedRequestFactory getStreamedRequestFactory();
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d5e29b02/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/CommonCUDRequestFactory.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/CommonCUDRequestFactory.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/CommonCUDRequestFactory.java
index b6c74dd..71cf1cf 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/CommonCUDRequestFactory.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/CommonCUDRequestFactory.java
@@ -21,14 +21,15 @@ package org.apache.olingo.client.api.communication.request.cud;
 import java.io.Serializable;
 import java.net.URI;
 import org.apache.olingo.commons.api.domain.CommonODataEntity;
-import org.apache.olingo.commons.api.domain.ODataLink;
 import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
 import org.apache.olingo.commons.api.domain.CommonODataProperty;
 
 /**
  * OData request factory class.
+ *
+ * @param <UT> concrete UpdateType.
  */
-public interface CommonCUDRequestFactory extends Serializable {
+public interface CommonCUDRequestFactory<UT extends CommonUpdateType> extends Serializable {
 
   /**
    * Gets a create request object instance.
@@ -45,14 +46,12 @@ public interface CommonCUDRequestFactory extends Serializable {
   /**
    * Gets an update request object instance.
    *
-   * @param <UT> concrete UpdateType.
    * @param targetURI edit link of the object to be updated.
    * @param type type of update to be performed.
    * @param changes changes to be applied.
    * @return new ODataEntityUpdateRequest instance.
    */
-  <UT extends UpdateType> ODataEntityUpdateRequest getEntityUpdateRequest(URI targetURI, UT type,
-          CommonODataEntity changes);
+  ODataEntityUpdateRequest getEntityUpdateRequest(URI targetURI, UT type, CommonODataEntity changes);
 
   /**
    * Gets an update request object instance; uses entity's edit link as endpoint.
@@ -61,7 +60,7 @@ public interface CommonCUDRequestFactory extends Serializable {
    * @param entity changes to be applied.
    * @return new ODataEntityUpdateRequest instance.
    */
-  ODataEntityUpdateRequest getEntityUpdateRequest(UpdateType type, CommonODataEntity entity);
+  ODataEntityUpdateRequest getEntityUpdateRequest(UT type, CommonODataEntity entity);
 
   /**
    * Gets a create request object instance.
@@ -73,7 +72,7 @@ public interface CommonCUDRequestFactory extends Serializable {
    * @param value value to be created.
    * @return new ODataValueUpdateRequest instance.
    */
-  ODataValueUpdateRequest getValueUpdateRequest(URI targetURI, UpdateType type, ODataPrimitiveValue value);
+  ODataValueUpdateRequest getValueUpdateRequest(URI targetURI, UT type, ODataPrimitiveValue value);
 
   /**
    * Gets an update request object instance.
@@ -96,8 +95,7 @@ public interface CommonCUDRequestFactory extends Serializable {
    * @param property value to be update.
    * @return new ODataPropertyUpdateRequest instance.
    */
-  ODataPropertyUpdateRequest getPropertyComplexValueUpdateRequest(
-          URI targetURI, UpdateType type, CommonODataProperty property);
+  ODataPropertyUpdateRequest getPropertyComplexValueUpdateRequest(URI targetURI, UT type, CommonODataProperty property);
 
   /**
    * Gets an update request object instance.
@@ -111,31 +109,6 @@ public interface CommonCUDRequestFactory extends Serializable {
   ODataPropertyUpdateRequest getPropertyCollectionValueUpdateRequest(URI targetURI, CommonODataProperty property);
 
   /**
-   * Gets an add link request object instance.
-   * <br/>
-   * Use this kind of request to create a navigation link between existing entities.
-   *
-   * @param targetURI navigation property's link collection.
-   * @param link navigation link to be added.
-   * @return new ODataLinkCreateRequest instance.
-   */
-  ODataLinkCreateRequest getLinkCreateRequest(URI targetURI, ODataLink link);
-
-  /**
-   * Gets a link update request object instance.
-   * <br/>
-   * Use this kind of request to update a navigation link between existing entities.
-   * <br/>
-   * In case of the old navigation link doesn't exist the new one will be added as well.
-   *
-   * @param targetURI navigation property's link collection.
-   * @param type type of update to be performed.
-   * @param link URL that identifies the entity to be linked.
-   * @return new ODataLinkUpdateRequest instance.
-   */
-  ODataLinkUpdateRequest getLinkUpdateRequest(URI targetURI, UpdateType type, ODataLink link);
-
-  /**
    * Gets a delete request object instance.
    * <br/>
    * Use this kind of request to delete an entity and media entity as well.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d5e29b02/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/CommonUpdateType.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/CommonUpdateType.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/CommonUpdateType.java
new file mode 100644
index 0000000..45e3e1f
--- /dev/null
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/CommonUpdateType.java
@@ -0,0 +1,31 @@
+/*
+ * 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.client.api.communication.request.cud;
+
+import org.apache.olingo.client.api.http.HttpMethod;
+
+public interface CommonUpdateType {
+
+  /**
+   * Gets HTTP request method.
+   *
+   * @return HTTP request method.
+   */
+  HttpMethod getMethod();
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d5e29b02/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataLinkCreateRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataLinkCreateRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataLinkCreateRequest.java
deleted file mode 100644
index adf6f0d..0000000
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataLinkCreateRequest.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.client.api.communication.request.cud;
-
-import org.apache.olingo.client.api.communication.request.ODataBasicRequest;
-import org.apache.olingo.client.api.communication.response.ODataLinkOperationResponse;
-import org.apache.olingo.commons.api.format.ODataFormat;
-
-/**
- * This class implements an insert link OData request.
- */
-public interface ODataLinkCreateRequest extends ODataBasicRequest<ODataLinkOperationResponse, ODataFormat> {
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d5e29b02/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataLinkUpdateRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataLinkUpdateRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataLinkUpdateRequest.java
deleted file mode 100644
index 00f9216..0000000
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataLinkUpdateRequest.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.client.api.communication.request.cud;
-
-import org.apache.olingo.client.api.communication.request.ODataBasicRequest;
-import org.apache.olingo.client.api.communication.response.ODataLinkOperationResponse;
-import org.apache.olingo.commons.api.format.ODataFormat;
-
-/**
- * This class implements an update link OData request.
- */
-public interface ODataLinkUpdateRequest extends ODataBasicRequest<ODataLinkOperationResponse, ODataFormat> {
-}

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

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d5e29b02/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v3/CUDRequestFactory.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v3/CUDRequestFactory.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v3/CUDRequestFactory.java
index 4250728..a7092e9 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v3/CUDRequestFactory.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v3/CUDRequestFactory.java
@@ -18,7 +18,34 @@
  */
 package org.apache.olingo.client.api.communication.request.cud.v3;
 
+import java.net.URI;
 import org.apache.olingo.client.api.communication.request.cud.CommonCUDRequestFactory;
+import org.apache.olingo.commons.api.domain.ODataLink;
 
-public interface CUDRequestFactory extends CommonCUDRequestFactory {
+public interface CUDRequestFactory extends CommonCUDRequestFactory<UpdateType> {
+
+  /**
+   * Gets an add link request object instance.
+   * <br/>
+   * Use this kind of request to create a navigation link between existing entities.
+   *
+   * @param targetURI navigation property's link collection.
+   * @param link navigation link to be added.
+   * @return new ODataLinkCreateRequest instance.
+   */
+  ODataLinkCreateRequest getLinkCreateRequest(URI targetURI, ODataLink link);
+
+  /**
+   * Gets a link update request object instance.
+   * <br/>
+   * Use this kind of request to update a navigation link between existing entities.
+   * <br/>
+   * In case of the old navigation link doesn't exist the new one will be added as well.
+   *
+   * @param targetURI navigation property's link collection.
+   * @param type type of update to be performed.
+   * @param link URL that identifies the entity to be linked.
+   * @return new ODataLinkUpdateRequest instance.
+   */
+  ODataLinkUpdateRequest getLinkUpdateRequest(URI targetURI, UpdateType type, ODataLink link);
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d5e29b02/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v3/ODataLinkCreateRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v3/ODataLinkCreateRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v3/ODataLinkCreateRequest.java
new file mode 100644
index 0000000..53bfde1
--- /dev/null
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v3/ODataLinkCreateRequest.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.api.communication.request.cud.v3;
+
+import org.apache.olingo.client.api.communication.request.ODataBasicRequest;
+import org.apache.olingo.client.api.communication.response.ODataLinkOperationResponse;
+import org.apache.olingo.commons.api.format.ODataFormat;
+
+/**
+ * This class implements an insert link OData request.
+ */
+public interface ODataLinkCreateRequest extends ODataBasicRequest<ODataLinkOperationResponse, ODataFormat> {
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d5e29b02/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v3/ODataLinkUpdateRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v3/ODataLinkUpdateRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v3/ODataLinkUpdateRequest.java
new file mode 100644
index 0000000..d76f6ed
--- /dev/null
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v3/ODataLinkUpdateRequest.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.api.communication.request.cud.v3;
+
+import org.apache.olingo.client.api.communication.request.ODataBasicRequest;
+import org.apache.olingo.client.api.communication.response.ODataLinkOperationResponse;
+import org.apache.olingo.commons.api.format.ODataFormat;
+
+/**
+ * This class implements an update link OData request.
+ */
+public interface ODataLinkUpdateRequest extends ODataBasicRequest<ODataLinkOperationResponse, ODataFormat> {
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d5e29b02/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v3/UpdateType.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v3/UpdateType.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v3/UpdateType.java
index 4bcb150..0506200 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v3/UpdateType.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v3/UpdateType.java
@@ -18,12 +18,13 @@
  */
 package org.apache.olingo.client.api.communication.request.cud.v3;
 
+import org.apache.olingo.client.api.communication.request.cud.CommonUpdateType;
 import org.apache.olingo.client.api.http.HttpMethod;
 
 /**
  * Update type.
  */
-public enum UpdateType implements org.apache.olingo.client.api.communication.request.cud.UpdateType {
+public enum UpdateType implements CommonUpdateType {
 
   /**
    * Replace all and remove missing attributes.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d5e29b02/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v4/CUDRequestFactory.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v4/CUDRequestFactory.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v4/CUDRequestFactory.java
index 5d68983..d04bc9b 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v4/CUDRequestFactory.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v4/CUDRequestFactory.java
@@ -18,7 +18,20 @@
  */
 package org.apache.olingo.client.api.communication.request.cud.v4;
 
+import java.net.URI;
 import org.apache.olingo.client.api.communication.request.cud.CommonCUDRequestFactory;
+import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
+import org.apache.olingo.commons.api.domain.v4.ODataEntity;
 
-public interface CUDRequestFactory extends CommonCUDRequestFactory {
+public interface CUDRequestFactory extends CommonCUDRequestFactory<UpdateType> {
+
+  /**
+   * Gets an update request object instance; uses given URL as endpoint (for upsert).
+   *
+   * @param type type of update to be performed
+   * @param uri endpoint for upsert
+   * @param entity entity to be upserted.
+   * @return new ODataEntityUpdateRequest instance.
+   */
+  ODataEntityUpdateRequest getEntityUpsertRequest(final UpdateType type, URI uri, ODataEntity entity);
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d5e29b02/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v4/UpdateType.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v4/UpdateType.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v4/UpdateType.java
index 9d8ec25..d6af5cc 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v4/UpdateType.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v4/UpdateType.java
@@ -18,12 +18,13 @@
  */
 package org.apache.olingo.client.api.communication.request.cud.v4;
 
+import org.apache.olingo.client.api.communication.request.cud.CommonUpdateType;
 import org.apache.olingo.client.api.http.HttpMethod;
 
 /**
  * Update type.
  */
-public enum UpdateType implements org.apache.olingo.client.api.communication.request.cud.UpdateType {
+public enum UpdateType implements CommonUpdateType {
 
   /**
    * Replace all and remove missing attributes.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d5e29b02/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java
index 81bf6dc..db9b8c8 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java
@@ -21,6 +21,7 @@ package org.apache.olingo.client.api.v3;
 import org.apache.olingo.client.api.CommonODataClient;
 import org.apache.olingo.client.api.communication.request.batch.v3.BatchRequestFactory;
 import org.apache.olingo.client.api.communication.request.cud.v3.CUDRequestFactory;
+import org.apache.olingo.client.api.communication.request.cud.v3.UpdateType;
 import org.apache.olingo.client.api.communication.request.invoke.v3.InvokeRequestFactory;
 import org.apache.olingo.client.api.communication.request.retrieve.v3.RetrieveRequestFactory;
 import org.apache.olingo.client.api.communication.request.streamed.v3.StreamedRequestFactory;
@@ -31,7 +32,7 @@ import org.apache.olingo.client.api.uri.v3.URIBuilder;
 import org.apache.olingo.client.api.uri.v3.FilterFactory;
 import org.apache.olingo.commons.api.domain.v3.ODataObjectFactory;
 
-public interface ODataClient extends CommonODataClient {
+public interface ODataClient extends CommonODataClient<UpdateType> {
 
   @Override
   Configuration getConfiguration();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d5e29b02/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java
index 51abf99..18306f2 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java
@@ -21,6 +21,7 @@ package org.apache.olingo.client.api.v4;
 import org.apache.olingo.client.api.CommonODataClient;
 import org.apache.olingo.client.api.communication.request.batch.v4.BatchRequestFactory;
 import org.apache.olingo.client.api.communication.request.cud.v4.CUDRequestFactory;
+import org.apache.olingo.client.api.communication.request.cud.v4.UpdateType;
 import org.apache.olingo.client.api.communication.request.invoke.v4.InvokeRequestFactory;
 import org.apache.olingo.client.api.communication.request.retrieve.v4.RetrieveRequestFactory;
 import org.apache.olingo.client.api.communication.request.streamed.v4.StreamedRequestFactory;
@@ -31,7 +32,7 @@ import org.apache.olingo.client.api.uri.v4.URIBuilder;
 import org.apache.olingo.client.api.uri.v4.FilterFactory;
 import org.apache.olingo.commons.api.domain.v4.ODataObjectFactory;
 
-public interface ODataClient extends CommonODataClient {
+public interface ODataClient extends CommonODataClient<UpdateType> {
 
   @Override
   Configuration getConfiguration();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d5e29b02/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractODataClient.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractODataClient.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractODataClient.java
index 57b24df..b29463a 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractODataClient.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractODataClient.java
@@ -19,10 +19,11 @@
 package org.apache.olingo.client.core;
 
 import org.apache.olingo.client.api.CommonODataClient;
+import org.apache.olingo.client.api.communication.request.cud.CommonUpdateType;
 import org.apache.olingo.client.api.op.ODataWriter;
 import org.apache.olingo.client.core.op.ODataWriterImpl;
 
-public abstract class AbstractODataClient implements CommonODataClient {
+public abstract class AbstractODataClient<UT extends CommonUpdateType> implements CommonODataClient<UT> {
 
   private static final long serialVersionUID = 7269096702397630265L;
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d5e29b02/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/AbstractCUDRequestFactory.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/AbstractCUDRequestFactory.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/AbstractCUDRequestFactory.java
index 16eecad..3f67f46 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/AbstractCUDRequestFactory.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/AbstractCUDRequestFactory.java
@@ -21,21 +21,18 @@ package org.apache.olingo.client.core.communication.request.cud;
 import java.net.URI;
 import org.apache.olingo.client.api.CommonODataClient;
 import org.apache.olingo.client.api.communication.request.cud.CommonCUDRequestFactory;
+import org.apache.olingo.client.api.communication.request.cud.CommonUpdateType;
 import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest;
 import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
 import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
-import org.apache.olingo.client.api.communication.request.cud.ODataLinkCreateRequest;
-import org.apache.olingo.client.api.communication.request.cud.ODataLinkUpdateRequest;
 import org.apache.olingo.client.api.communication.request.cud.ODataPropertyUpdateRequest;
 import org.apache.olingo.client.api.communication.request.cud.ODataValueUpdateRequest;
-import org.apache.olingo.client.api.communication.request.cud.UpdateType;
+import org.apache.olingo.client.api.http.HttpMethod;
 import org.apache.olingo.commons.api.domain.CommonODataEntity;
-import org.apache.olingo.commons.api.domain.ODataLink;
-import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
 import org.apache.olingo.commons.api.domain.CommonODataProperty;
-import org.apache.olingo.client.api.http.HttpMethod;
+import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
 
-public abstract class AbstractCUDRequestFactory implements CommonCUDRequestFactory {
+public abstract class AbstractCUDRequestFactory<UT extends CommonUpdateType> implements CommonCUDRequestFactory<UT> {
 
   private static final long serialVersionUID = -2723641791198745990L;
 
@@ -54,7 +51,7 @@ public abstract class AbstractCUDRequestFactory implements CommonCUDRequestFacto
 
   @Override
   public ODataEntityUpdateRequest getEntityUpdateRequest(
-          final URI targetURI, final UpdateType type, final CommonODataEntity changes) {
+          final URI targetURI, final UT type, final CommonODataEntity changes) {
 
     final ODataEntityUpdateRequest req;
 
@@ -69,7 +66,7 @@ public abstract class AbstractCUDRequestFactory implements CommonCUDRequestFacto
   }
 
   @Override
-  public ODataEntityUpdateRequest getEntityUpdateRequest(final UpdateType type, final CommonODataEntity entity) {
+  public ODataEntityUpdateRequest getEntityUpdateRequest(final UT type, final CommonODataEntity entity) {
     if (entity.getEditLink() == null) {
       throw new IllegalArgumentException("No edit link found");
     }
@@ -88,7 +85,7 @@ public abstract class AbstractCUDRequestFactory implements CommonCUDRequestFacto
 
   @Override
   public ODataValueUpdateRequest getValueUpdateRequest(
-          final URI targetURI, final UpdateType type, final ODataPrimitiveValue value) {
+          final URI targetURI, final UT type, final ODataPrimitiveValue value) {
 
     final ODataValueUpdateRequest req;
 
@@ -124,7 +121,7 @@ public abstract class AbstractCUDRequestFactory implements CommonCUDRequestFacto
 
   @Override
   public ODataPropertyUpdateRequest getPropertyComplexValueUpdateRequest(
-          final URI targetURI, final UpdateType type, final CommonODataProperty property) {
+          final URI targetURI, final UT type, final CommonODataProperty property) {
 
     if (!property.hasComplexValue()) {
       throw new IllegalArgumentException("A complex value is required");
@@ -163,27 +160,6 @@ public abstract class AbstractCUDRequestFactory implements CommonCUDRequestFacto
   }
 
   @Override
-  public ODataLinkCreateRequest getLinkCreateRequest(final URI targetURI, final ODataLink link) {
-    return new ODataLinkCreateRequestImpl(client, targetURI, link);
-  }
-
-  @Override
-  public ODataLinkUpdateRequest getLinkUpdateRequest(
-          final URI targetURI, final UpdateType type, final ODataLink link) {
-
-    final ODataLinkUpdateRequest req;
-
-    if (client.getConfiguration().isUseXHTTPMethod()) {
-      req = new ODataLinkUpdateRequestImpl(client, HttpMethod.POST, targetURI, link);
-      req.setXHTTPMethod(type.getMethod().name());
-    } else {
-      req = new ODataLinkUpdateRequestImpl(client, type.getMethod(), targetURI, link);
-    }
-
-    return req;
-  }
-
-  @Override
   public ODataDeleteRequest getDeleteRequest(final URI targetURI) {
     final ODataDeleteRequest req;
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d5e29b02/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityUpdateRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityUpdateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityUpdateRequestImpl.java
index dde98a4..ff9dc54 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityUpdateRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityUpdateRequestImpl.java
@@ -56,7 +56,7 @@ public class ODataEntityUpdateRequestImpl extends AbstractODataBasicRequest<ODat
    * @param uri URI of the entity to be updated.
    * @param changes changes to be applied.
    */
-  ODataEntityUpdateRequestImpl(final CommonODataClient odataClient,
+  public ODataEntityUpdateRequestImpl(final CommonODataClient odataClient,
           final HttpMethod method, final URI uri, final CommonODataEntity changes) {
 
     super(odataClient, ODataPubFormat.class, method, uri);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d5e29b02/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataLinkCreateRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataLinkCreateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataLinkCreateRequestImpl.java
deleted file mode 100644
index e64579d..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataLinkCreateRequestImpl.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.client.core.communication.request.cud;
-
-import java.io.InputStream;
-import java.net.URI;
-import org.apache.commons.io.IOUtils;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.olingo.client.api.CommonODataClient;
-import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
-import org.apache.olingo.client.api.communication.request.cud.ODataLinkCreateRequest;
-import org.apache.olingo.client.api.communication.response.ODataLinkOperationResponse;
-import org.apache.olingo.commons.api.domain.ODataLink;
-import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.client.api.http.HttpMethod;
-import org.apache.olingo.client.core.uri.URIUtils;
-import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
-import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
-
-/**
- * This class implements an insert link OData request.
- */
-public class ODataLinkCreateRequestImpl extends AbstractODataBasicRequest<ODataLinkOperationResponse, ODataFormat>
-        implements ODataLinkCreateRequest, ODataBatchableRequest {
-
-  /**
-   * OData entity to be linked.
-   */
-  private final ODataLink link;
-
-  /**
-   * Constructor.
-   *
-   * @param odataClient client instance getting this request
-   * @param targetURI entity set URI.
-   * @param link entity to be linked.
-   */
-  ODataLinkCreateRequestImpl(final CommonODataClient odataClient, final URI targetURI, final ODataLink link) {
-    super(odataClient, ODataFormat.class, HttpMethod.POST, targetURI);
-    // set request body
-    this.link = link;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public ODataLinkOperationResponse execute() {
-    final InputStream input = getPayload();
-    ((HttpPost) request).setEntity(URIUtils.buildInputStreamEntity(odataClient, input));
-
-    try {
-      return new ODataLinkCreateResponseImpl(httpClient, doExecute());
-    } finally {
-      IOUtils.closeQuietly(input);
-    }
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  protected InputStream getPayload() {
-    return odataClient.getWriter().writeLink(link, ODataFormat.fromString(getContentType()));
-  }
-
-  /**
-   * This class implements the response to an OData link operation request.
-   */
-  private class ODataLinkCreateResponseImpl extends AbstractODataResponse implements ODataLinkOperationResponse {
-
-    /**
-     * Constructor.
-     * <p>
-     * Just to create response templates to be initialized from batch.
-     */
-    private ODataLinkCreateResponseImpl() {
-    }
-
-    /**
-     * Constructor.
-     *
-     * @param client HTTP client.
-     * @param res HTTP response.
-     */
-    private ODataLinkCreateResponseImpl(final HttpClient client, final HttpResponse res) {
-      super(client, res);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d5e29b02/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataLinkUpdateRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataLinkUpdateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataLinkUpdateRequestImpl.java
deleted file mode 100644
index 2644189..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataLinkUpdateRequestImpl.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.client.core.communication.request.cud;
-
-import java.io.InputStream;
-import java.net.URI;
-import org.apache.commons.io.IOUtils;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
-import org.apache.olingo.client.api.CommonODataClient;
-import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
-import org.apache.olingo.client.api.communication.request.cud.ODataLinkUpdateRequest;
-import org.apache.olingo.client.api.communication.response.ODataLinkOperationResponse;
-import org.apache.olingo.commons.api.domain.ODataLink;
-import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.client.api.http.HttpMethod;
-import org.apache.olingo.client.core.uri.URIUtils;
-import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
-import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
-
-/**
- * This class implements an update link OData request.
- */
-public class ODataLinkUpdateRequestImpl extends AbstractODataBasicRequest<ODataLinkOperationResponse, ODataFormat>
-        implements ODataLinkUpdateRequest, ODataBatchableRequest {
-
-  /**
-   * Entity to be linked.
-   */
-  private final ODataLink link;
-
-  /**
-   * Constructor.
-   *
-   * @param odataClient client instance getting this request
-   * @param method request method.
-   * @param targetURI entity URI.
-   * @param link entity to be linked.
-   */
-  ODataLinkUpdateRequestImpl(final CommonODataClient odataClient,
-          final HttpMethod method, final URI targetURI, final ODataLink link) {
-
-    super(odataClient, ODataFormat.class, method, targetURI);
-    // set request body
-    this.link = link;
-  }
-
-  /**
-   * {@inheritDoc }
-   */
-  @Override
-  public ODataLinkOperationResponse execute() {
-    final InputStream input = getPayload();
-    ((HttpEntityEnclosingRequestBase) request).setEntity(URIUtils.buildInputStreamEntity(odataClient, input));
-
-    try {
-      return new ODataLinkUpdateResponseImpl(httpClient, doExecute());
-    } finally {
-      IOUtils.closeQuietly(input);
-    }
-  }
-
-  /**
-   * {@inheritDoc }
-   */
-  @Override
-  protected InputStream getPayload() {
-    return odataClient.getWriter().writeLink(link, ODataFormat.fromString(getContentType()));
-  }
-
-  /**
-   * This class implements the response to an OData link operation request.
-   */
-  public class ODataLinkUpdateResponseImpl extends AbstractODataResponse implements ODataLinkOperationResponse {
-
-    /**
-     * Constructor.
-     * <p>
-     * Just to create response templates to be initialized from batch.
-     */
-    private ODataLinkUpdateResponseImpl() {
-    }
-
-    /**
-     * Constructor.
-     *
-     * @param client HTTP client.
-     * @param res HTTP response.
-     */
-    public ODataLinkUpdateResponseImpl(final HttpClient client, final HttpResponse res) {
-      super(client, res);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d5e29b02/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/CUDRequestFactoryImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/CUDRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/CUDRequestFactoryImpl.java
index 425bcd3..96d61ae 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/CUDRequestFactoryImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/CUDRequestFactoryImpl.java
@@ -18,11 +18,17 @@
  */
 package org.apache.olingo.client.core.communication.request.cud.v3;
 
+import java.net.URI;
+import org.apache.olingo.client.api.communication.request.cud.v3.ODataLinkCreateRequest;
+import org.apache.olingo.client.api.communication.request.cud.v3.ODataLinkUpdateRequest;
 import org.apache.olingo.client.api.v3.ODataClient;
 import org.apache.olingo.client.api.communication.request.cud.v3.CUDRequestFactory;
+import org.apache.olingo.client.api.communication.request.cud.v3.UpdateType;
+import org.apache.olingo.client.api.http.HttpMethod;
 import org.apache.olingo.client.core.communication.request.cud.AbstractCUDRequestFactory;
+import org.apache.olingo.commons.api.domain.ODataLink;
 
-public class CUDRequestFactoryImpl extends AbstractCUDRequestFactory
+public class CUDRequestFactoryImpl extends AbstractCUDRequestFactory<UpdateType>
         implements CUDRequestFactory {
 
   private static final long serialVersionUID = 109196636064983035L;
@@ -30,4 +36,24 @@ public class CUDRequestFactoryImpl extends AbstractCUDRequestFactory
   public CUDRequestFactoryImpl(final ODataClient client) {
     super(client);
   }
+
+  @Override
+  public ODataLinkCreateRequest getLinkCreateRequest(final URI targetURI, final ODataLink link) {
+    return new ODataLinkCreateRequestImpl(client, targetURI, link);
+  }
+
+  @Override
+  public ODataLinkUpdateRequest getLinkUpdateRequest(final URI targetURI, final UpdateType type, final ODataLink link) {
+    final ODataLinkUpdateRequest req;
+
+    if (client.getConfiguration().isUseXHTTPMethod()) {
+      req = new ODataLinkUpdateRequestImpl(client, HttpMethod.POST, targetURI, link);
+      req.setXHTTPMethod(type.getMethod().name());
+    } else {
+      req = new ODataLinkUpdateRequestImpl(client, type.getMethod(), targetURI, link);
+    }
+
+    return req;
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d5e29b02/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/ODataLinkCreateRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/ODataLinkCreateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/ODataLinkCreateRequestImpl.java
new file mode 100644
index 0000000..8e57217
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/ODataLinkCreateRequestImpl.java
@@ -0,0 +1,108 @@
+/*
+ * 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.client.core.communication.request.cud.v3;
+
+import java.io.InputStream;
+import java.net.URI;
+import org.apache.commons.io.IOUtils;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.olingo.client.api.CommonODataClient;
+import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
+import org.apache.olingo.client.api.communication.request.cud.v3.ODataLinkCreateRequest;
+import org.apache.olingo.client.api.communication.response.ODataLinkOperationResponse;
+import org.apache.olingo.commons.api.domain.ODataLink;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.client.api.http.HttpMethod;
+import org.apache.olingo.client.core.uri.URIUtils;
+import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
+import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
+
+/**
+ * This class implements an insert link OData request.
+ */
+public class ODataLinkCreateRequestImpl extends AbstractODataBasicRequest<ODataLinkOperationResponse, ODataFormat>
+        implements ODataLinkCreateRequest, ODataBatchableRequest {
+
+  /**
+   * OData entity to be linked.
+   */
+  private final ODataLink link;
+
+  /**
+   * Constructor.
+   *
+   * @param odataClient client instance getting this request
+   * @param targetURI entity set URI.
+   * @param link entity to be linked.
+   */
+  ODataLinkCreateRequestImpl(final CommonODataClient odataClient, final URI targetURI, final ODataLink link) {
+    super(odataClient, ODataFormat.class, HttpMethod.POST, targetURI);
+    // set request body
+    this.link = link;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public ODataLinkOperationResponse execute() {
+    final InputStream input = getPayload();
+    ((HttpPost) request).setEntity(URIUtils.buildInputStreamEntity(odataClient, input));
+
+    try {
+      return new ODataLinkCreateResponseImpl(httpClient, doExecute());
+    } finally {
+      IOUtils.closeQuietly(input);
+    }
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  protected InputStream getPayload() {
+    return odataClient.getWriter().writeLink(link, ODataFormat.fromString(getContentType()));
+  }
+
+  /**
+   * This class implements the response to an OData link operation request.
+   */
+  private class ODataLinkCreateResponseImpl extends AbstractODataResponse implements ODataLinkOperationResponse {
+
+    /**
+     * Constructor.
+     * <p>
+     * Just to create response templates to be initialized from batch.
+     */
+    private ODataLinkCreateResponseImpl() {
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param client HTTP client.
+     * @param res HTTP response.
+     */
+    private ODataLinkCreateResponseImpl(final HttpClient client, final HttpResponse res) {
+      super(client, res);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d5e29b02/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/ODataLinkUpdateRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/ODataLinkUpdateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/ODataLinkUpdateRequestImpl.java
new file mode 100644
index 0000000..2bf5a39
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/ODataLinkUpdateRequestImpl.java
@@ -0,0 +1,111 @@
+/*
+ * 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.client.core.communication.request.cud.v3;
+
+import java.io.InputStream;
+import java.net.URI;
+import org.apache.commons.io.IOUtils;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
+import org.apache.olingo.client.api.CommonODataClient;
+import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
+import org.apache.olingo.client.api.communication.request.cud.v3.ODataLinkUpdateRequest;
+import org.apache.olingo.client.api.communication.response.ODataLinkOperationResponse;
+import org.apache.olingo.commons.api.domain.ODataLink;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.client.api.http.HttpMethod;
+import org.apache.olingo.client.core.uri.URIUtils;
+import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
+import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
+
+/**
+ * This class implements an update link OData request.
+ */
+public class ODataLinkUpdateRequestImpl extends AbstractODataBasicRequest<ODataLinkOperationResponse, ODataFormat>
+        implements ODataLinkUpdateRequest, ODataBatchableRequest {
+
+  /**
+   * Entity to be linked.
+   */
+  private final ODataLink link;
+
+  /**
+   * Constructor.
+   *
+   * @param odataClient client instance getting this request
+   * @param method request method.
+   * @param targetURI entity URI.
+   * @param link entity to be linked.
+   */
+  ODataLinkUpdateRequestImpl(final CommonODataClient odataClient,
+          final HttpMethod method, final URI targetURI, final ODataLink link) {
+
+    super(odataClient, ODataFormat.class, method, targetURI);
+    // set request body
+    this.link = link;
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  public ODataLinkOperationResponse execute() {
+    final InputStream input = getPayload();
+    ((HttpEntityEnclosingRequestBase) request).setEntity(URIUtils.buildInputStreamEntity(odataClient, input));
+
+    try {
+      return new ODataLinkUpdateResponseImpl(httpClient, doExecute());
+    } finally {
+      IOUtils.closeQuietly(input);
+    }
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  protected InputStream getPayload() {
+    return odataClient.getWriter().writeLink(link, ODataFormat.fromString(getContentType()));
+  }
+
+  /**
+   * This class implements the response to an OData link operation request.
+   */
+  public class ODataLinkUpdateResponseImpl extends AbstractODataResponse implements ODataLinkOperationResponse {
+
+    /**
+     * Constructor.
+     * <p>
+     * Just to create response templates to be initialized from batch.
+     */
+    private ODataLinkUpdateResponseImpl() {
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param client HTTP client.
+     * @param res HTTP response.
+     */
+    public ODataLinkUpdateResponseImpl(final HttpClient client, final HttpResponse res) {
+      super(client, res);
+    }
+  }
+}


Mime
View raw message