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/03/13 16:23:45 UTC

[3/7] OLINGO-205 ODataJClient request/response layer implementation imported

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d3b05e01/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java
new file mode 100644
index 0000000..2c0e737
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java
@@ -0,0 +1,125 @@
+/*
+ * 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.ODataClient;
+import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
+import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
+import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
+import org.apache.olingo.client.api.domain.ODataEntity;
+import org.apache.olingo.client.api.format.ODataPubFormat;
+import org.apache.olingo.client.api.http.HttpMethod;
+import org.apache.olingo.client.api.utils.URIUtils;
+import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
+import org.apache.olingo.client.core.communication.response.ODataResponseImpl;
+
+/**
+ * This class implements an OData create request.
+ */
+public class ODataEntityCreateRequestImpl extends AbstractODataBasicRequest<ODataEntityCreateResponse, ODataPubFormat>
+        implements ODataEntityCreateRequest, ODataBatchableRequest {
+
+  /**
+   * Entity to be created.
+   */
+  private final ODataEntity entity;
+
+  /**
+   * Constructor.
+   *
+   * @param odataClient client instance getting this request
+   * @param targetURI entity set URI.
+   * @param entity entity to be created.
+   */
+  ODataEntityCreateRequestImpl(final ODataClient odataClient, final URI targetURI, final ODataEntity entity) {
+    super(odataClient, ODataPubFormat.class, HttpMethod.POST, targetURI);
+    this.entity = entity;
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  protected InputStream getPayload() {
+    return odataClient.getWriter().writeEntity(entity, ODataPubFormat.fromString(getContentType()));
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  public ODataEntityCreateResponse execute() {
+    final InputStream input = getPayload();
+    ((HttpPost) request).setEntity(URIUtils.buildInputStreamEntity(odataClient, input));
+
+    try {
+      return new ODataEntityCreateResponseImpl(httpClient, doExecute());
+    } finally {
+      IOUtils.closeQuietly(input);
+    }
+  }
+
+  /**
+   * Response class about an ODataEntityCreateRequest.
+   */
+  private class ODataEntityCreateResponseImpl extends ODataResponseImpl implements ODataEntityCreateResponse {
+
+    private ODataEntity entity = null;
+
+    /**
+     * Constructor.
+     * <p>
+     * Just to create response templates to be initialized from batch.
+     */
+    private ODataEntityCreateResponseImpl() {
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param client HTTP client.
+     * @param res HTTP response.
+     */
+    private ODataEntityCreateResponseImpl(final HttpClient client, final HttpResponse res) {
+      super(client, res);
+    }
+
+    /**
+     * {@inheritDoc }
+     */
+    @Override
+    public ODataEntity getBody() {
+      if (entity == null) {
+        try {
+          entity = odataClient.getReader().
+                  readEntity(getRawResponse(), ODataPubFormat.fromString(getAccept()));
+        } finally {
+          this.close();
+        }
+      }
+      return entity;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d3b05e01/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
new file mode 100644
index 0000000..7c36d8d
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityUpdateRequestImpl.java
@@ -0,0 +1,131 @@
+/*
+ * 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.ODataClient;
+import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
+import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
+import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
+import org.apache.olingo.client.api.domain.ODataEntity;
+import org.apache.olingo.client.api.format.ODataPubFormat;
+import org.apache.olingo.client.api.http.HttpMethod;
+import org.apache.olingo.client.api.utils.URIUtils;
+import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
+import org.apache.olingo.client.core.communication.response.ODataResponseImpl;
+
+/**
+ * This class implements an OData update request.
+ */
+public class ODataEntityUpdateRequestImpl extends AbstractODataBasicRequest<ODataEntityUpdateResponse, ODataPubFormat>
+        implements ODataEntityUpdateRequest, ODataBatchableRequest {
+
+  /**
+   * Changes to be applied.
+   */
+  private final ODataEntity changes;
+
+  /**
+   * Constructor.
+   *
+   * @param odataClient client instance getting this request
+   * @param method request method.
+   * @param uri URI of the entity to be updated.
+   * @param changes changes to be applied.
+   */
+  ODataEntityUpdateRequestImpl(final ODataClient odataClient,
+          final HttpMethod method, final URI uri, final ODataEntity changes) {
+
+    super(odataClient, ODataPubFormat.class, method, uri);
+    this.changes = changes;
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  public ODataEntityUpdateResponse execute() {
+    final InputStream input = getPayload();
+    ((HttpEntityEnclosingRequestBase) request).setEntity(URIUtils.buildInputStreamEntity(odataClient, input));
+
+    try {
+      return new ODataEntityUpdateResponseImpl(httpClient, doExecute());
+    } finally {
+      IOUtils.closeQuietly(input);
+    }
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  protected InputStream getPayload() {
+    return odataClient.getWriter().writeEntity(changes, ODataPubFormat.fromString(getContentType()));
+  }
+
+  /**
+   * Response class about an ODataEntityUpdateRequest.
+   */
+  private class ODataEntityUpdateResponseImpl extends ODataResponseImpl implements ODataEntityUpdateResponse {
+
+    /**
+     * Changes.
+     */
+    private ODataEntity entity = null;
+
+    /**
+     * Constructor.
+     * <p>
+     * Just to create response templates to be initialized from batch.
+     */
+    private ODataEntityUpdateResponseImpl() {
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param client HTTP client.
+     * @param res HTTP response.
+     */
+    private ODataEntityUpdateResponseImpl(final HttpClient client, final HttpResponse res) {
+      super(client, res);
+    }
+
+    /**
+     * {@inheritDoc ]
+     */
+    @Override
+    public ODataEntity getBody() {
+      if (entity == null) {
+        try {
+          entity = odataClient.getReader().
+                  readEntity(getRawResponse(), ODataPubFormat.fromString(getAccept()));
+        } finally {
+          this.close();
+        }
+      }
+      return entity;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d3b05e01/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
new file mode 100644
index 0000000..fc52e93
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/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;
+
+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.ODataClient;
+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.client.api.domain.ODataLink;
+import org.apache.olingo.client.api.format.ODataFormat;
+import org.apache.olingo.client.api.http.HttpMethod;
+import org.apache.olingo.client.api.utils.URIUtils;
+import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
+import org.apache.olingo.client.core.communication.response.ODataResponseImpl;
+
+/**
+ * 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 ODataClient 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 ODataResponseImpl 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/incubator-olingo-odata4/blob/d3b05e01/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
new file mode 100644
index 0000000..c7c1bc8
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/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;
+
+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.ODataClient;
+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.client.api.domain.ODataLink;
+import org.apache.olingo.client.api.format.ODataFormat;
+import org.apache.olingo.client.api.http.HttpMethod;
+import org.apache.olingo.client.api.utils.URIUtils;
+import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
+import org.apache.olingo.client.core.communication.response.ODataResponseImpl;
+
+/**
+ * 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 ODataClient 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 ODataResponseImpl 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/incubator-olingo-odata4/blob/d3b05e01/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataPropertyUpdateRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataPropertyUpdateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataPropertyUpdateRequestImpl.java
new file mode 100644
index 0000000..597c6dd
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataPropertyUpdateRequestImpl.java
@@ -0,0 +1,129 @@
+/*
+ * 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.ODataClient;
+import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
+import org.apache.olingo.client.api.communication.request.cud.ODataPropertyUpdateRequest;
+import org.apache.olingo.client.api.communication.response.ODataPropertyUpdateResponse;
+import org.apache.olingo.client.api.domain.ODataProperty;
+import org.apache.olingo.client.api.format.ODataFormat;
+import org.apache.olingo.client.api.http.HttpMethod;
+import org.apache.olingo.client.api.utils.URIUtils;
+import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
+import org.apache.olingo.client.core.communication.response.ODataResponseImpl;
+
+/**
+ * This class implements an OData update entity property request.
+ */
+public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest<ODataPropertyUpdateResponse, ODataFormat>
+        implements ODataPropertyUpdateRequest, ODataBatchableRequest {
+
+  /**
+   * Value to be created.
+   */
+  private final ODataProperty property;
+
+  /**
+   * Constructor.
+   *
+   * @param odataClient client instance getting this request
+   * @param method request method.
+   * @param targetURI entity set or entity or entity property URI.
+   * @param property value to be created.
+   */
+  ODataPropertyUpdateRequestImpl(final ODataClient odataClient,
+          final HttpMethod method, final URI targetURI, final ODataProperty property) {
+
+    super(odataClient, ODataFormat.class, method, targetURI);
+    // set request body
+    this.property = property;
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  public ODataPropertyUpdateResponse execute() {
+    final InputStream input = getPayload();
+    ((HttpEntityEnclosingRequestBase) request).setEntity(URIUtils.buildInputStreamEntity(odataClient, input));
+
+    try {
+      return new ODataPropertyUpdateResponseImpl(httpClient, doExecute());
+    } finally {
+      IOUtils.closeQuietly(input);
+    }
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  protected InputStream getPayload() {
+    return odataClient.getWriter().writeProperty(property, ODataFormat.fromString(getContentType()));
+  }
+
+  /**
+   * Response class about an ODataPropertyUpdateRequest.
+   */
+  private class ODataPropertyUpdateResponseImpl extends ODataResponseImpl implements ODataPropertyUpdateResponse {
+
+    private ODataProperty property = null;
+
+    /**
+     * Constructor.
+     * <p>
+     * Just to create response templates to be initialized from batch.
+     */
+    private ODataPropertyUpdateResponseImpl() {
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param client HTTP client.
+     * @param res HTTP response.
+     */
+    private ODataPropertyUpdateResponseImpl(final HttpClient client, final HttpResponse res) {
+      super(client, res);
+    }
+
+    /**
+     * {@inheritDoc }
+     */
+    @Override
+    public ODataProperty getBody() {
+      if (property == null) {
+        try {
+          property = odataClient.getReader().
+                  readProperty(getRawResponse(), ODataFormat.fromString(getAccept()));
+        } finally {
+          this.close();
+        }
+      }
+      return property;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d3b05e01/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataValueUpdateRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataValueUpdateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataValueUpdateRequestImpl.java
new file mode 100644
index 0000000..90d3f37
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataValueUpdateRequestImpl.java
@@ -0,0 +1,140 @@
+/*
+ * 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.IOException;
+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.ODataClient;
+import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
+import org.apache.olingo.client.api.communication.request.cud.ODataValueUpdateRequest;
+import org.apache.olingo.client.api.communication.response.ODataValueUpdateResponse;
+import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType;
+import org.apache.olingo.client.api.domain.ODataPrimitiveValue;
+import org.apache.olingo.client.api.domain.ODataValue;
+import org.apache.olingo.client.api.format.ODataValueFormat;
+import org.apache.olingo.client.api.http.HttpClientException;
+import org.apache.olingo.client.api.http.HttpMethod;
+import org.apache.olingo.client.api.utils.URIUtils;
+import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
+import org.apache.olingo.client.core.communication.response.ODataResponseImpl;
+
+/**
+ * This class implements an OData update entity property value request.
+ */
+public class ODataValueUpdateRequestImpl extends AbstractODataBasicRequest<ODataValueUpdateResponse, ODataValueFormat>
+        implements ODataValueUpdateRequest, ODataBatchableRequest {
+
+  /**
+   * Value to be created.
+   */
+  private final ODataValue value;
+
+  /**
+   * Constructor.
+   *
+   * @param odataClient client instance getting this request
+   * @param method request method.
+   * @param targetURI entity set or entity or entity property URI.
+   * @param value value to be created.
+   */
+  ODataValueUpdateRequestImpl(final ODataClient odataClient,
+          final HttpMethod method, final URI targetURI, final ODataValue value) {
+
+    super(odataClient, ODataValueFormat.class, method, targetURI);
+    // set request body
+    this.value = value;
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  public ODataValueUpdateResponse execute() {
+    final InputStream input = getPayload();
+    ((HttpEntityEnclosingRequestBase) request).setEntity(URIUtils.buildInputStreamEntity(odataClient, input));
+
+    try {
+      return new ODataValueUpdateResponseImpl(httpClient, doExecute());
+    } finally {
+      IOUtils.closeQuietly(input);
+    }
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  protected InputStream getPayload() {
+    return IOUtils.toInputStream(value.toString());
+  }
+
+  /**
+   * Response class about an ODataValueUpdateRequest.
+   */
+  private class ODataValueUpdateResponseImpl extends ODataResponseImpl implements ODataValueUpdateResponse {
+
+    private ODataValue value = null;
+
+    /**
+     * Constructor.
+     * <p>
+     * Just to create response templates to be initialized from batch.
+     */
+    private ODataValueUpdateResponseImpl() {
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param client HTTP client.
+     * @param res HTTP response.
+     */
+    private ODataValueUpdateResponseImpl(final HttpClient client, final HttpResponse res) {
+      super(client, res);
+    }
+
+    /**
+     * {@inheritDoc }
+     */
+    @Override
+    public ODataValue getBody() {
+      if (value == null) {
+        final ODataValueFormat format = ODataValueFormat.fromString(getAccept());
+
+        try {
+          value = new ODataPrimitiveValue.Builder(odataClient).
+                  setType(format == ODataValueFormat.TEXT
+                  ? ODataJClientEdmPrimitiveType.String : ODataJClientEdmPrimitiveType.Stream).
+                  setText(IOUtils.toString(getRawResponse())).
+                  build();
+        } catch (IOException e) {
+          throw new HttpClientException(e);
+        } finally {
+          this.close();
+        }
+      }
+      return value;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d3b05e01/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/V3CUDRequestFactoryImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/V3CUDRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/V3CUDRequestFactoryImpl.java
new file mode 100644
index 0000000..a4d06b5
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/V3CUDRequestFactoryImpl.java
@@ -0,0 +1,32 @@
+/*
+ * 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 org.apache.olingo.client.api.ODataV3Client;
+import org.apache.olingo.client.api.communication.request.cud.V3CUDRequestFactory;
+
+public class V3CUDRequestFactoryImpl extends AbstractCUDRequestFactory
+        implements V3CUDRequestFactory {
+
+  private static final long serialVersionUID = 109196636064983035L;
+
+  public V3CUDRequestFactoryImpl(final ODataV3Client client) {
+    super(client);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d3b05e01/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/V4CUDRequestFactoryImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/V4CUDRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/V4CUDRequestFactoryImpl.java
new file mode 100644
index 0000000..fbbde56
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/V4CUDRequestFactoryImpl.java
@@ -0,0 +1,32 @@
+/*
+ * 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 org.apache.olingo.client.api.ODataV4Client;
+import org.apache.olingo.client.api.communication.request.cud.V4CUDRequestFactory;
+
+public class V4CUDRequestFactoryImpl extends AbstractCUDRequestFactory
+        implements V4CUDRequestFactory {
+
+  private static final long serialVersionUID = 3080623853913380425L;
+
+  public V4CUDRequestFactoryImpl(final ODataV4Client client) {
+    super(client);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d3b05e01/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractInvokeRequestFactory.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractInvokeRequestFactory.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractInvokeRequestFactory.java
new file mode 100644
index 0000000..c006ed1
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractInvokeRequestFactory.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.core.communication.request.invoke;
+
+import java.net.URI;
+import java.util.Map;
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.communication.request.invoke.InvokeRequestFactory;
+import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest;
+import org.apache.olingo.client.api.domain.ODataInvokeResult;
+import org.apache.olingo.client.api.domain.ODataValue;
+import org.apache.olingo.client.api.edm.xml.CommonFunctionImport;
+import org.apache.olingo.client.api.edm.xml.XMLMetadata;
+
+abstract class AbstractInvokeRequestFactory<FI extends CommonFunctionImport> implements InvokeRequestFactory<FI> {
+
+  private static final long serialVersionUID = -906760270085197249L;
+
+  protected final ODataClient client;
+
+  protected AbstractInvokeRequestFactory(final ODataClient client) {
+    this.client = client;
+  }
+
+  @Override
+  public <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getInvokeRequest(
+          final URI uri,
+          final XMLMetadata metadata,
+          final FI functionImport,
+          final Map<String, ODataValue> parameters) {
+    final ODataInvokeRequest<RES> result = getInvokeRequest(uri, metadata, functionImport);
+    result.setParameters(parameters);
+    return result;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d3b05e01/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/ODataInvokeRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/ODataInvokeRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/ODataInvokeRequestImpl.java
new file mode 100644
index 0000000..b03e623
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/ODataInvokeRequestImpl.java
@@ -0,0 +1,235 @@
+/*
+ * 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.invoke;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.LinkedHashMap;
+import java.util.Map;
+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.http.client.methods.HttpRequestBase;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
+import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest;
+import org.apache.olingo.client.api.communication.request.invoke.ODataNoContent;
+import org.apache.olingo.client.api.communication.response.ODataInvokeResponse;
+import org.apache.olingo.client.api.domain.ODataEntity;
+import org.apache.olingo.client.api.domain.ODataEntitySet;
+import org.apache.olingo.client.api.domain.ODataInvokeResult;
+import org.apache.olingo.client.api.domain.ODataProperty;
+import org.apache.olingo.client.api.domain.ODataValue;
+import org.apache.olingo.client.api.format.ODataFormat;
+import org.apache.olingo.client.api.format.ODataPubFormat;
+import org.apache.olingo.client.api.http.HttpClientException;
+import org.apache.olingo.client.api.http.HttpMethod;
+import org.apache.olingo.client.api.utils.URIUtils;
+import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
+import org.apache.olingo.client.core.communication.response.ODataResponseImpl;
+
+/**
+ * This class implements an OData invoke operation request.
+ */
+public class ODataInvokeRequestImpl<T extends ODataInvokeResult>
+        extends AbstractODataBasicRequest<ODataInvokeResponse<T>, ODataPubFormat>
+        implements ODataInvokeRequest<T>, ODataBatchableRequest {
+
+  private final Class<T> reference;
+
+  /**
+   * Function parameters.
+   */
+  private Map<String, ODataValue> parameters;
+
+  /**
+   * Constructor.
+   *
+   * @param odataClient client instance getting this request
+   * @param reference reference class for invoke result
+   * @param method HTTP method of the request.
+   * @param uri URI that identifies the operation.
+   */
+  ODataInvokeRequestImpl(
+          final ODataClient odataClient,
+          final Class<T> reference,
+          final HttpMethod method,
+          final URI uri) {
+
+    super(odataClient, ODataPubFormat.class, method, uri);
+
+    this.reference = reference;
+    this.parameters = new LinkedHashMap<String, ODataValue>();
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  public void setParameters(final Map<String, ODataValue> parameters) {
+    this.parameters.clear();
+    if (parameters != null && !parameters.isEmpty()) {
+      this.parameters.putAll(parameters);
+    }
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  public void setFormat(final ODataPubFormat format) {
+    final String _format = (reference.isAssignableFrom(ODataProperty.class) && format == ODataPubFormat.ATOM)
+            ? ODataFormat.XML.toString()
+            : format.toString();
+    setAccept(_format);
+    setContentType(_format);
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  protected InputStream getPayload() {
+    if (!this.parameters.isEmpty() && this.method == HttpMethod.POST) {
+      // Additional, non-binding parameters MUST be sent as JSON
+      final ODataEntity tmp = odataClient.getObjectFactory().newEntity("");
+      for (Map.Entry<String, ODataValue> param : parameters.entrySet()) {
+        ODataProperty property = null;
+
+        if (param.getValue().isPrimitive()) {
+          property = odataClient.getObjectFactory().
+                  newPrimitiveProperty(param.getKey(), param.getValue().asPrimitive());
+        } else if (param.getValue().isComplex()) {
+          property = odataClient.getObjectFactory().
+                  newComplexProperty(param.getKey(), param.getValue().asComplex());
+        } else if (param.getValue().isCollection()) {
+          property = odataClient.getObjectFactory().
+                  newCollectionProperty(param.getKey(), param.getValue().asCollection());
+        }
+
+        if (property != null) {
+          tmp.getProperties().add(property);
+        }
+      }
+
+      return odataClient.getWriter().writeEntity(tmp, ODataPubFormat.JSON, false);
+    }
+
+    return null;
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  public ODataInvokeResponse<T> execute() {
+    final InputStream input = getPayload();
+
+    if (!this.parameters.isEmpty()) {
+      if (this.method == HttpMethod.GET) {
+        final URIBuilder uriBuilder = new URIBuilder(this.uri);
+        for (Map.Entry<String, ODataValue> param : parameters.entrySet()) {
+          if (!param.getValue().isPrimitive()) {
+            throw new IllegalArgumentException("Only primitive values can be passed via GET");
+          }
+
+          uriBuilder.addParameter(param.getKey(), param.getValue().toString());
+        }
+        try {
+          ((HttpRequestBase) this.request).setURI(uriBuilder.build());
+        } catch (URISyntaxException e) {
+          throw new IllegalArgumentException("While adding GET parameters", e);
+        }
+      } else if (this.method == HttpMethod.POST) {
+        ((HttpPost) request).setEntity(URIUtils.buildInputStreamEntity(odataClient, input));
+
+        setContentType(ODataPubFormat.JSON.toString());
+      }
+    }
+
+    try {
+      return new ODataInvokeResponseImpl(httpClient, doExecute());
+    } finally {
+      IOUtils.closeQuietly(input);
+    }
+  }
+
+  /**
+   * Response class about an ODataInvokeRequest.
+   */
+  protected class ODataInvokeResponseImpl extends ODataResponseImpl implements ODataInvokeResponse<T> {
+
+    private T invokeResult = null;
+
+    /**
+     * Constructor.
+     * <p>
+     * Just to create response templates to be initialized from batch.
+     */
+    private ODataInvokeResponseImpl() {
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param client HTTP client.
+     * @param res HTTP response.
+     */
+    private ODataInvokeResponseImpl(final HttpClient client, final HttpResponse res) {
+      super(client, res);
+    }
+
+    /**
+     * {@inheritDoc }
+     */
+    @Override
+    @SuppressWarnings("unchecked")
+    public T getBody() {
+      if (invokeResult == null) {
+        if (reference.isAssignableFrom(ODataNoContent.class)) {
+          invokeResult = (T) new ODataNoContent();
+        }
+
+        try {
+          if (reference.isAssignableFrom(ODataEntitySet.class)) {
+            invokeResult = (T) odataClient.getReader().readEntitySet(res.getEntity().getContent(),
+                    ODataPubFormat.fromString(getContentType()));
+          }
+          if (reference.isAssignableFrom(ODataEntity.class)) {
+            invokeResult = (T) odataClient.getReader().readEntity(res.getEntity().getContent(),
+                    ODataPubFormat.fromString(getContentType()));
+          }
+          if (reference.isAssignableFrom(ODataProperty.class)) {
+            invokeResult = (T) odataClient.getReader().readProperty(res.getEntity().getContent(),
+                    ODataFormat.fromString(getContentType()));
+          }
+        } catch (IOException e) {
+          throw new HttpClientException(e);
+        } finally {
+          this.close();
+        }
+      }
+      return invokeResult;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d3b05e01/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/V3InvokeRequestFactoryImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/V3InvokeRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/V3InvokeRequestFactoryImpl.java
new file mode 100644
index 0000000..34203de
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/V3InvokeRequestFactoryImpl.java
@@ -0,0 +1,89 @@
+/*
+ * 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.invoke;
+
+import java.net.URI;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.client.api.ODataV3Client;
+import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest;
+import org.apache.olingo.client.api.communication.request.invoke.ODataNoContent;
+import org.apache.olingo.client.api.communication.request.invoke.V3InvokeRequestFactory;
+import org.apache.olingo.client.api.domain.ODataEntity;
+import org.apache.olingo.client.api.domain.ODataEntitySet;
+import org.apache.olingo.client.api.domain.ODataInvokeResult;
+import org.apache.olingo.client.api.domain.ODataJClientEdmType;
+import org.apache.olingo.client.api.domain.ODataProperty;
+import org.apache.olingo.client.api.edm.xml.XMLMetadata;
+import org.apache.olingo.client.api.edm.xml.v3.FunctionImport;
+import org.apache.olingo.client.api.http.HttpMethod;
+
+public class V3InvokeRequestFactoryImpl extends AbstractInvokeRequestFactory<FunctionImport>
+        implements V3InvokeRequestFactory {
+
+  private static final long serialVersionUID = -659256862901915496L;
+
+  public V3InvokeRequestFactoryImpl(final ODataV3Client client) {
+    super(client);
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  @SuppressWarnings("unchecked")
+  public <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getInvokeRequest(
+          final URI uri,
+          final XMLMetadata metadata,
+          final FunctionImport functionImport) {
+
+    HttpMethod method = null;
+    if (HttpMethod.GET.name().equals(functionImport.getHttpMethod())) {
+      method = HttpMethod.GET;
+    } else if (HttpMethod.POST.name().equals(functionImport.getHttpMethod())) {
+      method = HttpMethod.POST;
+    } else if (functionImport.getHttpMethod() == null) {
+      if (functionImport.isSideEffecting()) {
+        method = HttpMethod.POST;
+      } else {
+        method = HttpMethod.GET;
+      }
+    }
+
+    ODataInvokeRequest<RES> result;
+    if (StringUtils.isBlank(functionImport.getReturnType())) {
+      result = (ODataInvokeRequest<RES>) new ODataInvokeRequestImpl<ODataNoContent>(
+              client, ODataNoContent.class, method, uri);
+    } else {
+      final ODataJClientEdmType returnType = new ODataJClientEdmType(metadata, functionImport.getReturnType());
+
+      if (returnType.isCollection() && returnType.isEntityType()) {
+        result = (ODataInvokeRequest<RES>) new ODataInvokeRequestImpl<ODataEntitySet>(
+                client, ODataEntitySet.class, method, uri);
+      } else if (!returnType.isCollection() && returnType.isEntityType()) {
+        result = (ODataInvokeRequest<RES>) new ODataInvokeRequestImpl<ODataEntity>(
+                client, ODataEntity.class, method, uri);
+      } else {
+        result = (ODataInvokeRequest<RES>) new ODataInvokeRequestImpl<ODataProperty>(
+                client, ODataProperty.class, method, uri);
+      }
+    }
+
+    return result;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d3b05e01/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/V4InvokeRequestFactoryImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/V4InvokeRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/V4InvokeRequestFactoryImpl.java
new file mode 100644
index 0000000..4bbfb56
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/V4InvokeRequestFactoryImpl.java
@@ -0,0 +1,43 @@
+/*
+ * 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.invoke;
+
+import java.net.URI;
+import org.apache.olingo.client.api.ODataV4Client;
+import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest;
+import org.apache.olingo.client.api.communication.request.invoke.V4InvokeRequestFactory;
+import org.apache.olingo.client.api.domain.ODataInvokeResult;
+import org.apache.olingo.client.api.edm.xml.XMLMetadata;
+import org.apache.olingo.client.api.edm.xml.v4.FunctionImport;
+
+public class V4InvokeRequestFactoryImpl extends AbstractInvokeRequestFactory<FunctionImport>
+        implements V4InvokeRequestFactory {
+
+  private static final long serialVersionUID = 8452737360003104372L;
+
+  public V4InvokeRequestFactoryImpl(final ODataV4Client client) {
+    super(client);
+  }
+
+  @Override
+  public <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getInvokeRequest(
+          final URI uri, final XMLMetadata metadata, final FunctionImport functionImport) {
+    throw new UnsupportedOperationException("Not supported yet.");
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d3b05e01/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractODataRetrieveRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractODataRetrieveRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractODataRetrieveRequest.java
new file mode 100644
index 0000000..bd5166a
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractODataRetrieveRequest.java
@@ -0,0 +1,98 @@
+/*
+ * 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.retrieve;
+
+import java.io.InputStream;
+import java.net.URI;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataRetrieveRequest;
+import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
+import org.apache.olingo.client.api.http.HttpMethod;
+import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
+import org.apache.olingo.client.core.communication.response.ODataResponseImpl;
+
+/**
+ * This is an abstract representation of an OData retrieve query request returning one or more result item. Get instance
+ * by using ODataRetrieveRequestFactory.
+ */
+abstract class AbstractODataRetrieveRequest<V, T extends Enum<T>>
+        extends AbstractODataBasicRequest<ODataRetrieveResponse<V>, T>
+        implements ODataRetrieveRequest<V, T>, ODataBatchableRequest {
+
+  /**
+   * Private constructor.
+   *
+   * @param odataClient client instance getting this request
+   * @param formatRef reference class for the format being used
+   * @param query query to be executed.
+   */
+  AbstractODataRetrieveRequest(final ODataClient odataClient, final Class<T> formatRef, final URI query) {
+    super(odataClient, formatRef, HttpMethod.GET, query);
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  public abstract ODataRetrieveResponse<V> execute();
+
+  /**
+   * {@inheritDoc }
+   * <p>
+   * This kind of request doesn't have any payload: null will be returned.
+   */
+  @Override
+  protected InputStream getPayload() {
+    return null;
+  }
+
+  /**
+   * Response abstract class about an ODataRetrieveRequest.
+   */
+  protected abstract class ODataRetrieveResponseImpl extends ODataResponseImpl implements ODataRetrieveResponse<V> {
+
+    /**
+     * Constructor.
+     * <p>
+     * Just to create response templates to be initialized from batch.
+     */
+    protected ODataRetrieveResponseImpl() {
+      super();
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param client HTTP client.
+     * @param res HTTP response.
+     */
+    protected ODataRetrieveResponseImpl(final HttpClient client, final HttpResponse res) {
+      super(client, res);
+    }
+
+    /**
+     * {@inheritDoc }
+     */
+    @Override
+    public abstract V getBody();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d3b05e01/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractRetrieveRequestFactory.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractRetrieveRequestFactory.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractRetrieveRequestFactory.java
new file mode 100644
index 0000000..a660208
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractRetrieveRequestFactory.java
@@ -0,0 +1,98 @@
+/*
+ * 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.retrieve;
+
+import java.net.URI;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetIteratorRequest;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataGenericRetrieveRequest;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataMediaRequest;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataMetadataRequest;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataRawRequest;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataServiceDocumentRequest;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataValueRequest;
+import org.apache.olingo.client.api.communication.request.retrieve.RetrieveRequestFactory;
+
+public abstract class AbstractRetrieveRequestFactory implements RetrieveRequestFactory {
+
+  private static final long serialVersionUID = -111683263158803362L;
+
+  protected final ODataClient client;
+
+  protected AbstractRetrieveRequestFactory(final ODataClient client) {
+    this.client = client;
+  }
+
+  @Override
+  public ODataEntitySetRequest getEntitySetRequest(final URI query) {
+    return new ODataEntitySetRequestImpl(client, query);
+  }
+
+  @Override
+  public ODataEntitySetIteratorRequest getEntitySetIteratorRequest(final URI query) {
+    return new ODataEntitySetIteratorRequestImpl(client, query);
+  }
+
+  @Override
+  public ODataEntityRequest getEntityRequest(final URI query) {
+    return new ODataEntityRequestImpl(client, query);
+  }
+
+  @Override
+  public ODataPropertyRequest getPropertyRequest(final URI query) {
+    return new ODataPropertyRequestImpl(client, query);
+  }
+
+  @Override
+  public ODataValueRequest getValueRequest(final URI query) {
+    return new ODataValueRequestImpl(client, query);
+  }
+
+  @Override
+  public ODataMediaRequest getMediaRequest(final URI query) {
+    return new ODataMediaRequestImpl(client, query);
+  }
+
+  @Override
+  public ODataRawRequest getRawRequest(final URI uri) {
+    return new ODataRawRequestImpl(client, uri);
+  }
+
+  @Override
+  public ODataMetadataRequest getMetadataRequest(final String serviceRoot) {
+    return new ODataMetadataRequestImpl(client, client.getURIBuilder(serviceRoot).appendMetadataSegment().build());
+  }
+
+  @Override
+  public ODataServiceDocumentRequest getServiceDocumentRequest(final String serviceRoot) {
+    return new ODataServiceDocumentRequestImpl(client,
+            StringUtils.isNotBlank(serviceRoot) && serviceRoot.endsWith("/")
+            ? client.getURIBuilder(serviceRoot).build()
+            : client.getURIBuilder(serviceRoot + "/").build());
+  }
+
+  @Override
+  public ODataGenericRetrieveRequest getGenericRetrieveRequest(final URI uri) {
+    return new ODataGenericRetrieveRequestImpl(client, uri);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d3b05e01/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntityRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntityRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntityRequestImpl.java
new file mode 100644
index 0000000..2a35514
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntityRequestImpl.java
@@ -0,0 +1,95 @@
+/*
+ * 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.retrieve;
+
+import java.net.URI;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
+import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
+import org.apache.olingo.client.api.domain.ODataEntity;
+import org.apache.olingo.client.api.format.ODataPubFormat;
+
+/**
+ * This class implements an OData retrieve query request returning a single entity.
+ */
+public class ODataEntityRequestImpl extends AbstractODataRetrieveRequest<ODataEntity, ODataPubFormat>
+        implements ODataEntityRequest {
+
+  /**
+   * Private constructor.
+   *
+   * @param odataClient client instance getting this request
+   * @param query query to be executed.
+   */
+  ODataEntityRequestImpl(final ODataClient odataClient, final URI query) {
+    super(odataClient, ODataPubFormat.class, query);
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  public ODataRetrieveResponse<ODataEntity> execute() {
+    return new ODataEntityResponseImpl(httpClient, doExecute());
+  }
+
+  /**
+   * Response class about an ODataEntityRequest.
+   */
+  public class ODataEntityResponseImpl extends ODataRetrieveResponseImpl {
+
+    private ODataEntity entity = null;
+
+    /**
+     * Constructor.
+     * <p>
+     * Just to create response templates to be initialized from batch.
+     */
+    private ODataEntityResponseImpl() {
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param client HTTP client.
+     * @param res HTTP response.
+     */
+    private ODataEntityResponseImpl(final HttpClient client, final HttpResponse res) {
+      super(client, res);
+    }
+
+    /**
+     * {@inheritDoc }
+     */
+    @Override
+    public ODataEntity getBody() {
+      if (entity == null) {
+        try {
+          entity = odataClient.getReader().
+                  readEntity(getRawResponse(), ODataPubFormat.fromString(getContentType()));
+        } finally {
+          this.close();
+        }
+      }
+      return entity;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d3b05e01/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetIteratorRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetIteratorRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetIteratorRequestImpl.java
new file mode 100644
index 0000000..345f673
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetIteratorRequestImpl.java
@@ -0,0 +1,86 @@
+/*
+ * 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.retrieve;
+
+import java.net.URI;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetIteratorRequest;
+import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
+import org.apache.olingo.client.api.domain.ODataEntitySetIterator;
+import org.apache.olingo.client.api.format.ODataPubFormat;
+
+/**
+ * This class implements an OData EntitySet query request.
+ */
+public class ODataEntitySetIteratorRequestImpl
+        extends AbstractODataRetrieveRequest<ODataEntitySetIterator, ODataPubFormat>
+        implements ODataEntitySetIteratorRequest {
+
+  private ODataEntitySetIterator feedIterator = null;
+
+  /**
+   * Private constructor.
+   *
+   * @param odataClient client instance getting this request
+   * @param query query to be executed.
+   */
+  ODataEntitySetIteratorRequestImpl(final ODataClient odataClient, final URI query) {
+    super(odataClient, ODataPubFormat.class, query);
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  public ODataRetrieveResponse<ODataEntitySetIterator> execute() {
+    final HttpResponse res = doExecute();
+    return new ODataEntitySetIteratorResponseImpl(httpClient, res);
+  }
+
+  /**
+   * Response class about an ODataEntitySetIteratorRequest.
+   */
+  protected class ODataEntitySetIteratorResponseImpl extends ODataRetrieveResponseImpl {
+
+    /**
+     * Constructor.
+     *
+     * @param client HTTP client.
+     * @param res HTTP response.
+     */
+    private ODataEntitySetIteratorResponseImpl(final HttpClient client, final HttpResponse res) {
+      super(client, res);
+    }
+
+    /**
+     * {@inheritDoc }
+     */
+    @Override
+    @SuppressWarnings("unchecked")
+    public ODataEntitySetIterator getBody() {
+      if (feedIterator == null) {
+        feedIterator = new ODataEntitySetIterator(
+                odataClient, getRawResponse(), ODataPubFormat.fromString(getContentType()));
+      }
+      return feedIterator;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d3b05e01/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java
new file mode 100644
index 0000000..a18cba9
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java
@@ -0,0 +1,97 @@
+/*
+ * 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.retrieve;
+
+import java.net.URI;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
+import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
+import org.apache.olingo.client.api.domain.ODataEntitySet;
+import org.apache.olingo.client.api.format.ODataPubFormat;
+
+/**
+ * This class implements an OData EntitySet query request.
+ */
+public class ODataEntitySetRequestImpl extends AbstractODataRetrieveRequest<ODataEntitySet, ODataPubFormat>
+        implements ODataEntitySetRequest {
+
+  private ODataEntitySet feed = null;
+
+  /**
+   * Private constructor.
+   *
+   * @param odataClient client instance getting this request
+   * @param query query to be executed.
+   */
+  ODataEntitySetRequestImpl(final ODataClient odataClient, final URI query) {
+    super(odataClient, ODataPubFormat.class, query);
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  public ODataRetrieveResponse<ODataEntitySet> execute() {
+    final HttpResponse res = doExecute();
+    return new ODataEntitySetResponseImpl(httpClient, res);
+  }
+
+  /**
+   * Response class about an ODataEntitySetRequest.
+   */
+  protected class ODataEntitySetResponseImpl extends ODataRetrieveResponseImpl {
+
+    /**
+     * Constructor.
+     * <p>
+     * Just to create response templates to be initialized from batch.
+     */
+    private ODataEntitySetResponseImpl() {
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param client HTTP client.
+     * @param res HTTP response.
+     */
+    private ODataEntitySetResponseImpl(final HttpClient client, final HttpResponse res) {
+      super(client, res);
+    }
+
+    /**
+     * {@inheritDoc }
+     */
+    @Override
+    @SuppressWarnings("unchecked")
+    public ODataEntitySet getBody() {
+      if (feed == null) {
+        try {
+          feed = odataClient.getReader().
+                  readEntitySet(getRawResponse(), ODataPubFormat.fromString(getContentType()));
+        } finally {
+          this.close();
+        }
+      }
+      return feed;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d3b05e01/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataGenericRetrieveRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataGenericRetrieveRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataGenericRetrieveRequestImpl.java
new file mode 100644
index 0000000..a370881
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataGenericRetrieveRequestImpl.java
@@ -0,0 +1,105 @@
+/*
+ * 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.retrieve;
+
+import java.net.URI;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataGenericRetrieveRequest;
+import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
+import org.apache.olingo.client.api.data.ObjectWrapper;
+import org.apache.olingo.client.core.communication.response.ODataResponseImpl;
+
+/**
+ * This class implements a generic OData retrieve query request.
+ */
+public class ODataGenericRetrieveRequestImpl extends ODataRawRequestImpl implements ODataGenericRetrieveRequest {
+
+  /**
+   * Constructor.
+   *
+   * @param odataClient client instance getting this request
+   * @param uri query request.
+   */
+  public ODataGenericRetrieveRequestImpl(final ODataClient odataClient, final URI uri) {
+    super(odataClient, uri);
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  public void setFormat(final String format) {
+    setAccept(format);
+    setContentType(format);
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  public ODataRetrieveResponse<ObjectWrapper> execute() {
+    return new ODataGenericResponseImpl(httpClient, doExecute());
+  }
+
+  /**
+   * Query response implementation about a generic query request.
+   */
+  protected class ODataGenericResponseImpl extends ODataResponseImpl implements ODataRetrieveResponse<ObjectWrapper> {
+
+    /**
+     * Retrieved object wrapper.
+     */
+    private ObjectWrapper obj = null;
+
+    /**
+     * Constructor.
+     * <p>
+     * Just to create response templates to be initialized from batch.
+     */
+    private ODataGenericResponseImpl() {
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param client HTTP client.
+     * @param res HTTP response.
+     */
+    private ODataGenericResponseImpl(final HttpClient client, final HttpResponse res) {
+      super(client, res);
+    }
+
+    /**
+     * {@inheritDoc }
+     */
+    @Override
+    public ObjectWrapper getBody() {
+      if (obj == null) {
+        try {
+          obj = new ObjectWrapper(odataClient.getReader(), getRawResponse(), getContentType());
+        } finally {
+          this.close();
+        }
+      }
+      return obj;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d3b05e01/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataLinkCollectionRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataLinkCollectionRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataLinkCollectionRequestImpl.java
new file mode 100644
index 0000000..73e6c67
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataLinkCollectionRequestImpl.java
@@ -0,0 +1,98 @@
+/*
+ * 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.retrieve;
+
+import java.io.IOException;
+import java.net.URI;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.olingo.client.api.ODataV3Client;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataLinkCollectionRequest;
+import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
+import org.apache.olingo.client.api.domain.ODataLinkCollection;
+import org.apache.olingo.client.api.format.ODataFormat;
+import org.apache.olingo.client.api.http.HttpClientException;
+
+/**
+ * This class implements an OData link query request.
+ */
+public class ODataLinkCollectionRequestImpl extends AbstractODataRetrieveRequest<ODataLinkCollection, ODataFormat>
+        implements ODataLinkCollectionRequest {
+
+  /**
+   * Private constructor.
+   *
+   * @param odataClient client instance getting this request
+   * @param targetURI target URI.
+   * @param linkName link name.
+   */
+  ODataLinkCollectionRequestImpl(final ODataV3Client odataClient, final URI targetURI, final String linkName) {
+    super(odataClient, ODataFormat.class,
+            odataClient.getURIBuilder(targetURI.toASCIIString()).appendLinksSegment(linkName).build());
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  public ODataRetrieveResponse<ODataLinkCollection> execute() {
+    return new ODataLinkCollectionResponseImpl(httpClient, doExecute());
+  }
+
+  protected class ODataLinkCollectionResponseImpl extends ODataRetrieveResponseImpl {
+
+    private ODataLinkCollection links = null;
+
+    /**
+     * Constructor.
+     * <p>
+     * Just to create response templates to be initialized from batch.
+     */
+    private ODataLinkCollectionResponseImpl() {
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param client HTTP client.
+     * @param res HTTP response.
+     */
+    private ODataLinkCollectionResponseImpl(final HttpClient client, final HttpResponse res) {
+      super(client, res);
+    }
+
+    /**
+     * {@inheritDoc }
+     */
+    @Override
+    public ODataLinkCollection getBody() {
+      if (links == null) {
+        try {
+          links = odataClient.getReader().readLinks(
+                  res.getEntity().getContent(), ODataFormat.fromString(getContentType()));
+        } catch (IOException e) {
+          throw new HttpClientException(e);
+        } finally {
+          this.close();
+        }
+      }
+      return links;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d3b05e01/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataMediaRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataMediaRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataMediaRequestImpl.java
new file mode 100644
index 0000000..9209f96
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataMediaRequestImpl.java
@@ -0,0 +1,109 @@
+/*
+ * 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.retrieve;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.communication.header.HeaderName;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataMediaRequest;
+import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
+import org.apache.olingo.client.api.format.ODataMediaFormat;
+import org.apache.olingo.client.api.http.HttpClientException;
+
+/**
+ * This class implements an OData media query request.
+ */
+public class ODataMediaRequestImpl extends AbstractODataRetrieveRequest<InputStream, ODataMediaFormat>
+        implements ODataMediaRequest {
+
+  /**
+   * Private constructor.
+   *
+   * @param odataClient client instance getting this request
+   * @param query query to be executed.
+   */
+  ODataMediaRequestImpl(final ODataClient odataClient, final URI query) {
+    super(odataClient, ODataMediaFormat.class, query);
+
+    setAccept(ODataMediaFormat.APPLICATION_OCTET_STREAM.toString());
+    setContentType(ODataMediaFormat.APPLICATION_OCTET_STREAM.toString());
+
+    this.odataHeaders.removeHeader(HeaderName.minDataServiceVersion);
+    this.odataHeaders.removeHeader(HeaderName.maxDataServiceVersion);
+    this.odataHeaders.removeHeader(HeaderName.dataServiceVersion);
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  public ODataRetrieveResponse<InputStream> execute() {
+    final HttpResponse res = doExecute();
+    return new ODataMediaResponseImpl(httpClient, res);
+  }
+
+  /**
+   * Response class about an ODataMediaRequest.
+   */
+  protected class ODataMediaResponseImpl extends ODataRetrieveResponseImpl {
+
+    private InputStream input = null;
+
+    /**
+     * Constructor.
+     * <p>
+     * Just to create response templates to be initialized from batch.
+     */
+    private ODataMediaResponseImpl() {
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param client HTTP client.
+     * @param res HTTP response.
+     */
+    private ODataMediaResponseImpl(final HttpClient client, final HttpResponse res) {
+      super(client, res);
+    }
+
+    /**
+     * Gets query result objects.
+     * <br/>
+     * <b>WARNING</b>: Closing this <tt>ODataResponse</tt> instance is left to the caller.
+     *
+     * @return query result objects as <tt>InputStream</tt>.
+     */
+    @Override
+    public InputStream getBody() {
+      if (input == null) {
+        try {
+          input = res.getEntity().getContent();
+        } catch (IOException e) {
+          throw new HttpClientException(e);
+        }
+      }
+      return input;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d3b05e01/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataMetadataRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataMetadataRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataMetadataRequestImpl.java
new file mode 100644
index 0000000..b51b715
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataMetadataRequestImpl.java
@@ -0,0 +1,109 @@
+/*
+ * 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.retrieve;
+
+import java.net.URI;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.entity.ContentType;
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.communication.request.ODataRequest;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataMetadataRequest;
+import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
+import org.apache.olingo.client.api.edm.xml.XMLMetadata;
+import org.apache.olingo.client.api.format.ODataPubFormat;
+
+/**
+ * This class implements a metadata query request.
+ */
+class ODataMetadataRequestImpl extends AbstractODataRetrieveRequest<XMLMetadata, ODataPubFormat>
+        implements ODataMetadataRequest {
+
+  /**
+   * Constructor.
+   *
+   * @param odataClient client instance getting this request
+   * @param uri metadata URI.
+   */
+  ODataMetadataRequestImpl(final ODataClient odataClient, final URI uri) {
+    super(odataClient, ODataPubFormat.class, uri);
+    super.setAccept(ContentType.APPLICATION_XML.getMimeType());
+    super.setContentType(ContentType.APPLICATION_XML.getMimeType());
+  }
+
+  @Override
+  public ODataRequest setAccept(final String value) {
+    // do nothing: Accept is application/XML
+    return this;
+  }
+
+  @Override
+  public ODataRequest setContentType(final String value) {
+    // do nothing: Accept is application/XML
+    return this;
+  }
+
+  @Override
+  public ODataRetrieveResponse<XMLMetadata> execute() {
+    final HttpResponse res = doExecute();
+    return new ODataMetadataResponseImpl(httpClient, res);
+  }
+
+  /**
+   * Response class about an ODataMetadataRequest.
+   */
+  protected class ODataMetadataResponseImpl extends ODataRetrieveResponseImpl {
+
+    private XMLMetadata metadata = null;
+
+    /**
+     * Constructor.
+     * <p>
+     * Just to create response templates to be initialized from batch.
+     */
+    public ODataMetadataResponseImpl() {
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param client HTTP client.
+     * @param res HTTP response.
+     */
+    private ODataMetadataResponseImpl(final HttpClient client, final HttpResponse res) {
+      super(client, res);
+    }
+
+    /**
+     * {@inheritDoc }
+     */
+    @Override
+    @SuppressWarnings("unchecked")
+    public XMLMetadata getBody() {
+      if (metadata == null) {
+        try {
+          metadata = (XMLMetadata) odataClient.getReader().readMetadata(getRawResponse());
+        } finally {
+          this.close();
+        }
+      }
+      return metadata;
+    }
+  }
+}