You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2015/06/23 16:39:46 UTC

[01/39] olingo-odata4 git commit: Adding an OSGi version of Cars server sample

Repository: olingo-odata4
Updated Branches:
  refs/heads/IEE754Compatible 9d4cf6ad4 -> ef1fd7787


Adding an OSGi version of Cars server sample

Signed-off-by: Michael Bolz <mi...@sap.com>


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

Branch: refs/heads/IEE754Compatible
Commit: 5727d05871decb23cf729be2b7bb6ead3576a195
Parents: fd71b7e
Author: Aki Yoshida <el...@gmail.com>
Authored: Wed Apr 29 09:40:17 2015 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Fri May 29 18:50:26 2015 +0200

----------------------------------------------------------------------
 samples/osgi/server/README.txt                  | 183 ++++++++++
 samples/osgi/server/pom.xml                     |  93 +++++
 .../olingo/server/sample/CarsServlet.java       |  67 ++++
 .../olingo/server/sample/data/DataProvider.java | 171 +++++++++
 .../sample/edmprovider/CarsEdmProvider.java     | 183 ++++++++++
 .../server/sample/processor/CarsProcessor.java  | 355 +++++++++++++++++++
 .../server/src/main/resources/META-INF/LICENSE  | 331 +++++++++++++++++
 .../src/main/resources/simplelogger.properties  |  20 ++
 .../osgi/server/src/main/webapp/WEB-INF/web.xml |  42 +++
 .../osgi/server/src/main/webapp/css/olingo.css  |  91 +++++
 .../src/main/webapp/img/OlingoOrangeTM.png      | Bin 0 -> 113360 bytes
 samples/osgi/server/src/main/webapp/index.jsp   |  56 +++
 samples/pom.xml                                 |   1 +
 13 files changed, 1593 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5727d058/samples/osgi/server/README.txt
----------------------------------------------------------------------
diff --git a/samples/osgi/server/README.txt b/samples/osgi/server/README.txt
new file mode 100644
index 0000000..3c5d61d
--- /dev/null
+++ b/samples/osgi/server/README.txt
@@ -0,0 +1,183 @@
+#
+# 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.
+#
+
+Apache Olingo OData Cars service on OSGi
+=================================================
+
+This demo is an OSGi version of the Olingo Cars demo.
+
+Building
+--------
+From the base directory of this sample, the pom.xml file
+is used to build and run the standalone unit test.
+
+```
+  mvn clean install
+```
+
+Running the demo in OSGi
+------------------------
+After building the sample, install the bundle to your Karaf
+container.
+
+If you do not have Karaf installed, download apache-karaf-3.0.3.tar.gz from one of the [mirror sites](http://www.apache.org/dyn/closer.cgi/karaf/3.0.3/apache-karaf-3.0.3.tar.gz) and unpack the archive.
+
+```
+$ wget -N http://ftp.halifax.rwth-aachen.de/apache/karaf/3.0.3/apache-karaf-3.0.3.tar.gz
+$ tar -zxf apache-karaf-3.0.3.tar.gz
+$ cd apache-karaf-3.0.3
+```
+
+#### Starting Karaf
+
+```
+$ bin/karaf
+        __ __                  ____      
+       / //_/____ __________ _/ __/      
+      / ,<  / __ `/ ___/ __ `/ /_        
+     / /| |/ /_/ / /  / /_/ / __/        
+    /_/ |_|\__,_/_/   \__,_/_/         
+
+  Apache Karaf (3.0.3)
+
+Hit '<tab>' for a list of available commands
+and '[cmd] --help' for help on a specific command.
+Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown Karaf.
+
+karaf@root()>
+```
+
+#### Note on using Karaf behind a firewall
+
+If you do not have a direct access to the maven central repositories, you need to set Karaf's property
+org.ops4j.pax.url.mvn.repositories to point to your local repository
+
+To use your local repository http://nexus.mycorp.com:8081/nexus/content/groups/build.milestone, run the following commands.
+
+```
+config:edit org.ops4j.pax.url.mvn
+config:property-set org.ops4j.pax.url.mvn.repositories http://nexus.mycorp.com:8081/nexus/content/groups/build.milestone
+config:update
+```
+
+Alternatively, you can edit this property in file etc/org.ops4j.pax.url.mvn.cfg.
+
+For further details, please refer to [Karaf User Guide](http://karaf.apache.org/manual/latest/users-guide/index.html).
+
+#### Install Olingo libs and other depdenent libs
+
+For now, we install the individual bundles one by one. We can define feature olingo-server to install all the bundles at once in the future.
+
+First, to install the depending bundles of olingo, run the following karaf console commands.
+
+```
+feature:install war
+bundle:install -s mvn:commons-codec/commons-codec/1.9
+bundle:install -s mvn:org.apache.commons/commons-lang3/3.3.2
+bundle:install -s mvn:org.codehaus.woodstox/stax2-api/3.1.4
+bundle:install -s mvn:com.fasterxml/aalto-xml/0.9.10
+bundle:install -s 'wrap:mvn:org.antlr/antlr4-runtime/4.1/$Bundle-SymbolicName=antlr4-runtime&Bundle-Version=4.1&Export-Package=org.antlr.v4.runtime*'
+bundle:install -s mvn:com.fasterxml.jackson.core/jackson-core/2.4.1
+bundle:install -s mvn:com.fasterxml.jackson.core/jackson-annotations/2.4.1
+bundle:install -s mvn:com.fasterxml.jackson.core/jackson-databind/2.4.1
+```
+
+Now, install the olingo bundles by running the following commands. Note that
+we assume we are using the patched version regarding OLINGO-632.
+
+```
+bundle:install -s mvn:org.apache.olingo/odata-commons-api/4.0.0-SNAPSHOT
+bundle:install -s mvn:org.apache.olingo/odata-commons-core/4.0.0-SNAPSHOT
+bundle:install -s mvn:org.apache.olingo/odata-server-api/4.0.0-SNAPSHOT
+bundle:install -s mvn:org.apache.olingo/odata-server-core/4.0.0-SNAPSHOT
+```
+
+#### Install this sample bundle
+
+To install this sample bundle, run the karaf console command.
+
+```
+bundle:install -s mvn:org.apache.olingo/odata-server-osgi-sample/4.0.0-SNAPSHOT
+```
+
+Shown below is the output from running the above Karaf console commands.
+
+```
+karaf@root()> feature:install war
+karaf@root()> bundle:install -s mvn:commons-codec/commons-codec/1.9
+Bundle ID: 97
+karaf@root()> bundle:install -s mvn:org.apache.commons/commons-lang3/3.3.2
+Bundle ID: 98
+karaf@root()> bundle:install -s mvn:org.codehaus.woodstox/stax2-api/3.1.4
+Bundle ID: 99
+karaf@root()> bundle:install -s mvn:com.fasterxml/aalto-xml/0.9.10
+Bundle ID: 100
+karaf@root()> bundle:install -s 'wrap:mvn:org.antlr/antlr4-runtime/4.1/$Bundle-SymbolicName=antlr4-runtime&Bundle-Version=4.1&Export-Package=org.antlr.v4.runtime*'
+Bundle ID: 101
+karaf@root()> bundle:install -s mvn:com.fasterxml.jackson.core/jackson-core/2.4.1
+Bundle ID: 102
+karaf@root()> bundle:install -s mvn:com.fasterxml.jackson.core/jackson-annotations/2.4.1
+Bundle ID: 103
+karaf@root()> bundle:install -s mvn:com.fasterxml.jackson.core/jackson-databind/2.4.1
+Bundle ID: 104
+karaf@root()> bundle:install -s mvn:org.apache.olingo/odata-commons-api/4.0.0-SNAPSHOT
+Bundle ID: 105
+karaf@root()> bundle:install -s mvn:org.apache.olingo/odata-commons-core/4.0.0-SNAPSHOT
+Bundle ID: 106
+karaf@root()> bundle:install -s mvn:org.apache.olingo/odata-server-api/4.0.0-SNAPSHOT
+Bundle ID: 107
+karaf@root()> bundle:install -s mvn:org.apache.olingo/odata-server-core/4.0.0-SNAPSHOT
+Bundle ID: 108
+karaf@root()> bundle:install -s mvn:org.apache.olingo/odata-server-osgi-sample/4.0.0-SNAPSHOT
+Bundle ID: 109
+karaf@root()> 
+```
+
+To verify if the sample is correctly installed and running, use list and web:list to see its bundle status and its web context is registered.
+
+```
+karaf@root()> list
+START LEVEL 100 , List Threshold: 50
+ ID | State  | Lvl | Version        | Name                    
+--------------------------------------------------------------
+ 97 | Active |  80 | 1.9.0          | Apache Commons Codec    
+ 98 | Active |  80 | 3.3.2          | Apache Commons Lang     
+ 99 | Active |  80 | 3.1.4          | Stax2 API               
+100 | Active |  80 | 0.9.10         | aalto-xml               
+101 | Active |  80 | 4.1            | antlr4-runtime          
+102 | Active |  80 | 2.4.1          | Jackson-core            
+103 | Active |  80 | 2.4.1          | Jackson-annotations     
+104 | Active |  80 | 2.4.1          | jackson-databind        
+105 | Active |  80 | 4.0.0.SNAPSHOT | odata-commons-api       
+106 | Active |  80 | 4.0.0.SNAPSHOT | odata-commons-core      
+107 | Active |  80 | 4.0.0.SNAPSHOT | odata-server-api        
+108 | Active |  80 | 4.0.0.SNAPSHOT | odata-server-core       
+109 | Active |  80 | 4.0.0.SNAPSHOT | odata-server-osgi-sample
+karaf@root()> web:list
+ID  | State       | Web-State   | Level | Web-ContextPath | Name                                     
+-----------------------------------------------------------------------------------------------------
+109 | Active      | Deployed    | 80    | /olingo-cars    | odata-server-osgi-sample (4.0.0.SNAPSHOT)
+karaf@root()> 
+```
+
+#### Test this sample
+
+Using Browser, open [http://localhost:8181/olingo-cars](http://localhost:8181/olingo-cars) to access the default page and see some available
+queries. You can invoke these queries by clicking on those links or directly typing
+in the queries in Browser's URL field.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5727d058/samples/osgi/server/pom.xml
----------------------------------------------------------------------
diff --git a/samples/osgi/server/pom.xml b/samples/osgi/server/pom.xml
new file mode 100644
index 0000000..cb1afc0
--- /dev/null
+++ b/samples/osgi/server/pom.xml
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>odata-server-osgi-sample</artifactId>
+    <packaging>bundle</packaging>
+    <name>${project.artifactId}</name>
+
+    <parent>
+        <groupId>org.apache.olingo</groupId>
+        <artifactId>odata-samples</artifactId>
+        <version>4.0.0-SNAPSHOT</version>
+        <relativePath>../..</relativePath>
+    </parent>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-servlet_3.0_spec</artifactId>
+            <version>1.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.olingo</groupId>
+            <artifactId>odata-server-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.olingo</groupId>
+            <artifactId>odata-server-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.olingo</groupId>
+            <artifactId>odata-commons-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.olingo</groupId>
+            <artifactId>odata-commons-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Export-Package>
+                        </Export-Package>
+                        <Import-Package>
+                            org.apache.olingo.server.api*,
+                            org.apache.catalina;resolution:=optional,
+                            org.apache.catalina.comet;resolution:=optional,
+                            org.eclipse.jetty.continuation;resolution:=optional,
+                            org.eclipse.jetty.server;resolution:=optional,
+                            org.eclipse.jetty.util.ssl;resolution:=optional,
+                            *
+                        </Import-Package>
+                        <_wab>src/main/webapp/</_wab>
+                        <Web-ContextPath>olingo-cars</Web-ContextPath>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5727d058/samples/osgi/server/src/main/java/org/apache/olingo/server/sample/CarsServlet.java
----------------------------------------------------------------------
diff --git a/samples/osgi/server/src/main/java/org/apache/olingo/server/sample/CarsServlet.java b/samples/osgi/server/src/main/java/org/apache/olingo/server/sample/CarsServlet.java
new file mode 100644
index 0000000..f6a17dc
--- /dev/null
+++ b/samples/osgi/server/src/main/java/org/apache/olingo/server/sample/CarsServlet.java
@@ -0,0 +1,67 @@
+/*
+ * 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.server.sample;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.ODataHttpHandler;
+import org.apache.olingo.server.api.ServiceMetadata;
+import org.apache.olingo.server.api.edmx.EdmxReference;
+import org.apache.olingo.server.sample.data.DataProvider;
+import org.apache.olingo.server.sample.edmprovider.CarsEdmProvider;
+import org.apache.olingo.server.sample.processor.CarsProcessor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class CarsServlet extends HttpServlet {
+
+  private static final long serialVersionUID = 1L;
+  private static final Logger LOG = LoggerFactory.getLogger(CarsServlet.class);
+
+  @Override
+  protected void service(final HttpServletRequest req, final HttpServletResponse resp)
+      throws ServletException, IOException {
+    try {
+      HttpSession session = req.getSession(true);
+      DataProvider dataProvider = (DataProvider) session.getAttribute(DataProvider.class.getName());
+      if (dataProvider == null) {
+        dataProvider = new DataProvider();
+        session.setAttribute(DataProvider.class.getName(), dataProvider);
+        LOG.info("Created new data provider.");
+      }
+
+      OData odata = OData.newInstance();
+      ServiceMetadata edm = odata.createServiceMetadata(new CarsEdmProvider(), new ArrayList<EdmxReference>());
+      ODataHttpHandler handler = odata.createHandler(edm);
+      handler.register(new CarsProcessor(dataProvider));
+      handler.process(req, resp);
+    } catch (RuntimeException e) {
+      LOG.error("Server Error", e);
+      throw new ServletException(e);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5727d058/samples/osgi/server/src/main/java/org/apache/olingo/server/sample/data/DataProvider.java
----------------------------------------------------------------------
diff --git a/samples/osgi/server/src/main/java/org/apache/olingo/server/sample/data/DataProvider.java b/samples/osgi/server/src/main/java/org/apache/olingo/server/sample/data/DataProvider.java
new file mode 100644
index 0000000..69a4530
--- /dev/null
+++ b/samples/osgi/server/src/main/java/org/apache/olingo/server/sample/data/DataProvider.java
@@ -0,0 +1,171 @@
+/*
+ * 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.server.sample.data;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.olingo.commons.api.ODataException;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntityCollection;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ValueType;
+import org.apache.olingo.commons.api.data.ComplexValue;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.edm.EdmProperty;
+import org.apache.olingo.server.api.uri.UriParameter;
+import org.apache.olingo.server.sample.edmprovider.CarsEdmProvider;
+
+public class DataProvider {
+
+  private final Map<String, EntityCollection> data;
+
+  public DataProvider() {
+    data = new HashMap<String, EntityCollection>();
+    data.put("Cars", createCars());
+    data.put("Manufacturers", createManufacturers());
+  }
+
+  public EntityCollection readAll(EdmEntitySet edmEntitySet) {
+    return data.get(edmEntitySet.getName());
+  }
+
+  public Entity read(final EdmEntitySet edmEntitySet, final List<UriParameter> keys) throws DataProviderException {
+    final EdmEntityType entityType = edmEntitySet.getEntityType();
+    final EntityCollection entitySet = data.get(edmEntitySet.getName());
+    if (entitySet == null) {
+      return null;
+    } else {
+      try {
+        for (final Entity entity : entitySet.getEntities()) {
+          boolean found = true;
+          for (final UriParameter key : keys) {
+            final EdmProperty property = (EdmProperty) entityType.getProperty(key.getName());
+            final EdmPrimitiveType type = (EdmPrimitiveType) property.getType();
+            if (!type.valueToString(entity.getProperty(key.getName()).getValue(),
+                property.isNullable(), property.getMaxLength(), property.getPrecision(), property.getScale(),
+                property.isUnicode())
+                .equals(key.getText())) {
+              found = false;
+              break;
+            }
+          }
+          if (found) {
+            return entity;
+          }
+        }
+        return null;
+      } catch (final EdmPrimitiveTypeException e) {
+        throw new DataProviderException("Wrong key!", e);
+      }
+    }
+  }
+
+  public static class DataProviderException extends ODataException {
+    private static final long serialVersionUID = 5098059649321796156L;
+
+    public DataProviderException(String message, Throwable throwable) {
+      super(message, throwable);
+    }
+
+    public DataProviderException(String message) {
+      super(message);
+    }
+  }
+
+  private EntityCollection createCars() {
+    EntityCollection entitySet = new EntityCollection();
+
+    entitySet.getEntities().add(new Entity()
+        .addProperty(createPrimitive("Id", 1))
+        .addProperty(createPrimitive("Model", "F1 W03"))
+        .addProperty(createPrimitive("ModelYear", "2012"))
+        .addProperty(createPrimitive("Price", 189189.43))
+        .addProperty(createPrimitive("Currency", "EUR")));
+
+    entitySet.getEntities().add(new Entity()
+        .addProperty(createPrimitive("Id", 2))
+        .addProperty(createPrimitive("Model", "F1 W04"))
+        .addProperty(createPrimitive("ModelYear", "2013"))
+        .addProperty(createPrimitive("Price", 199999.99))
+        .addProperty(createPrimitive("Currency", "EUR")));
+
+    entitySet.getEntities().add(new Entity()
+        .addProperty(createPrimitive("Id", 3))
+        .addProperty(createPrimitive("Model", "F2012"))
+        .addProperty(createPrimitive("ModelYear", "2012"))
+        .addProperty(createPrimitive("Price", 137285.33))
+        .addProperty(createPrimitive("Currency", "EUR")));
+
+    entitySet.getEntities().add(new Entity()
+        .addProperty(createPrimitive("Id", 4))
+        .addProperty(createPrimitive("Model", "F2013"))
+        .addProperty(createPrimitive("ModelYear", "2013"))
+        .addProperty(createPrimitive("Price", 145285.00))
+        .addProperty(createPrimitive("Currency", "EUR")));
+
+    entitySet.getEntities().add(new Entity()
+        .addProperty(createPrimitive("Id", 5))
+        .addProperty(createPrimitive("Model", "F1 W02"))
+        .addProperty(createPrimitive("ModelYear", "2011"))
+        .addProperty(createPrimitive("Price", 167189.00))
+        .addProperty(createPrimitive("Currency", "EUR")));
+
+    for (Entity entity:entitySet.getEntities()) {
+      entity.setType(CarsEdmProvider.ET_CAR.getFullQualifiedNameAsString());
+    }
+    return entitySet;
+  }
+
+  private EntityCollection createManufacturers() {
+    EntityCollection entitySet = new EntityCollection();
+
+    entitySet.getEntities().add(new Entity()
+        .addProperty(createPrimitive("Id", 1))
+        .addProperty(createPrimitive("Name", "Star Powered Racing"))
+        .addProperty(createAddress("Star Street 137", "Stuttgart", "70173", "Germany")));
+
+    entitySet.getEntities().add(new Entity()
+        .addProperty(createPrimitive("Id", 2))
+        .addProperty(createPrimitive("Name", "Horse Powered Racing"))
+        .addProperty(createAddress("Horse Street 1", "Maranello", "41053", "Italy")));
+
+    for (Entity entity:entitySet.getEntities()) {
+      entity.setType(CarsEdmProvider.ET_MANUFACTURER.getFullQualifiedNameAsString());
+    }
+    return entitySet;
+  }
+
+  private Property createAddress(final String street, final String city, final String zipCode, final String country) {
+    ComplexValue complexValue=new ComplexValue();
+    List<Property> addressProperties = complexValue.getValue();
+    addressProperties.add(createPrimitive("Street", street));
+    addressProperties.add(createPrimitive("City", city));
+    addressProperties.add(createPrimitive("ZipCode", zipCode));
+    addressProperties.add(createPrimitive("Country", country));
+    return new Property(null, "Address", ValueType.COMPLEX, complexValue);
+  }
+
+  private Property createPrimitive(final String name, final Object value) {
+    return new Property(null, name, ValueType.PRIMITIVE, value);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5727d058/samples/osgi/server/src/main/java/org/apache/olingo/server/sample/edmprovider/CarsEdmProvider.java
----------------------------------------------------------------------
diff --git a/samples/osgi/server/src/main/java/org/apache/olingo/server/sample/edmprovider/CarsEdmProvider.java b/samples/osgi/server/src/main/java/org/apache/olingo/server/sample/edmprovider/CarsEdmProvider.java
new file mode 100644
index 0000000..4d3ba9d
--- /dev/null
+++ b/samples/osgi/server/src/main/java/org/apache/olingo/server/sample/edmprovider/CarsEdmProvider.java
@@ -0,0 +1,183 @@
+/*
+ * 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.server.sample.edmprovider;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.olingo.commons.api.ODataException;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.provider.CsdlAbstractEdmProvider;
+import org.apache.olingo.commons.api.edm.provider.CsdlComplexType;
+import org.apache.olingo.commons.api.edm.provider.CsdlEntityContainer;
+import org.apache.olingo.commons.api.edm.provider.CsdlEntityContainerInfo;
+import org.apache.olingo.commons.api.edm.provider.CsdlEntitySet;
+import org.apache.olingo.commons.api.edm.provider.CsdlEntityType;
+import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty;
+import org.apache.olingo.commons.api.edm.provider.CsdlNavigationPropertyBinding;
+import org.apache.olingo.commons.api.edm.provider.CsdlProperty;
+import org.apache.olingo.commons.api.edm.provider.CsdlPropertyRef;
+import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
+
+public class CarsEdmProvider extends CsdlAbstractEdmProvider {
+
+  // Service Namespace
+  public static final String NAMESPACE = "olingo.odata.sample";
+
+  // EDM Container
+  public static final String CONTAINER_NAME = "Container";
+  public static final FullQualifiedName CONTAINER_FQN = new FullQualifiedName(NAMESPACE, CONTAINER_NAME);
+
+  // Entity Types Names
+  public static final FullQualifiedName ET_CAR = new FullQualifiedName(NAMESPACE, "Car");
+  public static final FullQualifiedName ET_MANUFACTURER = new FullQualifiedName(NAMESPACE, "Manufacturer");
+
+  // Complex Type Names
+  public static final FullQualifiedName CT_ADDRESS = new FullQualifiedName(NAMESPACE, "Address");
+
+  // Entity Set Names
+  public static final String ES_CARS_NAME = "Cars";
+  public static final String ES_MANUFACTURER_NAME = "Manufacturers";
+
+  @Override
+  public CsdlEntityType getEntityType(final FullQualifiedName entityTypeName) throws ODataException {
+    if (ET_CAR.equals(entityTypeName)) {
+      return new CsdlEntityType()
+          .setName(ET_CAR.getName())
+          .setKey(Arrays.asList(
+              new CsdlPropertyRef().setName("Id")))
+          .setProperties(
+              Arrays.asList(
+                  new CsdlProperty().setName("Id").setType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName()),
+                  new CsdlProperty().setName("Model").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()),
+                  new CsdlProperty().setName("ModelYear").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName())
+                      .setMaxLength(4),
+                  new CsdlProperty().setName("Price").setType(EdmPrimitiveTypeKind.Decimal.getFullQualifiedName())
+                      .setScale(2),
+                  new CsdlProperty().setName("Currency").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName())
+                      .setMaxLength(3)
+                  )
+          ).setNavigationProperties(Arrays.asList(
+              new CsdlNavigationProperty().setName("Manufacturer").setType(ET_MANUFACTURER)
+              )
+          );
+
+    } else if (ET_MANUFACTURER.equals(entityTypeName)) {
+      return new CsdlEntityType()
+          .setName(ET_MANUFACTURER.getName())
+          .setKey(Arrays.asList(
+              new CsdlPropertyRef().setName("Id")))
+          .setProperties(Arrays.asList(
+              new CsdlProperty().setName("Id").setType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName()),
+              new CsdlProperty().setName("Name").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()),
+              new CsdlProperty().setName("Address").setType(CT_ADDRESS))
+          ).setNavigationProperties(Arrays.asList(
+              new CsdlNavigationProperty().setName("Cars").setType(ET_CAR).setCollection(true)
+              )
+          );
+    }
+
+    return null;
+  }
+
+  public CsdlComplexType getComplexType(final FullQualifiedName complexTypeName) throws ODataException {
+    if (CT_ADDRESS.equals(complexTypeName)) {
+      return new CsdlComplexType().setName(CT_ADDRESS.getName()).setProperties(Arrays.asList(
+          new CsdlProperty().setName("Street").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()),
+          new CsdlProperty().setName("City").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()),
+          new CsdlProperty().setName("ZipCode").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()),
+          new CsdlProperty().setName("Country").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName())
+          ));
+    }
+    return null;
+  }
+
+  @Override
+  public CsdlEntitySet getEntitySet(final FullQualifiedName entityContainer, final String entitySetName)
+      throws ODataException {
+    if (CONTAINER_FQN.equals(entityContainer)) {
+      if (ES_CARS_NAME.equals(entitySetName)) {
+        return new CsdlEntitySet()
+            .setName(ES_CARS_NAME)
+            .setType(ET_CAR)
+            .setNavigationPropertyBindings(
+                Arrays.asList(
+                    new CsdlNavigationPropertyBinding().setPath("Manufacturer").setTarget(
+                        CONTAINER_FQN.getFullQualifiedNameAsString() + "/" + ES_MANUFACTURER_NAME)));
+      } else if (ES_MANUFACTURER_NAME.equals(entitySetName)) {
+        return new CsdlEntitySet()
+            .setName(ES_MANUFACTURER_NAME)
+            .setType(ET_MANUFACTURER).setNavigationPropertyBindings(
+                Arrays.asList(
+                    new CsdlNavigationPropertyBinding().setPath("Cars")
+                        .setTarget(CONTAINER_FQN.getFullQualifiedNameAsString() + "/" + ES_CARS_NAME)));
+      }
+    }
+
+    return null;
+  }
+
+  @Override
+  public List<CsdlSchema> getSchemas() throws ODataException {
+    List<CsdlSchema> schemas = new ArrayList<CsdlSchema>();
+    CsdlSchema schema = new CsdlSchema();
+    schema.setNamespace(NAMESPACE);
+    // EntityTypes
+    List<CsdlEntityType> entityTypes = new ArrayList<CsdlEntityType>();
+    entityTypes.add(getEntityType(ET_CAR));
+    entityTypes.add(getEntityType(ET_MANUFACTURER));
+    schema.setEntityTypes(entityTypes);
+
+    // ComplexTypes
+    List<CsdlComplexType> complexTypes = new ArrayList<CsdlComplexType>();
+    complexTypes.add(getComplexType(CT_ADDRESS));
+    schema.setComplexTypes(complexTypes);
+
+    // EntityContainer
+    schema.setEntityContainer(getEntityContainer());
+    schemas.add(schema);
+
+    return schemas;
+  }
+
+  @Override
+  public CsdlEntityContainer getEntityContainer() throws ODataException {
+    CsdlEntityContainer container = new CsdlEntityContainer();
+    container.setName(CONTAINER_FQN.getName());
+
+    // EntitySets
+    List<CsdlEntitySet> entitySets = new ArrayList<CsdlEntitySet>();
+    container.setEntitySets(entitySets);
+    entitySets.add(getEntitySet(CONTAINER_FQN, ES_CARS_NAME));
+    entitySets.add(getEntitySet(CONTAINER_FQN, ES_MANUFACTURER_NAME));
+
+    return container;
+  }
+
+  @Override
+  public CsdlEntityContainerInfo getEntityContainerInfo(final FullQualifiedName entityContainerName)
+          throws ODataException {
+    if (entityContainerName == null || CONTAINER_FQN.equals(entityContainerName)) {
+      return new CsdlEntityContainerInfo().setContainerName(CONTAINER_FQN);
+    }
+    return null;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5727d058/samples/osgi/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java
----------------------------------------------------------------------
diff --git a/samples/osgi/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java b/samples/osgi/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java
new file mode 100644
index 0000000..4305415
--- /dev/null
+++ b/samples/osgi/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java
@@ -0,0 +1,355 @@
+/*
+ * 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.server.sample.processor;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.olingo.commons.api.data.ContextURL;
+import org.apache.olingo.commons.api.data.ContextURL.Suffix;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntityCollection;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.edm.EdmComplexType;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
+import org.apache.olingo.commons.api.edm.EdmProperty;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.http.HttpContentType;
+import org.apache.olingo.commons.api.http.HttpHeader;
+import org.apache.olingo.commons.api.http.HttpStatusCode;
+import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.ODataApplicationException;
+import org.apache.olingo.server.api.ODataRequest;
+import org.apache.olingo.server.api.ODataResponse;
+import org.apache.olingo.server.api.ServiceMetadata;
+import org.apache.olingo.server.api.deserializer.DeserializerException;
+import org.apache.olingo.server.api.processor.ComplexProcessor;
+import org.apache.olingo.server.api.processor.EntityCollectionProcessor;
+import org.apache.olingo.server.api.processor.EntityProcessor;
+import org.apache.olingo.server.api.processor.PrimitiveProcessor;
+import org.apache.olingo.server.api.processor.PrimitiveValueProcessor;
+import org.apache.olingo.server.api.serializer.ComplexSerializerOptions;
+import org.apache.olingo.server.api.serializer.EntityCollectionSerializerOptions;
+import org.apache.olingo.server.api.serializer.EntitySerializerOptions;
+import org.apache.olingo.server.api.serializer.ODataSerializer;
+import org.apache.olingo.server.api.serializer.PrimitiveSerializerOptions;
+import org.apache.olingo.server.api.serializer.SerializerException;
+import org.apache.olingo.server.api.uri.UriInfo;
+import org.apache.olingo.server.api.uri.UriInfoResource;
+import org.apache.olingo.server.api.uri.UriResource;
+import org.apache.olingo.server.api.uri.UriResourceEntitySet;
+import org.apache.olingo.server.api.uri.UriResourceProperty;
+import org.apache.olingo.server.api.uri.queryoption.ExpandOption;
+import org.apache.olingo.server.api.uri.queryoption.SelectOption;
+import org.apache.olingo.server.sample.data.DataProvider;
+import org.apache.olingo.server.sample.data.DataProvider.DataProviderException;
+
+/**
+ * This processor will deliver entity collections, single entities as well as properties of an entity.
+ * This is a very simple example which should give you a rough guideline on how to implement such an processor.
+ * See the JavaDoc of the server.api interfaces for more information.
+ */
+public class CarsProcessor implements EntityCollectionProcessor, EntityProcessor,
+    PrimitiveProcessor, PrimitiveValueProcessor, ComplexProcessor {
+
+  private OData odata;
+  private final DataProvider dataProvider;
+  private ServiceMetadata edm;
+
+  // This constructor is application specific and not mandatory for the Olingo library. We use it here to simulate the
+  // database access
+  public CarsProcessor(final DataProvider dataProvider) {
+    this.dataProvider = dataProvider;
+  }
+
+  @Override
+  public void init(OData odata, ServiceMetadata edm) {
+    this.odata = odata;
+    this.edm = edm;
+  }
+
+  @Override
+  public void readEntityCollection(final ODataRequest request, ODataResponse response, final UriInfo uriInfo,
+      final ContentType requestedContentType) throws ODataApplicationException, SerializerException {
+    // First we have to figure out which entity set to use
+    final EdmEntitySet edmEntitySet = getEdmEntitySet(uriInfo.asUriInfoResource());
+
+    // Second we fetch the data for this specific entity set from the mock database and transform it into an EntitySet
+    // object which is understood by our serialization
+    EntityCollection entitySet = dataProvider.readAll(edmEntitySet);
+
+    // Next we create a serializer based on the requested format. This could also be a custom format but we do not
+    // support them in this example
+    final ODataFormat format = ODataFormat.fromContentType(requestedContentType);
+    ODataSerializer serializer = odata.createSerializer(format);
+
+    // Now the content is serialized using the serializer.
+    final ExpandOption expand = uriInfo.getExpandOption();
+    final SelectOption select = uriInfo.getSelectOption();
+    InputStream serializedContent = serializer.entityCollection(edm, edmEntitySet.getEntityType(), entitySet,
+        EntityCollectionSerializerOptions.with()
+            .contextURL(format == ODataFormat.JSON_NO_METADATA ? null :
+                getContextUrl(edmEntitySet, false, expand, select, null))
+            .count(uriInfo.getCountOption())
+            .expand(expand).select(select)
+            .build()).getContent();
+
+    // Finally we set the response data, headers and status code
+    response.setContent(serializedContent);
+    response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+    response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString());
+  }
+
+  @Override
+  public void readEntity(final ODataRequest request, ODataResponse response, final UriInfo uriInfo,
+      final ContentType requestedContentType) throws ODataApplicationException, SerializerException {
+    // First we have to figure out which entity set the requested entity is in
+    final EdmEntitySet edmEntitySet = getEdmEntitySet(uriInfo.asUriInfoResource());
+
+    // Next we fetch the requested entity from the database
+    Entity entity;
+    try {
+      entity = readEntityInternal(uriInfo.asUriInfoResource(), edmEntitySet);
+    } catch (DataProviderException e) {
+      throw new ODataApplicationException(e.getMessage(), 500, Locale.ENGLISH);
+    }
+
+    if (entity == null) {
+      // If no entity was found for the given key we throw an exception.
+      throw new ODataApplicationException("No entity found for this key", HttpStatusCode.NOT_FOUND
+          .getStatusCode(), Locale.ENGLISH);
+    } else {
+      // If an entity was found we proceed by serializing it and sending it to the client.
+      final ODataFormat format = ODataFormat.fromContentType(requestedContentType);
+      ODataSerializer serializer = odata.createSerializer(format);
+      final ExpandOption expand = uriInfo.getExpandOption();
+      final SelectOption select = uriInfo.getSelectOption();
+      InputStream serializedContent = serializer.entity(edm, edmEntitySet.getEntityType(), entity,
+          EntitySerializerOptions.with()
+              .contextURL(format == ODataFormat.JSON_NO_METADATA ? null :
+                  getContextUrl(edmEntitySet, true, expand, select, null))
+              .expand(expand).select(select)
+              .build()).getContent();
+      response.setContent(serializedContent);
+      response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+      response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString());
+    }
+  }
+
+  @Override
+  public void createEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo,
+                           ContentType requestFormat, ContentType responseFormat)
+          throws ODataApplicationException, DeserializerException, SerializerException {
+    throw new ODataApplicationException("Entity create is not supported yet.",
+            HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ENGLISH);
+  }
+
+  @Override
+  public void deleteEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo)
+          throws ODataApplicationException {
+    throw new ODataApplicationException("Entity delete is not supported yet.",
+            HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ENGLISH);
+  }
+
+  @Override
+  public void readPrimitive(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType format)
+          throws ODataApplicationException, SerializerException {
+    readProperty(response, uriInfo, format, false);
+  }
+
+  @Override
+  public void readComplex(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType format)
+          throws ODataApplicationException, SerializerException {
+    readProperty(response, uriInfo, format, true);
+  }
+
+  @Override
+  public void readPrimitiveValue(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType format)
+          throws ODataApplicationException, SerializerException {
+    // First we have to figure out which entity set the requested entity is in
+    final EdmEntitySet edmEntitySet = getEdmEntitySet(uriInfo.asUriInfoResource());
+    // Next we fetch the requested entity from the database
+    final Entity entity;
+    try {
+      entity = readEntityInternal(uriInfo.asUriInfoResource(), edmEntitySet);
+    } catch (DataProviderException e) {
+      throw new ODataApplicationException(e.getMessage(), 500, Locale.ENGLISH);
+    }
+    if (entity == null) {
+      // If no entity was found for the given key we throw an exception.
+      throw new ODataApplicationException("No entity found for this key", HttpStatusCode.NOT_FOUND
+              .getStatusCode(), Locale.ENGLISH);
+    } else {
+      // Next we get the property value from the entity and pass the value to serialization
+      UriResourceProperty uriProperty = (UriResourceProperty) uriInfo
+              .getUriResourceParts().get(uriInfo.getUriResourceParts().size() - 1);
+      EdmProperty edmProperty = uriProperty.getProperty();
+      Property property = entity.getProperty(edmProperty.getName());
+      if (property == null) {
+        throw new ODataApplicationException("No property found", HttpStatusCode.NOT_FOUND
+                .getStatusCode(), Locale.ENGLISH);
+      } else {
+        if (property.getValue() == null) {
+          response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
+        } else {
+          String value = String.valueOf(property.getValue());
+          ByteArrayInputStream serializerContent = new ByteArrayInputStream(
+                  value.getBytes(Charset.forName("UTF-8")));
+          response.setContent(serializerContent);
+          response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+          response.setHeader(HttpHeader.CONTENT_TYPE, HttpContentType.TEXT_PLAIN);
+        }
+      }
+    }
+  }
+
+  private void readProperty(ODataResponse response, UriInfo uriInfo, ContentType contentType,
+      boolean complex) throws ODataApplicationException, SerializerException {
+    // To read a property we have to first get the entity out of the entity set
+    final EdmEntitySet edmEntitySet = getEdmEntitySet(uriInfo.asUriInfoResource());
+    Entity entity;
+    try {
+      entity = readEntityInternal(uriInfo.asUriInfoResource(), edmEntitySet);
+    } catch (DataProviderException e) {
+      throw new ODataApplicationException(e.getMessage(),
+              HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), Locale.ENGLISH);
+    }
+
+    if (entity == null) {
+      // If no entity was found for the given key we throw an exception.
+      throw new ODataApplicationException("No entity found for this key",
+              HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
+    } else {
+      // Next we get the property value from the entity and pass the value to serialization
+      UriResourceProperty uriProperty = (UriResourceProperty) uriInfo
+          .getUriResourceParts().get(uriInfo.getUriResourceParts().size() - 1);
+      EdmProperty edmProperty = uriProperty.getProperty();
+      Property property = entity.getProperty(edmProperty.getName());
+      if (property == null) {
+        throw new ODataApplicationException("No property found",
+                HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
+      } else {
+        if (property.getValue() == null) {
+          response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
+        } else {
+          final ODataFormat format = ODataFormat.fromContentType(contentType);
+          ODataSerializer serializer = odata.createSerializer(format);
+          final ContextURL contextURL = format == ODataFormat.JSON_NO_METADATA ? null :
+              getContextUrl(edmEntitySet, true, null, null, edmProperty.getName());
+          InputStream serializerContent = complex ?
+              serializer.complex(edm, (EdmComplexType) edmProperty.getType(), property,
+                  ComplexSerializerOptions.with().contextURL(contextURL).build()).getContent() :
+              serializer.primitive((EdmPrimitiveType) edmProperty.getType(), property,
+                                    PrimitiveSerializerOptions.with()
+                                    .contextURL(contextURL)
+                                    .scale(edmProperty.getScale())
+                                    .nullable(edmProperty.isNullable())
+                                    .precision(edmProperty.getPrecision())
+                                    .maxLength(edmProperty.getMaxLength())
+                                    .unicode(edmProperty.isUnicode()).build()).getContent();
+          response.setContent(serializerContent);
+          response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+          response.setHeader(HttpHeader.CONTENT_TYPE, contentType.toContentTypeString());
+        }
+      }
+    }
+  }
+
+  private Entity readEntityInternal(final UriInfoResource uriInfo, final EdmEntitySet entitySet)
+      throws DataProvider.DataProviderException {
+    // This method will extract the key values and pass them to the data provider
+    final UriResourceEntitySet resourceEntitySet = (UriResourceEntitySet) uriInfo.getUriResourceParts().get(0);
+    return dataProvider.read(entitySet, resourceEntitySet.getKeyPredicates());
+  }
+
+  private EdmEntitySet getEdmEntitySet(final UriInfoResource uriInfo) throws ODataApplicationException {
+    final List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
+    /*
+     * To get the entity set we have to interpret all URI segments
+     */
+    if (!(resourcePaths.get(0) instanceof UriResourceEntitySet)) {
+      throw new ODataApplicationException("Invalid resource type for first segment.",
+          HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ENGLISH);
+    }
+
+    /*
+     * Here we should interpret the whole URI but in this example we do not support navigation so we throw an exception
+     */
+
+    final UriResourceEntitySet uriResource = (UriResourceEntitySet) resourcePaths.get(0);
+    return uriResource.getEntitySet();
+  }
+
+  private ContextURL getContextUrl(final EdmEntitySet entitySet, final boolean isSingleEntity,
+      final ExpandOption expand, final SelectOption select, final String navOrPropertyPath)
+      throws SerializerException {
+
+    return ContextURL.with().entitySet(entitySet)
+        .selectList(odata.createUriHelper().buildContextURLSelectList(entitySet.getEntityType(), expand, select))
+        .suffix(isSingleEntity ? Suffix.ENTITY : null)
+        .navOrPropertyPath(navOrPropertyPath)
+        .build();
+  }
+
+  @Override
+  public void updatePrimitive(final ODataRequest request, final ODataResponse response,
+                              final UriInfo uriInfo, final ContentType requestFormat,
+                              final ContentType responseFormat)
+          throws ODataApplicationException, DeserializerException, SerializerException {
+    throw new ODataApplicationException("Primitive property update is not supported yet.",
+            HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ENGLISH);
+  }
+
+  @Override
+  public void deletePrimitive(ODataRequest request, ODataResponse response, UriInfo uriInfo) throws
+          ODataApplicationException {
+    throw new ODataApplicationException("Primitive property delete is not supported yet.",
+            HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ENGLISH);
+  }
+
+  @Override
+  public void updateComplex(final ODataRequest request, final ODataResponse response,
+                            final UriInfo uriInfo, final ContentType requestFormat,
+                            final ContentType responseFormat)
+          throws ODataApplicationException, DeserializerException, SerializerException {
+    throw new ODataApplicationException("Complex property update is not supported yet.",
+            HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ENGLISH);
+  }
+
+  @Override
+  public void deleteComplex(final ODataRequest request, final ODataResponse response, final UriInfo uriInfo)
+          throws ODataApplicationException {
+    throw new ODataApplicationException("Complex property delete is not supported yet.",
+            HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ENGLISH);
+  }
+
+  @Override
+  public void updateEntity(final ODataRequest request, final ODataResponse response,
+                           final UriInfo uriInfo, final ContentType requestFormat,
+                           final ContentType responseFormat)
+          throws ODataApplicationException, DeserializerException, SerializerException {
+    throw new ODataApplicationException("Entity update is not supported yet.",
+            HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ENGLISH);
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5727d058/samples/osgi/server/src/main/resources/META-INF/LICENSE
----------------------------------------------------------------------
diff --git a/samples/osgi/server/src/main/resources/META-INF/LICENSE b/samples/osgi/server/src/main/resources/META-INF/LICENSE
new file mode 100644
index 0000000..715ff30
--- /dev/null
+++ b/samples/osgi/server/src/main/resources/META-INF/LICENSE
@@ -0,0 +1,331 @@
+Licenses for TecSvc artifact
+
+
+                              Apache License
+                        Version 2.0, January 2004
+                     http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+   "License" shall mean the terms and conditions for use, reproduction,
+   and distribution as defined by Sections 1 through 9 of this document.
+
+   "Licensor" shall mean the copyright owner or entity authorized by
+   the copyright owner that is granting the License.
+
+   "Legal Entity" shall mean the union of the acting entity and all
+   other entities that control, are controlled by, or are under common
+   control with that entity. For the purposes of this definition,
+   "control" means (i) the power, direct or indirect, to cause the
+   direction or management of such entity, whether by contract or
+   otherwise, or (ii) ownership of fifty percent (50%) or more of the
+   outstanding shares, or (iii) beneficial ownership of such entity.
+
+   "You" (or "Your") shall mean an individual or Legal Entity
+   exercising permissions granted by this License.
+
+   "Source" form shall mean the preferred form for making modifications,
+   including but not limited to software source code, documentation
+   source, and configuration files.
+
+   "Object" form shall mean any form resulting from mechanical
+   transformation or translation of a Source form, including but
+   not limited to compiled object code, generated documentation,
+   and conversions to other media types.
+
+   "Work" shall mean the work of authorship, whether in Source or
+   Object form, made available under the License, as indicated by a
+   copyright notice that is included in or attached to the work
+   (an example is provided in the Appendix below).
+
+   "Derivative Works" shall mean any work, whether in Source or Object
+   form, that is based on (or derived from) the Work and for which the
+   editorial revisions, annotations, elaborations, or other modifications
+   represent, as a whole, an original work of authorship. For the purposes
+   of this License, Derivative Works shall not include works that remain
+   separable from, or merely link (or bind by name) to the interfaces of,
+   the Work and Derivative Works thereof.
+
+   "Contribution" shall mean any work of authorship, including
+   the original version of the Work and any modifications or additions
+   to that Work or Derivative Works thereof, that is intentionally
+   submitted to Licensor for inclusion in the Work by the copyright owner
+   or by an individual or Legal Entity authorized to submit on behalf of
+   the copyright owner. For the purposes of this definition, "submitted"
+   means any form of electronic, verbal, or written communication sent
+   to the Licensor or its representatives, including but not limited to
+   communication on electronic mailing lists, source code control systems,
+   and issue tracking systems that are managed by, or on behalf of, the
+   Licensor for the purpose of discussing and improving the Work, but
+   excluding communication that is conspicuously marked or otherwise
+   designated in writing by the copyright owner as "Not a Contribution."
+
+   "Contributor" shall mean Licensor and any individual or Legal Entity
+   on behalf of whom a Contribution has been received by Licensor and
+   subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+   this License, each Contributor hereby grants to You a perpetual,
+   worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+   copyright license to reproduce, prepare Derivative Works of,
+   publicly display, publicly perform, sublicense, and distribute the
+   Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+   this License, each Contributor hereby grants to You a perpetual,
+   worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+   (except as stated in this section) patent license to make, have made,
+   use, offer to sell, sell, import, and otherwise transfer the Work,
+   where such license applies only to those patent claims licensable
+   by such Contributor that are necessarily infringed by their
+   Contribution(s) alone or by combination of their Contribution(s)
+   with the Work to which such Contribution(s) was submitted. If You
+   institute patent litigation against any entity (including a
+   cross-claim or counterclaim in a lawsuit) alleging that the Work
+   or a Contribution incorporated within the Work constitutes direct
+   or contributory patent infringement, then any patent licenses
+   granted to You under this License for that Work shall terminate
+   as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+   Work or Derivative Works thereof in any medium, with or without
+   modifications, and in Source or Object form, provided that You
+   meet the following conditions:
+
+   (a) You must give any other recipients of the Work or
+       Derivative Works a copy of this License; and
+
+   (b) You must cause any modified files to carry prominent notices
+       stating that You changed the files; and
+
+   (c) You must retain, in the Source form of any Derivative Works
+       that You distribute, all copyright, patent, trademark, and
+       attribution notices from the Source form of the Work,
+       excluding those notices that do not pertain to any part of
+       the Derivative Works; and
+
+   (d) If the Work includes a "NOTICE" text file as part of its
+       distribution, then any Derivative Works that You distribute must
+       include a readable copy of the attribution notices contained
+       within such NOTICE file, excluding those notices that do not
+       pertain to any part of the Derivative Works, in at least one
+       of the following places: within a NOTICE text file distributed
+       as part of the Derivative Works; within the Source form or
+       documentation, if provided along with the Derivative Works; or,
+       within a display generated by the Derivative Works, if and
+       wherever such third-party notices normally appear. The contents
+       of the NOTICE file are for informational purposes only and
+       do not modify the License. You may add Your own attribution
+       notices within Derivative Works that You distribute, alongside
+       or as an addendum to the NOTICE text from the Work, provided
+       that such additional attribution notices cannot be construed
+       as modifying the License.
+
+   You may add Your own copyright statement to Your modifications and
+   may provide additional or different license terms and conditions
+   for use, reproduction, or distribution of Your modifications, or
+   for any such Derivative Works as a whole, provided Your use,
+   reproduction, and distribution of the Work otherwise complies with
+   the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+   any Contribution intentionally submitted for inclusion in the Work
+   by You to the Licensor shall be under the terms and conditions of
+   this License, without any additional terms or conditions.
+   Notwithstanding the above, nothing herein shall supersede or modify
+   the terms of any separate license agreement you may have executed
+   with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+   names, trademarks, service marks, or product names of the Licensor,
+   except as required for reasonable and customary use in describing the
+   origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+   agreed to in writing, Licensor provides the Work (and each
+   Contributor provides its Contributions) on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+   implied, including, without limitation, any warranties or conditions
+   of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+   PARTICULAR PURPOSE. You are solely responsible for determining the
+   appropriateness of using or redistributing the Work and assume any
+   risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+   whether in tort (including negligence), contract, or otherwise,
+   unless required by applicable law (such as deliberate and grossly
+   negligent acts) or agreed to in writing, shall any Contributor be
+   liable to You for damages, including any direct, indirect, special,
+   incidental, or consequential damages of any character arising as a
+   result of this License or out of the use or inability to use the
+   Work (including but not limited to damages for loss of goodwill,
+   work stoppage, computer failure or malfunction, or any and all
+   other commercial damages or losses), even if such Contributor
+   has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+   the Work or Derivative Works thereof, You may choose to offer,
+   and charge a fee for, acceptance of support, warranty, indemnity,
+   or other liability obligations and/or rights consistent with this
+   License. However, in accepting such obligations, You may act only
+   on Your own behalf and on Your sole responsibility, not on behalf
+   of any other Contributor, and only if You agree to indemnify,
+   defend, and hold each Contributor harmless for any liability
+   incurred by, or claims asserted against, such Contributor by reason
+   of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Apache License to your work.
+
+   To apply the Apache License to your work, attach the following
+   boilerplate notice, with the fields enclosed by brackets "[]"
+   replaced with your own identifying information. (Don't include
+   the brackets!)  The text should be enclosed in the appropriate
+   comment syntax for the file format. We also recommend that a
+   file or class name and description of purpose be included on the
+   same "printed page" as the copyright notice for easier
+   identification within third-party archives.
+
+Copyright [yyyy] [name of copyright owner]
+
+Licensed 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.
+
+
+From: 'abego Software GmbH, Germany' (http://abego-software.de) - abego
+TreeLayout Core (http://code.google.com/p/treelayout/)
+org.abego.treelayout:org.abego.treelayout.core:jar:1.0.1 License: BSD 3-Clause
+"New" or "Revised" License (BSD-3-Clause)
+(http://treelayout.googlecode.com/files/LICENSE.TXT)
+
+[The "BSD license"]
+Copyright (c) 2011, abego Software GmbH, Germany (http://www.abego.org)
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without 
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, 
+   this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice, 
+   this list of conditions and the following disclaimer in the documentation 
+   and/or other materials provided with the distribution.
+3. Neither the name of the abego Software GmbH nor the names of its 
+   contributors may be used to endorse or promote products derived from this 
+   software without specific prior written permission.
+   
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+POSSIBILITY OF SUCH DAMAGE.
+
+
+From: 'ANTLR' (http://www.antlr.org) - ANTLR 4 Runtime
+(http://www.antlr.org/antlr4-runtime) org.antlr:antlr4-runtime:jar:4.1 License:
+The BSD License (http://www.antlr.org/license.html)
+
+[The BSD License]
+Copyright (c) 2012 Terence Parr and Sam Harwell
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    Redistributions of source code must retain the above copyright notice, this
+    list of conditions and the following disclaimer. Redistributions in binary
+    form must reproduce the above copyright notice, this list of conditions and
+    the following disclaimer in the documentation and/or other materials
+    provided with the distribution. Neither the name of the author nor the
+    names of its contributors may be used to endorse or promote products
+    derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+From: 'fasterxml.com' (http://fasterxml.com) - Stax2 API
+(http://wiki.fasterxml.com/WoodstoxStax2)
+org.codehaus.woodstox:stax2-api:bundle:3.1.4 License: The BSD License
+(http://www.opensource.org/licenses/bsd-license.php)
+
+Copyright (c) 2004-2010, Woodstox Project (http://woodstox.codehaus.org/)
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice,
+   this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice,
+   this list of conditions and the following disclaimer in the documentation
+   and/or other materials provided with the distribution.
+3. Neither the name of the Woodstox XML Processor nor the names
+   of its contributors may be used to endorse or promote products derived
+   from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+
+From: 'QOS.ch' (http://www.qos.ch)
+  - SLF4J API Module (http://www.slf4j.org) org.slf4j:slf4j-api:jar:1.7.7
+    License: MIT License  (http://www.opensource.org/licenses/mit-license.php)
+  - SLF4J Simple Binding (http://www.slf4j.org) org.slf4j:slf4j-simple:jar:1.7.7
+    License: MIT License  (http://www.opensource.org/licenses/mit-license.php)
+
+
+Copyright (c) 2004-2013 QOS.ch 
+
+All rights reserved. Permission is hereby granted, free of charge, to any
+person obtaining a copy of this software and associated documentation files
+(the "Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons to whom
+the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5727d058/samples/osgi/server/src/main/resources/simplelogger.properties
----------------------------------------------------------------------
diff --git a/samples/osgi/server/src/main/resources/simplelogger.properties b/samples/osgi/server/src/main/resources/simplelogger.properties
new file mode 100644
index 0000000..2a3350c
--- /dev/null
+++ b/samples/osgi/server/src/main/resources/simplelogger.properties
@@ -0,0 +1,20 @@
+#
+# 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.
+#
+org.slf4j.simpleLogger.defaultLogLevel=debug
+org.slf4j.simpleLogger.logFile=System.out
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5727d058/samples/osgi/server/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/samples/osgi/server/src/main/webapp/WEB-INF/web.xml b/samples/osgi/server/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..6245ae2
--- /dev/null
+++ b/samples/osgi/server/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+         or more contributor license agreements.  See the NOTICE file
+         distributed with this work for additional information
+         regarding copyright ownership.  The ASF licenses this file
+         to you under the Apache License, Version 2.0 (the
+         "License"); you may not use this file except in compliance
+         with the License.  You may obtain a copy of the License at
+
+           http://www.apache.org/licenses/LICENSE-2.0
+
+         Unless required by applicable law or agreed to in writing,
+         software distributed under the License is distributed on an
+         "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+         KIND, either express or implied.  See the License for the
+         specific language governing permissions and limitations
+         under the License.
+-->
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+	id="WebApp_ID" version="2.5">
+
+	<display-name>Apache Olingo OData 4.0 Sample Service</display-name>
+
+	<welcome-file-list>
+		<welcome-file>index.jsp</welcome-file>
+	</welcome-file-list>
+
+	<servlet>
+		<servlet-name>CarsServlet</servlet-name>
+		<servlet-class>org.apache.olingo.server.sample.CarsServlet</servlet-class>
+		<load-on-startup>1</load-on-startup>
+	</servlet>
+
+    <servlet-mapping>
+        <servlet-name>CarsServlet</servlet-name>
+        <url-pattern>/cars.svc/*</url-pattern>
+    </servlet-mapping>
+
+</web-app>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5727d058/samples/osgi/server/src/main/webapp/css/olingo.css
----------------------------------------------------------------------
diff --git a/samples/osgi/server/src/main/webapp/css/olingo.css b/samples/osgi/server/src/main/webapp/css/olingo.css
new file mode 100644
index 0000000..5b9deec
--- /dev/null
+++ b/samples/osgi/server/src/main/webapp/css/olingo.css
@@ -0,0 +1,91 @@
+/*
+  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.
+*/
+body {
+	font-family: Arial, sans-serif;
+	font-size: 13px;
+	line-height: 18px;
+	color: #8904B1;
+	background-color: #ffffff;
+}
+
+a {
+	color: #8904B1;
+}
+
+a:VISITED {
+	color: #D358F7;
+}
+
+td {
+	padding: 5px;
+}
+
+h1,h2,h3,h4,h5,h6 {
+	font-family: inherit;
+	font-weight: bold;
+	line-height: 1;
+	color: #8904B1;
+}
+
+h1 {
+	font-size: 36px;
+	line-height: 40px;
+}
+
+h2 {
+	font-size: 30px;
+	line-height: 40px;
+}
+
+h3 {
+	font-size: 24px;
+	line-height: 40px;
+}
+
+h4 {
+	font-size: 18px;
+	line-height: 20px;
+}
+
+h5 {
+	font-size: 14px;
+	line-height: 20px;
+}
+
+h6 {
+	font-size: 12px;
+	line-height: 20px;
+}
+
+.logo {
+	float: right;
+}
+
+hr, thead, tfoot {
+	margin: 9px 0;
+	border-top: 1px solid #8904B1;
+	border-bottom: 1px solid #8904B1;
+}
+
+table { border-collapse: collapse; border: 1px solid #8904B1; }
+
+.version {
+	font-family: "Courier New", monospace;
+	font-size: 10px;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5727d058/samples/osgi/server/src/main/webapp/img/OlingoOrangeTM.png
----------------------------------------------------------------------
diff --git a/samples/osgi/server/src/main/webapp/img/OlingoOrangeTM.png b/samples/osgi/server/src/main/webapp/img/OlingoOrangeTM.png
new file mode 100644
index 0000000..4878e8a
Binary files /dev/null and b/samples/osgi/server/src/main/webapp/img/OlingoOrangeTM.png differ

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5727d058/samples/osgi/server/src/main/webapp/index.jsp
----------------------------------------------------------------------
diff --git a/samples/osgi/server/src/main/webapp/index.jsp b/samples/osgi/server/src/main/webapp/index.jsp
new file mode 100644
index 0000000..2940a76
--- /dev/null
+++ b/samples/osgi/server/src/main/webapp/index.jsp
@@ -0,0 +1,56 @@
+<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
+
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+         or more contributor license agreements.  See the NOTICE file
+         distributed with this work for additional information
+         regarding copyright ownership.  The ASF licenses this file
+         to you under the Apache License, Version 2.0 (the
+         "License"); you may not use this file except in compliance
+         with the License.  You may obtain a copy of the License at
+  
+           http://www.apache.org/licenses/LICENSE-2.0
+  
+         Unless required by applicable law or agreed to in writing,
+         software distributed under the License is distributed on an
+         "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+         KIND, either express or implied.  See the License for the
+         specific language governing permissions and limitations
+         under the License.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <title>Apache Olingo - OData 4.0</title>
+ <link type="text/css" rel="stylesheet" href="css/olingo.css">
+</head>
+
+<body>
+  <div class="logo">
+    <img height="40" src="img/OlingoOrangeTM.png" />
+  </div>
+  <h1>Olingo OData 4.0</h1>
+  <hr>
+  <h2>Cars Sample Service</h2>
+  <ul>
+    <li><a href="cars.svc/">Service Document</a></li>
+    <li><a href="cars.svc/$metadata">Metadata</a></li>
+    <li>Entity Set: <a href="cars.svc/Cars">Cars</a></li>
+    <li>Entity: <a href="cars.svc/Cars(1)">Cars(1)</a></li>
+    <li>Primitive Property: <a href="cars.svc/Cars(1)/Price">Cars(1)/Price</a></li>
+  </ul>
+  <hr>
+  <div class="version">
+    <% String version = "gen/version.html";
+      try {
+     %>
+    <jsp:include page='<%=version%>' />
+    <%} catch (Exception e) {
+     %>
+    <p>IDE Build</p>
+    <%}%>
+  </div>
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5727d058/samples/pom.xml
----------------------------------------------------------------------
diff --git a/samples/pom.xml b/samples/pom.xml
index a4c1e14..0efc961 100644
--- a/samples/pom.xml
+++ b/samples/pom.xml
@@ -37,5 +37,6 @@
 
   <modules>
     <module>server</module>
+    <module>osgi/server</module>
   </modules>
 </project>


[35/39] olingo-odata4 git commit: [OLINGO-663] conditional header required for property updates

Posted by ch...@apache.org.
[OLINGO-663] conditional header required for property updates

Signed-off-by: Christian Amend <ch...@sap.com>


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

Branch: refs/heads/IEE754Compatible
Commit: bfb5c93836123b5f60fac038c37ccfc1a55afd4f
Parents: 01425fa
Author: Klaus Straubinger <kl...@sap.com>
Authored: Fri Jun 19 16:29:47 2015 +0200
Committer: Christian Amend <ch...@sap.com>
Committed: Tue Jun 23 10:12:53 2015 +0200

----------------------------------------------------------------------
 .../fit/tecsvc/client/ConditionalITCase.java    |  30 +++++
 .../olingo/server/core/ODataDispatcher.java     |  59 +++++----
 .../core/etag/PreconditionsValidator.java       |  49 +++-----
 .../tecsvc/provider/EntityTypeProvider.java     |   2 +-
 .../tecsvc/provider/PropertyProvider.java       |   4 +-
 .../server/core/PreconditionsValidatorTest.java | 126 +++++++++----------
 6 files changed, 141 insertions(+), 129 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bfb5c938/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ConditionalITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ConditionalITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ConditionalITCase.java
index 9f5efc3..e035059 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ConditionalITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ConditionalITCase.java
@@ -195,6 +195,15 @@ public final class ConditionalITCase extends AbstractBaseTestITCase {
   }
 
   @Test
+  public void updatePropertyWithoutIfMatch() throws Exception {
+    final ODataPropertyUpdateRequest request = client.getCUDRequestFactory().getPropertyPrimitiveValueUpdateRequest(
+        uriProperty,
+        client.getObjectFactory().newPrimitiveProperty("PropertyDuration",
+            client.getObjectFactory().newPrimitiveValueBuilder().buildString("PT42S")));
+    executeAndExpectError(request, HttpStatusCode.PRECONDITION_REQUIRED);
+  }
+
+  @Test
   public void updatePropertyWithWrongIfMatch() throws Exception {
     ODataPropertyUpdateRequest request = client.getCUDRequestFactory().getPropertyPrimitiveValueUpdateRequest(
         uriProperty,
@@ -205,6 +214,15 @@ public final class ConditionalITCase extends AbstractBaseTestITCase {
   }
 
   @Test
+  public void updatePropertyValueWithoutIfMatch() throws Exception {
+    final ODataValueUpdateRequest request = client.getCUDRequestFactory().getValueUpdateRequest(
+        uriPropertyValue,
+        UpdateType.REPLACE,
+        client.getObjectFactory().newPrimitiveValueBuilder().buildString("PT42S"));
+    executeAndExpectError(request, HttpStatusCode.PRECONDITION_REQUIRED);
+  }
+
+  @Test
   public void updatePropertyValueWithWrongIfMatch() throws Exception {
     ODataValueUpdateRequest request = client.getCUDRequestFactory().getValueUpdateRequest(
         uriPropertyValue,
@@ -215,6 +233,12 @@ public final class ConditionalITCase extends AbstractBaseTestITCase {
   }
 
   @Test
+  public void deletePropertyWithoutIfMatch() throws Exception {
+    final ODataDeleteRequest request = client.getCUDRequestFactory().getDeleteRequest(uriProperty);
+    executeAndExpectError(request, HttpStatusCode.PRECONDITION_REQUIRED);
+  }
+
+  @Test
   public void deletePropertyWithWrongIfMatch() throws Exception {
     ODataDeleteRequest request = client.getCUDRequestFactory().getDeleteRequest(uriProperty);
     request.setIfMatch("W/\"1\"");
@@ -232,6 +256,12 @@ public final class ConditionalITCase extends AbstractBaseTestITCase {
   }
 
   @Test
+  public void deletePropertyValueWithoutIfMatch() throws Exception {
+    final ODataDeleteRequest request = client.getCUDRequestFactory().getDeleteRequest(uriPropertyValue);
+    executeAndExpectError(request, HttpStatusCode.PRECONDITION_REQUIRED);
+  }
+
+  @Test
   public void deletePropertyValueWithWrongIfMatch() throws Exception {
     ODataDeleteRequest request = client.getCUDRequestFactory().getDeleteRequest(uriPropertyValue);
     request.setIfMatch("W/\"1\"");

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bfb5c938/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataDispatcher.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataDispatcher.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataDispatcher.java
index e444cf4..ff2b599 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataDispatcher.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataDispatcher.java
@@ -33,6 +33,7 @@ import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.api.ODataLibraryException;
 import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
+import org.apache.olingo.server.api.etag.CustomETagSupport;
 import org.apache.olingo.server.api.etag.PreconditionException;
 import org.apache.olingo.server.api.processor.ActionComplexCollectionProcessor;
 import org.apache.olingo.server.api.processor.ActionComplexProcessor;
@@ -203,7 +204,7 @@ public class ODataDispatcher {
       final UriResourceAction uriResourceAction) throws ODataApplicationException, ODataLibraryException {
     final EdmAction action = uriResourceAction.getAction();
     if (action.isBound()) {
-      // Only bound actions can have etag control for the binding parameter
+      // Only bound actions can have ETag control for the binding parameter.
       validatePreconditions(request, false);
     }
     final EdmReturnType returnType = action.getReturnType();
@@ -322,6 +323,7 @@ public class ODataDispatcher {
         handler.selectProcessor(PrimitiveValueProcessor.class)
             .readPrimitiveValue(request, response, uriInfo, requestedContentType);
       } else if (method == HttpMethod.PUT && resource instanceof UriResourceProperty) {
+        validatePreconditions(request, false);
         final ContentType requestFormat = ContentType.parse(request.getHeader(HttpHeader.CONTENT_TYPE));
         checkContentTypeSupport(requestFormat, valueRepresentationType);
         final ContentType responseFormat = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(),
@@ -329,6 +331,7 @@ public class ODataDispatcher {
         handler.selectProcessor(PrimitiveValueProcessor.class)
             .updatePrimitiveValue(request, response, uriInfo, requestFormat, responseFormat);
       } else if (method == HttpMethod.DELETE && resource instanceof UriResourceProperty) {
+        validatePreconditions(request, false);
         handler.selectProcessor(PrimitiveValueProcessor.class)
             .deletePrimitiveValue(request, response, uriInfo);
       } else {
@@ -375,6 +378,7 @@ public class ODataDispatcher {
             .readComplex(request, response, uriInfo, requestedContentType);
       }
     } else if (method == HttpMethod.PUT || method == HttpMethod.PATCH) {
+      validatePreconditions(request, false);
       final ContentType requestFormat = ContentType.parse(request.getHeader(HttpHeader.CONTENT_TYPE));
       checkContentTypeSupport(requestFormat, complexRepresentationType);
       final ContentType responseFormat = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(),
@@ -387,6 +391,7 @@ public class ODataDispatcher {
             .updateComplex(request, response, uriInfo, requestFormat, responseFormat);
       }
     } else if (method == HttpMethod.DELETE) {
+      validatePreconditions(request, false);
       if (isCollection) {
         handler.selectProcessor(ComplexCollectionProcessor.class)
             .deleteComplexCollection(request, response, uriInfo);
@@ -416,6 +421,7 @@ public class ODataDispatcher {
             .readPrimitive(request, response, uriInfo, requestedContentType);
       }
     } else if (method == HttpMethod.PUT || method == HttpMethod.PATCH) {
+      validatePreconditions(request, false);
       final ContentType requestFormat = ContentType.parse(request.getHeader(HttpHeader.CONTENT_TYPE));
       checkContentTypeSupport(requestFormat, representationType);
       final ContentType responseFormat = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(),
@@ -428,6 +434,7 @@ public class ODataDispatcher {
             .updatePrimitive(request, response, uriInfo, requestFormat, responseFormat);
       }
     } else if (method == HttpMethod.DELETE) {
+      validatePreconditions(request, false);
       if (isCollection) {
         handler.selectProcessor(PrimitiveCollectionProcessor.class)
             .deletePrimitiveCollection(request, response, uriInfo);
@@ -443,27 +450,21 @@ public class ODataDispatcher {
 
   private void handleCountDispatching(final ODataRequest request, final ODataResponse response,
       final int lastPathSegmentIndex) throws ODataApplicationException, ODataLibraryException {
-    final HttpMethod method = request.getMethod();
-    if (method == HttpMethod.GET) {
-      final UriResource resource = uriInfo.getUriResourceParts().get(lastPathSegmentIndex - 1);
-      if (resource instanceof UriResourceEntitySet
-          || resource instanceof UriResourceNavigation
-          || resource instanceof UriResourceFunction
-          && ((UriResourceFunction) resource).getType().getKind() == EdmTypeKind.ENTITY) {
-        handler.selectProcessor(CountEntityCollectionProcessor.class)
-            .countEntityCollection(request, response, uriInfo);
-      } else if (resource instanceof UriResourcePrimitiveProperty
-          || resource instanceof UriResourceFunction
-          && ((UriResourceFunction) resource).getType().getKind() == EdmTypeKind.PRIMITIVE) {
-        handler.selectProcessor(CountPrimitiveCollectionProcessor.class)
-            .countPrimitiveCollection(request, response, uriInfo);
-      } else {
-        handler.selectProcessor(CountComplexCollectionProcessor.class)
-            .countComplexCollection(request, response, uriInfo);
-      }
+    final UriResource resource = uriInfo.getUriResourceParts().get(lastPathSegmentIndex - 1);
+    if (resource instanceof UriResourceEntitySet
+        || resource instanceof UriResourceNavigation
+        || resource instanceof UriResourceFunction
+        && ((UriResourceFunction) resource).getType().getKind() == EdmTypeKind.ENTITY) {
+      handler.selectProcessor(CountEntityCollectionProcessor.class)
+          .countEntityCollection(request, response, uriInfo);
+    } else if (resource instanceof UriResourcePrimitiveProperty
+        || resource instanceof UriResourceFunction
+        && ((UriResourceFunction) resource).getType().getKind() == EdmTypeKind.PRIMITIVE) {
+      handler.selectProcessor(CountPrimitiveCollectionProcessor.class)
+          .countPrimitiveCollection(request, response, uriInfo);
     } else {
-      throw new ODataHandlerException("HTTP method " + method + " is not allowed for count.",
-          ODataHandlerException.MessageKeys.HTTP_METHOD_NOT_ALLOWED, method.toString());
+      handler.selectProcessor(CountComplexCollectionProcessor.class)
+          .countComplexCollection(request, response, uriInfo);
     }
   }
 
@@ -517,12 +518,16 @@ public class ODataDispatcher {
     }
   }
 
-  private void validatePreconditions(ODataRequest request, boolean isMediaValue) throws PreconditionException {
-    // If needed perform preconditions validation
-    if (handler.getCustomETagSupport() != null) {
-      new PreconditionsValidator(handler.getCustomETagSupport(), uriInfo,
-          request.getHeader(HttpHeader.IF_MATCH),
-          request.getHeader(HttpHeader.IF_NONE_MATCH)).validatePreconditions(isMediaValue);
+  private void validatePreconditions(final ODataRequest request, final boolean isMediaValue)
+      throws PreconditionException {
+    // If needed perform preconditions validation.
+    final CustomETagSupport eTagSupport = handler.getCustomETagSupport();
+    if (eTagSupport != null
+        && new PreconditionsValidator(uriInfo).mustValidatePreconditions(eTagSupport, isMediaValue)
+        && request.getHeader(HttpHeader.IF_MATCH) == null
+        && request.getHeader(HttpHeader.IF_NONE_MATCH) == null) {
+      throw new PreconditionException("Expected an if-match or if-none-match header.",
+          PreconditionException.MessageKeys.MISSING_HEADER);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bfb5c938/lib/server-core/src/main/java/org/apache/olingo/server/core/etag/PreconditionsValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/etag/PreconditionsValidator.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/etag/PreconditionsValidator.java
index 32c055b..a8690d1 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/etag/PreconditionsValidator.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/etag/PreconditionsValidator.java
@@ -32,37 +32,20 @@ import org.apache.olingo.server.api.uri.UriResourceSingleton;
 
 public class PreconditionsValidator {
 
-  private final CustomETagSupport customETagSupport;
-  private final UriInfo uriInfo;
-  private final String ifMatch;
-  private final String ifNoneMatch;
+  private final EdmBindingTarget affectedEntitySetOrSingleton;
 
-  public PreconditionsValidator(CustomETagSupport customETagSupport, UriInfo uriInfo, String ifMatch,
-      String ifNoneMatch) {
-    this.customETagSupport = customETagSupport;
-    this.uriInfo = uriInfo;
-    this.ifMatch = ifMatch;
-    this.ifNoneMatch = ifNoneMatch;
+  public PreconditionsValidator(final UriInfo uriInfo) throws PreconditionException {
+    affectedEntitySetOrSingleton = extractInformation(uriInfo);
   }
 
-  public void validatePreconditions(boolean isMediaValue) throws PreconditionException {
-    EdmBindingTarget affectedEntitySetOrSingleton = extractInformation();
-    if (affectedEntitySetOrSingleton != null) {
-      if ((isMediaValue && customETagSupport.hasMediaETag(affectedEntitySetOrSingleton)) ||
-          (!isMediaValue && customETagSupport.hasETag(affectedEntitySetOrSingleton))) {
-        checkETagHeaderPresent();
-      }
-    }
-  }
-
-  private void checkETagHeaderPresent() throws PreconditionException {
-    if (ifMatch == null && ifNoneMatch == null) {
-      throw new PreconditionException("Expected an if-match or if-none-match header",
-          PreconditionException.MessageKeys.MISSING_HEADER);
-    }
+  public boolean mustValidatePreconditions(final CustomETagSupport customETagSupport, final boolean isMediaValue) {
+    return affectedEntitySetOrSingleton != null
+        && (isMediaValue ?
+            customETagSupport.hasMediaETag(affectedEntitySetOrSingleton) :
+            customETagSupport.hasETag(affectedEntitySetOrSingleton));
   }
 
-  private EdmBindingTarget extractInformation() throws PreconditionException {
+  private EdmBindingTarget extractInformation(final UriInfo uriInfo) throws PreconditionException {
     EdmBindingTarget lastFoundEntitySetOrSingleton = null;
     int counter = 0;
     for (UriResource uriResourcePart : uriInfo.getUriResourceParts()) {
@@ -78,13 +61,16 @@ public class PreconditionsValidator {
         break;
       case navigationProperty:
         lastFoundEntitySetOrSingleton = getEntitySetFromNavigation(lastFoundEntitySetOrSingleton,
-                (UriResourceNavigation) uriResourcePart);
+            (UriResourceNavigation) uriResourcePart);
+        break;
+      case primitiveProperty:
+      case complexProperty:
         break;
       case value:
       case action:
         // This should not be possible since the URI Parser validates this but to be sure we throw an exception.
         if (counter != uriInfo.getUriResourceParts().size() - 1) {
-          throw new PreconditionException("$Value or Action must be the last segment in the URI.",
+          throw new PreconditionException("$value or Action must be the last segment in the URI.",
               PreconditionException.MessageKeys.INVALID_URI);
         }
         break;
@@ -111,14 +97,11 @@ public class PreconditionsValidator {
   }
 
   private EdmBindingTarget getEntitySet(UriResourceEntitySet uriResourceEntitySet) {
-    if (!uriResourceEntitySet.isCollection()) {
-      return uriResourceEntitySet.getEntitySet();
-    }
-    return null;
+    return uriResourceEntitySet.isCollection() ? null : uriResourceEntitySet.getEntitySet();
   }
 
   private EdmBindingTarget getEntitySetFromNavigation(EdmBindingTarget lastFoundEntitySetOrSingleton,
-                                                      UriResourceNavigation uriResourceNavigation) {
+      UriResourceNavigation uriResourceNavigation) {
     if (lastFoundEntitySetOrSingleton != null && !uriResourceNavigation.isCollection()) {
       EdmNavigationProperty navProp = uriResourceNavigation.getProperty();
       return lastFoundEntitySetOrSingleton.getRelatedBindingTarget(navProp.getName());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bfb5c938/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/EntityTypeProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/EntityTypeProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/EntityTypeProvider.java
index b9a8221..6ee0d2d 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/EntityTypeProvider.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/EntityTypeProvider.java
@@ -371,7 +371,7 @@ public class EntityTypeProvider {
               PropertyProvider.collectionNavPropertyETKeyNavMany_ETKeyNav,
               PropertyProvider.navPropertyETTwoKeyNavOne_ETTwoKeyNav,
               PropertyProvider.collectionNavPropertyETTwoKeyNavMany_ETTwoKeyNav,
-              PropertyProvider.collectionNavPropertySINav));
+              PropertyProvider.navPropertySINav));
 
     } else if (entityTypeName.equals(nameETBaseTwoKeyNav)) {
       return new CsdlEntityType()

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bfb5c938/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/PropertyProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/PropertyProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/PropertyProvider.java
index 6efad33..690e1d3 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/PropertyProvider.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/PropertyProvider.java
@@ -687,9 +687,9 @@ public class PropertyProvider {
           .setType(EntityTypeProvider.nameETAllPrim)
           .setCollection(true);
 
-  public static final CsdlNavigationProperty collectionNavPropertySINav = new CsdlNavigationProperty()
+  public static final CsdlNavigationProperty navPropertySINav = new CsdlNavigationProperty()
       .setName("NavPropertySINav")
-      .setCollection(true)
+      .setCollection(false)
       .setType(EntityTypeProvider.nameETTwoKeyNav);
 
   public static final CsdlNavigationProperty collectionNavPropertyETKeyNavContMany_CT_ETKeyNav =

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bfb5c938/lib/server-test/src/test/java/org/apache/olingo/server/core/PreconditionsValidatorTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/PreconditionsValidatorTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/PreconditionsValidatorTest.java
index fae780d..e2fe3ac 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/PreconditionsValidatorTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/PreconditionsValidatorTest.java
@@ -19,7 +19,8 @@
 package org.apache.olingo.server.core;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -52,144 +53,146 @@ public class PreconditionsValidatorTest {
 
   @Test
   public void simpleEntity() throws Exception {
-    validate("ESAllPrim(1)", null, "*", "*");
+    assertTrue(mustValidate("ESAllPrim(1)", "ESAllPrim"));
   }
 
   @Test
   public void simpleEntityValue() throws Exception {
-    validate("ESMedia(1)/$value", null, "*", "*");
+    assertTrue(mustValidate("ESMedia(1)/$value", "ESMedia"));
+  }
+
+  @Test
+  public void property() throws Exception {
+    assertTrue(mustValidate("ESAllPrim(1)/PropertyInt16", "ESAllPrim"));
+    assertTrue(mustValidate("ESMixPrimCollComp(0)/PropertyComp", "ESMixPrimCollComp"));
+    assertTrue(mustValidate("ESMixPrimCollComp(0)/PropertyComp/PropertyString", "ESMixPrimCollComp"));
+  }
+
+  @Test
+  public void propertyValue() throws Exception {
+    assertTrue(mustValidate("ESAllPrim(1)/PropertyInt16/$value", "ESAllPrim"));
+    assertTrue(mustValidate("ESMixPrimCollComp(0)/PropertyComp/PropertyString/$value", "ESMixPrimCollComp"));
   }
 
   @Test
   public void EntityAndToOneNavigation() throws Exception {
-    validate("ESAllPrim(1)/NavPropertyETTwoPrimOne", "ESTwoPrim", "*", "*");
+    assertTrue(mustValidate("ESAllPrim(1)/NavPropertyETTwoPrimOne", "ESTwoPrim"));
   }
 
   @Test
   public void EntityAndToManyNavigationWithKey() throws Exception {
-    validate("ESAllPrim(1)/NavPropertyETTwoPrimMany(1)", "ESTwoPrim", "*", "*");
+    assertTrue(mustValidate("ESAllPrim(1)/NavPropertyETTwoPrimMany(1)", "ESTwoPrim"));
   }
 
   @Test
   public void EntityAndToOneNavigationValue() throws Exception {
-    validate("ESKeyNav(1)/NavPropertyETMediaOne/$value", "ESMedia", "*", "*");
+    assertTrue(mustValidate("ESKeyNav(1)/NavPropertyETMediaOne/$value", "ESMedia"));
+  }
+
+  @Test
+  public void navigationOnProperty() throws Exception {
+    assertTrue(mustValidate("ESAllPrim(1)/NavPropertyETTwoPrimOne/PropertyInt16", "ESTwoPrim"));
+  }
+
+  @Test
+  public void navigationOnFunction() throws Exception {
+    assertTrue(mustValidate("FICRTESTwoKeyNav()(PropertyInt16=1,PropertyString='1')/NavPropertySINav", "SINav"));
   }
 
   @Test
   public void boundActionOnEsKeyNav() throws Exception {
-    validate("ESKeyNav(1)/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav", "ESKeyNav", "*", "*");
+    assertTrue(mustValidate("ESKeyNav(1)/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav", "ESKeyNav"));
   }
 
   @Test
   public void boundActionOnEsKeyNavWithNavigation() throws Exception {
-    validate("ESKeyNav(1)/NavPropertyETKeyNavOne/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav",
-        "ESKeyNav", "*", "*");
+    assertTrue(
+        mustValidate("ESKeyNav(1)/NavPropertyETKeyNavOne/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav", "ESKeyNav"));
   }
 
   @Test
   public void singleton() throws Exception {
-    validate("SI", "SI", "*", "*");
+    assertTrue(mustValidate("SI", "SI"));
   }
 
   @Test
   public void singletonWithNavigation() throws Exception {
-    validate("SINav/NavPropertyETKeyNavOne", "ESKeyNav", "*", "*");
+    assertTrue(mustValidate("SINav/NavPropertyETKeyNavOne", "ESKeyNav"));
   }
 
   @Test
   public void singletonWithNavigationValue() throws Exception {
-    validate("SINav/NavPropertyETKeyNavOne/NavPropertyETMediaOne/$value", "ESMedia", "*", "*");
+    assertTrue(mustValidate("SINav/NavPropertyETKeyNavOne/NavPropertyETMediaOne/$value", "ESMedia"));
   }
 
   @Test
   public void singletonWithAction() throws Exception {
-    validate("SINav/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav", "SINav", "*", "*");
+    assertTrue(mustValidate("SINav/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav", "SINav"));
   }
 
   @Test
   public void singletonWithActionAndNavigation() throws Exception {
-    validate("SINav/NavPropertyETKeyNavOne/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav", "ESKeyNav", "*", "*");
+    assertTrue(mustValidate("SINav/NavPropertyETKeyNavOne/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav", "ESKeyNav"));
   }
 
   @Test
   public void simpleEntityValueValidationNotActiveForMedia() throws Exception {
+    final UriInfo uriInfo = new Parser().parseUri("ESMedia(1)/$value", null, null, edm);
+
     CustomETagSupport support = mock(CustomETagSupport.class);
     when(support.hasETag(any(EdmBindingTarget.class))).thenReturn(true);
     when(support.hasMediaETag(any(EdmBindingTarget.class))).thenReturn(false);
 
-    final UriInfo uriInfo = new Parser().parseUri("ESMedia(1)/$value", null, null, edm);
-    new PreconditionsValidator(support, uriInfo, null, null).validatePreconditions(true);
+    assertFalse(new PreconditionsValidator(uriInfo).mustValidatePreconditions(support, true));
   }
 
   // -------------- IGNORE VALIDATION TESTS -----------------------------------------------------------------------
 
   @Test
-  public void entitySetMustNotLeadToException() throws Exception {
-    validate("ESAllPrim", null, null, null);
-  }
-
-  @Test
-  public void propertyMustNotLeadToException() throws Exception {
-    validate("ESAllPrim(1)/PropertyInt16", null, null, null);
-  }
-
-  @Test
-  public void propertyValueMustNotLeadToException() throws Exception {
-    validate("ESAllPrim(1)/PropertyInt16/$value", null, null, null);
+  public void entitySetMustBeIgnored() throws Exception {
+    assertFalse(mustValidate("ESAllPrim", "ESAllPrim"));
   }
 
   @Test
-  public void navigationToManyMustNotLeadToException() throws Exception {
-    validate("ESAllPrim(1)/NavPropertyETTwoPrimMany", null, null, null);
+  public void navigationToManyMustBeIgnored() throws Exception {
+    assertFalse(mustValidate("ESAllPrim(1)/NavPropertyETTwoPrimMany", "ESTwoPrim"));
   }
 
   @Test
-  public void navigationOnPropertyMustNotLeadToException() throws Exception {
-    validate("ESAllPrim(1)/NavPropertyETTwoPrimOne/PropertyInt16", null, null, null);
+  public void navigationOnFunctionWithoutEntitySetMustBeIgnored() throws Exception {
+    assertFalse(mustValidate("FICRTETTwoKeyNavParam(ParameterInt16=1)/NavPropertyETKeyNavOne", null));
   }
 
   @Test
-  public void navigationToManyOnActionMustNotLeadToException() throws Exception {
-    validate("ESTwoPrim(1)/NavPropertyETAllPrimMany/Namespace1_Alias.BAESAllPrimRTETAllPrim", null, null, null);
+  public void navigationToManyToActionMustBeIgnored() throws Exception {
+    assertFalse(mustValidate("ESTwoPrim(1)/NavPropertyETAllPrimMany/Namespace1_Alias.BAESAllPrimRTETAllPrim", null));
   }
 
   @Test
-  public void navigationWithoutBindingMustNotLeadToException() throws Exception {
-    validate("ESTwoBaseTwoKeyNav(PropertyInt16=1,PropertyString='test')"
+  public void navigationWithoutBindingMustBeIgnored() throws Exception {
+    assertFalse(mustValidate("ESTwoBaseTwoKeyNav(PropertyInt16=1,PropertyString='test')"
         + "/NavPropertyETBaseTwoKeyNavMany(PropertyInt16=1,PropertyString='test')",
-        null, null, null);
+        null));
   }
 
-  // -------------- NEGATIVE TESTS --------------------------------------------------------------------------------
-
   @Test
-  public void positiveTestsMustLeadToAnExceptionIfNoHeaderIsPresent() throws Exception {
-    runException("ESAllPrim(1)");
-    runException("ESMedia(1)/$value");
-    runException("ESAllPrim(1)/NavPropertyETTwoPrimOne");
-    runException("ESAllPrim(1)/NavPropertyETTwoPrimMany(1)");
-    runException("ESKeyNav(1)/NavPropertyETMediaOne/$value");
-    runException("ESKeyNav(1)/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav");
-    runException("ESKeyNav(1)/NavPropertyETKeyNavOne/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav");
-
-    runException("SI");
-    runException("SINav/NavPropertyETKeyNavOne");
-    runException("SINav/NavPropertyETKeyNavOne/NavPropertyETMediaOne/$value");
-    runException("SINav/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav");
-    runException("SINav/NavPropertyETKeyNavOne/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav");
+  public void referencesMustBeIgnored() throws Exception {
+    assertFalse(mustValidate("ESAllPrim(1)/NavPropertyETTwoPrimOne/$ref", "ESTwoPrim"));
+    assertFalse(mustValidate("ESAllPrim(1)/NavPropertyETTwoPrimMany(1)/$ref", "ESTwoPrim"));
+    assertFalse(mustValidate("SINav/NavPropertyETKeyNavOne/$ref", "ESKeyNav"));
   }
 
   @Test(expected = UriParserSemanticException.class)
   public void resourceSegmentAfterActionMustLeadToUriParserException() throws Exception {
-    validate("ESKeyNav(1)/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav/PropertyInt16", "ESKeyNav", "*", "*");
+    mustValidate("ESKeyNav(1)/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav/PropertyInt16", "ESKeyNav");
   }
 
   @Test(expected = UriParserSemanticException.class)
   public void valueMustBeLastSegment() throws Exception {
-    validate("ESMedia(1)/$value/PropertyInt16", null, null, null);
+    mustValidate("ESMedia(1)/$value/PropertyInt16", "ESMedia");
   }
 
-  private void validate(final String uri, final String entitySetName, final String ifMatch, final String ifNoneMatch)
+  private boolean mustValidate(final String uri, final String entitySetName)
       throws UriParserException, PreconditionException {
     final UriInfo uriInfo = new Parser().parseUri(uri, null, null, edm);
     final List<UriResource> parts = uriInfo.getUriResourceParts();
@@ -207,15 +210,6 @@ public class PreconditionsValidatorTest {
     when(support.hasETag(any(EdmBindingTarget.class))).thenAnswer(answer);
     when(support.hasMediaETag(any(EdmBindingTarget.class))).thenAnswer(answer);
 
-    new PreconditionsValidator(support, uriInfo, ifMatch, ifNoneMatch).validatePreconditions(isMedia);
-  }
-
-  private void runException(final String uri) throws UriParserException {
-    try {
-      validate(uri, null, null, null);
-      fail("Expected a PreconditionRequiredException but was not thrown");
-    } catch (final PreconditionException e) {
-      assertEquals(PreconditionException.MessageKeys.MISSING_HEADER, e.getMessageKey());
-    }
+    return new PreconditionsValidator(uriInfo).mustValidatePreconditions(support, isMedia);
   }
 }


[05/39] olingo-odata4 git commit: [OLINGO-642] Merge branch 'master' into OLINGO-642_OSGi-Sample

Posted by ch...@apache.org.
[OLINGO-642] Merge branch 'master' into OLINGO-642_OSGi-Sample


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

Branch: refs/heads/IEE754Compatible
Commit: d53574d4d0e0085ae5709d01e8e15ae6ecca739c
Parents: e59b508 44ec578
Author: Michael Bolz <mi...@sap.com>
Authored: Wed Jun 10 10:58:50 2015 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Wed Jun 10 10:58:50 2015 +0200

----------------------------------------------------------------------
 .../fit/tecsvc/client/BatchClientITCase.java    |  10 +-
 .../fit/tecsvc/client/ConditionalITCase.java    |  35 +++
 .../tecsvc/client/PrimitiveComplexITCase.java   |  18 +-
 .../tecsvc/client/SystemQueryOptionITCase.java  |  14 +-
 .../fit/tecsvc/http/BasicBatchITCase.java       |   2 +-
 .../apache/olingo/fit/v4/OAuth2TestITCase.java  |  44 ++-
 .../response/ODataLinkOperationResponse.java    |  29 --
 .../retrieve/EdmMetadataRequestImpl.java        |  31 ++-
 .../retrieve/XMLMetadataRequestImpl.java        |  21 +-
 .../olingo/server/api/CustomETagSupport.java    |  50 ----
 .../olingo/server/api/EtagInformation.java      |  74 -----
 .../org/apache/olingo/server/api/OData.java     |  28 +-
 .../olingo/server/api/ODataHttpHandler.java     |   1 +
 .../server/api/ODataLibraryException.java       | 159 +++++++++++
 .../server/api/ODataTranslatedException.java    | 159 -----------
 .../olingo/server/api/ServiceMetadata.java      |   6 +
 .../olingo/server/api/batch/BatchFacade.java    |  88 +++---
 .../api/deserializer/DeserializerException.java |   4 +-
 .../server/api/etag/CustomETagSupport.java      |  51 ++++
 .../olingo/server/api/etag/ETagHelper.java      |  66 +++++
 .../server/api/etag/PreconditionException.java  |  54 ++++
 .../api/etag/ServiceMetadataETagSupport.java    |  45 ++++
 .../ActionComplexCollectionProcessor.java       |   9 +-
 .../api/processor/ActionComplexProcessor.java   |   9 +-
 .../ActionEntityCollectionProcessor.java        |   9 +-
 .../api/processor/ActionEntityProcessor.java    |   9 +-
 .../ActionPrimitiveCollectionProcessor.java     |   9 +-
 .../api/processor/ActionPrimitiveProcessor.java |   9 +-
 .../api/processor/ActionVoidProcessor.java      |   6 +-
 .../server/api/processor/BatchProcessor.java    |  15 +-
 .../processor/ComplexCollectionProcessor.java   |  20 +-
 .../server/api/processor/ComplexProcessor.java  |  20 +-
 .../CountComplexCollectionProcessor.java        |   6 +-
 .../CountEntityCollectionProcessor.java         |   6 +-
 .../CountPrimitiveCollectionProcessor.java      |   6 +-
 .../server/api/processor/DefaultProcessor.java  |  62 ++++-
 .../server/api/processor/DeltaProcessor.java    |   4 +-
 .../processor/EntityCollectionProcessor.java    |   6 +-
 .../server/api/processor/EntityProcessor.java   |  27 +-
 .../api/processor/MediaEntityProcessor.java     |  23 +-
 .../server/api/processor/MetadataProcessor.java |   6 +-
 .../processor/PrimitiveCollectionProcessor.java |  21 +-
 .../api/processor/PrimitiveProcessor.java       |  19 +-
 .../api/processor/PrimitiveValueProcessor.java  |   6 +-
 .../processor/ReferenceCollectionProcessor.java |  11 +-
 .../api/processor/ReferenceProcessor.java       |  18 +-
 .../api/processor/ServiceDocumentProcessor.java |   6 +-
 .../server/api/serializer/ODataSerializer.java  |  88 +++---
 .../api/serializer/SerializerException.java     |   4 +-
 .../olingo/server/api/uri/UriInfoCrossjoin.java |  54 ++++
 .../server/api/TranslatedExceptionsTest.java    |   4 +-
 .../olingo/server/core/OData4HttpHandler.java   |   4 +-
 .../server/core/RequestURLHierarchyVisitor.java |  35 +++
 .../olingo/server/core/ServiceDispatcher.java   |   6 +-
 .../olingo/server/core/ServiceHandler.java      |  82 +++---
 .../olingo/server/core/ServiceRequest.java      |   4 +-
 .../core/legacy/ProcessorServiceHandler.java    |  60 ++---
 .../server/core/requests/ActionRequest.java     |   4 +-
 .../server/core/requests/BatchRequest.java      |   6 +-
 .../server/core/requests/DataRequest.java       |  20 +-
 .../server/core/requests/FunctionRequest.java   |   4 +-
 .../server/core/requests/MediaRequest.java      |   4 +-
 .../server/core/requests/MetadataRequest.java   |   4 +-
 .../core/requests/ServiceDocumentRequest.java   |   4 +-
 .../server/core/responses/CountResponse.java    |   4 +-
 .../server/core/responses/EntityResponse.java   |   4 +-
 .../core/responses/EntitySetResponse.java       |   4 +-
 .../server/core/responses/MetadataResponse.java |   6 +-
 .../core/responses/NoContentResponse.java       |   4 +-
 .../core/responses/PrimitiveValueResponse.java  |   4 +-
 .../server/core/responses/PropertyResponse.java |  10 +-
 .../core/responses/ServiceDocumentResponse.java |   8 +-
 .../server/core/responses/ServiceResponse.java  |   4 +-
 .../core/responses/ServiceResponseVisior.java   |  20 +-
 .../server/core/responses/StreamResponse.java   |   4 +-
 .../olingo/server/example/TripPinHandler.java   |  50 ++--
 .../server/example/TripPinServiceTest.java      |   3 +-
 .../server/core/ContentNegotiatorException.java |   4 +-
 .../apache/olingo/server/core/EtagParser.java   |  86 ------
 .../olingo/server/core/ODataDispatcher.java     |  81 +++---
 .../server/core/ODataExceptionHelper.java       |  31 ++-
 .../apache/olingo/server/core/ODataHandler.java |  13 +-
 .../server/core/ODataHandlerException.java      |   4 +-
 .../server/core/ODataHttpHandlerImpl.java       |  12 +-
 .../apache/olingo/server/core/ODataImpl.java    |  37 +--
 .../core/PreconditionRequiredException.java     |  50 ----
 .../server/core/PreconditionsValidator.java     | 138 ----------
 .../olingo/server/core/ServiceMetadataImpl.java |  15 +-
 .../core/batchhandler/BatchFacadeImpl.java      |  58 ++++
 .../core/batchhandler/BatchFascadeImpl.java     |  54 ----
 .../server/core/batchhandler/BatchHandler.java  |   8 +-
 .../core/batchhandler/BatchPartHandler.java     |   8 +-
 .../json/ODataJsonDeserializer.java             |  13 +-
 .../olingo/server/core/etag/ETagHelperImpl.java |  72 +++++
 .../server/core/etag/ETagInformation.java       |  74 +++++
 .../olingo/server/core/etag/ETagParser.java     |  86 ++++++
 .../core/etag/PreconditionsValidator.java       | 128 +++++++++
 .../serializer/json/ODataJsonSerializer.java    |  75 ++++--
 .../json/ServiceDocumentJsonSerializer.java     |  33 ++-
 .../serializer/xml/ODataXmlSerializerImpl.java  |  12 +-
 .../core/uri/parser/UriParseTreeVisitor.java    |  17 +-
 .../core/uri/parser/UriParserException.java     |   4 +-
 .../uri/validator/UriValidationException.java   |   4 +-
 .../server-core-exceptions-i18n.properties      |   4 +-
 .../olingo/server/core/EtagParserTest.java      | 131 ---------
 .../olingo/server/core/ExceptionHelperTest.java | 137 ++++++++++
 .../server/core/ODataHttpHandlerImplTest.java   |   4 +-
 .../core/TranslatedExceptionSubclassesTest.java |  16 +-
 .../batchhandler/MockedBatchHandlerTest.java    |   4 +-
 .../json/ODataJsonDeserializerBasicTest.java    | 114 ++++++++
 .../olingo/server/core/etag/ETagHelperTest.java |  79 ++++++
 .../olingo/server/core/etag/ETagParserTest.java | 129 +++++++++
 .../xml/MetadataDocumentXmlSerializerTest.java  |   2 +-
 .../olingo/server/tecsvc/ETagSupport.java       |  11 +-
 .../server/tecsvc/MetadataETagSupport.java      |  40 +++
 .../olingo/server/tecsvc/TechnicalServlet.java  |  18 +-
 .../olingo/server/tecsvc/data/DataProvider.java |  19 +-
 .../server/tecsvc/data/RequestValidator.java    |  91 +++----
 .../processor/TechnicalActionProcessor.java     |  25 +-
 .../processor/TechnicalBatchProcessor.java      |   8 +-
 .../processor/TechnicalEntityProcessor.java     | 152 +++++------
 .../TechnicalPrimitiveComplexProcessor.java     |  66 +++--
 .../tecsvc/processor/TechnicalProcessor.java    |  50 +---
 .../expression/operand/TypedOperand.java        |  20 +-
 .../expression/operand/UntypedOperand.java      |   9 +-
 .../expression/operand/VisitorOperand.java      |   2 +
 .../operation/MethodCallOperator.java           |  14 +-
 .../expression/primitive/EdmNull.java           |  88 ++----
 .../server/core/PreconditionsValidatorTest.java | 209 ++++++++++----
 .../json/ODataJsonSerializerTest.java           | 270 ++++++++++---------
 .../serializer/json/ServiceDocumentTest.java    | 108 ++------
 .../serializer/xml/MetadataDocumentTest.java    |   5 +-
 .../core/uri/testutil/TestUriValidator.java     |   4 +-
 .../server/sample/processor/CarsProcessor.java  |   2 +-
 134 files changed, 2793 insertions(+), 1998 deletions(-)
----------------------------------------------------------------------



[15/39] olingo-odata4 git commit: [OLINGO-699] Moved serializer code to client module

Posted by ch...@apache.org.
[OLINGO-699] Moved serializer code to client module


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

Branch: refs/heads/IEE754Compatible
Commit: 20351253e2c00f6593cf4136375f1157c9310af5
Parents: a6d20f6
Author: Christian Amend <ch...@sap.com>
Authored: Mon Jun 15 10:48:03 2015 +0200
Committer: Christian Amend <ch...@sap.com>
Committed: Mon Jun 15 10:48:03 2015 +0200

----------------------------------------------------------------------
 fit/pom.xml                                     |  12 +-
 .../org/apache/olingo/fit/AbstractServices.java |  10 +-
 .../fit/serializer/FITAtomDeserializer.java     |   2 +-
 .../olingo/fit/utils/AbstractUtilities.java     |  14 +-
 .../org/apache/olingo/fit/utils/FSManager.java  |   6 +-
 .../olingo/fit/AbstractBaseTestITCase.java      |   2 +-
 .../apache/olingo/client/api/ODataClient.java   |   2 +-
 .../api/domain/ClientEntitySetIterator.java     |   2 +-
 .../serialization/ClientODataDeserializer.java  |   2 -
 .../api/serialization/ODataDeserializer.java    |  65 ++
 .../ODataDeserializerException.java             |  38 +
 .../client/api/serialization/ODataReader.java   |   1 -
 .../api/serialization/ODataSerializer.java      |  33 +
 .../serialization/ODataSerializerException.java |  38 +
 .../client/api/serialization/ODataWriter.java   |   1 -
 .../olingo/client/core/ODataClientImpl.java     |   6 +-
 .../header/ODataErrorResponseChecker.java       |   2 +-
 .../cud/ODataEntityCreateRequestImpl.java       |   4 +-
 .../cud/ODataEntityUpdateRequestImpl.java       |   4 +-
 .../cud/ODataPropertyUpdateRequestImpl.java     |   4 +-
 .../cud/ODataReferenceAddingRequestImpl.java    |   2 +-
 .../invoke/AbstractODataInvokeRequest.java      |   4 +-
 .../request/retrieve/ODataDeltaRequestImpl.java |   2 +-
 .../retrieve/ODataEntityRequestImpl.java        |   2 +-
 .../retrieve/ODataEntitySetRequestImpl.java     |   2 +-
 .../retrieve/ODataPropertyRequestImpl.java      |   2 +-
 .../request/retrieve/ODataRawRequestImpl.java   |   2 +-
 .../ODataServiceDocumentRequestImpl.java        |   2 +-
 .../ODataMediaEntityCreateRequestImpl.java      |   2 +-
 .../ODataMediaEntityUpdateRequestImpl.java      |   2 +-
 .../data/JSONServiceDocumentDeserializer.java   |   4 +-
 .../data/XMLServiceDocumentDeserializer.java    |   4 +-
 .../core/serialization/AbstractAtomDealer.java  |  97 +++
 .../core/serialization/AtomDeserializer.java    | 873 +++++++++++++++++++
 .../serialization/AtomGeoValueDeserializer.java | 269 ++++++
 .../serialization/AtomGeoValueSerializer.java   | 223 +++++
 .../core/serialization/AtomSerializer.java      | 570 ++++++++++++
 .../ClientODataDeserializerImpl.java            |   7 +-
 .../core/serialization/ContextURLParser.java    | 118 +++
 .../serialization/JsonDeltaDeserializer.java    | 100 +++
 .../core/serialization/JsonDeserializer.java    | 421 +++++++++
 .../serialization/JsonEntityDeserializer.java   | 229 +++++
 .../serialization/JsonEntitySerializer.java     | 135 +++
 .../JsonEntitySetDeserializer.java              | 120 +++
 .../serialization/JsonEntitySetSerializer.java  |  92 ++
 .../serialization/JsonGeoValueDeserializer.java | 262 ++++++
 .../serialization/JsonGeoValueSerializer.java   | 184 ++++
 .../JsonODataErrorDeserializer.java             |  87 ++
 .../JsonODataErrorDetailDeserializer.java       |  58 ++
 .../serialization/JsonPropertyDeserializer.java | 114 +++
 .../serialization/JsonPropertySerializer.java   |  93 ++
 .../core/serialization/JsonSerializer.java      | 376 ++++++++
 .../core/serialization/ODataBinderImpl.java     |   3 +-
 .../core/serialization/ODataReaderImpl.java     |   2 +-
 .../core/serialization/ODataWriterImpl.java     |   2 +-
 .../serialization/AtomDeserializerTest.java     | 329 +++++++
 .../serialization/ContextURLParserTest.java     | 256 ++++++
 .../olingo/client/core/v4/EntitySetTest.java    |   2 +-
 .../apache/olingo/client/core/v4/ErrorTest.java |   2 +-
 .../olingo/client/core/v4/PropertyTest.java     |   4 +-
 .../client/core/v4/ServiceDocumentTest.java     |   2 +-
 .../api/serialization/ODataDeserializer.java    |  65 --
 .../ODataDeserializerException.java             |  38 -
 .../api/serialization/ODataSerializer.java      |  33 -
 .../serialization/ODataSerializerException.java |  38 -
 .../core/serialization/AbstractAtomDealer.java  |  97 ---
 .../core/serialization/AtomDeserializer.java    | 873 -------------------
 .../serialization/AtomGeoValueDeserializer.java | 269 ------
 .../serialization/AtomGeoValueSerializer.java   | 223 -----
 .../core/serialization/AtomSerializer.java      | 570 ------------
 .../core/serialization/ContextURLParser.java    | 118 ---
 .../serialization/JsonDeltaDeserializer.java    | 100 ---
 .../core/serialization/JsonDeserializer.java    | 421 ---------
 .../serialization/JsonEntityDeserializer.java   | 229 -----
 .../serialization/JsonEntitySerializer.java     | 135 ---
 .../JsonEntitySetDeserializer.java              | 120 ---
 .../serialization/JsonEntitySetSerializer.java  |  92 --
 .../serialization/JsonGeoValueDeserializer.java | 262 ------
 .../serialization/JsonGeoValueSerializer.java   | 184 ----
 .../JsonODataErrorDeserializer.java             |  87 --
 .../JsonODataErrorDetailDeserializer.java       |  58 --
 .../serialization/JsonPropertyDeserializer.java | 114 ---
 .../serialization/JsonPropertySerializer.java   |  93 --
 .../core/serialization/JsonSerializer.java      | 376 --------
 .../serialization/AtomDeserializerTest.java     | 328 -------
 .../serialization/ContextURLParserTest.java     | 255 ------
 86 files changed, 5240 insertions(+), 5246 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/fit/pom.xml
----------------------------------------------------------------------
diff --git a/fit/pom.xml b/fit/pom.xml
index b35d5ae..de9743d 100644
--- a/fit/pom.xml
+++ b/fit/pom.xml
@@ -43,6 +43,12 @@
 
     <dependency>
       <groupId>org.apache.olingo</groupId>
+      <artifactId>odata-client-core</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.olingo</groupId>
       <artifactId>odata-client-proxy</artifactId>
       <version>${project.version}</version>
     </dependency>
@@ -118,12 +124,6 @@
 
     <dependency>
       <groupId>org.apache.olingo</groupId>
-      <artifactId>odata-client-core</artifactId>
-      <version>${project.version}</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.olingo</groupId>
       <artifactId>odata-server-tecsvc</artifactId>
       <version>${project.version}</version>
       <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/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 a5ca333..690e004 100644
--- a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
+++ b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
@@ -68,6 +68,11 @@ import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.cxf.jaxrs.ext.multipart.Attachment;
 import org.apache.cxf.jaxrs.ext.multipart.Multipart;
 import org.apache.cxf.jaxrs.ext.multipart.MultipartBody;
+import org.apache.olingo.client.api.serialization.ODataDeserializer;
+import org.apache.olingo.client.api.serialization.ODataSerializer;
+import org.apache.olingo.client.core.serialization.AtomSerializer;
+import org.apache.olingo.client.core.serialization.JsonDeserializer;
+import org.apache.olingo.client.core.serialization.JsonSerializer;
 import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntityCollection;
@@ -79,12 +84,7 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.commons.api.serialization.ODataDeserializer;
-import org.apache.olingo.commons.api.serialization.ODataSerializer;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
-import org.apache.olingo.commons.core.serialization.AtomSerializer;
-import org.apache.olingo.commons.core.serialization.JsonDeserializer;
-import org.apache.olingo.commons.core.serialization.JsonSerializer;
 import org.apache.olingo.fit.metadata.EntityType;
 import org.apache.olingo.fit.metadata.Metadata;
 import org.apache.olingo.fit.metadata.NavigationProperty;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/fit/src/main/java/org/apache/olingo/fit/serializer/FITAtomDeserializer.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/serializer/FITAtomDeserializer.java b/fit/src/main/java/org/apache/olingo/fit/serializer/FITAtomDeserializer.java
index 8ad62fe..d02475d 100644
--- a/fit/src/main/java/org/apache/olingo/fit/serializer/FITAtomDeserializer.java
+++ b/fit/src/main/java/org/apache/olingo/fit/serializer/FITAtomDeserializer.java
@@ -27,8 +27,8 @@ import java.nio.charset.CodingErrorAction;
 import javax.xml.stream.XMLEventReader;
 import javax.xml.stream.XMLStreamException;
 
+import org.apache.olingo.client.core.serialization.AtomDeserializer;
 import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.core.serialization.AtomDeserializer;
 
 public class FITAtomDeserializer extends AtomDeserializer {
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java b/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java
index 7fa9201..73eae08 100644
--- a/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java
@@ -42,19 +42,19 @@ import javax.ws.rs.core.Response;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.vfs2.FileObject;
+import org.apache.olingo.client.api.serialization.ODataDeserializer;
+import org.apache.olingo.client.api.serialization.ODataDeserializerException;
+import org.apache.olingo.client.api.serialization.ODataSerializer;
+import org.apache.olingo.client.api.serialization.ODataSerializerException;
+import org.apache.olingo.client.core.serialization.AtomSerializer;
+import org.apache.olingo.client.core.serialization.JsonDeserializer;
+import org.apache.olingo.client.core.serialization.JsonSerializer;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.api.serialization.ODataDeserializer;
-import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
-import org.apache.olingo.commons.api.serialization.ODataSerializer;
-import org.apache.olingo.commons.api.serialization.ODataSerializerException;
-import org.apache.olingo.commons.core.serialization.AtomSerializer;
-import org.apache.olingo.commons.core.serialization.JsonDeserializer;
-import org.apache.olingo.commons.core.serialization.JsonSerializer;
 import org.apache.olingo.fit.UnsupportedMediaTypeException;
 import org.apache.olingo.fit.metadata.Metadata;
 import org.apache.olingo.fit.metadata.NavigationProperty;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java b/fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java
index 02dcadd..0dad1e6 100644
--- a/fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java
@@ -38,12 +38,12 @@ import org.apache.commons.vfs2.FileSystemException;
 import org.apache.commons.vfs2.FileSystemManager;
 import org.apache.commons.vfs2.FileType;
 import org.apache.commons.vfs2.VFS;
+import org.apache.olingo.client.api.serialization.ODataSerializerException;
+import org.apache.olingo.client.core.serialization.AtomSerializer;
+import org.apache.olingo.client.core.serialization.JsonSerializer;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.api.serialization.ODataSerializerException;
-import org.apache.olingo.commons.core.serialization.AtomSerializer;
-import org.apache.olingo.commons.core.serialization.JsonSerializer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
index 523aedd..58dd2a3 100644
--- a/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
@@ -33,10 +33,10 @@ import org.apache.olingo.client.api.ODataClient;
 import org.apache.olingo.client.api.domain.ClientEntity;
 import org.apache.olingo.client.api.domain.ClientProperty;
 import org.apache.olingo.client.api.domain.ClientValue;
+import org.apache.olingo.client.api.serialization.ODataSerializerException;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.serialization.ODataSerializerException;
 import org.apache.olingo.fit.server.TomcatTestServer;
 import org.apache.olingo.server.tecsvc.TechnicalServlet;
 import org.junit.BeforeClass;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-api/src/main/java/org/apache/olingo/client/api/ODataClient.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/ODataClient.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/ODataClient.java
index 214ab98..b8d5830 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/ODataClient.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/ODataClient.java
@@ -28,6 +28,7 @@ import org.apache.olingo.client.api.communication.request.retrieve.RetrieveReque
 import org.apache.olingo.client.api.serialization.ClientODataDeserializer;
 import org.apache.olingo.client.api.serialization.ODataBinder;
 import org.apache.olingo.client.api.serialization.ODataReader;
+import org.apache.olingo.client.api.serialization.ODataSerializer;
 import org.apache.olingo.client.api.serialization.ODataWriter;
 import org.apache.olingo.client.api.uri.FilterFactory;
 import org.apache.olingo.client.api.uri.SearchFactory;
@@ -35,7 +36,6 @@ import org.apache.olingo.client.api.uri.URIBuilder;
 import org.apache.olingo.client.api.domain.ClientObjectFactory;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.serialization.ODataSerializer;
 
 public interface ODataClient {
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ClientEntitySetIterator.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ClientEntitySetIterator.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ClientEntitySetIterator.java
index accfce6..801ef1a 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ClientEntitySetIterator.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ClientEntitySetIterator.java
@@ -30,11 +30,11 @@ import java.util.NoSuchElementException;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.serialization.ODataDeserializerException;
 import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ClientODataDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ClientODataDeserializer.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ClientODataDeserializer.java
index 56c2e13..8317c22 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ClientODataDeserializer.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ClientODataDeserializer.java
@@ -24,8 +24,6 @@ import org.apache.olingo.client.api.data.ServiceDocument;
 import org.apache.olingo.client.api.edm.xml.XMLMetadata;
 import org.apache.olingo.commons.api.data.Delta;
 import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.serialization.ODataDeserializer;
-import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 
 public interface ClientODataDeserializer extends ODataDeserializer {
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataDeserializer.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataDeserializer.java
new file mode 100644
index 0000000..e91ba93
--- /dev/null
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataDeserializer.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.api.serialization;
+
+import java.io.InputStream;
+
+import org.apache.olingo.commons.api.ODataError;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntityCollection;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ResWrap;
+
+/**
+ * Interface for de-serialization.
+ */
+public interface ODataDeserializer {
+
+  /**
+   * Gets an entity set object from the given InputStream.
+   *
+   * @param input stream to be de-serialized.
+   * @return {@link EntityCollection} instance.
+   */
+  ResWrap<EntityCollection> toEntitySet(InputStream input) throws ODataDeserializerException;
+
+  /**
+   * Gets an entity object from the given InputStream.
+   *
+   * @param input stream to be de-serialized.
+   * @return {@link Entity} instance.
+   */
+  ResWrap<Entity> toEntity(InputStream input) throws ODataDeserializerException;
+
+  /**
+   * Gets a property object from the given InputStream.
+   *
+   * @param input stream to be de-serialized.
+   * @return Property instance.
+   */
+  ResWrap<Property> toProperty(InputStream input) throws ODataDeserializerException;
+
+  /**
+   * Gets the ODataError object represented by the given InputStream.
+   *
+   * @param input stream to be parsed and de-serialized.
+   * @return parsed ODataError object represented by the given InputStream
+   */
+  ODataError toError(InputStream input) throws ODataDeserializerException;
+}

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

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataReader.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataReader.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataReader.java
index 7e4aa96..4360cd8 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataReader.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataReader.java
@@ -30,7 +30,6 @@ import org.apache.olingo.client.api.domain.ClientServiceDocument;
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 
 /**
  * OData reader.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataSerializer.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataSerializer.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataSerializer.java
new file mode 100644
index 0000000..6d81981
--- /dev/null
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataSerializer.java
@@ -0,0 +1,33 @@
+/*
+ * 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.serialization;
+
+import java.io.Writer;
+
+import org.apache.olingo.commons.api.data.ResWrap;
+
+/**
+ * Interface for serialization.
+ */
+public interface ODataSerializer {
+
+  public <T> void write(final Writer writer, final T obj) throws ODataSerializerException;
+
+  public <T> void write(final Writer writer, final ResWrap<T> container) throws ODataSerializerException;
+}

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

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataWriter.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataWriter.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataWriter.java
index 5287c94..7b5dc5b 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataWriter.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataWriter.java
@@ -27,7 +27,6 @@ import org.apache.olingo.client.api.domain.ClientEntity;
 import org.apache.olingo.client.api.domain.ClientProperty;
 import org.apache.olingo.client.api.domain.ClientLink;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.serialization.ODataSerializerException;
 
 /**
  * OData writer.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/ODataClientImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/ODataClientImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/ODataClientImpl.java
index a934e3e..c490dae 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/ODataClientImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/ODataClientImpl.java
@@ -31,6 +31,7 @@ import org.apache.olingo.client.api.communication.request.retrieve.RetrieveReque
 import org.apache.olingo.client.api.serialization.ClientODataDeserializer;
 import org.apache.olingo.client.api.serialization.ODataBinder;
 import org.apache.olingo.client.api.serialization.ODataReader;
+import org.apache.olingo.client.api.serialization.ODataSerializer;
 import org.apache.olingo.client.api.serialization.ODataWriter;
 import org.apache.olingo.client.api.uri.FilterFactory;
 import org.apache.olingo.client.api.uri.SearchFactory;
@@ -41,7 +42,9 @@ import org.apache.olingo.client.core.communication.request.batch.BatchRequestFac
 import org.apache.olingo.client.core.communication.request.cud.CUDRequestFactoryImpl;
 import org.apache.olingo.client.core.communication.request.invoke.InvokeRequestFactoryImpl;
 import org.apache.olingo.client.core.communication.request.retrieve.RetrieveRequestFactoryImpl;
+import org.apache.olingo.client.core.serialization.AtomSerializer;
 import org.apache.olingo.client.core.serialization.ClientODataDeserializerImpl;
+import org.apache.olingo.client.core.serialization.JsonSerializer;
 import org.apache.olingo.client.core.serialization.ODataBinderImpl;
 import org.apache.olingo.client.core.serialization.ODataReaderImpl;
 import org.apache.olingo.client.core.serialization.ODataWriterImpl;
@@ -50,10 +53,7 @@ import org.apache.olingo.client.core.uri.URIBuilderImpl;
 import org.apache.olingo.client.api.domain.ClientObjectFactory;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.serialization.ODataSerializer;
 import org.apache.olingo.client.core.domain.ClientObjectFactoryImpl;
-import org.apache.olingo.commons.core.serialization.AtomSerializer;
-import org.apache.olingo.commons.core.serialization.JsonSerializer;
 
 public class ODataClientImpl implements ODataClient {
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/header/ODataErrorResponseChecker.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/header/ODataErrorResponseChecker.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/header/ODataErrorResponseChecker.java
index 2008149..e359e29 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/header/ODataErrorResponseChecker.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/header/ODataErrorResponseChecker.java
@@ -24,10 +24,10 @@ import org.apache.http.StatusLine;
 import org.apache.olingo.client.api.ODataClient;
 import org.apache.olingo.client.api.communication.ODataClientErrorException;
 import org.apache.olingo.client.api.communication.ODataServerErrorException;
+import org.apache.olingo.client.api.serialization.ODataDeserializerException;
 import org.apache.olingo.commons.api.ODataRuntimeException;
 import org.apache.olingo.commons.api.ODataError;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/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
index b2aba3d..424ff8f 100644
--- 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
@@ -34,10 +34,10 @@ import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.client.api.domain.ClientEntity;
+import org.apache.olingo.client.api.serialization.ODataDeserializerException;
+import org.apache.olingo.client.api.serialization.ODataSerializerException;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.http.HttpMethod;
-import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
-import org.apache.olingo.commons.api.serialization.ODataSerializerException;
 
 /**
  * This class implements an OData create request.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/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 195eaeb..44ff471 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
@@ -35,10 +35,10 @@ import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.client.api.domain.ClientEntity;
+import org.apache.olingo.client.api.serialization.ODataDeserializerException;
+import org.apache.olingo.client.api.serialization.ODataSerializerException;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.http.HttpMethod;
-import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
-import org.apache.olingo.commons.api.serialization.ODataSerializerException;
 
 /**
  * This class implements an OData update request.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/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
index a88652f..33ec73a 100644
--- 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
@@ -34,10 +34,10 @@ import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.client.api.domain.ClientProperty;
+import org.apache.olingo.client.api.serialization.ODataDeserializerException;
+import org.apache.olingo.client.api.serialization.ODataSerializerException;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.http.HttpMethod;
-import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
-import org.apache.olingo.commons.api.serialization.ODataSerializerException;
 
 /**
  * This class implements an OData update entity property request.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataReferenceAddingRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataReferenceAddingRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataReferenceAddingRequestImpl.java
index 477a91a..933f223 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataReferenceAddingRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataReferenceAddingRequestImpl.java
@@ -28,6 +28,7 @@ import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
 import org.apache.olingo.client.api.ODataClient;
 import org.apache.olingo.client.api.communication.request.cud.ODataReferenceAddingRequest;
 import org.apache.olingo.client.api.communication.response.ODataReferenceAddingResponse;
+import org.apache.olingo.client.api.serialization.ODataSerializerException;
 import org.apache.olingo.client.api.serialization.ODataWriter;
 import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
 import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
@@ -35,7 +36,6 @@ import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.http.HttpMethod;
-import org.apache.olingo.commons.api.serialization.ODataSerializerException;
 
 /**
  * See {@link ODataReferenceAddingRequest}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
index 5bd259c..29ad66e 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
@@ -35,6 +35,8 @@ import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequ
 import org.apache.olingo.client.api.communication.request.invoke.ClientNoContent;
 import org.apache.olingo.client.api.communication.response.ODataInvokeResponse;
 import org.apache.olingo.client.api.http.HttpClientException;
+import org.apache.olingo.client.api.serialization.ODataDeserializerException;
+import org.apache.olingo.client.api.serialization.ODataSerializerException;
 import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
 import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
 import org.apache.olingo.client.core.uri.URIUtils;
@@ -45,8 +47,6 @@ import org.apache.olingo.client.api.domain.ClientProperty;
 import org.apache.olingo.client.api.domain.ClientValue;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.http.HttpMethod;
-import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
-import org.apache.olingo.commons.api.serialization.ODataSerializerException;
 
 /**
  * This class implements an OData invoke operation request.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataDeltaRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataDeltaRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataDeltaRequestImpl.java
index 601e4ba..5eb4d84 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataDeltaRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataDeltaRequestImpl.java
@@ -27,11 +27,11 @@ import org.apache.olingo.client.api.ODataClient;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataDeltaRequest;
 import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
 import org.apache.olingo.client.api.http.HttpClientException;
+import org.apache.olingo.client.api.serialization.ODataDeserializerException;
 import org.apache.olingo.commons.api.data.Delta;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.client.api.domain.ClientDelta;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 
 public class ODataDeltaRequestImpl extends AbstractODataRetrieveRequest<ClientDelta>
     implements ODataDeltaRequest {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/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
index 57acf2a..d5a224f 100644
--- 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
@@ -28,8 +28,8 @@ import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.client.api.domain.ClientEntity;
+import org.apache.olingo.client.api.serialization.ODataDeserializerException;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 
 /**
  * This class implements an OData retrieve query request returning a single entity.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/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
index 620a88d..7e0164b 100644
--- 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
@@ -28,8 +28,8 @@ import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse
 import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.client.api.domain.ClientEntitySet;
+import org.apache.olingo.client.api.serialization.ODataDeserializerException;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 
 /**
  * This class implements an OData EntitySet query request.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataPropertyRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataPropertyRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataPropertyRequestImpl.java
index 36e9d0c..b5a3d10 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataPropertyRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataPropertyRequestImpl.java
@@ -27,11 +27,11 @@ import org.apache.olingo.client.api.ODataClient;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
 import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
 import org.apache.olingo.client.api.http.HttpClientException;
+import org.apache.olingo.client.api.serialization.ODataDeserializerException;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.client.api.domain.ClientProperty;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 
 /**
  * This class implements an OData entity property query request.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataRawRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataRawRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataRawRequestImpl.java
index 4c22c31..c29e7ee 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataRawRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataRawRequestImpl.java
@@ -28,12 +28,12 @@ import org.apache.http.client.HttpClient;
 import org.apache.olingo.client.api.ODataClient;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataRawRequest;
 import org.apache.olingo.client.api.communication.response.ODataRawResponse;
+import org.apache.olingo.client.api.serialization.ODataDeserializerException;
 import org.apache.olingo.client.core.communication.request.AbstractODataRequest;
 import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.http.HttpMethod;
-import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 
 /**
  * This class implements a generic OData request.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataServiceDocumentRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataServiceDocumentRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataServiceDocumentRequestImpl.java
index 363ba87..b4888f4 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataServiceDocumentRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataServiceDocumentRequestImpl.java
@@ -28,8 +28,8 @@ import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse
 import org.apache.olingo.client.api.data.ServiceDocument;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.client.api.domain.ClientServiceDocument;
+import org.apache.olingo.client.api.serialization.ODataDeserializerException;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 
 /**
  * This class implements an OData service document request.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityCreateRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityCreateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityCreateRequestImpl.java
index 175258b..1443f88 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityCreateRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityCreateRequestImpl.java
@@ -33,8 +33,8 @@ import org.apache.olingo.client.core.communication.response.AbstractODataRespons
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.client.api.domain.ClientEntity;
+import org.apache.olingo.client.api.serialization.ODataDeserializerException;
 import org.apache.olingo.commons.api.http.HttpMethod;
-import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 
 /**
  * This class implements an OData Media Entity create request. Get instance by using ODataStreamedRequestFactory.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityUpdateRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityUpdateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityUpdateRequestImpl.java
index d38533e..8c02eca 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityUpdateRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityUpdateRequestImpl.java
@@ -33,8 +33,8 @@ import org.apache.olingo.client.core.communication.response.AbstractODataRespons
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.client.api.domain.ClientEntity;
+import org.apache.olingo.client.api.serialization.ODataDeserializerException;
 import org.apache.olingo.commons.api.http.HttpMethod;
-import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 
 /**
  * This class implements an OData Media Entity create request. Get instance by using ODataStreamedRequestFactory.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/data/JSONServiceDocumentDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/JSONServiceDocumentDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/JSONServiceDocumentDeserializer.java
index e5bd7bd..9a95459 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/JSONServiceDocumentDeserializer.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/JSONServiceDocumentDeserializer.java
@@ -25,10 +25,10 @@ import java.util.Iterator;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.olingo.client.api.data.ServiceDocument;
+import org.apache.olingo.client.api.serialization.ODataDeserializerException;
+import org.apache.olingo.client.core.serialization.JsonDeserializer;
 import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
-import org.apache.olingo.commons.core.serialization.JsonDeserializer;
 
 import com.fasterxml.jackson.core.JsonFactory;
 import com.fasterxml.jackson.core.JsonParser;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/data/XMLServiceDocumentDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/XMLServiceDocumentDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/XMLServiceDocumentDeserializer.java
index 0b37722..2e9064c 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/XMLServiceDocumentDeserializer.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/XMLServiceDocumentDeserializer.java
@@ -23,10 +23,10 @@ import java.io.InputStream;
 import java.net.URI;
 
 import org.apache.olingo.client.api.data.ServiceDocument;
+import org.apache.olingo.client.api.serialization.ODataDeserializerException;
+import org.apache.olingo.client.core.serialization.JsonDeserializer;
 import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
-import org.apache.olingo.commons.core.serialization.JsonDeserializer;
 
 import com.fasterxml.jackson.core.JsonParser;
 import com.fasterxml.jackson.core.JsonToken;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AbstractAtomDealer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AbstractAtomDealer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AbstractAtomDealer.java
new file mode 100644
index 0000000..242ef31
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AbstractAtomDealer.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.serialization;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.Constants;
+
+abstract class AbstractAtomDealer {
+
+  protected static final String TYPE_TEXT = "text";
+
+  protected final String namespaceMetadata;
+  protected final String namespaceData;
+
+  protected final QName etagQName;
+  protected final QName metadataEtagQName;
+  protected final QName inlineQName;
+  protected final QName actionQName;
+  protected final QName propertiesQName;
+  protected final QName typeQName;
+  protected final QName nullQName;
+  protected final QName elementQName;
+  protected final QName countQName;
+  protected final QName uriQName;
+  protected final QName nextQName;
+  protected final QName annotationQName;
+  protected final QName contextQName;
+  protected final QName entryRefQName;
+  protected final QName propertyValueQName;
+  protected final QName deletedEntryQName;
+  protected final QName reasonQName;
+  protected final QName linkQName;
+  protected final QName deletedLinkQName;
+  protected final QName errorCodeQName;
+  protected final QName errorMessageQName;
+  protected final QName errorTargetQName;
+
+  public AbstractAtomDealer() {
+    namespaceMetadata = Constants.NS_METADATA;
+    namespaceData = Constants.NS_DATASERVICES;
+
+    etagQName = new QName(namespaceMetadata, Constants.ATOM_ATTR_ETAG);
+    metadataEtagQName = new QName(namespaceMetadata, Constants.ATOM_ATTR_METADATAETAG);
+    inlineQName = new QName(namespaceMetadata, Constants.ATOM_ELEM_INLINE);
+    actionQName = new QName(namespaceMetadata, Constants.ATOM_ELEM_ACTION);
+    propertiesQName = new QName(namespaceMetadata, Constants.PROPERTIES);
+    typeQName = new QName(namespaceMetadata, Constants.ATTR_TYPE);
+    nullQName = new QName(namespaceMetadata, Constants.ATTR_NULL);
+    elementQName = new QName(namespaceMetadata, Constants.ELEM_ELEMENT);
+    countQName = new QName(namespaceMetadata, Constants.ATOM_ELEM_COUNT);
+    uriQName = new QName(namespaceData, Constants.ELEM_URI);
+    nextQName = new QName(namespaceData, Constants.NEXT_LINK_REL);
+    annotationQName = new QName(namespaceMetadata, Constants.ANNOTATION);
+    contextQName = new QName(namespaceMetadata, Constants.CONTEXT);
+    entryRefQName = new QName(namespaceMetadata, Constants.ATOM_ELEM_ENTRY_REF);
+    propertyValueQName = new QName(namespaceMetadata, Constants.VALUE);
+
+    deletedEntryQName = new QName(Constants.NS_ATOM_TOMBSTONE, Constants.ATOM_ELEM_DELETED_ENTRY);
+    reasonQName = new QName(namespaceMetadata, Constants.ELEM_REASON);
+    linkQName = new QName(namespaceMetadata, Constants.ATOM_ELEM_LINK);
+    deletedLinkQName = new QName(namespaceMetadata, Constants.ELEM_DELETED_LINK);
+
+    errorCodeQName = new QName(namespaceMetadata, Constants.ERROR_CODE);
+    errorMessageQName = new QName(namespaceMetadata, Constants.ERROR_MESSAGE);
+    errorTargetQName = new QName(namespaceMetadata, Constants.ERROR_TARGET);
+  }
+
+  protected void namespaces(final XMLStreamWriter writer) throws XMLStreamException {
+    writer.writeNamespace(StringUtils.EMPTY, Constants.NS_ATOM);
+    writer.writeNamespace(XMLConstants.XML_NS_PREFIX, XMLConstants.XML_NS_URI);
+    writer.writeNamespace(Constants.PREFIX_METADATA, Constants.NS_METADATA);
+    writer.writeNamespace(Constants.PREFIX_DATASERVICES, Constants.NS_DATASERVICES);
+    writer.writeNamespace(Constants.PREFIX_GML, Constants.NS_GML);
+    writer.writeNamespace(Constants.PREFIX_GEORSS, Constants.NS_GEORSS);
+  }
+}


[38/39] olingo-odata4 git commit: Merge branch 'master' into ieee

Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java
index 8a84d95,e953cae..926f74c
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java
@@@ -49,29 -69,6 +69,10 @@@ import org.apache.olingo.client.api.dom
  import org.apache.olingo.client.api.domain.ClientServiceDocument;
  import org.apache.olingo.client.api.domain.ClientValuable;
  import org.apache.olingo.client.api.domain.ClientValue;
- import org.apache.olingo.client.api.serialization.ODataBinder;
 +import org.apache.olingo.client.core.domain.ClientAnnotationImpl;
 +import org.apache.olingo.client.core.domain.ClientDeletedEntityImpl;
 +import org.apache.olingo.client.core.domain.ClientDeltaLinkImpl;
 +import org.apache.olingo.client.core.domain.ClientPropertyImpl;
- import org.apache.olingo.client.core.uri.URIUtils;
- import org.apache.olingo.commons.api.Constants;
- import org.apache.olingo.commons.api.data.Annotatable;
- import org.apache.olingo.commons.api.data.Annotation;
- import org.apache.olingo.commons.api.data.ComplexValue;
- import org.apache.olingo.commons.api.data.ContextURL;
- import org.apache.olingo.commons.api.data.DeletedEntity;
- import org.apache.olingo.commons.api.data.Delta;
- import org.apache.olingo.commons.api.data.DeltaLink;
- import org.apache.olingo.commons.api.data.Entity;
- import org.apache.olingo.commons.api.data.EntityCollection;
- import org.apache.olingo.commons.api.data.Link;
- import org.apache.olingo.commons.api.data.Linked;
- import org.apache.olingo.commons.api.data.Operation;
- import org.apache.olingo.commons.api.data.Property;
- import org.apache.olingo.commons.api.data.ResWrap;
- import org.apache.olingo.commons.api.data.Valuable;
- import org.apache.olingo.commons.api.data.ValueType;
  import org.apache.olingo.commons.api.edm.Edm;
  import org.apache.olingo.commons.api.edm.EdmBindingTarget;
  import org.apache.olingo.commons.api.edm.EdmComplexType;
@@@ -90,11 -87,13 +91,9 @@@ import org.apache.olingo.commons.api.ed
  import org.apache.olingo.commons.api.edm.EdmType;
  import org.apache.olingo.commons.api.edm.FullQualifiedName;
  import org.apache.olingo.commons.api.edm.geo.Geospatial;
 -import org.apache.olingo.commons.api.format.ODataFormat;
 -import org.apache.olingo.client.core.domain.ClientAnnotationImpl;
 -import org.apache.olingo.client.core.domain.ClientDeletedEntityImpl;
 -import org.apache.olingo.client.core.domain.ClientDeltaLinkImpl;
 -import org.apache.olingo.client.core.domain.ClientPropertyImpl;
 -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
 +import org.apache.olingo.commons.api.format.ContentType;
- import org.apache.olingo.commons.api.serialization.ODataSerializerException;
  import org.apache.olingo.commons.core.edm.EdmTypeInfo;
 +import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
- import org.apache.olingo.commons.core.serialization.ContextURLParser;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java
index 17436e9,6153cdb..aba9357
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java
@@@ -25,16 -25,11 +25,17 @@@ import java.util.Map
  import org.apache.commons.io.IOUtils;
  import org.apache.olingo.client.api.ODataClient;
  import org.apache.olingo.client.api.data.ServiceDocument;
 +import org.apache.olingo.client.api.domain.ClientEntity;
 +import org.apache.olingo.client.api.domain.ClientEntitySet;
  import org.apache.olingo.client.api.domain.ClientEntitySetIterator;
 +import org.apache.olingo.client.api.domain.ClientProperty;
 +import org.apache.olingo.client.api.domain.ClientServiceDocument;
 +import org.apache.olingo.client.api.domain.ClientValue;
  import org.apache.olingo.client.api.edm.xml.XMLMetadata;
+ import org.apache.olingo.client.api.serialization.ODataDeserializerException;
  import org.apache.olingo.client.api.serialization.ODataReader;
  import org.apache.olingo.client.core.edm.ClientCsdlEdmProvider;
 +import org.apache.olingo.commons.api.ODataError;
  import org.apache.olingo.commons.api.data.Entity;
  import org.apache.olingo.commons.api.data.EntityCollection;
  import org.apache.olingo.commons.api.data.Property;
@@@ -42,8 -37,13 +43,7 @@@ import org.apache.olingo.commons.api.da
  import org.apache.olingo.commons.api.edm.Edm;
  import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
  import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
 -import org.apache.olingo.commons.api.format.ODataFormat;
 +import org.apache.olingo.commons.api.format.ContentType;
- import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
  import org.apache.olingo.commons.core.edm.EdmProviderImpl;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataWriterImpl.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataWriterImpl.java
index fe93cb1,584c420..88a433f
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataWriterImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataWriterImpl.java
@@@ -32,11 -32,11 +32,11 @@@ import org.apache.olingo.client.api.ODa
  import org.apache.olingo.client.api.domain.ClientEntity;
  import org.apache.olingo.client.api.domain.ClientLink;
  import org.apache.olingo.client.api.domain.ClientProperty;
 -import org.apache.olingo.commons.api.format.ODataFormat;
 +import org.apache.olingo.client.api.serialization.ODataWriter;
 +import org.apache.olingo.commons.api.Constants;
 +import org.apache.olingo.commons.api.data.ResWrap;
 +import org.apache.olingo.commons.api.format.ContentType;
- import org.apache.olingo.commons.api.serialization.ODataSerializerException;
++import org.apache.olingo.client.api.serialization.ODataSerializerException;
  
  public class ODataWriterImpl implements ODataWriter {
  

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntitySetTest.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntitySetTest.java
index e64d158,d3746e1..50af30f
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntitySetTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntitySetTest.java
@@@ -32,10 -22,20 +32,10 @@@ import org.apache.olingo.client.api.dom
  import org.apache.olingo.client.core.AbstractTest;
  import org.apache.olingo.commons.api.data.EntityCollection;
  import org.apache.olingo.commons.api.data.ResWrap;
 -import org.apache.olingo.client.api.domain.ClientEntity;
 -import org.apache.olingo.client.api.domain.ClientEntitySet;
 +import org.apache.olingo.commons.api.format.ContentType;
- import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+ import org.apache.olingo.client.api.serialization.ODataDeserializerException;
 -import org.apache.olingo.commons.api.format.ODataFormat;
  import org.junit.Test;
  
 -import java.io.IOException;
 -import java.io.InputStream;
 -import java.net.URI;
 -
 -import static org.junit.Assert.assertEquals;
 -import static org.junit.Assert.assertNotNull;
 -import static org.junit.Assert.assertNull;
 -
  public class EntitySetTest extends AbstractTest {
  
    @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ErrorTest.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ErrorTest.java
index 7fd7c45,93b43df..217f1d1
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ErrorTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ErrorTest.java
@@@ -18,16 -18,16 +18,16 @@@
   */
  package org.apache.olingo.client.core.v4;
  
 +import static org.junit.Assert.assertEquals;
 +import static org.junit.Assert.assertNotNull;
 +
  import org.apache.olingo.client.api.ODataClient;
+ import org.apache.olingo.client.api.serialization.ODataDeserializerException;
  import org.apache.olingo.client.core.AbstractTest;
  import org.apache.olingo.commons.api.ODataError;
 -import org.apache.olingo.commons.api.format.ODataFormat;
 +import org.apache.olingo.commons.api.format.ContentType;
- import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
  import org.junit.Test;
  
 -import static org.junit.Assert.assertEquals;
 -import static org.junit.Assert.assertNotNull;
 -
  public class ErrorTest extends AbstractTest {
  
    @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PropertyTest.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PropertyTest.java
index 73ae7f1,b0423e7..0ee5471
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PropertyTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PropertyTest.java
@@@ -30,12 -24,18 +30,12 @@@ import org.apache.olingo.client.api.dom
  import org.apache.olingo.client.api.domain.ClientComplexValue;
  import org.apache.olingo.client.api.domain.ClientProperty;
  import org.apache.olingo.client.api.domain.ClientValue;
 +import org.apache.olingo.client.core.AbstractTest;
 +import org.apache.olingo.commons.api.format.ContentType;
- import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
- import org.apache.olingo.commons.api.serialization.ODataSerializerException;
+ import org.apache.olingo.client.api.serialization.ODataDeserializerException;
+ import org.apache.olingo.client.api.serialization.ODataSerializerException;
 -import org.apache.olingo.commons.api.format.ODataFormat;
  import org.junit.Test;
  
 -import java.io.InputStream;
 -import java.util.Iterator;
 -
 -import static org.junit.Assert.assertEquals;
 -import static org.junit.Assert.assertNotNull;
 -import static org.junit.Assert.assertTrue;
 -
  public class PropertyTest extends AbstractTest {
  
    @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ServiceDocumentTest.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ServiceDocumentTest.java
index 97f6d81,b0a769f..008b165
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ServiceDocumentTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ServiceDocumentTest.java
@@@ -18,21 -18,21 +18,21 @@@
   */
  package org.apache.olingo.client.core.v4;
  
 +import static org.junit.Assert.assertEquals;
 +import static org.junit.Assert.assertNotNull;
 +import static org.junit.Assert.assertTrue;
 +
 +import java.net.URI;
 +
  import org.apache.olingo.client.api.ODataClient;
  import org.apache.olingo.client.api.data.ServiceDocument;
 +import org.apache.olingo.client.api.domain.ClientServiceDocument;
  import org.apache.olingo.client.core.AbstractTest;
  import org.apache.olingo.commons.api.data.ResWrap;
 -import org.apache.olingo.client.api.domain.ClientServiceDocument;
 +import org.apache.olingo.commons.api.format.ContentType;
- import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+ import org.apache.olingo.client.api.serialization.ODataDeserializerException;
 -import org.apache.olingo.commons.api.format.ODataFormat;
  import org.junit.Test;
  
 -import java.net.URI;
 -
 -import static org.junit.Assert.assertEquals;
 -import static org.junit.Assert.assertNotNull;
 -import static org.junit.Assert.assertTrue;
 -
  public class ServiceDocumentTest extends AbstractTest {
  
    @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalActionProcessor.java
----------------------------------------------------------------------
diff --cc lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalActionProcessor.java
index 1e038b2,d7fc00f..663a7eb
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalActionProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalActionProcessor.java
@@@ -77,8 -80,9 +79,8 @@@ public class TechnicalActionProcessor e
      final EdmAction action = ((UriResourceAction) uriInfo.asUriInfoResource().getUriResourceParts().get(0))
          .getAction();
  
-     DeserializerResult deserializerResult = 
+     DeserializerResult deserializerResult =
 -        odata.createDeserializer(ODataFormat.fromContentType(requestFormat))
 -            .actionParameters(request.getBody(), action);
 +        odata.createDeserializer(requestFormat).actionParameters(request.getBody(), action);
  
      EntityCollection collection =
          dataProvider.processActionEntityCollection(action.getName(), deserializerResult.getActionParameters());
@@@ -90,15 -94,26 +92,25 @@@
        throw new ODataApplicationException("The action could not be executed.",
            HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), Locale.ROOT);
      }
-     final EdmEntitySet edmEntitySet = getEdmEntitySet(uriInfo.asUriInfoResource());
-     final EdmEntityType type = (EdmEntityType) action.getReturnType().getType();
-     EntityCollectionSerializerOptions options = EntityCollectionSerializerOptions.with()
-         .contextURL(isODataMetadataNone(responseFormat) ? null : 
-           getContextUrl(edmEntitySet, type, false)).build();
-     response.setContent(odata.createSerializer(requestFormat)
-         .entityCollection(serviceMetadata, type, collection, options).getContent());
-     response.setStatusCode(HttpStatusCode.OK.getStatusCode());
-     response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+ 
+     final Return returnPreference = odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).getReturn();
+     if (returnPreference == null || returnPreference == Return.REPRESENTATION) {
+       final EdmEntitySet edmEntitySet = getEdmEntitySet(uriInfo.asUriInfoResource());
+       final EdmEntityType type = (EdmEntityType) action.getReturnType().getType();
 -      final ODataFormat format = ODataFormat.fromContentType(responseFormat);
+       final EntityCollectionSerializerOptions options = EntityCollectionSerializerOptions.with()
 -          .contextURL(format == ODataFormat.JSON_NO_METADATA ? null : getContextUrl(edmEntitySet, type, false))
++          .contextURL(isODataMetadataNone(responseFormat) ? null : getContextUrl(edmEntitySet, type, false))
+           .build();
 -      response.setContent(odata.createSerializer(format)
++      response.setContent(odata.createSerializer(responseFormat)
+           .entityCollection(serviceMetadata, type, collection, options).getContent());
+       response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+       response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+     } else {
+       response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
+     }
+     if (returnPreference != null) {
+       response.setHeader(HttpHeader.PREFERENCE_APPLIED,
+           PreferencesApplied.with().returnRepresentation(returnPreference).build().toValueString());
+     }
    }
  
    @Override
@@@ -125,17 -141,32 +137,31 @@@
              HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), Locale.ROOT);
        }
      } else {
-       response.setContent(odata.createSerializer(requestFormat).entity(
-           serviceMetadata,
-           type,
-           entityResult.getEntity(),
-           EntitySerializerOptions.with()
-               .contextURL(isODataMetadataNone(responseFormat) ? null : 
-                 getContextUrl(edmEntitySet, type, true)).build())
-           .getContent());
-       response.setStatusCode((entityResult.isCreated() ? HttpStatusCode.CREATED : HttpStatusCode.OK)
-           .getStatusCode());
-       response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+       final Return returnPreference = odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).getReturn();
+       if (returnPreference == null || returnPreference == Return.REPRESENTATION) {
 -        final ODataFormat format = ODataFormat.fromContentType(responseFormat);
 -        response.setContent(odata.createSerializer(format).entity(
++        response.setContent(odata.createSerializer(responseFormat).entity(
+             serviceMetadata,
+             type,
+             entityResult.getEntity(),
+             EntitySerializerOptions.with()
 -                .contextURL(format == ODataFormat.JSON_NO_METADATA ? null : getContextUrl(edmEntitySet, type, true))
++                .contextURL(isODataMetadataNone(responseFormat) ? null : getContextUrl(edmEntitySet, type, true))
+                 .build())
+             .getContent());
+         response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+         response.setStatusCode((entityResult.isCreated() ? HttpStatusCode.CREATED : HttpStatusCode.OK)
+             .getStatusCode());
+       } else {
+         response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
+       }
+       if (returnPreference != null) {
+         response.setHeader(HttpHeader.PREFERENCE_APPLIED,
+             PreferencesApplied.with().returnRepresentation(returnPreference).build().toValueString());
+       }
+       if (entityResult.isCreated()) {
+         response.setHeader(HttpHeader.LOCATION,
+             request.getRawBaseUri() + '/'
 -            + odata.createUriHelper().buildCanonicalURL(edmEntitySet, entityResult.getEntity()));
++                + odata.createUriHelper().buildCanonicalURL(edmEntitySet, entityResult.getEntity()));
+       }
        if (entityResult.getEntity().getETag() != null) {
          response.setHeader(HttpHeader.ETAG, entityResult.getEntity().getETag());
        }
@@@ -164,16 -196,25 +190,24 @@@
        throw new ODataApplicationException("The action could not be executed.",
            HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), Locale.ROOT);
      }
-     EdmPrimitiveType type = (EdmPrimitiveType) action.getReturnType().getType();
-     ContextURL contextURL = ContextURL.with().type(type).asCollection().build();
-     PrimitiveSerializerOptions options = PrimitiveSerializerOptions.with().contextURL(contextURL).build();
- 
-     SerializerResult result =
-         odata.createSerializer(requestFormat).primitiveCollection(serviceMetadata, type, property, options);
  
-     response.setStatusCode(HttpStatusCode.OK.getStatusCode());
-     response.setContent(result.getContent());
-     response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+     final Return returnPreference = odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).getReturn();
+     if (returnPreference == null || returnPreference == Return.REPRESENTATION) {
+       final EdmPrimitiveType type = (EdmPrimitiveType) action.getReturnType().getType();
+       final ContextURL contextURL = ContextURL.with().type(type).asCollection().build();
+       final PrimitiveSerializerOptions options = PrimitiveSerializerOptions.with().contextURL(contextURL).build();
+       final SerializerResult result =
 -          odata.createSerializer(ODataFormat.fromContentType(responseFormat))
 -              .primitiveCollection(serviceMetadata, type, property, options);
++          odata.createSerializer(responseFormat).primitiveCollection(serviceMetadata, type, property, options);
+       response.setContent(result.getContent());
+       response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+       response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+     } else {
+       response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
+     }
+     if (returnPreference != null) {
+       response.setHeader(HttpHeader.PREFERENCE_APPLIED,
+           PreferencesApplied.with().returnRepresentation(returnPreference).build().toValueString());
+     }
    }
  
    @Override
@@@ -197,15 -239,22 +231,22 @@@
              HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), Locale.ROOT);
        }
      } else {
-       ContextURL contextURL = ContextURL.with().type(type).build();
-       PrimitiveSerializerOptions options = PrimitiveSerializerOptions.with().contextURL(contextURL).build();
- 
-       SerializerResult result = odata.createSerializer(requestFormat)
-                                      .primitive(serviceMetadata, type, property, options);
- 
-       response.setStatusCode(HttpStatusCode.OK.getStatusCode());
-       response.setContent(result.getContent());
-       response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+       final Return returnPreference = odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).getReturn();
+       if (returnPreference == null || returnPreference == Return.REPRESENTATION) {
+         final ContextURL contextURL = ContextURL.with().type(type).build();
+         final PrimitiveSerializerOptions options = PrimitiveSerializerOptions.with().contextURL(contextURL).build();
 -        final SerializerResult result = odata.createSerializer(ODataFormat.fromContentType(responseFormat))
++        final SerializerResult result = odata.createSerializer(responseFormat)
+             .primitive(serviceMetadata, type, property, options);
+         response.setContent(result.getContent());
+         response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+         response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+       } else {
+         response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
+       }
+       if (returnPreference != null) {
+         response.setHeader(HttpHeader.PREFERENCE_APPLIED,
+             PreferencesApplied.with().returnRepresentation(returnPreference).build().toValueString());
+       }
      }
    }
  
@@@ -231,16 -281,25 +272,23 @@@
        throw new ODataApplicationException("The action could not be executed.",
            HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), Locale.ROOT);
      }
-     EdmComplexType type = (EdmComplexType) action.getReturnType().getType();
-     ContextURL contextURL = ContextURL.with().type(type).asCollection().build();
-     ComplexSerializerOptions options = ComplexSerializerOptions.with().contextURL(contextURL).build();
- 
-     SerializerResult result =
-         odata.createSerializer(requestFormat).complexCollection(serviceMetadata, type, property, options);
--
-     response.setStatusCode(HttpStatusCode.OK.getStatusCode());
-     response.setContent(result.getContent());
-     response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+     final Return returnPreference = odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).getReturn();
+     if (returnPreference == null || returnPreference == Return.REPRESENTATION) {
+       final EdmComplexType type = (EdmComplexType) action.getReturnType().getType();
+       final ContextURL contextURL = ContextURL.with().type(type).asCollection().build();
+       final ComplexSerializerOptions options = ComplexSerializerOptions.with().contextURL(contextURL).build();
+       final SerializerResult result =
 -          odata.createSerializer(ODataFormat.fromContentType(responseFormat)).complexCollection(serviceMetadata, type,
 -              property, options);
++          odata.createSerializer(responseFormat).complexCollection(serviceMetadata, type, property, options);
+       response.setContent(result.getContent());
+       response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+       response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+     } else {
+       response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
+     }
+     if (returnPreference != null) {
+       response.setHeader(HttpHeader.PREFERENCE_APPLIED,
+           PreferencesApplied.with().returnRepresentation(returnPreference).build().toValueString());
+     }
    }
  
    @Override
@@@ -264,12 -324,23 +312,22 @@@
              HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), Locale.ROOT);
        }
      } else {
-       ContextURL contextURL = ContextURL.with().type(type).build();
-       ComplexSerializerOptions options = ComplexSerializerOptions.with().contextURL(contextURL).build();
-       SerializerResult result = odata.createSerializer(requestFormat).complex(serviceMetadata, type, property, options);
-       response.setStatusCode(HttpStatusCode.OK.getStatusCode());
-       response.setContent(result.getContent());
-       response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+       final Return returnPreference = odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).getReturn();
+       if (returnPreference == null || returnPreference == Return.REPRESENTATION) {
+         final ContextURL contextURL = ContextURL.with().type(type).build();
+         final ComplexSerializerOptions options = ComplexSerializerOptions.with().contextURL(contextURL).build();
+         final SerializerResult result =
 -            odata.createSerializer(ODataFormat.fromContentType(responseFormat)).complex(serviceMetadata, type, property,
 -                options);
++            odata.createSerializer(responseFormat).complex(serviceMetadata, type, property, options);
+         response.setContent(result.getContent());
+         response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+         response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+       } else {
+         response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
+       }
+       if (returnPreference != null) {
+         response.setHeader(HttpHeader.PREFERENCE_APPLIED,
+             PreferencesApplied.with().returnRepresentation(returnPreference).build().toValueString());
+       }
      }
    }
  

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
----------------------------------------------------------------------
diff --cc lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
index f86646d,807c815..9844d71
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
@@@ -162,10 -164,20 +164,19 @@@ public class TechnicalEntityProcessor e
        expand = deserializerResult.getExpandTree();
      }
  
-     response.setContent(serializeEntity(entity, edmEntitySet, edmEntityType, responseFormat, expand, null)
-         .getContent());
-     response.setStatusCode(HttpStatusCode.CREATED.getStatusCode());
-     response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+     final Return returnPreference = odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).getReturn();
+     if (returnPreference == null || returnPreference == Return.REPRESENTATION) {
 -      final ODataFormat format = ODataFormat.fromContentType(responseFormat);
 -      response.setContent(serializeEntity(entity, edmEntitySet, edmEntityType, format, expand, null)
++      response.setContent(serializeEntity(entity, edmEntitySet, edmEntityType, responseFormat, expand, null)
+           .getContent());
+       response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+       response.setStatusCode(HttpStatusCode.CREATED.getStatusCode());
+     } else {
+       response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
+     }
+     if (returnPreference != null) {
+       response.setHeader(HttpHeader.PREFERENCE_APPLIED,
+           PreferencesApplied.with().returnRepresentation(returnPreference).build().toValueString());
+     }
      response.setHeader(HttpHeader.LOCATION,
          request.getRawBaseUri() + '/' + odata.createUriHelper().buildCanonicalURL(edmEntitySet, entity));
      if (entity.getETag() != null) {
@@@ -208,10 -220,20 +219,19 @@@
      dataProvider.update(request.getRawBaseUri(), edmEntitySet, entity, changedEntity,
          request.getMethod() == HttpMethod.PATCH, false);
  
-     response.setStatusCode(HttpStatusCode.OK.getStatusCode());
-     response.setContent(serializeEntity(entity, edmEntitySet, edmEntityType, responseFormat, null, null)
-         .getContent());
-     response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+     final Return returnPreference = odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).getReturn();
+     if (returnPreference == null || returnPreference == Return.REPRESENTATION) {
+       response.setStatusCode(HttpStatusCode.OK.getStatusCode());
 -      final ODataFormat format = ODataFormat.fromContentType(responseFormat);
 -      response.setContent(serializeEntity(entity, edmEntitySet, edmEntityType, format, null, null)
++      response.setContent(serializeEntity(entity, edmEntitySet, edmEntityType, responseFormat, null, null)
+           .getContent());
+       response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+     } else {
+       response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
+     }
+     if (returnPreference != null) {
+       response.setHeader(HttpHeader.PREFERENCE_APPLIED,
+           PreferencesApplied.with().returnRepresentation(returnPreference).build().toValueString());
+     }
      if (entity.getETag() != null) {
        response.setHeader(HttpHeader.ETAG, entity.getETag());
      }
@@@ -232,10 -254,20 +252,19 @@@
      dataProvider.setMedia(entity, odata.createFixedFormatDeserializer().binary(request.getBody()),
          requestFormat.toContentTypeString());
  
-     response.setContent(serializeEntity(entity, edmEntitySet, edmEntityType, responseFormat, null, null)
-         .getContent());
-     response.setStatusCode(HttpStatusCode.OK.getStatusCode());
-     response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+     final Return returnPreference = odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).getReturn();
+     if (returnPreference == null || returnPreference == Return.REPRESENTATION) {
 -      final ODataFormat format = ODataFormat.fromContentType(responseFormat);
 -      response.setContent(serializeEntity(entity, edmEntitySet, edmEntityType, format, null, null)
++      response.setContent(serializeEntity(entity, edmEntitySet, edmEntityType, responseFormat, null, null)
+           .getContent());
+       response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+       response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+     } else {
+       response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
+     }
+     if (returnPreference != null) {
+       response.setHeader(HttpHeader.PREFERENCE_APPLIED,
+           PreferencesApplied.with().returnRepresentation(returnPreference).build().toValueString());
+     }
      if (entity.getETag() != null) {
        response.setHeader(HttpHeader.ETAG, entity.getETag());
      }
@@@ -410,12 -443,15 +439,14 @@@
      SkipHandler.applySkipSystemQueryHandler(uriInfo.getSkipOption(), entitySet);
      TopHandler.applyTopSystemQueryOption(uriInfo.getTopOption(), entitySet);
  
-     ServerSidePagingHandler.applyServerSidePaging(uriInfo.getSkipTokenOption(),
+     final Integer pageSize = odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).getMaxPageSize();
+     final Integer serverPageSize = ServerSidePagingHandler.applyServerSidePaging(uriInfo.getSkipTokenOption(),
          entitySet,
          edmEntitySet,
-         request.getRawRequestUri());
+         request.getRawRequestUri(),
+         pageSize);
  
      // Apply expand system query option
 -    final ODataFormat format = ODataFormat.fromContentType(requestedContentType);
      final ExpandOption expand = uriInfo.getExpandOption();
      final SelectOption select = uriInfo.getSelectOption();
  

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
----------------------------------------------------------------------
diff --cc lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
index 7a31f84,4d1e834..cf4b38e
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
@@@ -303,16 -307,26 +305,25 @@@ public class TechnicalPrimitiveComplexP
  
      dataProvider.updateETag(entity);
  
-     response.setStatusCode(HttpStatusCode.OK.getStatusCode());
-     if (representationType == RepresentationType.VALUE) {
-       response.setContent(
-           serializePrimitiveValue(property, edmProperty, (EdmPrimitiveType) edmProperty.getType(), null));
+     final Return returnPreference = odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).getReturn();
+     if (returnPreference == null || returnPreference == Return.REPRESENTATION) {
+       response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+       if (representationType == RepresentationType.VALUE) {
+         response.setContent(
+             serializePrimitiveValue(property, edmProperty, (EdmPrimitiveType) edmProperty.getType(), null));
+       } else {
 -        final ODataFormat format = ODataFormat.fromContentType(responseFormat);
+         final SerializerResult result = serializeProperty(entity, edmEntitySet, path, property, edmProperty,
 -            edmProperty.getType(), null, representationType, format, null, null);
++            edmProperty.getType(), null, representationType, responseFormat, null, null);
+         response.setContent(result.getContent());
+       }
+       response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
      } else {
-       final SerializerResult result = serializeProperty(entity, edmEntitySet, path, property, edmProperty,
-           edmProperty.getType(), null, representationType, responseFormat, null, null);
-       response.setContent(result.getContent());
+       response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
+     }
+     if (returnPreference != null) {
+       response.setHeader(HttpHeader.PREFERENCE_APPLIED,
+           PreferencesApplied.with().returnRepresentation(returnPreference).build().toValueString());
      }
-     response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
      if (entity.getETag() != null) {
        response.setHeader(HttpHeader.ETAG, entity.getETag());
      }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
----------------------------------------------------------------------
diff --cc lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
index c9a5f32,ec5a33d..a3f75eb
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
@@@ -726,16 -708,13 +707,13 @@@ public class ODataHandlerTest 
      request.setRawODataPath(path);
      request.setRawQueryPath(query);
  
-     if (headers != null) {
-       Set<Map.Entry<String, List<String>>> headerSet = headers.entrySet();
-       for (Map.Entry<String, List<String>> headerItem : headerSet) {
-         request.addHeader(headerItem.getKey(), headerItem.getValue());
-       }
+     if (headerName != null) {
+       request.addHeader(headerName, Collections.singletonList(headerValue));
      }
  
-     if (request.getHeaders(HttpHeader.CONTENT_TYPE) == null) {
+     if (headerName != HttpHeader.CONTENT_TYPE) {
        request.addHeader(HttpHeader.CONTENT_TYPE, Collections.singletonList(
 -          ODataFormat.JSON.getContentType().toContentTypeString()));
 +          ContentType.JSON.toContentTypeString()));
      }
  
      final OData odata = OData.newInstance();


[37/39] olingo-odata4 git commit: [OLINGO-695] Merge branch 'master' into OLINGO-695_OSGi-Support

Posted by ch...@apache.org.
[OLINGO-695] Merge branch 'master' into OLINGO-695_OSGi-Support


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

Branch: refs/heads/IEE754Compatible
Commit: a4288fca259ceab92dfee59cafa2d7256e646a55
Parents: 85cd907 a3fbf39
Author: Michael Bolz <mi...@sap.com>
Authored: Tue Jun 23 15:49:40 2015 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Tue Jun 23 15:49:40 2015 +0200

----------------------------------------------------------------------
 fit/pom.xml                                     |   2 +-
 .../fit/tecsvc/client/ConditionalITCase.java    |  30 +++++
 .../olingo/server/core/ODataDispatcher.java     |  59 +++++----
 .../core/etag/PreconditionsValidator.java       |  49 +++-----
 .../processor/TechnicalEntityProcessor.java     |   8 +-
 .../tecsvc/provider/EntityTypeProvider.java     |   2 +-
 .../tecsvc/provider/PropertyProvider.java       |   4 +-
 .../server/core/PreconditionsValidatorTest.java | 126 +++++++++----------
 pom.xml                                         |   1 +
 9 files changed, 147 insertions(+), 134 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a4288fca/pom.xml
----------------------------------------------------------------------


[31/39] olingo-odata4 git commit: [OLINGO-659] fix for URI parser to disallow anything after actions

Posted by ch...@apache.org.
[OLINGO-659] fix for URI parser to disallow anything after actions

Change-Id: I578ee4562d13b220cec7fb05f1b6c9d69c0b25e4

Signed-off-by: Christian Amend <ch...@sap.com>


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

Branch: refs/heads/IEE754Compatible
Commit: fd513e22f1d1a63f014702e3b07b929bdece707f
Parents: 971deb5
Author: Klaus Straubinger <kl...@sap.com>
Authored: Fri Jun 19 11:17:38 2015 +0200
Committer: Christian Amend <ch...@sap.com>
Committed: Fri Jun 19 13:05:28 2015 +0200

----------------------------------------------------------------------
 .../server/core/uri/UriResourceActionImpl.java  | 13 +++++++++++--
 .../server/core/uri/UriResourceTypedImpl.java   |  8 +-------
 .../uri/queryoption/expression/MemberImpl.java  |  5 +++++
 .../server/core/PreconditionsValidatorTest.java |  2 --
 .../core/uri/antlr/TestFullResourcePath.java    | 12 ++++++++++++
 .../core/uri/antlr/TestUriParserImpl.java       |  2 +-
 .../queryoption/expression/ExpressionTest.java  | 20 +++++++++++---------
 7 files changed, 41 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fd513e22/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceActionImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceActionImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceActionImpl.java
index a78d79f..6acb6ea 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceActionImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceActionImpl.java
@@ -24,7 +24,12 @@ import org.apache.olingo.commons.api.edm.EdmType;
 import org.apache.olingo.server.api.uri.UriResourceAction;
 import org.apache.olingo.server.api.uri.UriResourceKind;
 
-public class UriResourceActionImpl extends UriResourceTypedImpl implements UriResourceAction {
+/**
+ * Implementation of the {@link UriResourceAction} interface. This class does not extend
+ * {@link org.apache.olingo.server.core.uri.UriResourceTypedImpl UriResourceTypedImpl}
+ * since that would allow type filters and subsequent path segments.
+ */
+public class UriResourceActionImpl extends UriResourceImpl implements UriResourceAction {
 
   protected EdmAction action;
   protected EdmActionImport actionImport;
@@ -71,8 +76,12 @@ public class UriResourceActionImpl extends UriResourceTypedImpl implements UriRe
   }
 
   @Override
-  public String toString() {
+  public String toString(final boolean includeFilters) {
     return actionImport == null ? (action == null ? "" : action.getName()) : actionImport.getName();
   }
 
+  @Override
+  public String toString() {
+    return toString(false);
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fd513e22/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceTypedImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceTypedImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceTypedImpl.java
index d5f01ea..cef7098 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceTypedImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceTypedImpl.java
@@ -20,7 +20,6 @@ package org.apache.olingo.server.core.uri;
 
 import org.apache.olingo.commons.api.edm.EdmStructuredType;
 import org.apache.olingo.commons.api.edm.EdmType;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.server.api.uri.UriResourceKind;
 import org.apache.olingo.server.api.uri.UriResourcePartTyped;
 
@@ -45,16 +44,11 @@ public abstract class UriResourceTypedImpl extends UriResourceImpl implements Ur
   public String toString(final boolean includeFilters) {
     if (includeFilters) {
       if (typeFilter != null) {
-        return toString() + "/" + getFQN(typeFilter).toString();
+        return toString() + "/" + typeFilter.getFullQualifiedName().toString();
       } else {
         return toString();
       }
     }
     return toString();
   }
-
-  private FullQualifiedName getFQN(final EdmType type) {
-    return new FullQualifiedName(type.getNamespace(), type.getName());
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fd513e22/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/MemberImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/MemberImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/MemberImpl.java
index 8940bcf..5f6162f 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/MemberImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/MemberImpl.java
@@ -25,6 +25,7 @@ import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitEx
 import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitor;
 import org.apache.olingo.server.api.uri.queryoption.expression.Member;
 import org.apache.olingo.server.core.uri.UriInfoImpl;
+import org.apache.olingo.server.core.uri.UriResourceActionImpl;
 import org.apache.olingo.server.core.uri.UriResourceImpl;
 import org.apache.olingo.server.core.uri.UriResourceTypedImpl;
 import org.apache.olingo.server.core.uri.UriResourceWithKeysImpl;
@@ -69,6 +70,8 @@ public class MemberImpl extends ExpressionImpl implements Member {
         return type;
       }
       return lastTyped.getType();
+    } else if (lastResourcePart instanceof UriResourceActionImpl) {
+      return ((UriResourceActionImpl) lastResourcePart).getType();
     } else {
       return null;
     }
@@ -81,6 +84,8 @@ public class MemberImpl extends ExpressionImpl implements Member {
     if (lastResourcePart instanceof UriResourceTypedImpl) {
       UriResourceTypedImpl lastTyped = (UriResourceTypedImpl) lastResourcePart;
       return lastTyped.isCollection();
+    } else if (lastResourcePart instanceof UriResourceActionImpl) {
+      return ((UriResourceActionImpl) lastResourcePart).isCollection();
     }
     return false;
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fd513e22/lib/server-test/src/test/java/org/apache/olingo/server/core/PreconditionsValidatorTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/PreconditionsValidatorTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/PreconditionsValidatorTest.java
index a70bbc7..fae780d 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/PreconditionsValidatorTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/PreconditionsValidatorTest.java
@@ -40,7 +40,6 @@ import org.apache.olingo.server.core.uri.parser.Parser;
 import org.apache.olingo.server.core.uri.parser.UriParserException;
 import org.apache.olingo.server.core.uri.parser.UriParserSemanticException;
 import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
@@ -180,7 +179,6 @@ public class PreconditionsValidatorTest {
     runException("SINav/NavPropertyETKeyNavOne/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav");
   }
 
-  @Ignore
   @Test(expected = UriParserSemanticException.class)
   public void resourceSegmentAfterActionMustLeadToUriParserException() throws Exception {
     validate("ESKeyNav(1)/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav/PropertyInt16", "ESKeyNav", "*", "*");

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fd513e22/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
index f5e625a..db58288 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
@@ -38,6 +38,7 @@ import org.apache.olingo.server.core.uri.testutil.EdmTechTestProvider;
 import org.apache.olingo.server.core.uri.testutil.FilterValidator;
 import org.apache.olingo.server.core.uri.testutil.ResourceValidator;
 import org.apache.olingo.server.core.uri.testutil.TestUriValidator;
+import org.apache.olingo.server.core.uri.validator.UriValidationException;
 import org.apache.olingo.server.tecsvc.provider.ComplexTypeProvider;
 import org.apache.olingo.server.tecsvc.provider.ContainerProvider;
 import org.apache.olingo.server.tecsvc.provider.EntityTypeProvider;
@@ -5201,6 +5202,17 @@ public class TestFullResourcePath {
     .isExSemantic(UriParserSemanticException.MessageKeys.ONLY_FOR_ENTITY_TYPES);
     testUri.runEx("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/PropertyCompTwoPrim/$count")
     .isExSemantic(UriParserSemanticException.MessageKeys.ONLY_FOR_COLLECTIONS);
+
+    // Actions must not be followed by anything.
+    testUri.runEx(ContainerProvider.AIRT_STRING + "/$value")
+        .isExValidation(UriValidationException.MessageKeys.UNALLOWED_KIND_BEFORE_VALUE);
+    testUri.runEx(ContainerProvider.AIRTCT_TWO_PRIM_PARAM + "/PropertyInt16")
+        .isExSemantic(UriParserSemanticException.MessageKeys.RESOURCE_PART_ONLY_FOR_TYPED_PARTS);
+    testUri.runEx("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/"
+        + "olingo.odata.test1.BAETTwoKeyNavRTETTwoKeyNav/olingo.odata.test1.ETTwoKeyNav")
+        .isExSemantic(UriParserSemanticException.MessageKeys.RESOURCE_PART_ONLY_FOR_TYPED_PARTS);
+    testUri.runEx("ESTwoKeyNav/olingo.odata.test1.BAESTwoKeyNavRTESTwoKeyNav/$count")
+        .isExValidation(UriValidationException.MessageKeys.UNALLOWED_KIND_BEFORE_COUNT);
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fd513e22/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
index 068edd7..0d333f3 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
@@ -193,7 +193,7 @@ public class TestUriParserImpl {
     .isType(EntityTypeProvider.nameETTwoKeyTwoPrim, false);
 
     testUri.runEx(ContainerProvider.AIRT_STRING + "/invalidElement")
-    .isExSemantic(UriParserSemanticException.MessageKeys.RESOURCE_PART_MUST_BE_PRECEDED_BY_STRUCTURAL_TYPE);
+        .isExSemantic(UriParserSemanticException.MessageKeys.RESOURCE_PART_ONLY_FOR_TYPED_PARTS);
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fd513e22/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/queryoption/expression/ExpressionTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/queryoption/expression/ExpressionTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/queryoption/expression/ExpressionTest.java
index e466f2d..98abf20 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/queryoption/expression/ExpressionTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/queryoption/expression/ExpressionTest.java
@@ -19,7 +19,9 @@
 package org.apache.olingo.server.core.uri.queryoption.expression;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import java.util.Arrays;
 
@@ -134,7 +136,7 @@ public class ExpressionTest {
     MemberImpl expression = new MemberImpl();
     EdmEntityType entityType = edm.getEntityType(EntityTypeProvider.nameETKeyNav);
 
-    // UriResourceImplTyped
+    // UriResourceImpl
     EdmAction action = edm.getUnboundAction(ActionProvider.nameUARTString);
     UriInfoResource uriInfo = new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
         new UriResourceActionImpl().setAction(action)).asUriInfoResource();
@@ -146,24 +148,24 @@ public class ExpressionTest {
     assertEquals("<UARTString>", expression.accept(new FilterTreeToText()));
 
     // UriResourceImplTyped check collection = false case
-    assertEquals(false, expression.isCollection());
+    assertFalse(expression.isCollection());
 
     // UriResourceImplTyped check collection = true case
     action = edm.getUnboundAction(ActionProvider.nameUARTCollStringTwoParam);
-    expression.setResourcePath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
-        new UriResourceActionImpl().setAction(action))
+    expression.setResourcePath(new UriInfoImpl().setKind(UriInfoKind.resource)
+        .addResourcePart(new UriResourceActionImpl().setAction(action))
         .asUriInfoResource());
-    assertEquals(true, expression.isCollection());
+    assertTrue(expression.isCollection());
 
     // UriResourceImplTyped with filter
-    action = edm.getUnboundAction(ActionProvider.nameUARTString);
+    EdmFunction function = edm.getUnboundFunction(FunctionProvider.nameUFCRTETKeyNav, null);
     expression.setResourcePath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
-        new UriResourceActionImpl().setAction(action).setTypeFilter(entityType))
+        new UriResourceFunctionImpl().setFunction(function).setEntryTypeFilter(entityType))
         .asUriInfoResource());
     assertEquals(entityType, expression.getType());
 
     // UriResourceImplKeyPred
-    EdmFunction function = edm.getUnboundFunction(FunctionProvider.nameUFCRTETKeyNav, null);
+    function = edm.getUnboundFunction(FunctionProvider.nameUFCRTETKeyNav, null);
     expression.setResourcePath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
         new UriResourceFunctionImpl().setFunction(function))
         .asUriInfoResource());
@@ -192,7 +194,7 @@ public class ExpressionTest {
     assertEquals(null, expression.getType());
 
     // no typed collection else case
-    assertEquals(false, expression.isCollection());
+    assertFalse(expression.isCollection());
   }
 
   @Test


[07/39] olingo-odata4 git commit: PATCH

Posted by ch...@apache.org.
PATCH

Signed-off-by: Christian Amend <ch...@sap.com>


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

Branch: refs/heads/IEE754Compatible
Commit: 3b506eaade59d5596a2465b7ec0686d6c425a172
Parents: 5501e8e
Author: x.x@sap.com <x....@sap.com>
Authored: Wed Jun 10 22:02:36 2015 +0200
Committer: Christian Amend <ch...@sap.com>
Committed: Mon Jun 15 10:05:36 2015 +0200

----------------------------------------------------------------------
 .../org/apache/olingo/server/api/OData.java     |   8 +
 .../olingo/server/api/prefer/Preferences.java   | 107 ++++++++++++
 .../server/api/prefer/PreferencesApplied.java   | 164 ++++++++++++++++++
 .../api/prefer/PreferencesAppliedTest.java      |  67 ++++++++
 .../apache/olingo/server/core/ODataImpl.java    |   8 +
 .../olingo/server/core/prefer/PreferParser.java | 150 +++++++++++++++++
 .../server/core/prefer/PreferencesImpl.java     | 117 +++++++++++++
 .../server/core/prefer/PreferencesTest.java     | 168 +++++++++++++++++++
 8 files changed, 789 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3b506eaa/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java
index 3a9c1cb..e9dc225 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java
@@ -18,6 +18,7 @@
  */
 package org.apache.olingo.server.api;
 
+import java.util.Collection;
 import java.util.List;
 
 import org.apache.olingo.commons.api.ODataRuntimeException;
@@ -31,6 +32,7 @@ import org.apache.olingo.server.api.deserializer.ODataDeserializer;
 import org.apache.olingo.server.api.edmx.EdmxReference;
 import org.apache.olingo.server.api.etag.ETagHelper;
 import org.apache.olingo.server.api.etag.ServiceMetadataETagSupport;
+import org.apache.olingo.server.api.prefer.Preferences;
 import org.apache.olingo.server.api.serializer.FixedFormatSerializer;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
 import org.apache.olingo.server.api.serializer.SerializerException;
@@ -135,4 +137,10 @@ public abstract class OData {
    * It can be used in Processor implementations.
    */
   public abstract ETagHelper createETagHelper();
+
+  /**
+   * Creates a new Preferences object out of Prefer HTTP request headers.
+   * It can be used in Processor implementations.
+   */
+  public abstract Preferences createPreferences(Collection<String> preferHeaders);
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3b506eaa/lib/server-api/src/main/java/org/apache/olingo/server/api/prefer/Preferences.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/prefer/Preferences.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/prefer/Preferences.java
new file mode 100644
index 0000000..91f0d45
--- /dev/null
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/prefer/Preferences.java
@@ -0,0 +1,107 @@
+/*
+ * 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.server.api.prefer;
+
+import java.net.URI;
+import java.util.Map;
+
+/**
+ * Provides access methods to the preferences set in Prefer HTTP request headers
+ * as described in <a href="https://www.ietf.org/rfc/rfc7240.txt">RFC 7240</a>.
+ * Preferences defined in the OData standard can be accessed with named methods.
+ */
+public interface Preferences {
+
+  /**
+   * Gets named preference. Names are case insensitive.
+   * @param name name of the preference
+   * @return {@link Preference} or <code>null</code> if no such preference has been set
+   */
+  public Preference getPreference(String name);
+
+  /** Whether the preference <code>odata.allow-entityreferences</code> has been set. */
+  public boolean hasAllowEntityReferences();
+
+  /**
+   * Gets the value of the <code>url</code> parameter of the preference
+   * <code>odata.callback</code> or <code>null</code> if not set or the URI is not valid.
+   * @return the callback URI
+   */
+  public URI getCallback();
+
+  /** Whether the preference <code>odata.continue-on-error</code> has been set. */
+  public boolean hasContinueOnError();
+
+  /**
+   * Gets the value of the preference <code>odata.maxpagesize</code>
+   * or <code>null</code> if not set or an invalid value has been set.
+   * @return the page size for server-driven paging
+   */
+  public Integer getMaxPageSize();
+
+  /** Whether the preference <code>odata.track-changes</code> has been set. */
+  public boolean hasTrackChanges();
+
+  public enum Return { REPRESENTATION, MINIMAL }
+  /**
+   * Gets the value of the preference <code>return</code> or <code>null</code> if not set
+   * or the value is not valid.
+   */
+  public Return getReturn();
+
+  /** Whether the preference <code>respond-async</code> has been set. */
+  public boolean hasRespondAsync();
+
+  /**
+   * Gets the value of the preference <code>wait</code> or <code>null</code> if not set
+   * or the value is not valid.
+   * @return the number of seconds the client is prepared to wait for the service
+   *         to process the request synchronously
+   */
+  public Integer getWait();
+
+  /** Generic preference object. */
+  public class Preference {
+    private final String value;
+    private final Map<String, String> parameters;
+
+    public Preference(final String value, final Map<String, String> parameters) {
+      this.value = value;
+      this.parameters = parameters;
+    }
+
+    /**
+     * Gets the value of the preference. It may be <code>null</code> if the preference has
+     * no value; this is not the same as the preference not set.
+     */
+    public String getValue() {
+      return value;
+    }
+
+    /**
+     * Gets the parameters of the preference. The value of a parameter may be
+     * <code>null</code> if the parameter has no value; this is not the same as
+     * the parameter not set. Parameter names are all lowercase.
+     * @return a map from parameter names to parameter values
+     */
+    public Map<String, String> getParameters() {
+      return parameters;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3b506eaa/lib/server-api/src/main/java/org/apache/olingo/server/api/prefer/PreferencesApplied.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/prefer/PreferencesApplied.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/prefer/PreferencesApplied.java
new file mode 100644
index 0000000..fd89a3a
--- /dev/null
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/prefer/PreferencesApplied.java
@@ -0,0 +1,164 @@
+/*
+ * 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.server.api.prefer;
+
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Locale;
+import java.util.Map;
+
+import org.apache.olingo.server.api.prefer.Preferences.Return;
+
+/**
+ * Provides methods to set values suitable for the Preference-Applied HTTP response header
+ * as described in <a href="https://www.ietf.org/rfc/rfc7240.txt">RFC 7240</a>.
+ * There are named methods for preferences defined in the OData standard.
+ */
+public class PreferencesApplied {
+
+  private Map<String, String> applied;
+
+  private PreferencesApplied() {
+    applied = new LinkedHashMap<String, String>();
+  }
+
+  /**
+   * Gets the applied preferences.
+   * @return a map from preference names to preference values
+   */
+  public Map<String, String> getAppliedPreferences() {
+    return Collections.unmodifiableMap(applied);
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder result = new StringBuilder();
+    for (final String name : applied.keySet()) {
+      if (result.length() > 0) {
+        result.append(',').append(' ');
+      }
+      result.append(name);
+      if (applied.get(name) != null) {
+        result.append('=').append('"')
+            .append(applied.get(name).replaceAll("\\\\|\"", "\\\\$0"))
+            .append('"');
+      }
+    }
+    return result.toString();
+  }
+
+  /** Initializes the builder. */
+  public static Builder with() {
+    return new Builder();
+  }
+
+  /** Builder of OData serializer options. */
+  public static final class Builder {
+
+    private static final String ALLOW_ENTITY_REFERENCES = "odata.allow-entityreferences";
+    private static final String CALLBACK = "odata.callback";
+    private static final String CONTINUE_ON_ERROR = "odata.continue-on-error";
+    // private static final String INCLUDE_ANNOTATIONS = "odata.include-annotations";
+    private static final String MAX_PAGE_SIZE = "odata.maxpagesize";
+    private static final String TRACK_CHANGES = "odata.track-changes";
+    private static final String RETURN = "return";
+    private static final String RESPOND_ASYNC = "respond-async";
+    private static final String WAIT = "wait";
+
+    private final PreferencesApplied preferencesApplied;
+
+    private Builder() {
+      preferencesApplied = new PreferencesApplied();
+    }
+
+    /** Sets <code>odata.allow-entityreferences</code>. */
+    public Builder allowEntityReferences() {
+      add(ALLOW_ENTITY_REFERENCES, null);
+      return this;
+    }
+
+    /** Sets <code>odata.callback</code>. */
+    public Builder callback() {
+      add(CALLBACK, null);
+      return this;
+    }
+
+    /** Sets <code>odata.continue-on-error</code>. */
+    public Builder continueOnError() {
+      add(CONTINUE_ON_ERROR, null);
+      return this;
+    }
+
+    /** Sets the value of the applied preference <code>odata.maxpagesize</code>. */
+    public Builder maxPageSize(final Integer maxPageSize) {
+      add(MAX_PAGE_SIZE, Integer.toString(maxPageSize));
+      return this;
+    }
+
+    /** Sets <code>odata.track-changes</code>. */
+    public Builder trackChanges() {
+      add(TRACK_CHANGES, null);
+      return this;
+    }
+
+    /** Sets the value of the applied preference <code>return</code>. */
+    public Builder returnRepresentation(final Return returnRepresentation) {
+      add(RETURN, returnRepresentation.name().toLowerCase(Locale.ROOT));
+      return this;
+    }
+
+    /** Sets <code>odata.respond-async</code>. */
+    public Builder respondAsync() {
+      add(RESPOND_ASYNC, null);
+      return this;
+    }
+
+    /** Sets the value of the applied preference <code>wait</code>. */
+    public Builder waitPreference(final Integer wait) {
+      add(WAIT, Integer.toString(wait));
+      return this;
+    }
+
+    /**
+     * Sets an arbitrary preference as applied.
+     * The preference name is converted to lowercase.
+     * The value of this preference may be <code>null</code>.
+     * Name and value are not checked for validity.
+     * @param name  preference name
+     * @param value preference value
+     */
+    public Builder preference(final String name, final String value) {
+      if (name != null) {
+        add(name.toLowerCase(Locale.ROOT), value);
+      }
+      return this;
+    }
+
+    /** Builds the applied preferences. */
+    public PreferencesApplied build() {
+      return preferencesApplied;
+    }
+
+    private void add(final String name, final String value) {
+      if (!preferencesApplied.applied.containsKey(name)) {
+        preferencesApplied.applied.put(name, value);
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3b506eaa/lib/server-api/src/test/java/org/apache/olingo/server/api/prefer/PreferencesAppliedTest.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/test/java/org/apache/olingo/server/api/prefer/PreferencesAppliedTest.java b/lib/server-api/src/test/java/org/apache/olingo/server/api/prefer/PreferencesAppliedTest.java
new file mode 100644
index 0000000..0d5edf9
--- /dev/null
+++ b/lib/server-api/src/test/java/org/apache/olingo/server/api/prefer/PreferencesAppliedTest.java
@@ -0,0 +1,67 @@
+/*
+ * 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.server.api.prefer;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.olingo.server.api.prefer.Preferences.Return;
+import org.junit.Test;
+
+public class PreferencesAppliedTest {
+
+  @Test
+  public void empty() {
+    assertEquals("", PreferencesApplied.with().build().toString());
+  }
+
+  @Test
+  public void all() {
+    assertEquals("odata.allow-entityreferences, odata.callback,"
+        + " odata.continue-on-error, odata.include-annotations=\"*\", odata.maxpagesize=\"42\","
+        + " odata.track-changes, return=\"representation\", respond-async, wait=\"12345\"",
+        PreferencesApplied.with().allowEntityReferences().callback().continueOnError()
+            .preference("odata.include-annotations", "*").maxPageSize(42).trackChanges()
+            .returnRepresentation(Return.REPRESENTATION).respondAsync().waitPreference(12345)
+            .build().toString());
+  }
+
+  @Test
+  public void caseSensitivity() {
+    assertEquals("odata.include-annotations=\"*\", odata.maxpagesize=\"255\"",
+        PreferencesApplied.with()
+            .preference("OData.Include-Annotations", "*").maxPageSize(0xFF)
+            .build().toString());
+  }
+
+  @Test
+  public void multipleValues() {
+    assertEquals("return=\"minimal\", wait=\"1\"",
+        PreferencesApplied.with()
+            .returnRepresentation(Return.MINIMAL).returnRepresentation(Return.REPRESENTATION)
+            .preference(null, null).preference(null, "nullValue")
+            .waitPreference(1).waitPreference(2).waitPreference(3)
+            .build().toString());
+  }
+
+  @Test
+  public void quotedValue() {
+    assertEquals("strangepreference=\"x\\\\y,\\\"abc\\\"z\"",
+        PreferencesApplied.with().preference("strangePreference", "x\\y,\"abc\"z").build().toString());
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3b506eaa/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java
index 57cceaf..35c1ccf 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java
@@ -18,6 +18,7 @@
  */
 package org.apache.olingo.server.core;
 
+import java.util.Collection;
 import java.util.List;
 
 import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
@@ -34,6 +35,7 @@ import org.apache.olingo.server.api.deserializer.ODataDeserializer;
 import org.apache.olingo.server.api.edmx.EdmxReference;
 import org.apache.olingo.server.api.etag.ETagHelper;
 import org.apache.olingo.server.api.etag.ServiceMetadataETagSupport;
+import org.apache.olingo.server.api.prefer.Preferences;
 import org.apache.olingo.server.api.serializer.FixedFormatSerializer;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
 import org.apache.olingo.server.api.serializer.SerializerException;
@@ -41,6 +43,7 @@ import org.apache.olingo.server.api.uri.UriHelper;
 import org.apache.olingo.server.core.deserializer.FixedFormatDeserializerImpl;
 import org.apache.olingo.server.core.deserializer.json.ODataJsonDeserializer;
 import org.apache.olingo.server.core.etag.ETagHelperImpl;
+import org.apache.olingo.server.core.prefer.PreferencesImpl;
 import org.apache.olingo.server.core.serializer.FixedFormatSerializerImpl;
 import org.apache.olingo.server.core.serializer.json.ODataJsonSerializer;
 import org.apache.olingo.server.core.serializer.xml.ODataXmlSerializerImpl;
@@ -128,4 +131,9 @@ public class ODataImpl extends OData {
     return new ETagHelperImpl();
   }
 
+  @Override
+  public Preferences createPreferences(final Collection<String> preferHeaders) {
+    return new PreferencesImpl(preferHeaders);
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3b506eaa/lib/server-core/src/main/java/org/apache/olingo/server/core/prefer/PreferParser.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/prefer/PreferParser.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/prefer/PreferParser.java
new file mode 100644
index 0000000..a3a2a42
--- /dev/null
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/prefer/PreferParser.java
@@ -0,0 +1,150 @@
+/*
+ * 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.server.core.prefer;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.olingo.server.api.prefer.Preferences.Preference;
+
+/**
+ * <p>Parses the values of <code>Prefer</code> HTTP header fields.</p>
+ * <p>See <a href="https://www.ietf.org/rfc/rfc7240.txt">RFC 7240</a> for details;
+ * there the following grammar is defined:</p>
+ * <pre>
+ *     Prefer        = "Prefer" ":" 1#preference
+ *     preference    = token [ BWS "=" BWS word ] *( OWS ";" [ OWS parameter ] )
+ *     parameter     = token [ BWS "=" BWS word ]
+ *     token         = 1*tchar
+ *     tchar         = "!" / "#" / "$" / "%" / "&" / "'" / "*"
+                     / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA
+ *     word          = token / quoted-string
+ *     quoted-string = DQUOTE *( qdtext / quoted-pair ) DQUOTE
+ *     qdtext        = HTAB / SP / %x21 / %x23-5B / %x5D-7E / %x80-FF
+ *     quoted-pair   = "\" ( HTAB / SP / %x21-7E /  %x80-FF )
+ *     OWS           = *( SP / HTAB )  ; optional whitespace
+ *     BWS           = OWS             ; "bad" whitespace
+ * </pre>
+ * <p>Values with illegal syntax do not contribute to the result but no exception is thrown.</p>
+ */
+public class PreferParser {
+
+  private static final String token = "(?:[-!#$%&'*+.^_`|~]|\\w)+";
+  private static final String quotedString = "(?:\"(?:[\\t !#-\\[\\]-~\\x80-\\xFF]|"
+      + "(?:\\\\[\\t !-~\\x80-\\xFF]))*\")";
+  private static final String namedValue =
+      "(" + token + ")(?:\\s*=\\s*(" + token + "|" + quotedString + "))?";
+  private static final Pattern PREFERENCE = Pattern.compile("\\s*(,\\s*)+|"
+      + "(?:" + namedValue + "((?:\\s*;\\s*(?:" + namedValue + ")?)*))");
+  private static final Pattern PARAMETER = Pattern.compile("\\s*(;\\s*)+|(?:" + namedValue + ")");
+
+  protected static Map<String, Preference> parse(final Collection<String> values) {
+    if (values == null || values.isEmpty()) {
+      return Collections.emptyMap();
+    }
+
+    Map<String, Preference> result = new HashMap<String, Preference>();
+    for (final String value : values) {
+      if (value != null && !value.isEmpty()) {
+        parse(value, result);
+      }
+    }
+    return result;
+  }
+
+  private static void parse(final String value, Map<String, Preference> result) {
+    Map<String, Preference> partResult = new HashMap<String, Preference>();
+    String separator = "";
+    int start = 0;
+    Matcher matcher = PREFERENCE.matcher(value.trim());
+    while (matcher.find() && matcher.start() == start) {
+      start = matcher.end();
+      if (matcher.group(1) != null) {
+        separator = matcher.group(1);
+      } else if (separator != null) {
+        final String name = matcher.group(2).toLowerCase(Locale.ROOT);
+        // RFC 7240:
+        // If any preference is specified more than once, only the first instance is to be
+        // considered.  All subsequent occurrences SHOULD be ignored without signaling
+        // an error or otherwise altering the processing of the request.
+        if (!partResult.containsKey(name)) {
+          final String preferenceValue = getValue(matcher.group(3));
+          final Map<String, String> parameters =
+              matcher.group(4) == null || matcher.group(4).isEmpty() ? null :
+                  parseParameters(matcher.group(4));
+          partResult.put(name, new Preference(preferenceValue, parameters));
+        }
+        separator = null;
+      } else {
+        return;
+      }
+    }
+    if (matcher.hitEnd()) {
+      // Here we also have to keep already existing preferences.
+      for (final String key : partResult.keySet()) {
+        if (!result.containsKey(key)) {
+          result.put(key, partResult.get(key));
+        }
+      }
+    }
+  }
+
+  private static Map<String, String> parseParameters(final String parameters) {
+    Map<String, String> result = new HashMap<String, String>();
+    String separator = "";
+    int start = 0;
+    Matcher matcher = PARAMETER.matcher(parameters.trim());
+    while (matcher.find() && matcher.start() == start) {
+      start = matcher.end();
+      if (matcher.group(1) != null) {
+        separator = matcher.group(1);
+      } else if (separator != null) {
+        final String name = matcher.group(2).toLowerCase(Locale.ROOT);
+        // We have to keep already existing parameters.
+        if (!result.containsKey(name)) {
+          result.put(name, getValue(matcher.group(3)));
+        }
+        separator = null;
+      } else {
+        return null;
+      }
+    }
+    return matcher.hitEnd() ? Collections.unmodifiableMap(result) : null;
+  }
+
+  private static String getValue(final String value) {
+    if (value == null) {
+      return null;
+    }
+    String result = value;
+    if (value.startsWith("\"")) {
+      result = value.substring(1, value.length() - 1);
+    }
+    // Unquote backslash-quoted characters.
+    if (result.indexOf('\\') >= 0) {
+      result = result.replaceAll("\\\\(.)", "$1");
+    }
+    return result;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3b506eaa/lib/server-core/src/main/java/org/apache/olingo/server/core/prefer/PreferencesImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/prefer/PreferencesImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/prefer/PreferencesImpl.java
new file mode 100644
index 0000000..9661cd3
--- /dev/null
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/prefer/PreferencesImpl.java
@@ -0,0 +1,117 @@
+/*
+ * 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.server.core.prefer;
+
+import java.net.URI;
+import java.util.Collection;
+import java.util.Locale;
+import java.util.Map;
+
+import org.apache.olingo.server.api.prefer.Preferences;
+
+/**
+ * Provides access methods to the preferences set in the Prefer HTTP request
+ * header as described in <a href="https://www.ietf.org/rfc/rfc7240.txt">RFC 7240</a>.
+ * Preferences defined in the OData standard can be accessed with named methods.
+ */
+public class PreferencesImpl implements Preferences {
+
+  private static final String ALLOW_ENTITY_REFERENCES = "odata.allow-entityreferences";
+  private static final String CALLBACK = "odata.callback";
+  private static final String CONTINUE_ON_ERROR = "odata.continue-on-error";
+  // private static final String INCLUDE_ANNOTATIONS = "odata.include-annotations";
+  private static final String MAX_PAGE_SIZE = "odata.maxpagesize";
+  private static final String TRACK_CHANGES = "odata.track-changes";
+  private static final String RETURN = "return";
+  private static final String RESPOND_ASYNC = "respond-async";
+  private static final String WAIT = "wait";
+
+  private static final String URL = "url"; // parameter name for odata.callback
+
+  private final Map<String, Preference> preferences;
+
+  public PreferencesImpl(final Collection<String> preferHeaders) {
+    preferences = PreferParser.parse(preferHeaders);
+  }
+
+  public Preference getPreference(final String name) {
+    return preferences.get(name.toLowerCase(Locale.ROOT));
+  }
+
+  public boolean hasAllowEntityReferences() {
+    return preferences.containsKey(ALLOW_ENTITY_REFERENCES);
+  }
+
+  public URI getCallback() {
+    if (preferences.containsKey(CALLBACK)
+        && preferences.get(CALLBACK).getParameters() != null
+        && preferences.get(CALLBACK).getParameters().get(URL) != null) {
+      try {
+        return URI.create(preferences.get(CALLBACK).getParameters().get(URL));
+      } catch (final IllegalArgumentException e) {
+        return null;
+      }
+    }
+    return null;
+  }
+
+  public boolean hasContinueOnError() {
+    return preferences.containsKey(CONTINUE_ON_ERROR);
+  }
+
+  public Integer getMaxPageSize() {
+    return getNonNegativeIntegerPreference(MAX_PAGE_SIZE);
+  }
+
+  public boolean hasTrackChanges() {
+    return preferences.containsKey(TRACK_CHANGES);
+  }
+
+  public Return getReturn() {
+    if (preferences.containsKey(RETURN)) {
+      final String value = preferences.get(RETURN).getValue();
+      if (Return.REPRESENTATION.toString().toLowerCase(Locale.ROOT).equals(value)) {
+        return Return.REPRESENTATION;
+      } else if (Return.MINIMAL.toString().toLowerCase(Locale.ROOT).equals(value)) {
+        return Return.MINIMAL;
+      }
+    }
+    return null;
+  }
+
+  public boolean hasRespondAsync() {
+    return preferences.containsKey(RESPOND_ASYNC);
+  }
+
+  public Integer getWait() {
+    return getNonNegativeIntegerPreference(WAIT);
+  }
+
+  private Integer getNonNegativeIntegerPreference(final String name) {
+    if (preferences.containsKey(name) && preferences.get(name).getValue() != null) {
+      try {
+        final Integer result = Integer.valueOf(preferences.get(name).getValue());
+        return result < 0 ? null : result;
+      } catch (final NumberFormatException e) {
+        return null;
+      }
+    }
+    return null;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3b506eaa/lib/server-core/src/test/java/org/apache/olingo/server/core/prefer/PreferencesTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/prefer/PreferencesTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/prefer/PreferencesTest.java
new file mode 100644
index 0000000..b0e8d74
--- /dev/null
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/prefer/PreferencesTest.java
@@ -0,0 +1,168 @@
+/*
+ * 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.server.core.prefer;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.net.URI;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Map;
+
+import org.apache.olingo.server.api.prefer.Preferences;
+import org.apache.olingo.server.api.prefer.Preferences.Preference;
+import org.apache.olingo.server.api.prefer.Preferences.Return;
+import org.junit.Test;
+
+public class PreferencesTest {
+
+  @Test
+  public void empty() {
+    final Preferences preferences = new PreferencesImpl(null);
+    assertFalse(preferences.hasAllowEntityReferences());
+    assertNull(preferences.getCallback());
+    assertFalse(preferences.hasContinueOnError());
+    assertNull(preferences.getMaxPageSize());
+    assertFalse(preferences.hasTrackChanges());
+    assertNull(preferences.getReturn());
+    assertFalse(preferences.hasRespondAsync());
+    assertNull(preferences.getWait());
+  }
+
+  @Test
+  public void all() {
+    final Preferences preferences = new PreferencesImpl(Collections.singleton(
+        "odata.allow-entityreferences, odata.callback;url=\"callbackURI\","
+        + "odata.continue-on-error, odata.include-annotations=\"*\", odata.maxpagesize=42,"
+        + "odata.track-changes, return=representation, respond-async, wait=12345"));
+    assertTrue(preferences.hasAllowEntityReferences());
+    assertEquals(URI.create("callbackURI"), preferences.getCallback());
+    assertNotNull(preferences.getPreference("odata.callback"));
+    assertNull(preferences.getPreference("odata.callback").getValue());
+    assertEquals("callbackURI", preferences.getPreference("odata.callback").getParameters().get("url"));
+    assertTrue(preferences.hasContinueOnError());
+    assertEquals("*", preferences.getPreference("odata.Include-Annotations").getValue());
+    assertEquals(Integer.valueOf(42), preferences.getMaxPageSize());
+    assertEquals("42", preferences.getPreference("odata.MaxPageSize").getValue());
+    assertTrue(preferences.hasTrackChanges());
+    assertEquals(Return.REPRESENTATION, preferences.getReturn());
+    assertTrue(preferences.hasRespondAsync());
+    assertEquals(Integer.valueOf(12345), preferences.getWait());
+  }
+
+  @Test
+  public void caseSensitivity() {
+    final Preferences preferences = new PreferencesImpl(Collections.singleton(
+        "OData.Callback;URL=\"callbackURI\", return=REPRESENTATION, Wait=42"));
+    assertEquals(URI.create("callbackURI"), preferences.getCallback());
+    assertNull(preferences.getReturn());
+    assertEquals(Integer.valueOf(42), preferences.getWait());
+  }
+
+  @Test
+  public void multipleValues() {
+    final Preferences preferences = new PreferencesImpl(Collections.singleton(
+        ",return=minimal, ,, return=representation, wait=1, wait=2, wait=3,"));
+    assertEquals(Return.MINIMAL, preferences.getReturn());
+    assertEquals(Integer.valueOf(1), preferences.getWait());
+  }
+
+  @Test
+  public void multipleValuesDifferentHeaders() {
+    final Preferences preferences = new PreferencesImpl(Arrays.asList(
+        null, "",
+        "return=representation, wait=1",
+        "return=minimal, wait=2",
+        "wait=3"));
+    assertEquals(Return.REPRESENTATION, preferences.getReturn());
+    assertEquals(Integer.valueOf(1), preferences.getWait());
+  }
+
+  @Test
+  public void multipleParameters() {
+    final Preferences preferences = new PreferencesImpl(Collections.singleton(
+        "preference=a;;b=c; d = e; f;; ; g; h=\"i\";, wait=42"));
+    final Preference preference = preferences.getPreference("preference");
+    assertEquals("a", preference.getValue());
+    final Map<String, String> parameters = preference.getParameters();
+    assertEquals(5, parameters.size());
+    assertEquals("c", parameters.get("b"));
+    assertEquals("e", parameters.get("d"));
+    assertTrue(parameters.containsKey("f"));
+    assertNull(parameters.get("f"));
+    assertTrue(parameters.containsKey("g"));
+    assertNull(parameters.get("g"));
+    assertEquals("i", parameters.get("h"));
+    assertEquals(Integer.valueOf(42), preferences.getWait());
+  }
+
+  @Test
+  public void quotedValue() {
+    final Preferences preferences = new PreferencesImpl(Collections.singleton(
+        "strangePreference=\"x\\\\y,\\\"abc\\\"z\", wait=42"));
+    assertEquals("x\\y,\"abc\"z", preferences.getPreference("strangePreference").getValue());
+    assertEquals(Integer.valueOf(42), preferences.getWait());
+  }
+
+  @Test
+  public void specialCharacters() {
+    final Preferences preferences = new PreferencesImpl(Collections.singleton(
+        "!#$%&'*+-.^_`|~ = \"!#$%&'()*+,-./:;<=>?@[]^_`{|}~¡\u00FF\", wait=42"));
+    assertEquals("!#$%&'()*+,-./:;<=>?@[]^_`{|}~¡\u00FF",
+        preferences.getPreference("!#$%&'*+-.^_`|~").getValue());
+    assertEquals(Integer.valueOf(42), preferences.getWait());
+  }
+
+  @Test
+  public void wrongContent() {
+    final Preferences preferences = new PreferencesImpl(Arrays.asList(
+        "odata.callback;url=\":\"",
+        "odata.maxpagesize=12345678901234567890",
+        "return=something",
+        "wait=-1"));
+    assertNull(preferences.getCallback());
+    assertEquals(":", preferences.getPreference("odata.callback").getParameters().get("url"));
+    assertNull(preferences.getMaxPageSize());
+    assertEquals("12345678901234567890", preferences.getPreference("odata.maxpagesize").getValue());
+    assertNull(preferences.getReturn());
+    assertEquals("something", preferences.getPreference("return").getValue());
+    assertNull(preferences.getWait());
+    assertEquals("-1", preferences.getPreference("wait").getValue());
+  }
+
+  @Test
+  public void wrongFormat() {
+    final Preferences preferences = new PreferencesImpl(Arrays.asList(
+        "return=, wait=1",
+        "return=;, wait=2",
+        "return=representation=, wait=3",
+        "return=\"representation\"respond-async, wait=4",
+        "respond-async[], wait=5",
+        "odata.callback;=, wait=6",
+        "odata.callback;url=, wait=7",
+        "odata.callback;[], wait=8",
+        "odata.callback;url=\"url\"parameter, wait=9",
+        "wait=10"));
+    assertEquals(Integer.valueOf(10), preferences.getWait());
+  }
+}


[04/39] olingo-odata4 git commit: [OLINGO-691] Refactored karaf module structure

Posted by ch...@apache.org.
[OLINGO-691] Refactored karaf module structure


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

Branch: refs/heads/IEE754Compatible
Commit: e59b5082ffdca5948536e1a8988239a1559fdf8a
Parents: 7ab54a2
Author: Michael Bolz <mi...@sap.com>
Authored: Wed Jun 10 06:26:45 2015 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Wed Jun 10 10:50:08 2015 +0200

----------------------------------------------------------------------
 ext/karaf/features/pom.xml                      |  81 ----------
 .../features/src/main/resources/features.xml    |  59 -------
 ext/karaf/itests/pom.xml                        | 152 -------------------
 .../apache/olingo/osgi/itests/BundlesTest.java  |  56 -------
 .../osgi/itests/OlingoOSGiTestSupport.java      | 137 -----------------
 .../osgi/itests/server/CarServiceTest.java      | 105 -------------
 ext/karaf/karaf-features/pom.xml                |  81 ++++++++++
 .../src/main/resources/features.xml             |  59 +++++++
 ext/karaf/karaf-fit/pom.xml                     | 152 +++++++++++++++++++
 .../apache/olingo/osgi/itests/BundlesTest.java  |  55 +++++++
 .../osgi/itests/OlingoOSGiTestSupport.java      | 134 ++++++++++++++++
 .../osgi/itests/server/CarServiceTest.java      | 105 +++++++++++++
 ext/karaf/pom.xml                               |  41 +++++
 ext/pom.xml                                     |  10 +-
 pom.xml                                         |   2 +-
 samples/pom.xml                                 |  11 +-
 16 files changed, 646 insertions(+), 594 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e59b5082/ext/karaf/features/pom.xml
----------------------------------------------------------------------
diff --git a/ext/karaf/features/pom.xml b/ext/karaf/features/pom.xml
deleted file mode 100644
index 921eac2..0000000
--- a/ext/karaf/features/pom.xml
+++ /dev/null
@@ -1,81 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    Licensed to the Apache Software Foundation (ASF) under one
-    or more contributor license agreements.  See the NOTICE file
-    distributed with this work for additional information
-    regarding copyright ownership.  The ASF licenses this file
-    to you under the Apache License, Version 2.0 (the
-    "License"); you may not use this file except in compliance
-    with the License.  You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing,
-    software distributed under the License is distributed on an
-    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-    KIND, either express or implied.  See the License for the
-    specific language governing permissions and limitations
-    under the License.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-
-  <artifactId>odata-karaf-features</artifactId>
-  <packaging>pom</packaging>
-  <name>${project.artifactId}</name>
-
-  <parent>
-    <groupId>org.apache.olingo</groupId>
-    <artifactId>odata-ext</artifactId>
-    <version>4.0.0-SNAPSHOT</version>
-    <relativePath>../..</relativePath>
-  </parent>
-    <build>
-        <resources>
-            <resource>
-                <directory>src/main/resources</directory>
-                <filtering>true</filtering>
-            </resource>
-        </resources>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-resources-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>filter</id>
-                        <phase>generate-resources</phase>
-                        <goals>
-                            <goal>resources</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>build-helper-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>attach-artifacts</id>
-                        <phase>package</phase>
-                        <goals>
-                            <goal>attach-artifact</goal>
-                        </goals>
-                        <configuration>
-                            <artifacts>
-                                <artifact>
-                                    <file>target/classes/features.xml</file>
-                                    <type>xml</type>
-                                    <classifier>features</classifier>
-                                </artifact>
-                            </artifacts>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
-        </plugins>
-    </build>
-</project>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e59b5082/ext/karaf/features/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/ext/karaf/features/src/main/resources/features.xml b/ext/karaf/features/src/main/resources/features.xml
deleted file mode 100644
index 0a433c5..0000000
--- a/ext/karaf/features/src/main/resources/features.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 
-      Licensed to the Apache Software Foundation (ASF) under one or more
-      contributor license agreements.  See the NOTICE file distributed with
-      this work for additional information regarding copyright ownership.
-      The ASF licenses this file to You under the Apache License, Version 2.0
-      (the "License"); you may not use this file except in compliance with
-      the License.  You may obtain a copy of the License at
- 
-         http://www.apache.org/licenses/LICENSE-2.0
- 
-      Unless required by applicable law or agreed to in writing, software
-      distributed under the License is distributed on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-      See the License for the specific language governing permissions and
-      limitations under the License.
--->
-<features xmlns="http://karaf.apache.org/xmlns/features/v1.0.0" name="olingo-${project.version}">
-
-    <feature name="olingo-server" version="${project.version}" resolver="(obr)" start-level="50">
-      <feature>war</feature>
-	  <bundle>mvn:commons-codec/commons-codec/${commons.codec.version}</bundle>
-	  <bundle>mvn:org.apache.commons/commons-lang3/${commons.lang3.version}</bundle>
-	  <bundle>mvn:org.codehaus.woodstox/stax2-api/${woodstox.stax2-api.version}</bundle>
-	  <bundle>mvn:com.fasterxml/aalto-xml/${aalto-xml.version}</bundle>
-	  <bundle>wrap:mvn:org.antlr/antlr4-runtime/${antlr.version}/$Bundle-SymbolicName=antlr4-runtime&amp;Bundle-Version=${antlr.version}&amp;Export-Package=org.antlr.v4.runtime*</bundle>
-
-	  <bundle>mvn:com.fasterxml.jackson.core/jackson-core/${jackson.version}</bundle>
-	  <bundle>mvn:com.fasterxml.jackson.core/jackson-annotations/${jackson.version}</bundle>
-	  <bundle>mvn:com.fasterxml.jackson.core/jackson-databind/${jackson.version}</bundle>
-
-	  <bundle>mvn:org.apache.olingo/odata-commons-api/${project.version}</bundle>
-	  <bundle>mvn:org.apache.olingo/odata-commons-core/${project.version}</bundle>
-	  <bundle>mvn:org.apache.olingo/odata-server-api/${project.version}</bundle>
-	  <bundle>mvn:org.apache.olingo/odata-server-core/${project.version}</bundle>
-    </feature>
-
-    <feature name="olingo-client" version="${project.version}" resolver="(obr)" start-level="50">
-	  <bundle>mvn:commons-codec/commons-codec/${commons.codec.version}</bundle>
-	  <bundle>mvn:commons-io/commons-io/${commons.io.version}</bundle>
-	  <bundle>mvn:org.apache.commons/commons-lang3/${commons.lang3.version}</bundle>
-	  <bundle>mvn:org.codehaus.woodstox/stax2-api/${woodstox.stax2-api.version}</bundle>
-	  <bundle>mvn:com.fasterxml/aalto-xml/${aalto-xml.version}</bundle>
-	  <bundle>mvn:org.apache.httpcomponents/httpcore-osgi/${hc.core.version}</bundle>
-	  <bundle>mvn:org.apache.httpcomponents/httpclient-osgi/${hc.client.version}</bundle>
-
-	  <bundle>mvn:com.fasterxml.jackson.core/jackson-core/${jackson.version}</bundle>
-	  <bundle>mvn:com.fasterxml.jackson.core/jackson-annotations/${jackson.version}</bundle>
-	  <bundle>mvn:com.fasterxml.jackson.core/jackson-databind/${jackson.version}</bundle>
-	  <bundle>mvn:com.fasterxml.jackson.module/jackson-module-jaxb-annotations/${jackson.version}</bundle>
-	  <bundle>mvn:com.fasterxml.jackson.dataformat/jackson-dataformat-xml/${jackson.version}</bundle>
-
-	  <bundle>mvn:org.apache.olingo/odata-commons-api/${project.version}</bundle>
-	  <bundle>mvn:org.apache.olingo/odata-commons-core/${project.version}</bundle>
-	  <bundle>mvn:org.apache.olingo/odata-client-api/${project.version}</bundle>
-	  <bundle>mvn:org.apache.olingo/odata-client-core/${project.version}</bundle>
-    </feature>
-</features>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e59b5082/ext/karaf/itests/pom.xml
----------------------------------------------------------------------
diff --git a/ext/karaf/itests/pom.xml b/ext/karaf/itests/pom.xml
deleted file mode 100644
index 989a7bd..0000000
--- a/ext/karaf/itests/pom.xml
+++ /dev/null
@@ -1,152 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    Licensed to the Apache Software Foundation (ASF) under one
-    or more contributor license agreements.  See the NOTICE file
-    distributed with this work for additional information
-    regarding copyright ownership.  The ASF licenses this file
-    to you under the Apache License, Version 2.0 (the
-    "License"); you may not use this file except in compliance
-    with the License.  You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing,
-    software distributed under the License is distributed on an
-    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-    KIND, either express or implied.  See the License for the
-    specific language governing permissions and limitations
-    under the License.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-
-  <artifactId>odata-karaf-itests</artifactId>
-  <packaging>jar</packaging>
-  <name>${project.artifactId}</name>
-
-  <parent>
-    <groupId>org.apache.olingo</groupId>
-    <artifactId>odata-ext</artifactId>
-    <version>4.0.0-SNAPSHOT</version>
-    <relativePath>../..</relativePath>
-  </parent>
-  <dependencies>
-    <!-- Karaf features -->
-    <dependency>
-      <groupId>org.apache.olingo</groupId>
-      <artifactId>odata-karaf-features</artifactId>
-      <version>${project.version}</version>
-      <type>xml</type>
-      <classifier>features</classifier>
-    </dependency>
-
-    <dependency>
-      <groupId>org.apache.karaf.features</groupId>
-      <artifactId>org.apache.karaf.features.core</artifactId>
-      <version>${karaf.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.karaf.shell</groupId>
-      <artifactId>org.apache.karaf.shell.console</artifactId>
-      <version>${karaf.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.osgi</groupId>
-      <artifactId>org.osgi.core</artifactId>
-      <version>${osgi.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.osgi</groupId>
-      <artifactId>org.osgi.compendium</artifactId>
-      <version>${osgi.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.geronimo.specs</groupId>
-      <artifactId>geronimo-atinject_1.0_spec</artifactId>
-      <version>1.0</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <scope>test</scope>
-    </dependency>
-
-    <!-- pax-exam -->
-    <dependency>
-      <groupId>org.ops4j.pax.exam</groupId>
-      <artifactId>pax-exam-junit4</artifactId>
-      <version>${pax.exam.version}</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.ops4j.pax.exam</groupId>
-      <artifactId>pax-exam</artifactId>
-      <version>${pax.exam.version}</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.ops4j.pax.exam</groupId>
-      <artifactId>pax-exam-container-karaf</artifactId>
-      <version>${pax.exam.version}</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.ops4j.pax.exam</groupId>
-      <artifactId>pax-exam-link-mvn</artifactId>
-      <version>${pax.exam.version}</version>
-      <scope>test</scope>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.apache.karaf</groupId>
-      <artifactId>apache-karaf</artifactId>
-      <version>${karaf.version}</version>
-      <type>tar.gz</type>
-      <scope>test</scope>
-      <exclusions>
-        <exclusion>
-          <groupId>org.apache.karaf.shell</groupId>
-          <artifactId>org.apache.karaf.shell.dev</artifactId>
-        </exclusion>
-        <exclusion>
-          <groupId>org.eclipse</groupId>
-          <artifactId>osgi</artifactId>
-        </exclusion>
-        <exclusion>
-          <groupId>org.eclipse</groupId>
-          <artifactId>org.eclipse.osgi</artifactId>
-        </exclusion>
-        <exclusion>
-          <groupId>org.apache.karaf</groupId>
-          <artifactId>org.apache.karaf.client</artifactId>
-        </exclusion>
-        <exclusion>
-          <groupId>org.apache.felix</groupId>
-          <artifactId>org.apache.felix.framework</artifactId>
-        </exclusion>
-      </exclusions>
-    </dependency>
-  </dependencies>
-  <build>
-    <plugins>
-      <!-- generate dependencies versions that are needed -->
-      <plugin>
-        <groupId>org.apache.servicemix.tooling</groupId>
-        <artifactId>depends-maven-plugin</artifactId>
-        <version>1.2</version>
-        <executions>
-          <execution>
-            <id>generate-depends-file</id>
-            <goals>
-              <goal>generate-depends-file</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
-</project>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e59b5082/ext/karaf/itests/src/test/java/org/apache/olingo/osgi/itests/BundlesTest.java
----------------------------------------------------------------------
diff --git a/ext/karaf/itests/src/test/java/org/apache/olingo/osgi/itests/BundlesTest.java b/ext/karaf/itests/src/test/java/org/apache/olingo/osgi/itests/BundlesTest.java
deleted file mode 100644
index 4b542a1..0000000
--- a/ext/karaf/itests/src/test/java/org/apache/olingo/osgi/itests/BundlesTest.java
+++ /dev/null
@@ -1,56 +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.osgi.itests;
-
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Configuration;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.PaxExam;
-import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
-import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
-import org.ops4j.pax.exam.spi.reactors.PerClass;
-import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
-import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;
-
-
-@RunWith(PaxExam.class)
-@ExamReactorStrategy(PerClass.class)
-public class BundlesTest extends OlingoOSGiTestSupport {
-    @Test
-    public void test() throws Exception {
-        // check the server-api and server-core
-        assertBundleStarted("org.apache.olingo.odata-server-api");
-        assertBundleStarted("org.apache.olingo.odata-server-core");
-
-        // check the client-api and client-core
-        assertBundleStarted("org.apache.olingo.odata-client-api");
-        assertBundleStarted("org.apache.olingo.odata-client-core");
-    }
-
-    @Configuration
-    public Option[] config() {
-        return new Option[]{
-            olingoBaseConfig(),
-            features(olingoUrl, "olingo-server", "olingo-client"),
-            logLevel(LogLevel.INFO)};
-    }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e59b5082/ext/karaf/itests/src/test/java/org/apache/olingo/osgi/itests/OlingoOSGiTestSupport.java
----------------------------------------------------------------------
diff --git a/ext/karaf/itests/src/test/java/org/apache/olingo/osgi/itests/OlingoOSGiTestSupport.java b/ext/karaf/itests/src/test/java/org/apache/olingo/osgi/itests/OlingoOSGiTestSupport.java
deleted file mode 100644
index e882736..0000000
--- a/ext/karaf/itests/src/test/java/org/apache/olingo/osgi/itests/OlingoOSGiTestSupport.java
+++ /dev/null
@@ -1,137 +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.osgi.itests;
-
-
-
-import java.io.File;
-import java.io.InputStream;
-import java.util.Properties;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import javax.inject.Inject;
-
-import org.apache.karaf.features.FeaturesService;
-import org.junit.Assert;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.ProbeBuilder;
-import org.ops4j.pax.exam.TestProbeBuilder;
-import org.ops4j.pax.exam.options.MavenUrlReference;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import static org.ops4j.pax.exam.CoreOptions.composite;
-import static org.ops4j.pax.exam.CoreOptions.maven;
-import static org.ops4j.pax.exam.CoreOptions.systemProperty;
-import static org.ops4j.pax.exam.CoreOptions.when;
-import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
-import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
-
-/**
- * 
- */
-public class OlingoOSGiTestSupport {
-    private static final String MAVEN_DEPENDENCIES_PROPERTIES = "/META-INF/maven/dependencies.properties";
-
-    @Inject
-    protected BundleContext bundleContext;
-
-    @Inject
-    protected FeaturesService featureService;
-
-    protected ExecutorService executor = Executors.newCachedThreadPool();
-
-    protected MavenUrlReference olingoUrl;
-    protected MavenUrlReference karafUrl;
-
-    /**
-     * @param probe
-     * @return
-     */
-    @ProbeBuilder
-    public TestProbeBuilder probeConfiguration(TestProbeBuilder probe) {
-        probe.setHeader(Constants.DYNAMICIMPORT_PACKAGE, "*,org.apache.felix.service.*;status=provisional");
-        return probe;
-    }
-
-    private static String getKarafVersion() {
-        String karafVersion = getVersionFromPom("org.apache.karaf/apache-karaf/version");
-        if (karafVersion == null) {
-            karafVersion = System.getProperty("karaf.version");
-        }
-        if (karafVersion == null) {
-            // setup the default version of it
-            karafVersion = "3.0.3";
-        }
-        return karafVersion;
-    }
-
-    private static String getVersionFromPom(String key) {
-        try {
-            InputStream ins = OlingoOSGiTestSupport.class.getResourceAsStream(MAVEN_DEPENDENCIES_PROPERTIES);
-            Properties p = new Properties();
-            p.load(ins);
-            return p.getProperty(key);
-        } catch (Exception t) {
-            throw new IllegalStateException(MAVEN_DEPENDENCIES_PROPERTIES + " can not be found", t);
-        }
-    }    
-    /**
-     * Create an {@link org.ops4j.pax.exam.Option} for using a .
-     * 
-     * @return
-     */
-    protected Option olingoBaseConfig() {
-        karafUrl = maven().groupId("org.apache.karaf").artifactId("apache-karaf").version(getKarafVersion())
-            .type("tar.gz");
-        olingoUrl = maven().groupId("org.apache.olingo").artifactId("odata-karaf-features").versionAsInProject()
-            .type("xml").classifier("features");
-        String localRepo = System.getProperty("localRepository");
-        return composite(karafDistributionConfiguration()
-                             .frameworkUrl(karafUrl)
-                             .karafVersion(getKarafVersion())
-                             .name("Apache Karaf")
-                             .useDeployFolder(false)
-                             .unpackDirectory(new File("target/paxexam/")),
-                         //DO NOT COMMIT WITH THIS LINE ENABLED!!!    
-                         //KarafDistributionOption.keepRuntimeFolder(),                         
-                         systemProperty("java.awt.headless").value("true"),
-                         when(localRepo != null)
-                             .useOptions(editConfigurationFilePut("etc/org.ops4j.pax.url.mvn.cfg",
-                                                                  "org.ops4j.pax.url.mvn.localRepository",
-                                                                  localRepo)));
-    }
-
-    protected void assertBundleStarted(String name) {
-        Bundle bundle = findBundleByName(name);
-        Assert.assertNotNull("Bundle " + name + " should be installed", bundle);
-        Assert.assertEquals("Bundle " + name + " should be started", Bundle.ACTIVE, bundle.getState());
-    }
-
-    protected Bundle findBundleByName(String symbolicName) {
-        for (Bundle bundle : bundleContext.getBundles()) {
-            if (bundle.getSymbolicName().equals(symbolicName)) {
-                return bundle;
-            }
-        }
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e59b5082/ext/karaf/itests/src/test/java/org/apache/olingo/osgi/itests/server/CarServiceTest.java
----------------------------------------------------------------------
diff --git a/ext/karaf/itests/src/test/java/org/apache/olingo/osgi/itests/server/CarServiceTest.java b/ext/karaf/itests/src/test/java/org/apache/olingo/osgi/itests/server/CarServiceTest.java
deleted file mode 100644
index d727253..0000000
--- a/ext/karaf/itests/src/test/java/org/apache/olingo/osgi/itests/server/CarServiceTest.java
+++ /dev/null
@@ -1,105 +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.osgi.itests.server;
-
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.net.URL;
-import java.net.URLConnection;
-
-import org.apache.olingo.osgi.itests.OlingoOSGiTestSupport;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Configuration;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.PaxExam;
-import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
-import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
-import org.ops4j.pax.exam.spi.reactors.PerMethod;
-
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
-import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;
-
-/**
- *
- */
-@RunWith(PaxExam.class)
-@ExamReactorStrategy(PerMethod.class)
-public class CarServiceTest extends OlingoOSGiTestSupport {
-    private static final String SERVICE_URL = "http://localhost:8181/olingo-cars/cars.svc/";
-
-    @Test
-    public void testServiceStarted() throws Exception {
-        // check if the bundle is started
-        assertBundleStarted("org.apache.olingo.odata-server-osgi-sample");
-        
-        // use the jdk http client to verify the server side
-        verifyContent(getContent(SERVICE_URL));
-        
-        verifyContent(getContent(SERVICE_URL + "$metadata"));
-        
-        verifyContent(getContent(SERVICE_URL + "Cars"));
-        
-        verifyContent(getContent(SERVICE_URL + "Cars(1)"));
-        
-        verifyContent(getContent(SERVICE_URL + "Cars(1)/Price"));
-    }    
-
-    private static void verifyContent(String content) {
-        // this is currently a simple test to check if there is no error
-        Assert.assertNotNull(content);
-        Assert.assertTrue(content.indexOf("error") < 0);
-    }
-
-    private static String getContent(String target) throws Exception {
-        InputStream in = null;
-        try {
-            URL url = new URL(target);
-            URLConnection urlConnection = url.openConnection();
-            urlConnection.setRequestProperty("Accept", "*/*");
-            in = urlConnection.getInputStream();
-            ByteArrayOutputStream baos = new ByteArrayOutputStream();
-            byte[] buf = new byte[4096];
-            int n = 0;
-            while ((n = in.read(buf, 0, buf.length)) != -1) {
-                baos.write(buf, 0, n);
-            }
-            return new String(baos.toByteArray(), "utf-8");
-        } finally {
-            if (in != null) {
-                in.close();
-            }
-        }
-        
-    }
-
-    @Configuration
-    public Option[] config() {
-        return new Option[] {
-            olingoBaseConfig(),
-            features(olingoUrl, "olingo-server", "olingo-client"),
-            mavenBundle("org.apache.olingo", "odata-server-osgi-sample", "4.0.0-SNAPSHOT"),
-            logLevel(LogLevel.INFO)
-        };
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e59b5082/ext/karaf/karaf-features/pom.xml
----------------------------------------------------------------------
diff --git a/ext/karaf/karaf-features/pom.xml b/ext/karaf/karaf-features/pom.xml
new file mode 100644
index 0000000..2ae3f2c
--- /dev/null
+++ b/ext/karaf/karaf-features/pom.xml
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>odata-karaf-features</artifactId>
+  <packaging>pom</packaging>
+  <name>${project.artifactId}</name>
+
+  <parent>
+    <groupId>org.apache.olingo</groupId>
+    <artifactId>odata-karaf</artifactId>
+    <version>4.0.0-SNAPSHOT</version>
+    <relativePath>..</relativePath>
+  </parent>
+    <build>
+        <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+                <filtering>true</filtering>
+            </resource>
+        </resources>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-resources-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>filter</id>
+                        <phase>generate-resources</phase>
+                        <goals>
+                            <goal>resources</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>attach-artifacts</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>attach-artifact</goal>
+                        </goals>
+                        <configuration>
+                            <artifacts>
+                                <artifact>
+                                    <file>target/classes/features.xml</file>
+                                    <type>xml</type>
+                                    <classifier>features</classifier>
+                                </artifact>
+                            </artifacts>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e59b5082/ext/karaf/karaf-features/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/ext/karaf/karaf-features/src/main/resources/features.xml b/ext/karaf/karaf-features/src/main/resources/features.xml
new file mode 100644
index 0000000..0f2b5f4
--- /dev/null
+++ b/ext/karaf/karaf-features/src/main/resources/features.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 
+      Licensed to the Apache Software Foundation (ASF) under one or more
+      contributor license agreements.  See the NOTICE file distributed with
+      this work for additional information regarding copyright ownership.
+      The ASF licenses this file to You under the Apache License, Version 2.0
+      (the "License"); you may not use this file except in compliance with
+      the License.  You may obtain a copy of the License at
+ 
+         http://www.apache.org/licenses/LICENSE-2.0
+ 
+      Unless required by applicable law or agreed to in writing, software
+      distributed under the License is distributed on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+      See the License for the specific language governing permissions and
+      limitations under the License.
+-->
+<features xmlns="http://karaf.apache.org/xmlns/features/v1.0.0" name="olingo-${project.version}">
+
+  <feature name="olingo-server" version="${project.version}" resolver="(obr)" start-level="50">
+    <feature>war</feature>
+    <bundle>mvn:commons-codec/commons-codec/${commons.codec.version}</bundle>
+    <bundle>mvn:org.apache.commons/commons-lang3/${commons.lang3.version}</bundle>
+    <bundle>mvn:org.codehaus.woodstox/stax2-api/${woodstox.stax2-api.version}</bundle>
+    <bundle>mvn:com.fasterxml/aalto-xml/${aalto-xml.version}</bundle>
+    <bundle>wrap:mvn:org.antlr/antlr4-runtime/${antlr.version}/$Bundle-SymbolicName=antlr4-runtime&amp;Bundle-Version=${antlr.version}&amp;Export-Package=org.antlr.v4.runtime*</bundle>
+
+    <bundle>mvn:com.fasterxml.jackson.core/jackson-core/${jackson.version}</bundle>
+    <bundle>mvn:com.fasterxml.jackson.core/jackson-annotations/${jackson.version}</bundle>
+    <bundle>mvn:com.fasterxml.jackson.core/jackson-databind/${jackson.version}</bundle>
+
+    <bundle>mvn:org.apache.olingo/odata-commons-api/${project.version}</bundle>
+    <bundle>mvn:org.apache.olingo/odata-commons-core/${project.version}</bundle>
+    <bundle>mvn:org.apache.olingo/odata-server-api/${project.version}</bundle>
+    <bundle>mvn:org.apache.olingo/odata-server-core/${project.version}</bundle>
+  </feature>
+
+  <feature name="olingo-client" version="${project.version}" resolver="(obr)" start-level="50">
+    <bundle>mvn:commons-codec/commons-codec/${commons.codec.version}</bundle>
+    <bundle>mvn:commons-io/commons-io/${commons.io.version}</bundle>
+    <bundle>mvn:org.apache.commons/commons-lang3/${commons.lang3.version}</bundle>
+    <bundle>mvn:org.codehaus.woodstox/stax2-api/${woodstox.stax2-api.version}</bundle>
+    <bundle>mvn:com.fasterxml/aalto-xml/${aalto-xml.version}</bundle>
+    <bundle>mvn:org.apache.httpcomponents/httpcore-osgi/${hc.core.version}</bundle>
+    <bundle>mvn:org.apache.httpcomponents/httpclient-osgi/${hc.client.version}</bundle>
+
+    <bundle>mvn:com.fasterxml.jackson.core/jackson-core/${jackson.version}</bundle>
+    <bundle>mvn:com.fasterxml.jackson.core/jackson-annotations/${jackson.version}</bundle>
+    <bundle>mvn:com.fasterxml.jackson.core/jackson-databind/${jackson.version}</bundle>
+    <bundle>mvn:com.fasterxml.jackson.module/jackson-module-jaxb-annotations/${jackson.version}</bundle>
+    <bundle>mvn:com.fasterxml.jackson.dataformat/jackson-dataformat-xml/${jackson.version}</bundle>
+
+    <bundle>mvn:org.apache.olingo/odata-commons-api/${project.version}</bundle>
+    <bundle>mvn:org.apache.olingo/odata-commons-core/${project.version}</bundle>
+    <bundle>mvn:org.apache.olingo/odata-client-api/${project.version}</bundle>
+    <bundle>mvn:org.apache.olingo/odata-client-core/${project.version}</bundle>
+  </feature>
+</features>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e59b5082/ext/karaf/karaf-fit/pom.xml
----------------------------------------------------------------------
diff --git a/ext/karaf/karaf-fit/pom.xml b/ext/karaf/karaf-fit/pom.xml
new file mode 100644
index 0000000..14a7238
--- /dev/null
+++ b/ext/karaf/karaf-fit/pom.xml
@@ -0,0 +1,152 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>odata-karaf-fit</artifactId>
+  <packaging>jar</packaging>
+  <name>${project.artifactId}</name>
+
+  <parent>
+    <groupId>org.apache.olingo</groupId>
+    <artifactId>odata-karaf</artifactId>
+    <version>4.0.0-SNAPSHOT</version>
+    <relativePath>..</relativePath>
+  </parent>
+  <dependencies>
+    <!-- Karaf features -->
+    <dependency>
+      <groupId>org.apache.olingo</groupId>
+      <artifactId>odata-karaf-feature</artifactId>
+      <version>${project.version}</version>
+      <type>xml</type>
+      <classifier>features</classifier>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.karaf.features</groupId>
+      <artifactId>org.apache.karaf.features.core</artifactId>
+      <version>${karaf.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.karaf.shell</groupId>
+      <artifactId>org.apache.karaf.shell.console</artifactId>
+      <version>${karaf.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <version>${osgi.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.compendium</artifactId>
+      <version>${osgi.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-atinject_1.0_spec</artifactId>
+      <version>1.0</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <!-- pax-exam -->
+    <dependency>
+      <groupId>org.ops4j.pax.exam</groupId>
+      <artifactId>pax-exam-junit4</artifactId>
+      <version>${pax.exam.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.ops4j.pax.exam</groupId>
+      <artifactId>pax-exam</artifactId>
+      <version>${pax.exam.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.ops4j.pax.exam</groupId>
+      <artifactId>pax-exam-container-karaf</artifactId>
+      <version>${pax.exam.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.ops4j.pax.exam</groupId>
+      <artifactId>pax-exam-link-mvn</artifactId>
+      <version>${pax.exam.version}</version>
+      <scope>test</scope>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.apache.karaf</groupId>
+      <artifactId>apache-karaf</artifactId>
+      <version>${karaf.version}</version>
+      <type>tar.gz</type>
+      <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>org.apache.karaf.shell</groupId>
+          <artifactId>org.apache.karaf.shell.dev</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.eclipse</groupId>
+          <artifactId>osgi</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.eclipse</groupId>
+          <artifactId>org.eclipse.osgi</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.apache.karaf</groupId>
+          <artifactId>org.apache.karaf.client</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.apache.felix</groupId>
+          <artifactId>org.apache.felix.framework</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <!-- generate dependencies versions that are needed -->
+      <plugin>
+        <groupId>org.apache.servicemix.tooling</groupId>
+        <artifactId>depends-maven-plugin</artifactId>
+        <version>1.2</version>
+        <executions>
+          <execution>
+            <id>generate-depends-file</id>
+            <goals>
+              <goal>generate-depends-file</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e59b5082/ext/karaf/karaf-fit/src/test/java/org/apache/olingo/osgi/itests/BundlesTest.java
----------------------------------------------------------------------
diff --git a/ext/karaf/karaf-fit/src/test/java/org/apache/olingo/osgi/itests/BundlesTest.java b/ext/karaf/karaf-fit/src/test/java/org/apache/olingo/osgi/itests/BundlesTest.java
new file mode 100644
index 0000000..85d0f42
--- /dev/null
+++ b/ext/karaf/karaf-fit/src/test/java/org/apache/olingo/osgi/itests/BundlesTest.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * 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.osgi.itests;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;
+
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class BundlesTest extends OlingoOSGiTestSupport {
+    @Test
+    public void test() throws Exception {
+        // check the server-api and server-core
+        assertBundleStarted("org.apache.olingo.odata-server-api");
+        assertBundleStarted("org.apache.olingo.odata-server-core");
+
+        // check the client-api and client-core
+        assertBundleStarted("org.apache.olingo.odata-client-api");
+        assertBundleStarted("org.apache.olingo.odata-client-core");
+    }
+
+    @Configuration
+    public Option[] config() {
+        return new Option[]{
+            olingoBaseConfig(),
+            features(olingoUrl, "olingo-server", "olingo-client"),
+            logLevel(LogLevel.INFO)};
+    }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e59b5082/ext/karaf/karaf-fit/src/test/java/org/apache/olingo/osgi/itests/OlingoOSGiTestSupport.java
----------------------------------------------------------------------
diff --git a/ext/karaf/karaf-fit/src/test/java/org/apache/olingo/osgi/itests/OlingoOSGiTestSupport.java b/ext/karaf/karaf-fit/src/test/java/org/apache/olingo/osgi/itests/OlingoOSGiTestSupport.java
new file mode 100644
index 0000000..b055071
--- /dev/null
+++ b/ext/karaf/karaf-fit/src/test/java/org/apache/olingo/osgi/itests/OlingoOSGiTestSupport.java
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ * 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.osgi.itests;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.Properties;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import javax.inject.Inject;
+
+import org.apache.karaf.features.FeaturesService;
+import org.junit.Assert;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.ProbeBuilder;
+import org.ops4j.pax.exam.TestProbeBuilder;
+import org.ops4j.pax.exam.options.MavenUrlReference;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import static org.ops4j.pax.exam.CoreOptions.composite;
+import static org.ops4j.pax.exam.CoreOptions.maven;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+import static org.ops4j.pax.exam.CoreOptions.when;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
+
+/**
+ * 
+ */
+public class OlingoOSGiTestSupport {
+    private static final String MAVEN_DEPENDENCIES_PROPERTIES = "/META-INF/maven/dependencies.properties";
+
+    @Inject
+    protected BundleContext bundleContext;
+
+    @Inject
+    protected FeaturesService featureService;
+
+    protected ExecutorService executor = Executors.newCachedThreadPool();
+
+    protected MavenUrlReference olingoUrl;
+    protected MavenUrlReference karafUrl;
+
+    /**
+     * @param probe
+     * @return
+     */
+    @ProbeBuilder
+    public TestProbeBuilder probeConfiguration(TestProbeBuilder probe) {
+        probe.setHeader(Constants.DYNAMICIMPORT_PACKAGE, "*,org.apache.felix.service.*;status=provisional");
+        return probe;
+    }
+
+    private static String getKarafVersion() {
+        String karafVersion = getVersionFromPom("org.apache.karaf/apache-karaf/version");
+        if (karafVersion == null) {
+            karafVersion = System.getProperty("karaf.version");
+        }
+        if (karafVersion == null) {
+            // setup the default version of it
+            karafVersion = "3.0.3";
+        }
+        return karafVersion;
+    }
+
+    private static String getVersionFromPom(String key) {
+        try {
+            InputStream ins = OlingoOSGiTestSupport.class.getResourceAsStream(MAVEN_DEPENDENCIES_PROPERTIES);
+            Properties p = new Properties();
+            p.load(ins);
+            return p.getProperty(key);
+        } catch (Exception t) {
+            throw new IllegalStateException(MAVEN_DEPENDENCIES_PROPERTIES + " can not be found", t);
+        }
+    }    
+    /**
+     * Create an {@link org.ops4j.pax.exam.Option} for using a .
+     * 
+     * @return
+     */
+    protected Option olingoBaseConfig() {
+        karafUrl = maven().groupId("org.apache.karaf").artifactId("apache-karaf").version(getKarafVersion())
+            .type("tar.gz");
+        olingoUrl = maven().groupId("org.apache.olingo").artifactId("odata-karaf-feature").versionAsInProject()
+            .type("xml").classifier("features");
+        String localRepo = System.getProperty("localRepository");
+        return composite(karafDistributionConfiguration()
+                             .frameworkUrl(karafUrl)
+                             .karafVersion(getKarafVersion())
+                             .name("Apache Karaf")
+                             .useDeployFolder(false)
+                             .unpackDirectory(new File("target/paxexam/")),
+                         //DO NOT COMMIT WITH THIS LINE ENABLED!!!    
+                         //KarafDistributionOption.keepRuntimeFolder(),                         
+                         systemProperty("java.awt.headless").value("true"),
+                         when(localRepo != null)
+                             .useOptions(editConfigurationFilePut("etc/org.ops4j.pax.url.mvn.cfg",
+                                                                  "org.ops4j.pax.url.mvn.localRepository",
+                                                                  localRepo)));
+    }
+
+    protected void assertBundleStarted(String name) {
+        Bundle bundle = findBundleByName(name);
+        Assert.assertNotNull("Bundle " + name + " should be installed", bundle);
+        Assert.assertEquals("Bundle " + name + " should be started", Bundle.ACTIVE, bundle.getState());
+    }
+
+    protected Bundle findBundleByName(String symbolicName) {
+        for (Bundle bundle : bundleContext.getBundles()) {
+            if (bundle.getSymbolicName().equals(symbolicName)) {
+                return bundle;
+            }
+        }
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e59b5082/ext/karaf/karaf-fit/src/test/java/org/apache/olingo/osgi/itests/server/CarServiceTest.java
----------------------------------------------------------------------
diff --git a/ext/karaf/karaf-fit/src/test/java/org/apache/olingo/osgi/itests/server/CarServiceTest.java b/ext/karaf/karaf-fit/src/test/java/org/apache/olingo/osgi/itests/server/CarServiceTest.java
new file mode 100644
index 0000000..d727253
--- /dev/null
+++ b/ext/karaf/karaf-fit/src/test/java/org/apache/olingo/osgi/itests/server/CarServiceTest.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.osgi.itests.server;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+
+import org.apache.olingo.osgi.itests.OlingoOSGiTestSupport;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
+
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;
+
+/**
+ *
+ */
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerMethod.class)
+public class CarServiceTest extends OlingoOSGiTestSupport {
+    private static final String SERVICE_URL = "http://localhost:8181/olingo-cars/cars.svc/";
+
+    @Test
+    public void testServiceStarted() throws Exception {
+        // check if the bundle is started
+        assertBundleStarted("org.apache.olingo.odata-server-osgi-sample");
+        
+        // use the jdk http client to verify the server side
+        verifyContent(getContent(SERVICE_URL));
+        
+        verifyContent(getContent(SERVICE_URL + "$metadata"));
+        
+        verifyContent(getContent(SERVICE_URL + "Cars"));
+        
+        verifyContent(getContent(SERVICE_URL + "Cars(1)"));
+        
+        verifyContent(getContent(SERVICE_URL + "Cars(1)/Price"));
+    }    
+
+    private static void verifyContent(String content) {
+        // this is currently a simple test to check if there is no error
+        Assert.assertNotNull(content);
+        Assert.assertTrue(content.indexOf("error") < 0);
+    }
+
+    private static String getContent(String target) throws Exception {
+        InputStream in = null;
+        try {
+            URL url = new URL(target);
+            URLConnection urlConnection = url.openConnection();
+            urlConnection.setRequestProperty("Accept", "*/*");
+            in = urlConnection.getInputStream();
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            byte[] buf = new byte[4096];
+            int n = 0;
+            while ((n = in.read(buf, 0, buf.length)) != -1) {
+                baos.write(buf, 0, n);
+            }
+            return new String(baos.toByteArray(), "utf-8");
+        } finally {
+            if (in != null) {
+                in.close();
+            }
+        }
+        
+    }
+
+    @Configuration
+    public Option[] config() {
+        return new Option[] {
+            olingoBaseConfig(),
+            features(olingoUrl, "olingo-server", "olingo-client"),
+            mavenBundle("org.apache.olingo", "odata-server-osgi-sample", "4.0.0-SNAPSHOT"),
+            logLevel(LogLevel.INFO)
+        };
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e59b5082/ext/karaf/pom.xml
----------------------------------------------------------------------
diff --git a/ext/karaf/pom.xml b/ext/karaf/pom.xml
new file mode 100644
index 0000000..14e3645
--- /dev/null
+++ b/ext/karaf/pom.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>odata-karaf</artifactId>
+  <packaging>pom</packaging>
+  <name>${project.artifactId}</name>
+
+  <parent>
+    <groupId>org.apache.olingo</groupId>
+    <artifactId>odata-ext</artifactId>
+    <version>4.0.0-SNAPSHOT</version>
+    <relativePath>..</relativePath>
+  </parent>
+
+  <modules>
+    <module>karaf-features</module>
+    <module>karaf-fit</module>
+  </modules>
+</project>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e59b5082/ext/pom.xml
----------------------------------------------------------------------
diff --git a/ext/pom.xml b/ext/pom.xml
index 93a78e3..92a4bc2 100644
--- a/ext/pom.xml
+++ b/ext/pom.xml
@@ -39,6 +39,14 @@
     <module>pojogen-maven-plugin</module>
     <module>client-proxy</module>
     <module>client-android</module>
-    <module>karaf/features</module>
   </modules>
+
+  <profiles>
+    <profile>
+      <id>karaf</id>
+      <modules>
+        <module>karaf</module>
+      </modules>
+    </profile>
+  </profiles>
 </project>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e59b5082/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 1544783..0ae3c97 100644
--- a/pom.xml
+++ b/pom.xml
@@ -100,7 +100,7 @@
     <!-- for osgi integration testing -->
     <osgi.version>4.2.0</osgi.version>
     <karaf.version>3.0.3</karaf.version>
-    <pax.exam.version>4.5.0</pax.exam.version>
+    <pax.exam.version>3.4.0</pax.exam.version>
 
     <!-- Project build settings -->
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e59b5082/samples/pom.xml
----------------------------------------------------------------------
diff --git a/samples/pom.xml b/samples/pom.xml
index 0efc961..2d6b235 100644
--- a/samples/pom.xml
+++ b/samples/pom.xml
@@ -23,7 +23,6 @@
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
 
-  <groupId>org.apache.olingo</groupId>
   <artifactId>odata-samples</artifactId>
   <packaging>pom</packaging>
   <name>${project.artifactId}</name>
@@ -37,6 +36,14 @@
 
   <modules>
     <module>server</module>
-    <module>osgi/server</module>
   </modules>
+
+  <profiles>
+    <profile>
+      <id>samples</id>
+      <modules>
+        <module>osgi/server</module>
+      </modules>
+    </profile>
+  </profiles>
 </project>


[26/39] olingo-odata4 git commit: [OLINGO-694] Changed final build name

Posted by ch...@apache.org.
[OLINGO-694] Changed final build name


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

Branch: refs/heads/IEE754Compatible
Commit: 93999d510ea8fac1bd4d7d94ad2be1d2e7175592
Parents: 89d134e
Author: Michael Bolz <mi...@sap.com>
Authored: Fri Jun 19 06:46:01 2015 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Fri Jun 19 06:46:01 2015 +0200

----------------------------------------------------------------------
 samples/tutorials/p1_read/pom.xml   | 4 ++++
 samples/tutorials/p2_readep/pom.xml | 4 ++++
 samples/tutorials/p3_write/pom.xml  | 4 ++++
 3 files changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/93999d51/samples/tutorials/p1_read/pom.xml
----------------------------------------------------------------------
diff --git a/samples/tutorials/p1_read/pom.xml b/samples/tutorials/p1_read/pom.xml
index bcae4ef..7f212c5 100755
--- a/samples/tutorials/p1_read/pom.xml
+++ b/samples/tutorials/p1_read/pom.xml
@@ -29,6 +29,10 @@
 
 	<name>${project.artifactId}-Webapp</name>
 
+	<build>
+		<finalName>DemoService</finalName>
+	</build>
+
 	<properties>
 		<javax.version>2.5</javax.version>
 		<odata.version>4.0.0-beta-03</odata.version>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/93999d51/samples/tutorials/p2_readep/pom.xml
----------------------------------------------------------------------
diff --git a/samples/tutorials/p2_readep/pom.xml b/samples/tutorials/p2_readep/pom.xml
index abe0601..9a47d1c 100755
--- a/samples/tutorials/p2_readep/pom.xml
+++ b/samples/tutorials/p2_readep/pom.xml
@@ -29,6 +29,10 @@
 
 	<name>${project.artifactId}-Webapp</name>
 
+	<build>
+		<finalName>DemoService</finalName>
+	</build>
+
 	<properties>
 		<javax.version>2.5</javax.version>
 		<odata.version>4.0.0-beta-03</odata.version>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/93999d51/samples/tutorials/p3_write/pom.xml
----------------------------------------------------------------------
diff --git a/samples/tutorials/p3_write/pom.xml b/samples/tutorials/p3_write/pom.xml
index 4511a6f..dc9ba69 100755
--- a/samples/tutorials/p3_write/pom.xml
+++ b/samples/tutorials/p3_write/pom.xml
@@ -29,6 +29,10 @@
 
 	<name>${project.artifactId}-Webapp</name>
 
+	<build>
+		<finalName>DemoService</finalName>
+	</build>
+
 	<properties>
 		<javax.version>2.5</javax.version>
 		<odata.version>4.0.0-beta-03</odata.version>


[21/39] olingo-odata4 git commit: [OLINGO-694] Added read tutorial (part 1)

Posted by ch...@apache.org.
[OLINGO-694] Added read tutorial (part 1)


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

Branch: refs/heads/IEE754Compatible
Commit: 7c557f25bd47b90aa75ed684b22db79b519b4e74
Parents: 5e2c60d
Author: Michael Bolz <mi...@sap.com>
Authored: Wed Jun 17 15:48:14 2015 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Wed Jun 17 15:48:14 2015 +0200

----------------------------------------------------------------------
 samples/pom.xml                                 |   6 +
 samples/tutorials/p1_read/pom.xml               |  75 +++++++++
 .../mynamespace/service/DemoEdmProvider.java    | 153 +++++++++++++++++++
 .../service/DemoEntityCollectionProcessor.java  | 129 ++++++++++++++++
 .../myservice/mynamespace/web/DemoServlet.java  |  67 ++++++++
 .../p1_read/src/main/webapp/WEB-INF/web.xml     |  40 +++++
 .../tutorials/p1_read/src/main/webapp/index.jsp |   6 +
 samples/tutorials/pom.xml                       |  52 +++++++
 8 files changed, 528 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/7c557f25/samples/pom.xml
----------------------------------------------------------------------
diff --git a/samples/pom.xml b/samples/pom.xml
index 765bd95..95e3ddb 100644
--- a/samples/pom.xml
+++ b/samples/pom.xml
@@ -45,5 +45,11 @@
         <module>client</module>
       </modules>
     </profile>
+    <profile>
+      <id>tutorials</id>
+      <modules>
+        <module>tutorials</module>
+      </modules>
+    </profile>
   </profiles>
 </project>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/7c557f25/samples/tutorials/p1_read/pom.xml
----------------------------------------------------------------------
diff --git a/samples/tutorials/p1_read/pom.xml b/samples/tutorials/p1_read/pom.xml
new file mode 100755
index 0000000..c815f8d
--- /dev/null
+++ b/samples/tutorials/p1_read/pom.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>myservice.mynamespace</groupId>
+	<artifactId>DemoService</artifactId>
+	<packaging>war</packaging>
+	<version>0.0.1</version>
+
+	<name>DemoService Maven Webapp</name>
+
+	<properties>
+		<javax.version>2.5</javax.version>
+		<odata.version>4.0.0-beta-03</odata.version>
+		<slf4j.version>1.7.7</slf4j.version>
+	</properties>
+
+	<dependencies>
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>servlet-api</artifactId>
+			<version>${javax.version}</version>
+			<scope>provided</scope>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.olingo</groupId>
+			<artifactId>odata-server-api</artifactId>
+			<version>${odata.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.olingo</groupId>
+			<artifactId>odata-server-core</artifactId>
+			<version>${odata.version}</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.olingo</groupId>
+			<artifactId>odata-commons-api</artifactId>
+			<version>${odata.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.olingo</groupId>
+			<artifactId>odata-commons-core</artifactId>
+			<version>${odata.version}</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-simple</artifactId>
+			<version>${slf4j.version}</version>
+			<scope>runtime</scope>
+		</dependency>
+	</dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/7c557f25/samples/tutorials/p1_read/src/main/java/myservice/mynamespace/service/DemoEdmProvider.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p1_read/src/main/java/myservice/mynamespace/service/DemoEdmProvider.java b/samples/tutorials/p1_read/src/main/java/myservice/mynamespace/service/DemoEdmProvider.java
new file mode 100755
index 0000000..dd46e86
--- /dev/null
+++ b/samples/tutorials/p1_read/src/main/java/myservice/mynamespace/service/DemoEdmProvider.java
@@ -0,0 +1,153 @@
+/*
+ * 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 myservice.mynamespace.service;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.olingo.commons.api.ODataException;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.provider.CsdlAbstractEdmProvider;
+import org.apache.olingo.commons.api.edm.provider.CsdlEntityContainer;
+import org.apache.olingo.commons.api.edm.provider.CsdlEntityContainerInfo;
+import org.apache.olingo.commons.api.edm.provider.CsdlEntitySet;
+import org.apache.olingo.commons.api.edm.provider.CsdlEntityType;
+import org.apache.olingo.commons.api.edm.provider.CsdlProperty;
+import org.apache.olingo.commons.api.edm.provider.CsdlPropertyRef;
+import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
+
+/**
+ * this class is supposed to declare the metadata of the OData service
+ * it is invoked by the Olingo framework e.g. when the metadata document of the service is invoked
+ * e.g. http://localhost:8080/ExampleService1/ExampleService1.svc/$metadata
+ */
+public class DemoEdmProvider extends CsdlAbstractEdmProvider {
+
+  // Service Namespace
+  public static final String NAMESPACE = "OData.Demo";
+
+  // EDM Container
+  public static final String CONTAINER_NAME = "Container";
+  public static final FullQualifiedName CONTAINER = new FullQualifiedName(NAMESPACE, CONTAINER_NAME);
+
+  // Entity Types Names
+  public static final String ET_PRODUCT_NAME = "Product";
+  public static final FullQualifiedName ET_PRODUCT_FQN = new FullQualifiedName(NAMESPACE, ET_PRODUCT_NAME);
+
+  // Entity Set Names
+  public static final String ES_PRODUCTS_NAME = "Products";
+
+
+  @Override
+  public List<CsdlSchema> getSchemas() throws ODataException {
+
+    // create Schema
+    CsdlSchema schema = new CsdlSchema();
+    schema.setNamespace(NAMESPACE);
+
+    // add EntityTypes
+    List<CsdlEntityType> entityTypes = new ArrayList<CsdlEntityType>();
+    entityTypes.add(getEntityType(ET_PRODUCT_FQN));
+    schema.setEntityTypes(entityTypes);
+
+    // add EntityContainer
+    schema.setEntityContainer(getEntityContainer());
+
+    // finally
+    List<CsdlSchema> schemas = new ArrayList<CsdlSchema>();
+    schemas.add(schema);
+
+    return schemas;
+  }
+
+
+  @Override
+  public CsdlEntityType getEntityType(FullQualifiedName entityTypeName) throws ODataException {
+
+    // this method is called for one of the EntityTypes that are configured in the Schema
+    if(entityTypeName.equals(ET_PRODUCT_FQN)){
+
+      //create EntityType properties
+      CsdlProperty id = new CsdlProperty().setName("ID").setType(EdmPrimitiveTypeKind.Int32.getFullQualifiedName());
+      CsdlProperty name = new CsdlProperty().setName("Name").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
+      CsdlProperty  description = new CsdlProperty().setName("Description").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
+
+      // create CsdlPropertyRef for Key element
+      CsdlPropertyRef propertyRef = new CsdlPropertyRef();
+      propertyRef.setName("ID");
+
+      // configure EntityType
+      CsdlEntityType entityType = new CsdlEntityType();
+      entityType.setName(ET_PRODUCT_NAME);
+      entityType.setProperties(Arrays.asList(id, name , description));
+      entityType.setKey(Collections.singletonList(propertyRef));
+
+      return entityType;
+    }
+
+    return null;
+  }
+
+  @Override
+  public CsdlEntitySet getEntitySet(FullQualifiedName entityContainer, String entitySetName) throws ODataException {
+
+    if(entityContainer.equals(CONTAINER)){
+      if(entitySetName.equals(ES_PRODUCTS_NAME)){
+        CsdlEntitySet entitySet = new CsdlEntitySet();
+        entitySet.setName(ES_PRODUCTS_NAME);
+        entitySet.setType(ET_PRODUCT_FQN);
+
+        return entitySet;
+      }
+    }
+
+    return null;
+  }
+
+  @Override
+  public CsdlEntityContainer getEntityContainer() throws ODataException {
+
+    // create EntitySets
+    List<CsdlEntitySet> entitySets = new ArrayList<CsdlEntitySet>();
+    entitySets.add(getEntitySet(CONTAINER, ES_PRODUCTS_NAME));
+
+    // create EntityContainer
+    CsdlEntityContainer entityContainer = new CsdlEntityContainer();
+    entityContainer.setName(CONTAINER_NAME);
+    entityContainer.setEntitySets(entitySets);
+
+    return entityContainer;
+  }
+
+  @Override
+  public CsdlEntityContainerInfo getEntityContainerInfo(FullQualifiedName entityContainerName) throws ODataException {
+
+    // This method is invoked when displaying the service document at e.g. http://localhost:8080/DemoService/DemoService.svc
+    if(entityContainerName == null || entityContainerName.equals(CONTAINER)){
+      CsdlEntityContainerInfo entityContainerInfo = new CsdlEntityContainerInfo();
+      entityContainerInfo.setContainerName(CONTAINER);
+      return entityContainerInfo;
+    }
+
+    return null;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/7c557f25/samples/tutorials/p1_read/src/main/java/myservice/mynamespace/service/DemoEntityCollectionProcessor.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p1_read/src/main/java/myservice/mynamespace/service/DemoEntityCollectionProcessor.java b/samples/tutorials/p1_read/src/main/java/myservice/mynamespace/service/DemoEntityCollectionProcessor.java
new file mode 100755
index 0000000..e82a3ca
--- /dev/null
+++ b/samples/tutorials/p1_read/src/main/java/myservice/mynamespace/service/DemoEntityCollectionProcessor.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 myservice.mynamespace.service;
+
+import java.util.List;
+
+import org.apache.olingo.commons.api.data.ContextURL;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntityCollection;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ValueType;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.http.HttpHeader;
+import org.apache.olingo.commons.api.http.HttpStatusCode;
+import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.ODataApplicationException;
+import org.apache.olingo.server.api.ODataRequest;
+import org.apache.olingo.server.api.ODataResponse;
+import org.apache.olingo.server.api.ServiceMetadata;
+import org.apache.olingo.server.api.processor.EntityCollectionProcessor;
+import org.apache.olingo.server.api.serializer.EntityCollectionSerializerOptions;
+import org.apache.olingo.server.api.serializer.ODataSerializer;
+import org.apache.olingo.server.api.serializer.SerializerException;
+import org.apache.olingo.server.api.serializer.SerializerResult;
+import org.apache.olingo.server.api.uri.UriInfo;
+import org.apache.olingo.server.api.uri.UriResource;
+import org.apache.olingo.server.api.uri.UriResourceEntitySet;
+
+/**
+ * This class is invoked by the Olingo framework when the the OData service is invoked order to display a list/collection of data (entities).
+ * This is the case if an EntitySet is requested by the user.
+ * Such an example URL would be:
+ * http://localhost:8080/ExampleService1/ExampleService1.svc/Products
+ */
+public class DemoEntityCollectionProcessor implements EntityCollectionProcessor {
+
+  private OData odata;
+  private ServiceMetadata serviceMetadata;
+
+  // our processor is initialized with the OData context object
+  public void init(OData odata, ServiceMetadata serviceMetadata) {
+    this.odata = odata;
+    this.serviceMetadata = serviceMetadata;
+  }
+
+
+  // the only method that is declared in the EntityCollectionProcessor interface
+  // this method is called, when the user fires a request to an EntitySet
+  // in our example, the URL would be:
+  // http://localhost:8080/ExampleService1/ExampleServlet1.svc/Products
+  public void readEntityCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType responseFormat) throws ODataApplicationException, SerializerException {
+
+    // 1st we have retrieve the requested EntitySet from the uriInfo object (representation of the parsed service URI)
+    List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
+    UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0); // in our example, the first segment is the EntitySet
+    EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();
+
+    // 2nd: fetch the data from backend for this requested EntitySetName // it has to be delivered as EntitySet object
+    EntityCollection entitySet = getData(edmEntitySet);
+
+    // 3rd: create a serializer based on the requested format (json)
+    ODataFormat format = ODataFormat.fromContentType(responseFormat);
+    ODataSerializer serializer = odata.createSerializer(format);
+
+    // 4th: Now serialize the content: transform from the EntitySet object to InputStream
+    EdmEntityType edmEntityType = edmEntitySet.getEntityType();
+    ContextURL contextUrl = ContextURL.with().entitySet(edmEntitySet).build();
+
+    EntityCollectionSerializerOptions opts = EntityCollectionSerializerOptions.with().contextURL(contextUrl).build();
+    SerializerResult serializedContent = serializer.entityCollection(serviceMetadata, edmEntityType, entitySet, opts);
+
+    // Finally: configure the response object: set the body, headers and status code
+    response.setContent(serializedContent.getContent());
+    response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+    response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+  }
+
+
+  /**
+   * Helper method for providing some sample data
+   * @param edmEntitySet for which the data is requested
+   * @return data of requested entity set
+   */
+  private EntityCollection getData(EdmEntitySet edmEntitySet){
+
+    EntityCollection entityCollection = new EntityCollection();
+    // check for which EdmEntitySet the data is requested
+    if(DemoEdmProvider.ES_PRODUCTS_NAME.equals(edmEntitySet.getName())) {
+      List<Entity> entityList = entityCollection.getEntities();
+
+      // add some sample product entities
+      entityList.add(new Entity()
+            .addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 1))
+            .addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "Notebook Basic 15"))
+            .addProperty(new Property(null, "Description", ValueType.PRIMITIVE, "Notebook Basic, 1.7GHz - 15 XGA - 1024MB DDR2 SDRAM - 40GB")));
+
+      entityList.add(new Entity()
+            .addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 2))
+            .addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "1UMTS PDA"))
+            .addProperty(new Property(null, "Description", ValueType.PRIMITIVE, "Ultrafast 3G UMTS/HSDPA Pocket PC, supports GSM network")));
+
+      entityList.add(new Entity()
+            .addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 3))
+            .addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "Ergo Screen"))
+            .addProperty(new Property(null, "Description", ValueType.PRIMITIVE, "17 Optimum Resolution 1024 x 768 @ 85Hz, resolution 1280 x 960")));
+    }
+
+    return entityCollection;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/7c557f25/samples/tutorials/p1_read/src/main/java/myservice/mynamespace/web/DemoServlet.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p1_read/src/main/java/myservice/mynamespace/web/DemoServlet.java b/samples/tutorials/p1_read/src/main/java/myservice/mynamespace/web/DemoServlet.java
new file mode 100755
index 0000000..486770c
--- /dev/null
+++ b/samples/tutorials/p1_read/src/main/java/myservice/mynamespace/web/DemoServlet.java
@@ -0,0 +1,67 @@
+/*
+ * 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 myservice.mynamespace.web;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import myservice.mynamespace.service.DemoEdmProvider;
+import myservice.mynamespace.service.DemoEntityCollectionProcessor;
+
+import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.ODataHttpHandler;
+import org.apache.olingo.server.api.ServiceMetadata;
+import org.apache.olingo.server.api.edmx.EdmxReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class represents a standard HttpServlet implementation.
+ * It is used as main entry point for the web application that carries the OData service.
+ * The implementation of this HttpServlet simply delegates the user requests to the ODataHttpHandler
+ */
+public class DemoServlet extends HttpServlet {
+
+  private static final long serialVersionUID = 1L;
+  private static final Logger LOG = LoggerFactory.getLogger(DemoServlet.class);
+
+  @Override
+  protected void service(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
+
+    try {
+      // create odata handler and configure it with EdmProvider and Processor
+      OData odata = OData.newInstance();
+      ServiceMetadata edm = odata.createServiceMetadata(new DemoEdmProvider(), new ArrayList<EdmxReference>());
+      ODataHttpHandler handler = odata.createHandler(edm);
+      handler.register(new DemoEntityCollectionProcessor());
+
+      // let the handler do the work
+      handler.process(req, resp);
+
+    } catch (RuntimeException e) {
+      LOG.error("Server Error occurred in ExampleServlet", e);
+      throw new ServletException(e);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/7c557f25/samples/tutorials/p1_read/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/samples/tutorials/p1_read/src/main/webapp/WEB-INF/web.xml b/samples/tutorials/p1_read/src/main/webapp/WEB-INF/web.xml
new file mode 100755
index 0000000..21de52a
--- /dev/null
+++ b/samples/tutorials/p1_read/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+         or more contributor license agreements.  See the NOTICE file
+         distributed with this work for additional information
+         regarding copyright ownership.  The ASF licenses this file
+         to you under the Apache License, Version 2.0 (the
+         "License"); you may not use this file except in compliance
+         with the License.  You may obtain a copy of the License at
+
+           http://www.apache.org/licenses/LICENSE-2.0
+
+         Unless required by applicable law or agreed to in writing,
+         software distributed under the License is distributed on an
+         "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+         KIND, either express or implied.  See the License for the
+         specific language governing permissions and limitations
+         under the License.
+-->
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+				 id="WebApp_ID" version="2.5">
+
+	<!-- Register the HttpServlet implementation -->
+	<servlet>
+	  <servlet-name>DemoServlet</servlet-name>
+	  <servlet-class>myservice.mynamespace.web.DemoServlet</servlet-class>
+	  <load-on-startup>1</load-on-startup>
+	</servlet>
+	
+	<!-- 
+		Our OData service can be invoked at 
+		http://localhost:8080/DemoService/DemoService.svc
+	-->
+	<servlet-mapping>
+	  <servlet-name>DemoServlet</servlet-name>
+	  <url-pattern>/DemoService.svc/*</url-pattern>
+	</servlet-mapping>
+</web-app>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/7c557f25/samples/tutorials/p1_read/src/main/webapp/index.jsp
----------------------------------------------------------------------
diff --git a/samples/tutorials/p1_read/src/main/webapp/index.jsp b/samples/tutorials/p1_read/src/main/webapp/index.jsp
new file mode 100755
index 0000000..2baf543
--- /dev/null
+++ b/samples/tutorials/p1_read/src/main/webapp/index.jsp
@@ -0,0 +1,6 @@
+<html>
+<body>
+<h2>Hello World!</h2>
+<a href="DemoService.svc/">OData Olingo V4 Demo Service</a>
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/7c557f25/samples/tutorials/pom.xml
----------------------------------------------------------------------
diff --git a/samples/tutorials/pom.xml b/samples/tutorials/pom.xml
new file mode 100644
index 0000000..ba86233
--- /dev/null
+++ b/samples/tutorials/pom.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>odata-tutorials</artifactId>
+  <packaging>pom</packaging>
+  <name>${project.artifactId}</name>
+
+  <parent>
+    <groupId>org.apache.olingo</groupId>
+    <artifactId>odata-samples</artifactId>
+    <version>4.0.0-SNAPSHOT</version>
+    <relativePath>..</relativePath>
+  </parent>
+
+  <modules>
+    <module>p1_read</module>
+  </modules>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-deploy-plugin</artifactId>
+        <configuration>
+          <skip>true</skip>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>


[23/39] olingo-odata4 git commit: [OLINGO-694] Added read property and write tutorial (part 2 and 3)

Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f24c3874/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/util/Util.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/util/Util.java b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/util/Util.java
new file mode 100755
index 0000000..8ad19a0
--- /dev/null
+++ b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/util/Util.java
@@ -0,0 +1,122 @@
+/*
+ * 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 myservice.mynamespace.util;
+
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntityCollection;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.edm.EdmProperty;
+import org.apache.olingo.commons.api.edm.EdmType;
+import org.apache.olingo.commons.api.http.HttpStatusCode;
+import org.apache.olingo.server.api.ODataApplicationException;
+import org.apache.olingo.server.api.uri.UriInfoResource;
+import org.apache.olingo.server.api.uri.UriParameter;
+import org.apache.olingo.server.api.uri.UriResource;
+import org.apache.olingo.server.api.uri.UriResourceEntitySet;
+
+public class Util {
+
+  public static EdmEntitySet getEdmEntitySet(UriInfoResource uriInfo) throws ODataApplicationException {
+
+    List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
+    // To get the entity set we have to interpret all URI segments
+    if (!(resourcePaths.get(0) instanceof UriResourceEntitySet)) {
+      // Here we should interpret the whole URI but in this example we do not support navigation so we throw an
+      // exception
+      throw new ODataApplicationException("Invalid resource type for first segment.", HttpStatusCode.NOT_IMPLEMENTED
+          .getStatusCode(), Locale.ENGLISH);
+    }
+
+    UriResourceEntitySet uriResource = (UriResourceEntitySet) resourcePaths.get(0);
+
+    return uriResource.getEntitySet();
+  }
+
+  public static Entity findEntity(EdmEntityType edmEntityType, EntityCollection entitySet,
+      List<UriParameter> keyParams) throws ODataApplicationException {
+
+    List<Entity> entityList = entitySet.getEntities();
+
+    // loop over all entities in order to find that one that matches all keys in request
+    // e.g. contacts(ContactID=1, CompanyID=1)
+    for (Entity entity: entityList) {
+      boolean foundEntity = entityMatchesAllKeys(edmEntityType, entity, keyParams);
+      if (foundEntity) {
+        return entity;
+      }
+    }
+
+    return null;
+  }
+
+  public static boolean
+      entityMatchesAllKeys(EdmEntityType edmEntityType, Entity entity, List<UriParameter> keyParams)
+          throws ODataApplicationException {
+
+    // loop over all keys
+    for (final UriParameter key : keyParams) {
+      // key
+      String keyName = key.getName();
+      String keyText = key.getText();
+      
+      // Edm: we need this info for the comparison below
+      EdmProperty edmKeyProperty = (EdmProperty) edmEntityType.getProperty(keyName);
+      Boolean isNullable = edmKeyProperty.isNullable();
+      Integer maxLength = edmKeyProperty.getMaxLength();
+      Integer precision = edmKeyProperty.getPrecision();
+      Boolean isUnicode = edmKeyProperty.isUnicode();
+      Integer scale = edmKeyProperty.getScale();
+      // get the EdmType in order to compare
+      EdmType edmType = edmKeyProperty.getType();
+      EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) edmType;
+
+      // Runtime data: the value of the current entity
+      // don't need to check for null, this is done in olingo library
+      Object valueObject = entity.getProperty(keyName).getValue();
+
+      // now need to compare the valueObject with the keyText String
+      // this is done using the type.valueToString //
+      String valueAsString = null;
+      try {
+        valueAsString = edmPrimitiveType.valueToString(valueObject, isNullable, maxLength, precision, scale, isUnicode);
+      } catch (EdmPrimitiveTypeException e) {
+        throw new ODataApplicationException("Failed to retrieve String value", HttpStatusCode.INTERNAL_SERVER_ERROR
+            .getStatusCode(), Locale.ENGLISH, e);
+      }
+
+      if (valueAsString == null) {
+        return false;
+      }
+
+      boolean matches = valueAsString.equals(keyText);
+      if (!matches) {
+        // if any of the key properties is not found in the entity, we don't need to search further
+        return false;
+      }
+    }
+
+    return true;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f24c3874/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/web/DemoServlet.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/web/DemoServlet.java b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/web/DemoServlet.java
new file mode 100755
index 0000000..2e7b65f
--- /dev/null
+++ b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/web/DemoServlet.java
@@ -0,0 +1,73 @@
+/*
+ * 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 myservice.mynamespace.web;
+
+import java.io.IOException;
+import java.lang.Override;import java.lang.RuntimeException;import java.util.ArrayList;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import myservice.mynamespace.data.Storage;
+import myservice.mynamespace.service.DemoEdmProvider;
+import myservice.mynamespace.service.DemoEntityCollectionProcessor;
+import myservice.mynamespace.service.DemoEntityProcessor;
+import myservice.mynamespace.service.DemoPrimitiveProcessor;
+
+import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.ODataHttpHandler;
+import org.apache.olingo.server.api.ServiceMetadata;
+import org.apache.olingo.server.api.edmx.EdmxReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DemoServlet extends HttpServlet {
+
+  private static final long serialVersionUID = 1L;
+  private static final Logger LOG = LoggerFactory.getLogger(DemoServlet.class);
+
+  @Override
+  protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+    try {
+      HttpSession session = req.getSession(true);
+      Storage storage = (Storage) session.getAttribute(Storage.class.getName());
+      if (storage == null) {
+        storage = new Storage();
+        session.setAttribute(Storage.class.getName(), storage);
+      }
+
+      // create odata handler and configure it with EdmProvider and Processor
+      OData odata = OData.newInstance();
+      ServiceMetadata edm = odata.createServiceMetadata(new DemoEdmProvider(), new ArrayList<EdmxReference>());
+      ODataHttpHandler handler = odata.createHandler(edm);
+      handler.register(new DemoEntityCollectionProcessor(storage));
+      handler.register(new DemoEntityProcessor(storage));
+      handler.register(new DemoPrimitiveProcessor(storage));
+
+      // let the handler do the work
+      handler.process(req, resp);
+    } catch (RuntimeException e) {
+      LOG.error("Server Error occurred in ExampleServlet", e);
+      throw new ServletException(e);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f24c3874/samples/tutorials/p3_write/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/samples/tutorials/p3_write/src/main/webapp/WEB-INF/web.xml b/samples/tutorials/p3_write/src/main/webapp/WEB-INF/web.xml
new file mode 100755
index 0000000..21de52a
--- /dev/null
+++ b/samples/tutorials/p3_write/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+         or more contributor license agreements.  See the NOTICE file
+         distributed with this work for additional information
+         regarding copyright ownership.  The ASF licenses this file
+         to you under the Apache License, Version 2.0 (the
+         "License"); you may not use this file except in compliance
+         with the License.  You may obtain a copy of the License at
+
+           http://www.apache.org/licenses/LICENSE-2.0
+
+         Unless required by applicable law or agreed to in writing,
+         software distributed under the License is distributed on an
+         "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+         KIND, either express or implied.  See the License for the
+         specific language governing permissions and limitations
+         under the License.
+-->
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+				 id="WebApp_ID" version="2.5">
+
+	<!-- Register the HttpServlet implementation -->
+	<servlet>
+	  <servlet-name>DemoServlet</servlet-name>
+	  <servlet-class>myservice.mynamespace.web.DemoServlet</servlet-class>
+	  <load-on-startup>1</load-on-startup>
+	</servlet>
+	
+	<!-- 
+		Our OData service can be invoked at 
+		http://localhost:8080/DemoService/DemoService.svc
+	-->
+	<servlet-mapping>
+	  <servlet-name>DemoServlet</servlet-name>
+	  <url-pattern>/DemoService.svc/*</url-pattern>
+	</servlet-mapping>
+</web-app>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f24c3874/samples/tutorials/p3_write/src/main/webapp/index.jsp
----------------------------------------------------------------------
diff --git a/samples/tutorials/p3_write/src/main/webapp/index.jsp b/samples/tutorials/p3_write/src/main/webapp/index.jsp
new file mode 100755
index 0000000..7ffb4ba
--- /dev/null
+++ b/samples/tutorials/p3_write/src/main/webapp/index.jsp
@@ -0,0 +1,26 @@
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+
+-->
+<html>
+<body>
+<h2>Hello World!</h2>
+<a href="DemoService.svc/">OData Olingo V4 Demo Service</a>
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f24c3874/samples/tutorials/pom.xml
----------------------------------------------------------------------
diff --git a/samples/tutorials/pom.xml b/samples/tutorials/pom.xml
index ba86233..e64da0a 100644
--- a/samples/tutorials/pom.xml
+++ b/samples/tutorials/pom.xml
@@ -36,6 +36,8 @@
 
   <modules>
     <module>p1_read</module>
+    <module>p2_readep</module>
+    <module>p3_write</module>
   </modules>
 
   <build>


[22/39] olingo-odata4 git commit: [OLINGO-694] Fixed missing apache header in jsp file

Posted by ch...@apache.org.
[OLINGO-694] Fixed missing apache header in jsp file


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

Branch: refs/heads/IEE754Compatible
Commit: bff2ecf0a8a60b5a457663780404a7e5d25f0ed8
Parents: 7c557f2
Author: Michael Bolz <mi...@sap.com>
Authored: Wed Jun 17 15:51:57 2015 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Wed Jun 17 15:51:57 2015 +0200

----------------------------------------------------------------------
 .../tutorials/p1_read/src/main/webapp/index.jsp | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bff2ecf0/samples/tutorials/p1_read/src/main/webapp/index.jsp
----------------------------------------------------------------------
diff --git a/samples/tutorials/p1_read/src/main/webapp/index.jsp b/samples/tutorials/p1_read/src/main/webapp/index.jsp
index 2baf543..7ffb4ba 100755
--- a/samples/tutorials/p1_read/src/main/webapp/index.jsp
+++ b/samples/tutorials/p1_read/src/main/webapp/index.jsp
@@ -1,3 +1,23 @@
+<!--
+
+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.
+
+-->
 <html>
 <body>
 <h2>Hello World!</h2>


[10/39] olingo-odata4 git commit: [OLINGO-699] Moved serializer code to client module

Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java
deleted file mode 100755
index 5163412..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java
+++ /dev/null
@@ -1,421 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.serialization;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.AbstractMap.SimpleEntry;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.ODataError;
-import org.apache.olingo.commons.api.ODataPropertyType;
-import org.apache.olingo.commons.api.data.Annotatable;
-import org.apache.olingo.commons.api.data.Annotation;
-import org.apache.olingo.commons.api.data.ComplexValue;
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntityCollection;
-import org.apache.olingo.commons.api.data.Link;
-import org.apache.olingo.commons.api.data.Linked;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.data.Valuable;
-import org.apache.olingo.commons.api.data.ValueType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.geo.Geospatial;
-import org.apache.olingo.commons.api.serialization.ODataDeserializer;
-import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
-import org.apache.olingo.commons.core.edm.EdmTypeInfo;
-
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.ObjectCodec;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-public class JsonDeserializer implements ODataDeserializer {
-
-  protected final Pattern CUSTOM_ANNOTATION = Pattern.compile("(.+)@(.+)\\.(.+)");
-
-  protected final boolean serverMode;
-
-  private JsonGeoValueDeserializer geoDeserializer;
-
-  private JsonParser parser;
-
-  public JsonDeserializer(final boolean serverMode) {
-    this.serverMode = serverMode;
-  }
-
-  private JsonGeoValueDeserializer getGeoDeserializer() {
-    if (geoDeserializer == null) {
-      geoDeserializer = new JsonGeoValueDeserializer();
-    }
-    return geoDeserializer;
-  }
-
-  protected String getJSONAnnotation(final String string) {
-    return StringUtils.prependIfMissing(string, "@");
-  }
-
-  protected String getTitle(final Map.Entry<String, JsonNode> entry) {
-    return entry.getKey().substring(0, entry.getKey().indexOf('@'));
-  }
-
-  protected String setInline(final String name, final String suffix, final JsonNode tree,
-      final ObjectCodec codec, final Link link) throws IOException {
-
-    final String entityNamePrefix = name.substring(0, name.indexOf(suffix));
-    if (tree.has(entityNamePrefix)) {
-      final JsonNode inline = tree.path(entityNamePrefix);
-      JsonEntityDeserializer entityDeserializer = new JsonEntityDeserializer(serverMode);
-
-      if (inline instanceof ObjectNode) {
-        link.setType(Constants.ENTITY_NAVIGATION_LINK_TYPE);
-        link.setInlineEntity(entityDeserializer.doDeserialize(inline.traverse(codec)).getPayload());
-
-      } else if (inline instanceof ArrayNode) {
-        link.setType(Constants.ENTITY_SET_NAVIGATION_LINK_TYPE);
-
-        final EntityCollection entitySet = new EntityCollection();
-        for (final Iterator<JsonNode> entries = inline.elements(); entries.hasNext();) {
-          entitySet.getEntities().add(entityDeserializer.doDeserialize(entries.next().traverse(codec)).getPayload());
-        }
-
-        link.setInlineEntitySet(entitySet);
-      }
-    }
-    return entityNamePrefix;
-  }
-
-  protected void links(final Map.Entry<String, JsonNode> field, final Linked linked, final Set<String> toRemove,
-      final JsonNode tree, final ObjectCodec codec) throws IOException {
-    if (serverMode) {
-      serverLinks(field, linked, toRemove, tree, codec);
-    } else {
-      clientLinks(field, linked, toRemove, tree, codec);
-    }
-  }
-
-  private void clientLinks(final Map.Entry<String, JsonNode> field, final Linked linked, final Set<String> toRemove,
-      final JsonNode tree, final ObjectCodec codec) throws IOException {
-
-    if (field.getKey().endsWith(Constants.JSON_NAVIGATION_LINK)) {
-      final Link link = new Link();
-      link.setTitle(getTitle(field));
-      link.setRel(Constants.NS_NAVIGATION_LINK_REL + getTitle(field));
-
-      if (field.getValue().isValueNode()) {
-        link.setHref(field.getValue().textValue());
-        link.setType(Constants.ENTITY_NAVIGATION_LINK_TYPE);
-      }
-
-      linked.getNavigationLinks().add(link);
-
-      toRemove.add(field.getKey());
-      toRemove.add(setInline(field.getKey(), Constants.JSON_NAVIGATION_LINK, tree, codec, link));
-    } else if (field.getKey().endsWith(Constants.JSON_ASSOCIATION_LINK)) {
-      final Link link = new Link();
-      link.setTitle(getTitle(field));
-      link.setRel(Constants.NS_ASSOCIATION_LINK_REL + getTitle(field));
-      link.setHref(field.getValue().textValue());
-      link.setType(Constants.ASSOCIATION_LINK_TYPE);
-      linked.getAssociationLinks().add(link);
-
-      toRemove.add(field.getKey());
-    }
-  }
-
-  private void serverLinks(final Map.Entry<String, JsonNode> field, final Linked linked, final Set<String> toRemove,
-      final JsonNode tree, final ObjectCodec codec) throws IOException {
-
-    if (field.getKey().endsWith(Constants.JSON_BIND_LINK_SUFFIX)
-        || field.getKey().endsWith(Constants.JSON_NAVIGATION_LINK)) {
-
-      if (field.getValue().isValueNode()) {
-        final String suffix = field.getKey().replaceAll("^.*@", "@");
-
-        final Link link = new Link();
-        link.setTitle(getTitle(field));
-        link.setRel(Constants.NS_NAVIGATION_LINK_REL + getTitle(field));
-        link.setHref(field.getValue().textValue());
-        link.setType(Constants.ENTITY_NAVIGATION_LINK_TYPE);
-        linked.getNavigationLinks().add(link);
-
-        toRemove.add(setInline(field.getKey(), suffix, tree, codec, link));
-      } else if (field.getValue().isArray()) {
-        for (final Iterator<JsonNode> itor = field.getValue().elements(); itor.hasNext();) {
-          final JsonNode node = itor.next();
-
-          final Link link = new Link();
-          link.setTitle(getTitle(field));
-          link.setRel(Constants.NS_NAVIGATION_LINK_REL + getTitle(field));
-          link.setHref(node.asText());
-          link.setType(Constants.ENTITY_SET_NAVIGATION_LINK_TYPE);
-          linked.getNavigationLinks().add(link);
-          toRemove.add(setInline(field.getKey(), Constants.JSON_BIND_LINK_SUFFIX, tree, codec, link));
-        }
-      }
-      toRemove.add(field.getKey());
-    }
-  }
-
-  private Map.Entry<ODataPropertyType, EdmTypeInfo> guessPropertyType(final JsonNode node) {
-    ODataPropertyType type;
-    String typeExpression = null;
-
-    if (node.isValueNode() || node.isNull()) {
-      type = ODataPropertyType.PRIMITIVE;
-      typeExpression = guessPrimitiveTypeKind(node).getFullQualifiedName().toString();
-    } else if (node.isArray()) {
-      type = ODataPropertyType.COLLECTION;
-      if (node.has(0) && node.get(0).isValueNode()) {
-        typeExpression = "Collection(" + guessPrimitiveTypeKind(node.get(0)) + ')';
-      }
-    } else if (node.isObject()) {
-      if (node.has(Constants.ATTR_TYPE)) {
-        type = ODataPropertyType.PRIMITIVE;
-        typeExpression = "Edm.Geography" + node.get(Constants.ATTR_TYPE).asText();
-      } else {
-        type = ODataPropertyType.COMPLEX;
-      }
-    } else {
-      type = ODataPropertyType.EMPTY;
-    }
-
-    final EdmTypeInfo typeInfo = typeExpression == null ? null :
-      new EdmTypeInfo.Builder().setTypeExpression(typeExpression).build();
-    return new SimpleEntry<ODataPropertyType, EdmTypeInfo>(type, typeInfo);
-  }
-
-  private EdmPrimitiveTypeKind guessPrimitiveTypeKind(final JsonNode node) {
-    return node.isShort() ? EdmPrimitiveTypeKind.Int16 :
-      node.isInt() ? EdmPrimitiveTypeKind.Int32 :
-        node.isLong() ? EdmPrimitiveTypeKind.Int64 :
-          node.isBoolean() ? EdmPrimitiveTypeKind.Boolean :
-            node.isFloat() ? EdmPrimitiveTypeKind.Single :
-              node.isDouble() ? EdmPrimitiveTypeKind.Double :
-                node.isBigDecimal() ? EdmPrimitiveTypeKind.Decimal :
-                  EdmPrimitiveTypeKind.String;
-  }
-
-  protected void populate(final Annotatable annotatable, final List<Property> properties,
-      final ObjectNode tree, final ObjectCodec codec)
-          throws IOException, EdmPrimitiveTypeException {
-
-    String type = null;
-    Annotation annotation = null;
-    for (final Iterator<Map.Entry<String, JsonNode>> itor = tree.fields(); itor.hasNext();) {
-      final Map.Entry<String, JsonNode> field = itor.next();
-      final Matcher customAnnotation = CUSTOM_ANNOTATION.matcher(field.getKey());
-
-      if (field.getKey().charAt(0) == '@') {
-        final Annotation entityAnnot = new Annotation();
-        entityAnnot.setTerm(field.getKey().substring(1));
-
-        value(entityAnnot, field.getValue(), codec);
-        if (annotatable != null) {
-          annotatable.getAnnotations().add(entityAnnot);
-        }
-      } else if (type == null && field.getKey().endsWith(getJSONAnnotation(Constants.JSON_TYPE))) {
-        type = field.getValue().asText();
-      } else if (annotation == null && customAnnotation.matches() && !"odata".equals(customAnnotation.group(2))) {
-        annotation = new Annotation();
-        annotation.setTerm(customAnnotation.group(2) + "." + customAnnotation.group(3));
-        value(annotation, field.getValue(), codec);
-      } else {
-        final Property property = new Property();
-        property.setName(field.getKey());
-        property.setType(type == null
-            ? null
-                : new EdmTypeInfo.Builder().setTypeExpression(type).build().internal());
-        type = null;
-
-        value(property, field.getValue(), codec);
-        properties.add(property);
-
-        if (annotation != null) {
-          property.getAnnotations().add(annotation);
-          annotation = null;
-        }
-      }
-    }
-  }
-
-  private Object fromPrimitive(final JsonNode node, final EdmTypeInfo typeInfo) throws EdmPrimitiveTypeException {
-    return node.isNull() ? null
-        : typeInfo == null ? node.asText()
-            : typeInfo.getPrimitiveTypeKind().isGeospatial()
-            ? getGeoDeserializer().deserialize(node, typeInfo)
-                : ((EdmPrimitiveType) typeInfo.getType())
-                .valueOfString(node.asText(), true, null,
-                    Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, true,
-                    ((EdmPrimitiveType) typeInfo.getType()).getDefaultType());
-  }
-
-  private Object fromComplex(final ObjectNode node, final ObjectCodec codec)
-      throws IOException, EdmPrimitiveTypeException {
-
-    final ComplexValue complexValue = new ComplexValue();
-    final Set<String> toRemove = new HashSet<String>();
-    for (final Iterator<Map.Entry<String, JsonNode>> itor = node.fields(); itor.hasNext();) {
-      final Map.Entry<String, JsonNode> field = itor.next();
-
-      links(field, complexValue, toRemove, node, codec);
-    }
-    node.remove(toRemove);
-
-    populate(complexValue, complexValue.getValue(), node, codec);
-    return complexValue;
-  }
-
-  private void fromCollection(final Valuable valuable, final Iterator<JsonNode> nodeItor, final EdmTypeInfo typeInfo,
-      final ObjectCodec codec) throws IOException, EdmPrimitiveTypeException {
-
-    final List<Object> values = new ArrayList<Object>();
-    ValueType valueType = ValueType.COLLECTION_PRIMITIVE;
-
-    final EdmTypeInfo type = typeInfo == null ? null
-        : new EdmTypeInfo.Builder().setTypeExpression(typeInfo.getFullQualifiedName().toString()).build();
-
-    while (nodeItor.hasNext()) {
-      final JsonNode child = nodeItor.next();
-
-      if (child.isValueNode()) {
-        if (typeInfo == null || typeInfo.isPrimitiveType()) {
-          final Object value = fromPrimitive(child, type);
-          valueType = value instanceof Geospatial ? ValueType.COLLECTION_GEOSPATIAL : ValueType.COLLECTION_PRIMITIVE;
-          values.add(value);
-        } else {
-          valueType = ValueType.COLLECTION_ENUM;
-          values.add(child.asText());
-        }
-      } else if (child.isContainerNode()) {
-        if (child.has(Constants.JSON_TYPE)) {
-          ((ObjectNode) child).remove(Constants.JSON_TYPE);
-        }
-        final Object value = fromComplex((ObjectNode) child, codec);
-        valueType = ValueType.COLLECTION_COMPLEX;
-        values.add(value);
-      }
-    }
-    valuable.setValue(valueType, values);
-  }
-
-  protected void value(final Valuable valuable, final JsonNode node, final ObjectCodec codec)
-      throws IOException, EdmPrimitiveTypeException {
-
-    EdmTypeInfo typeInfo = StringUtils.isBlank(valuable.getType()) ? null
-        : new EdmTypeInfo.Builder().setTypeExpression(valuable.getType()).build();
-
-    final Map.Entry<ODataPropertyType, EdmTypeInfo> guessed = guessPropertyType(node);
-    if (typeInfo == null) {
-      typeInfo = guessed.getValue();
-    }
-
-    final ODataPropertyType propType = typeInfo == null ? guessed.getKey()
-        : typeInfo.isCollection() ? ODataPropertyType.COLLECTION
-            : typeInfo.isPrimitiveType() ? ODataPropertyType.PRIMITIVE
-                : node.isValueNode() ? ODataPropertyType.ENUM : ODataPropertyType.COMPLEX;
-
-    switch (propType) {
-    case COLLECTION:
-      fromCollection(valuable, node.elements(), typeInfo, codec);
-      break;
-
-    case COMPLEX:
-      if (node.has(Constants.JSON_TYPE)) {
-        valuable.setType(node.get(Constants.JSON_TYPE).asText());
-        ((ObjectNode) node).remove(Constants.JSON_TYPE);
-      }
-      final Object value = fromComplex((ObjectNode) node, codec);
-      valuable.setValue(ValueType.COMPLEX, value);
-      break;
-
-    case ENUM:
-      valuable.setValue(ValueType.ENUM, node.asText());
-      break;
-
-    case PRIMITIVE:
-      if (valuable.getType() == null && typeInfo != null) {
-        valuable.setType(typeInfo.getFullQualifiedName().toString());
-      }
-      final Object primitiveValue = fromPrimitive(node, typeInfo);
-      valuable.setValue(primitiveValue instanceof Geospatial ? ValueType.GEOSPATIAL : ValueType.PRIMITIVE,
-          primitiveValue);
-      break;
-
-    case EMPTY:
-    default:
-      valuable.setValue(ValueType.PRIMITIVE, StringUtils.EMPTY);
-    }
-  }
-
-  @Override
-  public ResWrap<EntityCollection> toEntitySet(final InputStream input) throws ODataDeserializerException {
-    try {
-      parser = new JsonFactory(new ObjectMapper()).createParser(input);
-      return new JsonEntitySetDeserializer(serverMode).doDeserialize(parser);
-    } catch (final IOException e) {
-      throw new ODataDeserializerException(e);
-    }
-  }
-
-  @Override
-  public ResWrap<Entity> toEntity(final InputStream input) throws ODataDeserializerException {
-    try {
-      parser = new JsonFactory(new ObjectMapper()).createParser(input);
-      return new JsonEntityDeserializer(serverMode).doDeserialize(parser);
-    } catch (final IOException e) {
-      throw new ODataDeserializerException(e);
-    }
-  }
-
-  @Override
-  public ResWrap<Property> toProperty(final InputStream input) throws ODataDeserializerException {
-    try {
-      parser = new JsonFactory(new ObjectMapper()).createParser(input);
-      return new JsonPropertyDeserializer(serverMode).doDeserialize(parser);
-    } catch (final IOException e) {
-      throw new ODataDeserializerException(e);
-    }
-  }
-
-  @Override
-  public ODataError toError(final InputStream input) throws ODataDeserializerException {
-    try {
-      parser = new JsonFactory(new ObjectMapper()).createParser(input);
-      return new JsonODataErrorDeserializer(serverMode).doDeserialize(parser);
-    } catch (final IOException e) {
-      throw new ODataDeserializerException(e);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntityDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntityDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntityDeserializer.java
deleted file mode 100644
index 10cc3bb..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntityDeserializer.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.serialization;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Matcher;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.Annotation;
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.Link;
-import org.apache.olingo.commons.api.data.Operation;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.core.edm.EdmTypeInfo;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Reads JSON string into an entity.
- * <br/>
- * If metadata information is available, the corresponding entity fields and content will be populated.
- */
-public class JsonEntityDeserializer extends JsonDeserializer {
-
-  public JsonEntityDeserializer(final boolean serverMode) {
-    super(serverMode);
-  }
-
-  protected ResWrap<Entity> doDeserialize(final JsonParser parser) throws IOException {
-
-    final ObjectNode tree = parser.getCodec().readTree(parser);
-
-    if (tree.has(Constants.VALUE) && tree.get(Constants.VALUE).isArray()) {
-      throw new JsonParseException("Expected OData Entity, found EntitySet", parser.getCurrentLocation());
-    }
-
-    final Entity entity = new Entity();
-
-    final URI contextURL;
-    if (tree.hasNonNull(Constants.JSON_CONTEXT)) {
-      contextURL = URI.create(tree.get(Constants.JSON_CONTEXT).textValue());
-      tree.remove(Constants.JSON_CONTEXT);
-    } else if (tree.hasNonNull(Constants.JSON_METADATA)) {
-      contextURL = URI.create(tree.get(Constants.JSON_METADATA).textValue());
-      tree.remove(Constants.JSON_METADATA);
-    } else {
-      contextURL = null;
-    }
-    if (contextURL != null) {
-      entity.setBaseURI(URI.create(StringUtils.substringBefore(contextURL.toASCIIString(), Constants.METADATA)));
-    }
-
-    final String metadataETag;
-    if (tree.hasNonNull(Constants.JSON_METADATA_ETAG)) {
-      metadataETag = tree.get(Constants.JSON_METADATA_ETAG).textValue();
-      tree.remove(Constants.JSON_METADATA_ETAG);
-    } else {
-      metadataETag = null;
-    }
-
-    if (tree.hasNonNull(Constants.JSON_ETAG)) {
-      entity.setETag(tree.get(Constants.JSON_ETAG).textValue());
-      tree.remove(Constants.JSON_ETAG);
-    }
-
-    if (tree.hasNonNull(Constants.JSON_TYPE)) {
-      entity.setType(new EdmTypeInfo.Builder().setTypeExpression(tree.get(Constants.JSON_TYPE).textValue()).build()
-          .internal());
-      tree.remove(Constants.JSON_TYPE);
-    }
-
-    if (tree.hasNonNull(Constants.JSON_ID)) {
-      entity.setId(URI.create(tree.get(Constants.JSON_ID).textValue()));
-      tree.remove(Constants.JSON_ID);
-    }
-
-    if (tree.hasNonNull(Constants.JSON_READ_LINK)) {
-      final Link link = new Link();
-      link.setRel(Constants.SELF_LINK_REL);
-      link.setHref(tree.get(Constants.JSON_READ_LINK).textValue());
-      entity.setSelfLink(link);
-
-      tree.remove(Constants.JSON_READ_LINK);
-    }
-
-    if (tree.hasNonNull(Constants.JSON_EDIT_LINK)) {
-      final Link link = new Link();
-      if (serverMode) {
-        link.setRel(Constants.EDIT_LINK_REL);
-      }
-      link.setHref(tree.get(Constants.JSON_EDIT_LINK).textValue());
-      entity.setEditLink(link);
-
-      tree.remove(Constants.JSON_EDIT_LINK);
-    }
-
-    if (tree.hasNonNull(Constants.JSON_MEDIA_READ_LINK)) {
-      entity.setMediaContentSource(URI.create(tree.get(Constants.JSON_MEDIA_READ_LINK).textValue()));
-      tree.remove(Constants.JSON_MEDIA_READ_LINK);
-    }
-    if (tree.hasNonNull(Constants.JSON_MEDIA_EDIT_LINK)) {
-      entity.setMediaContentSource(URI.create(tree.get(Constants.JSON_MEDIA_EDIT_LINK).textValue()));
-      tree.remove(Constants.JSON_MEDIA_EDIT_LINK);
-    }
-    if (tree.hasNonNull(Constants.JSON_MEDIA_CONTENT_TYPE)) {
-      entity.setMediaContentType(tree.get(Constants.JSON_MEDIA_CONTENT_TYPE).textValue());
-      tree.remove(Constants.JSON_MEDIA_CONTENT_TYPE);
-    }
-    if (tree.hasNonNull(Constants.JSON_MEDIA_ETAG)) {
-      entity.setMediaETag(tree.get(Constants.JSON_MEDIA_ETAG).textValue());
-      tree.remove(Constants.JSON_MEDIA_ETAG);
-    }
-
-    final Set<String> toRemove = new HashSet<String>();
-
-    final Map<String, List<Annotation>> annotations = new HashMap<String, List<Annotation>>();
-    for (final Iterator<Map.Entry<String, JsonNode>> itor = tree.fields(); itor.hasNext();) {
-      final Map.Entry<String, JsonNode> field = itor.next();
-      final Matcher customAnnotation = CUSTOM_ANNOTATION.matcher(field.getKey());
-
-      links(field, entity, toRemove, tree, parser.getCodec());
-      if (field.getKey().endsWith(getJSONAnnotation(Constants.JSON_MEDIA_EDIT_LINK))) {
-        final Link link = new Link();
-        link.setTitle(getTitle(field));
-        link.setRel(Constants.NS_MEDIA_EDIT_LINK_REL + getTitle(field));
-        link.setHref(field.getValue().textValue());
-        link.setType(Constants.MEDIA_EDIT_LINK_TYPE);
-        entity.getMediaEditLinks().add(link);
-
-        if (tree.has(link.getTitle() + getJSONAnnotation(Constants.JSON_MEDIA_ETAG))) {
-          link.setMediaETag(tree.get(link.getTitle() + getJSONAnnotation(Constants.JSON_MEDIA_ETAG)).asText());
-          toRemove.add(link.getTitle() + getJSONAnnotation(Constants.JSON_MEDIA_ETAG));
-        }
-
-        toRemove.add(field.getKey());
-        toRemove.add(setInline(field.getKey(), getJSONAnnotation(Constants.JSON_MEDIA_EDIT_LINK), tree, parser
-            .getCodec(), link));
-      } else if (field.getKey().endsWith(getJSONAnnotation(Constants.JSON_MEDIA_CONTENT_TYPE))) {
-        final String linkTitle = getTitle(field);
-        for (Link link : entity.getMediaEditLinks()) {
-          if (linkTitle.equals(link.getTitle())) {
-            link.setType(field.getValue().asText());
-          }
-        }
-        toRemove.add(field.getKey());
-      } else if (field.getKey().charAt(0) == '#') {
-        final Operation operation = new Operation();
-        operation.setMetadataAnchor(field.getKey());
-
-        final ObjectNode opNode = (ObjectNode) tree.get(field.getKey());
-        operation.setTitle(opNode.get(Constants.ATTR_TITLE).asText());
-        operation.setTarget(URI.create(opNode.get(Constants.ATTR_TARGET).asText()));
-
-        entity.getOperations().add(operation);
-
-        toRemove.add(field.getKey());
-      } else if (customAnnotation.matches() && !"odata".equals(customAnnotation.group(2))) {
-        final Annotation annotation = new Annotation();
-        annotation.setTerm(customAnnotation.group(2) + "." + customAnnotation.group(3));
-        try {
-          value(annotation, field.getValue(), parser.getCodec());
-        } catch (final EdmPrimitiveTypeException e) {
-          throw new IOException(e);
-        }
-
-        if (!annotations.containsKey(customAnnotation.group(1))) {
-          annotations.put(customAnnotation.group(1), new ArrayList<Annotation>());
-        }
-        annotations.get(customAnnotation.group(1)).add(annotation);
-      }
-    }
-
-    for (Link link : entity.getNavigationLinks()) {
-      if (annotations.containsKey(link.getTitle())) {
-        link.getAnnotations().addAll(annotations.get(link.getTitle()));
-        for (Annotation annotation : annotations.get(link.getTitle())) {
-          toRemove.add(link.getTitle() + "@" + annotation.getTerm());
-        }
-      }
-    }
-    for (Link link : entity.getMediaEditLinks()) {
-      if (annotations.containsKey(link.getTitle())) {
-        link.getAnnotations().addAll(annotations.get(link.getTitle()));
-        for (Annotation annotation : annotations.get(link.getTitle())) {
-          toRemove.add(link.getTitle() + "@" + annotation.getTerm());
-        }
-      }
-    }
-
-    tree.remove(toRemove);
-
-    try {
-      populate(entity, entity.getProperties(), tree, parser.getCodec());
-    } catch (final EdmPrimitiveTypeException e) {
-      throw new IOException(e);
-    }
-
-    return new ResWrap<Entity>(contextURL, metadataETag, entity);
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySerializer.java
deleted file mode 100644
index ddb789d..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySerializer.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.serialization;
-
-import java.io.IOException;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.Annotation;
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.Link;
-import org.apache.olingo.commons.api.data.Operation;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.core.edm.EdmTypeInfo;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-
-/**
- * Writes out JSON string from an entity.
- */
-public class JsonEntitySerializer extends JsonSerializer {
-
-  public JsonEntitySerializer(final boolean serverMode) {
-    super(serverMode);
-  }
-
-  public JsonEntitySerializer(final boolean serverMode, final ODataFormat format) {
-    super(serverMode, format);
-  }
-
-  protected void doSerialize(final Entity entity, final JsonGenerator jgen)
-      throws IOException, EdmPrimitiveTypeException {
-
-    doContainerSerialize(new ResWrap<Entity>(null, null, entity), jgen);
-  }
-
-  protected void doContainerSerialize(final ResWrap<Entity> container, final JsonGenerator jgen)
-      throws IOException, EdmPrimitiveTypeException {
-
-    final Entity entity = container.getPayload();
-
-    jgen.writeStartObject();
-
-    if (serverMode) {
-      if (container.getContextURL() != null) {
-        jgen.writeStringField(Constants.JSON_CONTEXT, container.getContextURL().toASCIIString());
-      }
-      if (StringUtils.isNotBlank(container.getMetadataETag())) {
-        jgen.writeStringField(Constants.JSON_METADATA_ETAG, container.getMetadataETag());
-      }
-
-      if (StringUtils.isNotBlank(entity.getETag())) {
-        jgen.writeStringField(Constants.JSON_ETAG, entity.getETag());
-      }
-    }
-
-    if (StringUtils.isNotBlank(entity.getType()) && format != ODataFormat.JSON_NO_METADATA) {
-      jgen.writeStringField(Constants.JSON_TYPE,
-          new EdmTypeInfo.Builder().setTypeExpression(entity.getType()).build().external());
-    }
-
-    if (entity.getId() != null && format != ODataFormat.JSON_NO_METADATA) {
-      jgen.writeStringField(Constants.JSON_ID, entity.getId().toASCIIString());
-    }
-
-    for (Annotation annotation : entity.getAnnotations()) {
-      valuable(jgen, annotation, "@" + annotation.getTerm());
-    }
-
-    for (Property property : entity.getProperties()) {
-      valuable(jgen, property, property.getName());
-    }
-
-    if (serverMode && entity.getEditLink() != null && StringUtils.isNotBlank(entity.getEditLink().getHref())) {
-      jgen.writeStringField(Constants.JSON_EDIT_LINK,
-          entity.getEditLink().getHref());
-
-      if (entity.isMediaEntity()) {
-        jgen.writeStringField(Constants.JSON_MEDIA_READ_LINK,
-            entity.getEditLink().getHref() + "/$value");
-      }
-    }
-
-    if (format != ODataFormat.JSON_NO_METADATA) {
-      links(entity, jgen);
-    }
-
-    for (Link link : entity.getMediaEditLinks()) {
-      if (link.getTitle() == null) {
-        jgen.writeStringField(Constants.JSON_MEDIA_EDIT_LINK, link.getHref());
-      }
-
-      if (link.getInlineEntity() != null) {
-        jgen.writeObjectField(link.getTitle(), link.getInlineEntity());
-      }
-      if (link.getInlineEntitySet() != null) {
-        jgen.writeArrayFieldStart(link.getTitle());
-        for (Entity subEntry : link.getInlineEntitySet().getEntities()) {
-          jgen.writeObject(subEntry);
-        }
-        jgen.writeEndArray();
-      }
-    }
-
-    if (serverMode) {
-      for (Operation operation : entity.getOperations()) {
-        jgen.writeObjectFieldStart("#" + StringUtils.substringAfterLast(operation.getMetadataAnchor(), "#"));
-        jgen.writeStringField(Constants.ATTR_TITLE, operation.getTitle());
-        jgen.writeStringField(Constants.ATTR_TARGET, operation.getTarget().toASCIIString());
-        jgen.writeEndObject();
-      }
-    }
-
-    jgen.writeEndObject();
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetDeserializer.java
deleted file mode 100644
index 354d4dd..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetDeserializer.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.serialization;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.Annotation;
-import org.apache.olingo.commons.api.data.EntityCollection;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Reads JSON string into an entity set.
- * <br/>
- * If metadata information is available, the corresponding entity fields and content will be populated.
- */
-public class JsonEntitySetDeserializer extends JsonDeserializer {
-
-  public JsonEntitySetDeserializer(final boolean serverMode) {
-    super(serverMode);
-  }
-
-  protected ResWrap<EntityCollection> doDeserialize(final JsonParser parser) throws IOException {
-
-    final ObjectNode tree = (ObjectNode) parser.getCodec().readTree(parser);
-
-    if (!tree.has(Constants.VALUE)) {
-      return null;
-    }
-
-    final EntityCollection entitySet = new EntityCollection();
-
-    URI contextURL;
-    if (tree.hasNonNull(Constants.JSON_CONTEXT)) {
-      contextURL = URI.create(tree.get(Constants.JSON_CONTEXT).textValue());
-      tree.remove(Constants.JSON_CONTEXT);
-    } else if (tree.hasNonNull(Constants.JSON_METADATA)) {
-      contextURL = URI.create(tree.get(Constants.JSON_METADATA).textValue());
-      tree.remove(Constants.JSON_METADATA);
-    } else {
-      contextURL = null;
-    }
-    if (contextURL != null) {
-      entitySet.setBaseURI(URI.create(StringUtils.substringBefore(contextURL.toASCIIString(), Constants.METADATA)));
-    }
-
-    final String metadataETag;
-    if (tree.hasNonNull(Constants.JSON_METADATA_ETAG)) {
-      metadataETag = tree.get(Constants.JSON_METADATA_ETAG).textValue();
-      tree.remove(Constants.JSON_METADATA_ETAG);
-    } else {
-      metadataETag = null;
-    }
-
-    if (tree.hasNonNull(Constants.JSON_COUNT)) {
-      entitySet.setCount(tree.get(Constants.JSON_COUNT).asInt());
-      tree.remove(Constants.JSON_COUNT);
-    }
-    if (tree.hasNonNull(Constants.JSON_NEXT_LINK)) {
-      entitySet.setNext(URI.create(tree.get(Constants.JSON_NEXT_LINK).textValue()));
-      tree.remove(Constants.JSON_NEXT_LINK);
-    }
-    if (tree.hasNonNull(Constants.JSON_DELTA_LINK)) {
-      entitySet.setDeltaLink(URI.create(tree.get(Constants.JSON_DELTA_LINK).textValue()));
-      tree.remove(Constants.JSON_DELTA_LINK);
-    }
-
-    if (tree.hasNonNull(Constants.VALUE)) {
-      final JsonEntityDeserializer entityDeserializer = new JsonEntityDeserializer(serverMode);
-      for (JsonNode jsonNode : tree.get(Constants.VALUE)) {
-        entitySet.getEntities().add(
-            entityDeserializer.doDeserialize(jsonNode.traverse(parser.getCodec())).getPayload());
-      }
-      tree.remove(Constants.VALUE);
-    }
-
-    // any remaining entry is supposed to be an annotation or is ignored
-    for (final Iterator<Map.Entry<String, JsonNode>> itor = tree.fields(); itor.hasNext();) {
-      final Map.Entry<String, JsonNode> field = itor.next();
-      if (field.getKey().charAt(0) == '@') {
-        final Annotation annotation = new Annotation();
-        annotation.setTerm(field.getKey().substring(1));
-
-        try {
-          value(annotation, field.getValue(), parser.getCodec());
-        } catch (final EdmPrimitiveTypeException e) {
-          throw new IOException(e);
-        }
-        entitySet.getAnnotations().add(annotation);
-      }
-    }
-
-    return new ResWrap<EntityCollection>(contextURL, metadataETag, entitySet);
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetSerializer.java
deleted file mode 100644
index b7a21da..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetSerializer.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.serialization;
-
-import java.io.IOException;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.Annotation;
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntityCollection;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-
-public class JsonEntitySetSerializer extends JsonSerializer {
-
-  public JsonEntitySetSerializer(final boolean serverMode) {
-    super(serverMode);
-  }
-
-  protected void doSerialize(final EntityCollection entitySet, final JsonGenerator jgen)
-      throws IOException, EdmPrimitiveTypeException {
-    doContainerSerialize(new ResWrap<EntityCollection>(null, null, entitySet), jgen);
-  }
-
-  protected void doContainerSerialize(final ResWrap<EntityCollection> container, final JsonGenerator jgen)
-      throws IOException, EdmPrimitiveTypeException {
-
-    final EntityCollection entitySet = container.getPayload();
-
-    jgen.writeStartObject();
-
-    if (serverMode) {
-      if (container.getContextURL() != null) {
-        jgen.writeStringField(Constants.JSON_CONTEXT, container.getContextURL().toASCIIString());
-      }
-
-      if (StringUtils.isNotBlank(container.getMetadataETag())) {
-        jgen.writeStringField(
-            Constants.JSON_METADATA_ETAG,
-            container.getMetadataETag());
-      }
-    }
-
-    if (entitySet.getId() != null) {
-      jgen.writeStringField(Constants.JSON_ID, entitySet.getId().toASCIIString());
-    }
-    jgen.writeNumberField(Constants.JSON_COUNT,
-        entitySet.getCount() == null ? entitySet.getEntities().size() : entitySet.getCount());
-    if (serverMode) {
-      if (entitySet.getNext() != null) {
-        jgen.writeStringField(Constants.JSON_NEXT_LINK,
-            entitySet.getNext().toASCIIString());
-      }
-      if (entitySet.getDeltaLink() != null) {
-        jgen.writeStringField(Constants.JSON_DELTA_LINK,
-            entitySet.getDeltaLink().toASCIIString());
-      }
-    }
-
-    for (Annotation annotation : entitySet.getAnnotations()) {
-      valuable(jgen, annotation, "@" + annotation.getTerm());
-    }
-
-    jgen.writeArrayFieldStart(Constants.VALUE);
-    final JsonEntitySerializer entitySerializer = new JsonEntitySerializer(serverMode);
-    for (Entity entity : entitySet.getEntities()) {
-      entitySerializer.doSerialize(entity, jgen);
-    }
-    jgen.writeEndArray();
-
-    jgen.writeEndObject();
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonGeoValueDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonGeoValueDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonGeoValueDeserializer.java
deleted file mode 100644
index 6bd3d7e..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonGeoValueDeserializer.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.serialization;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.GeoUtils;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.geo.Geospatial;
-import org.apache.olingo.commons.api.edm.geo.GeospatialCollection;
-import org.apache.olingo.commons.api.edm.geo.LineString;
-import org.apache.olingo.commons.api.edm.geo.MultiLineString;
-import org.apache.olingo.commons.api.edm.geo.MultiPoint;
-import org.apache.olingo.commons.api.edm.geo.MultiPolygon;
-import org.apache.olingo.commons.api.edm.geo.Point;
-import org.apache.olingo.commons.api.edm.geo.Polygon;
-import org.apache.olingo.commons.api.edm.geo.SRID;
-import org.apache.olingo.commons.core.edm.EdmTypeInfo;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmDouble;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-class JsonGeoValueDeserializer {
-
-  private Point point(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type, final SRID srid) {
-    Point point = null;
-
-    if (itor.hasNext()) {
-      point = new Point(GeoUtils.getDimension(type), srid);
-      try {
-        point.setX(EdmDouble.getInstance().valueOfString(itor.next().asText(), null, null,
-            Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, Double.class));
-        point.setY(EdmDouble.getInstance().valueOfString(itor.next().asText(), null, null,
-            Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, Double.class));
-      } catch (EdmPrimitiveTypeException e) {
-        throw new IllegalArgumentException("While deserializing point coordinates as double", e);
-      }
-    }
-
-    return point;
-  }
-
-  private MultiPoint multipoint(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type, final SRID srid) {
-    final MultiPoint multiPoint;
-
-    if (itor.hasNext()) {
-      final List<Point> points = new ArrayList<Point>();
-      while (itor.hasNext()) {
-        final Iterator<JsonNode> mpItor = itor.next().elements();
-        points.add(point(mpItor, type, srid));
-      }
-      multiPoint = new MultiPoint(GeoUtils.getDimension(type), srid, points);
-    } else {
-      multiPoint = new MultiPoint(GeoUtils.getDimension(type), srid, Collections.<Point> emptyList());
-    }
-
-    return multiPoint;
-  }
-
-  private LineString lineString(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type, final SRID srid) {
-    final LineString lineString;
-
-    if (itor.hasNext()) {
-      final List<Point> points = new ArrayList<Point>();
-      while (itor.hasNext()) {
-        final Iterator<JsonNode> mpItor = itor.next().elements();
-        points.add(point(mpItor, type, srid));
-      }
-      lineString = new LineString(GeoUtils.getDimension(type), srid, points);
-    } else {
-      lineString = new LineString(GeoUtils.getDimension(type), srid, Collections.<Point> emptyList());
-    }
-
-    return lineString;
-  }
-
-  private MultiLineString multiLineString(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type,
-      final SRID srid) {
-
-    final MultiLineString multiLineString;
-
-    if (itor.hasNext()) {
-      final List<LineString> lineStrings = new ArrayList<LineString>();
-      while (itor.hasNext()) {
-        final Iterator<JsonNode> mlsItor = itor.next().elements();
-        lineStrings.add(lineString(mlsItor, type, srid));
-      }
-      multiLineString = new MultiLineString(GeoUtils.getDimension(type), srid, lineStrings);
-    } else {
-      multiLineString = new MultiLineString(GeoUtils.getDimension(type), srid, Collections.<LineString> emptyList());
-    }
-
-    return multiLineString;
-  }
-
-  private Polygon polygon(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type, final SRID srid) {
-    List<Point> extPoints = null;
-    if (itor.hasNext()) {
-      final Iterator<JsonNode> extItor = itor.next().elements();
-      if (extItor.hasNext()) {
-        extPoints = new ArrayList<Point>();
-        while (extItor.hasNext()) {
-          final Iterator<JsonNode> mpItor = extItor.next().elements();
-          extPoints.add(point(mpItor, type, srid));
-        }
-      }
-    }
-
-    List<Point> intPoints = null;
-    if (itor.hasNext()) {
-      final Iterator<JsonNode> intItor = itor.next().elements();
-      if (intItor.hasNext()) {
-        intPoints = new ArrayList<Point>();
-        while (intItor.hasNext()) {
-          final Iterator<JsonNode> mpItor = intItor.next().elements();
-          intPoints.add(point(mpItor, type, srid));
-        }
-      }
-    }
-
-    return new Polygon(GeoUtils.getDimension(type), srid, intPoints, extPoints);
-  }
-
-  private MultiPolygon multiPolygon(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type, final SRID srid) {
-    final MultiPolygon multiPolygon;
-
-    if (itor.hasNext()) {
-      final List<Polygon> polygons = new ArrayList<Polygon>();
-      while (itor.hasNext()) {
-        final Iterator<JsonNode> mpItor = itor.next().elements();
-        polygons.add(polygon(mpItor, type, srid));
-      }
-      multiPolygon = new MultiPolygon(GeoUtils.getDimension(type), srid, polygons);
-    } else {
-      multiPolygon = new MultiPolygon(GeoUtils.getDimension(type), srid, Collections.<Polygon> emptyList());
-    }
-
-    return multiPolygon;
-  }
-
-  private GeospatialCollection collection(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type,
-      final SRID srid) {
-
-    final GeospatialCollection collection;
-
-    if (itor.hasNext()) {
-      final List<Geospatial> geospatials = new ArrayList<Geospatial>();
-
-      while (itor.hasNext()) {
-        final JsonNode geo = itor.next();
-        final String collItemType = geo.get(Constants.ATTR_TYPE).asText();
-        final String callAsType;
-        if (EdmPrimitiveTypeKind.GeographyCollection.name().equals(collItemType)
-            || EdmPrimitiveTypeKind.GeometryCollection.name().equals(collItemType)) {
-
-          callAsType = collItemType;
-        } else {
-          callAsType = (type == EdmPrimitiveTypeKind.GeographyCollection ? "Geography" : "Geometry")
-              + collItemType;
-        }
-
-        geospatials.add(deserialize(geo, new EdmTypeInfo.Builder().setTypeExpression(callAsType).build()));
-      }
-
-      collection = new GeospatialCollection(GeoUtils.getDimension(type), srid, geospatials);
-    } else {
-      collection = new GeospatialCollection(GeoUtils.getDimension(type), srid, Collections.<Geospatial> emptyList());
-    }
-
-    return collection;
-  }
-
-  public Geospatial deserialize(final JsonNode node, final EdmTypeInfo typeInfo) {
-    final EdmPrimitiveTypeKind actualType;
-    if ((typeInfo.getPrimitiveTypeKind() == EdmPrimitiveTypeKind.Geography
-        || typeInfo.getPrimitiveTypeKind() == EdmPrimitiveTypeKind.Geometry)
-        && node.has(Constants.ATTR_TYPE)) {
-
-      String nodeType = node.get(Constants.ATTR_TYPE).asText();
-      if (nodeType.startsWith("Geo")) {
-        final int yIdx = nodeType.indexOf('y');
-        nodeType = nodeType.substring(yIdx + 1);
-      }
-      actualType = EdmPrimitiveTypeKind.valueOfFQN(typeInfo.getFullQualifiedName().toString() + nodeType);
-    } else {
-      actualType = typeInfo.getPrimitiveTypeKind();
-    }
-
-    final Iterator<JsonNode> cooItor = node.has(Constants.JSON_COORDINATES)
-        ? node.get(Constants.JSON_COORDINATES).elements()
-            : Collections.<JsonNode> emptyList().iterator();
-
-        SRID srid = null;
-        if (node.has(Constants.JSON_CRS)) {
-          srid = SRID.valueOf(
-              node.get(Constants.JSON_CRS).get(Constants.PROPERTIES).get(Constants.JSON_NAME).asText().split(":")[1]);
-        }
-
-        Geospatial value = null;
-        switch (actualType) {
-        case GeographyPoint:
-        case GeometryPoint:
-          value = point(cooItor, actualType, srid);
-          break;
-
-        case GeographyMultiPoint:
-        case GeometryMultiPoint:
-          value = multipoint(cooItor, actualType, srid);
-          break;
-
-        case GeographyLineString:
-        case GeometryLineString:
-          value = lineString(cooItor, actualType, srid);
-          break;
-
-        case GeographyMultiLineString:
-        case GeometryMultiLineString:
-          value = multiLineString(cooItor, actualType, srid);
-          break;
-
-        case GeographyPolygon:
-        case GeometryPolygon:
-          value = polygon(cooItor, actualType, srid);
-          break;
-
-        case GeographyMultiPolygon:
-        case GeometryMultiPolygon:
-          value = multiPolygon(cooItor, actualType, srid);
-          break;
-
-        case GeographyCollection:
-        case GeometryCollection:
-          value = collection(node.get(Constants.JSON_GEOMETRIES).elements(), actualType, srid);
-          break;
-
-        default:
-        }
-
-        return value;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonGeoValueSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonGeoValueSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonGeoValueSerializer.java
deleted file mode 100644
index 7cd382b..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonGeoValueSerializer.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.serialization;
-
-import java.io.IOException;
-
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.geo.ComposedGeospatial;
-import org.apache.olingo.commons.api.edm.geo.Geospatial;
-import org.apache.olingo.commons.api.edm.geo.GeospatialCollection;
-import org.apache.olingo.commons.api.edm.geo.LineString;
-import org.apache.olingo.commons.api.edm.geo.MultiLineString;
-import org.apache.olingo.commons.api.edm.geo.MultiPoint;
-import org.apache.olingo.commons.api.edm.geo.MultiPolygon;
-import org.apache.olingo.commons.api.edm.geo.Point;
-import org.apache.olingo.commons.api.edm.geo.Polygon;
-import org.apache.olingo.commons.api.edm.geo.SRID;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmDouble;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-
-class JsonGeoValueSerializer {
-
-  private void srid(final JsonGenerator jgen, final SRID srid) throws IOException {
-    jgen.writeObjectFieldStart(Constants.JSON_CRS);
-    jgen.writeStringField(Constants.ATTR_TYPE, Constants.JSON_NAME);
-    jgen.writeObjectFieldStart(Constants.PROPERTIES);
-    jgen.writeStringField(Constants.JSON_NAME, "EPSG:" + srid.toString());
-    jgen.writeEndObject();
-    jgen.writeEndObject();
-  }
-
-  private void point(final JsonGenerator jgen, final Point point) throws IOException {
-    try {
-      jgen.writeNumber(EdmDouble.getInstance().valueToString(point.getX(), null, null,
-          Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null));
-      jgen.writeNumber(EdmDouble.getInstance().valueToString(point.getY(), null, null,
-          Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null));
-    } catch (EdmPrimitiveTypeException e) {
-      throw new IllegalArgumentException("While serializing point coordinates as double", e);
-    }
-  }
-
-  private void multipoint(final JsonGenerator jgen, final MultiPoint multiPoint) throws IOException {
-    for (Point point : multiPoint) {
-      jgen.writeStartArray();
-      point(jgen, point);
-      jgen.writeEndArray();
-    }
-  }
-
-  private void lineString(final JsonGenerator jgen, final ComposedGeospatial<Point> lineString) throws IOException {
-    for (Point point : lineString) {
-      jgen.writeStartArray();
-      point(jgen, point);
-      jgen.writeEndArray();
-    }
-  }
-
-  private void multiLineString(final JsonGenerator jgen, final MultiLineString multiLineString) throws IOException {
-    for (LineString lineString : multiLineString) {
-      jgen.writeStartArray();
-      lineString(jgen, lineString);
-      jgen.writeEndArray();
-    }
-  }
-
-  private void polygon(final JsonGenerator jgen, final Polygon polygon) throws IOException {
-    if (!polygon.getExterior().isEmpty()) {
-      jgen.writeStartArray();
-      lineString(jgen, polygon.getExterior());
-      jgen.writeEndArray();
-    }
-    if (!polygon.getInterior().isEmpty()) {
-      jgen.writeStartArray();
-      lineString(jgen, polygon.getInterior());
-      jgen.writeEndArray();
-    }
-  }
-
-  private void multiPolygon(final JsonGenerator jgen, final MultiPolygon multiPolygon) throws IOException {
-    for (Polygon polygon : multiPolygon) {
-      jgen.writeStartArray();
-      polygon(jgen, polygon);
-      jgen.writeEndArray();
-    }
-  }
-
-  private void collection(final JsonGenerator jgen, final GeospatialCollection collection) throws IOException {
-    jgen.writeArrayFieldStart(Constants.JSON_GEOMETRIES);
-    for (Geospatial geospatial : collection) {
-      jgen.writeStartObject();
-      serialize(jgen, geospatial);
-      jgen.writeEndObject();
-    }
-    jgen.writeEndArray();
-  }
-
-  public void serialize(final JsonGenerator jgen, final Geospatial value) throws IOException {
-    if (value.getEdmPrimitiveTypeKind().equals(EdmPrimitiveTypeKind.GeographyCollection)
-        || value.getEdmPrimitiveTypeKind().equals(EdmPrimitiveTypeKind.GeometryCollection)) {
-
-      jgen.writeStringField(Constants.ATTR_TYPE, EdmPrimitiveTypeKind.GeometryCollection.name());
-    } else {
-      final int yIdx = value.getEdmPrimitiveTypeKind().name().indexOf('y');
-      final String itemType = value.getEdmPrimitiveTypeKind().name().substring(yIdx + 1);
-      jgen.writeStringField(Constants.ATTR_TYPE, itemType);
-    }
-
-    switch (value.getEdmPrimitiveTypeKind()) {
-    case GeographyPoint:
-    case GeometryPoint:
-      jgen.writeArrayFieldStart(Constants.JSON_COORDINATES);
-      point(jgen, (Point) value);
-      jgen.writeEndArray();
-      break;
-
-    case GeographyMultiPoint:
-    case GeometryMultiPoint:
-      jgen.writeArrayFieldStart(Constants.JSON_COORDINATES);
-      multipoint(jgen, (MultiPoint) value);
-      jgen.writeEndArray();
-      break;
-
-    case GeographyLineString:
-    case GeometryLineString:
-      jgen.writeArrayFieldStart(Constants.JSON_COORDINATES);
-      lineString(jgen, (LineString) value);
-      jgen.writeEndArray();
-      break;
-
-    case GeographyMultiLineString:
-    case GeometryMultiLineString:
-      jgen.writeArrayFieldStart(Constants.JSON_COORDINATES);
-      multiLineString(jgen, (MultiLineString) value);
-      jgen.writeEndArray();
-      break;
-
-    case GeographyPolygon:
-    case GeometryPolygon:
-      jgen.writeArrayFieldStart(Constants.JSON_COORDINATES);
-      polygon(jgen, (Polygon) value);
-      jgen.writeEndArray();
-      break;
-
-    case GeographyMultiPolygon:
-    case GeometryMultiPolygon:
-      jgen.writeArrayFieldStart(Constants.JSON_COORDINATES);
-      multiPolygon(jgen, (MultiPolygon) value);
-      jgen.writeEndArray();
-      break;
-
-    case GeographyCollection:
-    case GeometryCollection:
-      collection(jgen, (GeospatialCollection) value);
-      break;
-
-    default:
-    }
-
-    if (value.getSrid() != null && value.getSrid().isNotDefault()) {
-      srid(jgen, value.getSrid());
-    }
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonODataErrorDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonODataErrorDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonODataErrorDeserializer.java
deleted file mode 100644
index 3636db6..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonODataErrorDeserializer.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.serialization;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.ODataError;
-import org.apache.olingo.commons.api.ODataErrorDetail;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-public class JsonODataErrorDeserializer extends JsonDeserializer {
-
-  public JsonODataErrorDeserializer(final boolean serverMode) {
-    super(serverMode);
-  }
-
-  protected ODataError doDeserialize(final JsonParser parser) throws IOException {
-
-    final ODataError error = new ODataError();
-
-    final ObjectNode tree = parser.getCodec().readTree(parser);
-    if (tree.has(Constants.JSON_ERROR)) {
-      final JsonNode errorNode = tree.get(Constants.JSON_ERROR);
-
-      if (errorNode.has(Constants.ERROR_CODE)) {
-        error.setCode(errorNode.get(Constants.ERROR_CODE).textValue());
-      }
-      if (errorNode.has(Constants.ERROR_MESSAGE)) {
-        final JsonNode message = errorNode.get(Constants.ERROR_MESSAGE);
-        if (message.isValueNode()) {
-          error.setMessage(message.textValue());
-        } else if (message.isObject()) {
-          error.setMessage(message.get(Constants.VALUE).asText());
-        }
-      }
-      if (errorNode.has(Constants.ERROR_TARGET)) {
-        error.setTarget(errorNode.get(Constants.ERROR_TARGET).textValue());
-      }
-      if (errorNode.hasNonNull(Constants.ERROR_DETAILS)) {
-        List<ODataErrorDetail> details = new ArrayList<ODataErrorDetail>();
-        JsonODataErrorDetailDeserializer detailDeserializer = new JsonODataErrorDetailDeserializer(serverMode);
-        for (JsonNode jsonNode : errorNode.get(Constants.ERROR_DETAILS)) {
-          details.add(detailDeserializer.doDeserialize(jsonNode.traverse(parser.getCodec()))
-              .getPayload());
-        }
-
-        error.setDetails(details);
-      }
-      if (errorNode.hasNonNull(Constants.ERROR_INNERERROR)) {
-        HashMap<String, String> innerErrorMap = new HashMap<String, String>();
-        final JsonNode innerError = errorNode.get(Constants.ERROR_INNERERROR);
-        for (final Iterator<String> itor = innerError.fieldNames(); itor.hasNext();) {
-          final String keyTmp = itor.next();
-          final String val = innerError.get(keyTmp).toString();
-          innerErrorMap.put(keyTmp, val);
-        }
-        error.setInnerError(innerErrorMap);
-      }
-    }
-
-    return error;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonODataErrorDetailDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonODataErrorDetailDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonODataErrorDetailDeserializer.java
deleted file mode 100644
index 1c6a187..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonODataErrorDetailDeserializer.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.serialization;
-
-import java.io.IOException;
-import java.net.URI;
-
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.ODataErrorDetail;
-import org.apache.olingo.commons.api.data.ResWrap;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.JsonNode;
-
-public class JsonODataErrorDetailDeserializer extends JsonDeserializer {
-
-  public JsonODataErrorDetailDeserializer(final boolean serverMode) {
-    super(serverMode);
-  }
-
-  protected ResWrap<ODataErrorDetail> doDeserialize(final JsonParser parser) throws IOException {
-
-    final ODataErrorDetail error = new ODataErrorDetail();
-    final JsonNode errorNode = parser.getCodec().readTree(parser);
-    if (errorNode.has(Constants.ERROR_CODE)) {
-      error.setCode(errorNode.get(Constants.ERROR_CODE).textValue());
-    }
-    if (errorNode.has(Constants.ERROR_MESSAGE)) {
-      final JsonNode message = errorNode.get(Constants.ERROR_MESSAGE);
-      if (message.isValueNode()) {
-        error.setMessage(message.textValue());
-      } else if (message.isObject()) {
-        error.setMessage(message.get(Constants.VALUE).asText());
-      }
-    }
-    if (errorNode.has(Constants.ERROR_TARGET)) {
-      error.setTarget(errorNode.get(Constants.ERROR_TARGET).textValue());
-    }
-
-    return new ResWrap<ODataErrorDetail>((URI) null, null, error);
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertyDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertyDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertyDeserializer.java
deleted file mode 100644
index 8738dd5..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertyDeserializer.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.serialization;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.Annotation;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.data.ValueType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.core.edm.EdmTypeInfo;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Parse JSON string into <tt>Property</tt>.
- */
-public class JsonPropertyDeserializer extends JsonDeserializer {
-
-  public JsonPropertyDeserializer(final boolean serverMode) {
-    super(serverMode);
-  }
-
-  protected ResWrap<Property> doDeserialize(final JsonParser parser) throws IOException {
-
-    final ObjectNode tree = parser.getCodec().readTree(parser);
-
-    final String metadataETag;
-    final URI contextURL;
-    final Property property = new Property();
-
-    if (tree.hasNonNull(Constants.JSON_METADATA_ETAG)) {
-      metadataETag = tree.get(Constants.JSON_METADATA_ETAG).textValue();
-      tree.remove(Constants.JSON_METADATA_ETAG);
-    } else {
-      metadataETag = null;
-    }
-
-    if (tree.hasNonNull(Constants.JSON_CONTEXT)) {
-      contextURL = URI.create(tree.get(Constants.JSON_CONTEXT).textValue());
-      property.setName(StringUtils.substringAfterLast(contextURL.toASCIIString(), "/"));
-      tree.remove(Constants.JSON_CONTEXT);
-    } else if (tree.hasNonNull(Constants.JSON_METADATA)) {
-      contextURL = URI.create(tree.get(Constants.JSON_METADATA).textValue());
-      property.setType(new EdmTypeInfo.Builder().
-          setTypeExpression(StringUtils.substringAfterLast(contextURL.toASCIIString(), "#")).build().internal());
-      tree.remove(Constants.JSON_METADATA);
-    } else {
-      contextURL = null;
-    }
-
-    if (tree.has(Constants.JSON_TYPE)) {
-      property.setType(new EdmTypeInfo.Builder().setTypeExpression(tree.get(Constants.JSON_TYPE).textValue()).build()
-          .internal());
-      tree.remove(Constants.JSON_TYPE);
-    }
-
-    if (tree.has(Constants.JSON_NULL) && tree.get(Constants.JSON_NULL).asBoolean()) {
-      property.setValue(ValueType.PRIMITIVE, null);
-      tree.remove(Constants.JSON_NULL);
-    }
-
-    if (property.getValue() == null) {
-      try {
-        value(property, tree.has(Constants.VALUE) ? tree.get(Constants.VALUE) : tree, parser.getCodec());
-      } catch (final EdmPrimitiveTypeException e) {
-        throw new IOException(e);
-      }
-      tree.remove(Constants.VALUE);
-    }
-
-    // any remaining entry is supposed to be an annotation or is ignored
-    for (final Iterator<Map.Entry<String, JsonNode>> itor = tree.fields(); itor.hasNext();) {
-      final Map.Entry<String, JsonNode> field = itor.next();
-      if (field.getKey().charAt(0) == '@') {
-        final Annotation annotation = new Annotation();
-        annotation.setTerm(field.getKey().substring(1));
-
-        try {
-          value(annotation, field.getValue(), parser.getCodec());
-        } catch (final EdmPrimitiveTypeException e) {
-          throw new IOException(e);
-        }
-        property.getAnnotations().add(annotation);
-      }
-    }
-
-    return new ResWrap<Property>(contextURL, metadataETag, property);
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertySerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertySerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertySerializer.java
deleted file mode 100644
index cd2227f..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertySerializer.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.serialization;
-
-import java.io.IOException;
-import java.net.URI;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.Annotation;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.core.edm.EdmTypeInfo;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-
-/**
- * Writes out JSON string from <tt>PropertyImpl</tt>.
- */
-public class JsonPropertySerializer extends JsonSerializer {
-
-  public JsonPropertySerializer(final boolean serverMode) {
-    super(serverMode);
-  }
-
-  protected void doSerialize(final Property property, final JsonGenerator jgen)
-      throws IOException, EdmPrimitiveTypeException {
-    doContainerSerialize(new ResWrap<Property>((URI) null, null, property), jgen);
-  }
-
-  protected void doContainerSerialize(final ResWrap<Property> container, final JsonGenerator jgen)
-      throws IOException, EdmPrimitiveTypeException {
-
-    final Property property = container.getPayload();
-
-    jgen.writeStartObject();
-
-    if (serverMode && container.getContextURL() != null) {
-      jgen.writeStringField(Constants.JSON_CONTEXT, container.getContextURL().toASCIIString());
-    }
-
-    if (StringUtils.isNotBlank(property.getType())) {
-      jgen.writeStringField(Constants.JSON_TYPE,
-          new EdmTypeInfo.Builder().setTypeExpression(property.getType()).build().external());
-    }
-
-    for (Annotation annotation : property.getAnnotations()) {
-      valuable(jgen, annotation, "@" + annotation.getTerm());
-    }
-
-    if (property.isNull()) {
-      jgen.writeBooleanField(Constants.JSON_NULL, true);
-    } else if (property.isGeospatial() || property.isCollection()) {
-      valuable(jgen, property, Constants.VALUE);
-    } else if (property.isPrimitive()) {
-      final EdmTypeInfo typeInfo = property.getType() == null
-          ? null
-              : new EdmTypeInfo.Builder().setTypeExpression(property.getType()).build();
-
-      jgen.writeFieldName(Constants.VALUE);
-      primitiveValue(jgen, typeInfo, property.asPrimitive());
-    } else if (property.isEnum()) {
-      jgen.writeStringField(Constants.VALUE, property.asEnum().toString());
-    } else if (property.isComplex()) {
-      for (Property cproperty : property.asComplex().getValue()) {
-        valuable(jgen, cproperty, cproperty.getName());
-      }
-    } else if (property.isComplex()) {
-      for (Property cproperty : property.asComplex().getValue()) {
-        valuable(jgen, cproperty, cproperty.getName());
-      }
-    }
-
-    jgen.writeEndObject();
-  }
-}


[28/39] olingo-odata4 git commit: [OLINGO-695] Merged with master

Posted by ch...@apache.org.
[OLINGO-695] Merged with master


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

Branch: refs/heads/IEE754Compatible
Commit: 74fddd1df72bf14b14fa9f3e28cbf832f6c86350
Parents: 9e75563 431938c
Author: Michael Bolz <mi...@sap.com>
Authored: Fri Jun 19 07:44:04 2015 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Fri Jun 19 07:44:04 2015 +0200

----------------------------------------------------------------------
 fit/pom.xml                                     |  12 +-
 .../org/apache/olingo/fit/AbstractServices.java |  10 +-
 .../fit/serializer/FITAtomDeserializer.java     |   2 +-
 .../olingo/fit/utils/AbstractUtilities.java     |  14 +-
 .../org/apache/olingo/fit/utils/FSManager.java  |   6 +-
 .../olingo/fit/AbstractBaseTestITCase.java      |   2 +-
 .../fit/tecsvc/client/ActionImportITCase.java   | 197 +++--
 .../olingo/fit/tecsvc/client/BasicITCase.java   | 145 +--
 .../fit/tecsvc/client/BatchClientITCase.java    |  64 +-
 .../fit/tecsvc/client/ConditionalITCase.java    |  22 +
 .../tecsvc/client/FilterSystemQueryITCase.java  | 247 +++---
 .../tecsvc/client/PrimitiveComplexITCase.java   |  99 ++-
 .../tecsvc/client/SystemQueryOptionITCase.java  |  50 +-
 lib/client-api/pom.xml                          |   1 +
 .../apache/olingo/client/api/ODataClient.java   |   2 +-
 .../api/domain/ClientEntitySetIterator.java     |   2 +-
 .../serialization/ClientODataDeserializer.java  |   2 -
 .../api/serialization/ODataDeserializer.java    |  65 ++
 .../ODataDeserializerException.java             |  38 +
 .../client/api/serialization/ODataReader.java   |   1 -
 .../api/serialization/ODataSerializer.java      |  33 +
 .../serialization/ODataSerializerException.java |  38 +
 .../client/api/serialization/ODataWriter.java   |   1 -
 .../olingo/client/api/uri/URIBuilder.java       |   6 +
 lib/client-core/pom.xml                         |   1 +
 .../olingo/client/core/ODataClientImpl.java     |   6 +-
 .../header/ODataErrorResponseChecker.java       |   2 +-
 .../cud/ODataEntityCreateRequestImpl.java       |   4 +-
 .../cud/ODataEntityUpdateRequestImpl.java       |   4 +-
 .../cud/ODataPropertyUpdateRequestImpl.java     |   4 +-
 .../cud/ODataReferenceAddingRequestImpl.java    |   2 +-
 .../invoke/AbstractODataInvokeRequest.java      |   4 +-
 .../request/retrieve/ODataDeltaRequestImpl.java |   2 +-
 .../retrieve/ODataEntityRequestImpl.java        |   2 +-
 .../retrieve/ODataEntitySetRequestImpl.java     |   2 +-
 .../retrieve/ODataPropertyRequestImpl.java      |   2 +-
 .../request/retrieve/ODataRawRequestImpl.java   |   2 +-
 .../ODataServiceDocumentRequestImpl.java        |   2 +-
 .../ODataMediaEntityCreateRequestImpl.java      |   2 +-
 .../ODataMediaEntityUpdateRequestImpl.java      |   2 +-
 .../data/JSONServiceDocumentDeserializer.java   |   4 +-
 .../data/XMLServiceDocumentDeserializer.java    |   4 +-
 .../core/serialization/AbstractAtomDealer.java  |  97 +++
 .../core/serialization/AtomDeserializer.java    | 873 +++++++++++++++++++
 .../serialization/AtomGeoValueDeserializer.java | 269 ++++++
 .../serialization/AtomGeoValueSerializer.java   | 223 +++++
 .../core/serialization/AtomSerializer.java      | 570 ++++++++++++
 .../ClientODataDeserializerImpl.java            |   7 +-
 .../core/serialization/ContextURLParser.java    | 118 +++
 .../serialization/JsonDeltaDeserializer.java    | 100 +++
 .../core/serialization/JsonDeserializer.java    | 421 +++++++++
 .../serialization/JsonEntityDeserializer.java   | 229 +++++
 .../serialization/JsonEntitySerializer.java     | 135 +++
 .../JsonEntitySetDeserializer.java              | 120 +++
 .../serialization/JsonEntitySetSerializer.java  |  92 ++
 .../serialization/JsonGeoValueDeserializer.java | 262 ++++++
 .../serialization/JsonGeoValueSerializer.java   | 184 ++++
 .../JsonODataErrorDeserializer.java             |  87 ++
 .../JsonODataErrorDetailDeserializer.java       |  58 ++
 .../serialization/JsonPropertyDeserializer.java | 114 +++
 .../serialization/JsonPropertySerializer.java   |  93 ++
 .../core/serialization/JsonSerializer.java      | 376 ++++++++
 .../core/serialization/ODataBinderImpl.java     |   3 +-
 .../core/serialization/ODataReaderImpl.java     |   2 +-
 .../core/serialization/ODataWriterImpl.java     |   2 +-
 .../olingo/client/core/uri/URIBuilderImpl.java  |   6 +
 .../serialization/AtomDeserializerTest.java     | 329 +++++++
 .../serialization/ContextURLParserTest.java     | 256 ++++++
 .../olingo/client/core/v4/EntitySetTest.java    |   2 +-
 .../apache/olingo/client/core/v4/ErrorTest.java |   2 +-
 .../olingo/client/core/v4/PropertyTest.java     |   4 +-
 .../client/core/v4/ServiceDocumentTest.java     |   2 +-
 lib/commons-api/pom.xml                         |   1 +
 .../commons/api/data/AbstractODataObject.java   |   4 +-
 .../commons/api/edm/provider/CsdlNamed.java     |   3 +-
 .../olingo/commons/api/http/HttpHeader.java     |  15 +-
 .../api/serialization/ODataDeserializer.java    |  65 --
 .../ODataDeserializerException.java             |  38 -
 .../api/serialization/ODataSerializer.java      |  33 -
 .../serialization/ODataSerializerException.java |  38 -
 lib/commons-core/pom.xml                        |   1 +
 .../core/serialization/AbstractAtomDealer.java  |  97 ---
 .../core/serialization/AtomDeserializer.java    | 873 -------------------
 .../serialization/AtomGeoValueDeserializer.java | 269 ------
 .../serialization/AtomGeoValueSerializer.java   | 223 -----
 .../core/serialization/AtomSerializer.java      | 570 ------------
 .../core/serialization/ContextURLParser.java    | 118 ---
 .../serialization/JsonDeltaDeserializer.java    | 100 ---
 .../core/serialization/JsonDeserializer.java    | 421 ---------
 .../serialization/JsonEntityDeserializer.java   | 229 -----
 .../serialization/JsonEntitySerializer.java     | 135 ---
 .../JsonEntitySetDeserializer.java              | 120 ---
 .../serialization/JsonEntitySetSerializer.java  |  92 --
 .../serialization/JsonGeoValueDeserializer.java | 262 ------
 .../serialization/JsonGeoValueSerializer.java   | 184 ----
 .../JsonODataErrorDeserializer.java             |  87 --
 .../JsonODataErrorDetailDeserializer.java       |  58 --
 .../serialization/JsonPropertyDeserializer.java | 114 ---
 .../serialization/JsonPropertySerializer.java   |  93 --
 .../core/serialization/JsonSerializer.java      | 376 --------
 .../serialization/AtomDeserializerTest.java     | 328 -------
 .../serialization/ContextURLParserTest.java     | 255 ------
 lib/server-api/pom.xml                          |   1 +
 .../org/apache/olingo/server/api/OData.java     |   8 +
 .../api/deserializer/DeserializerException.java |   2 +-
 .../deserializer/FixedFormatDeserializer.java   |  10 +-
 .../deserializer/batch/ODataResponsePart.java   |  29 +-
 .../olingo/server/api/prefer/Preferences.java   | 107 +++
 .../server/api/prefer/PreferencesApplied.java   | 164 ++++
 .../CountComplexCollectionProcessor.java        |   2 +-
 .../CountEntityCollectionProcessor.java         |   2 +-
 .../CountPrimitiveCollectionProcessor.java      |   2 +-
 .../api/processor/MediaEntityProcessor.java     |  13 +-
 .../api/processor/PrimitiveValueProcessor.java  |  29 +-
 .../apache/olingo/server/api/uri/UriInfo.java   |  19 +-
 .../olingo/server/api/uri/UriInfoEntityId.java  |  13 +-
 .../olingo/server/api/uri/UriInfoMetadata.java  |   4 +-
 .../olingo/server/api/uri/UriParameter.java     |  11 +-
 .../server/api/uri/UriResourceFunction.java     |   2 +-
 .../server/api/uri/UriResourceLambdaAll.java    |   5 +-
 .../server/api/uri/UriResourceLambdaAny.java    |   4 +-
 .../api/uri/UriResourceLambdaVariable.java      |   3 +-
 .../server/api/uri/UriResourceNavigation.java   |   2 +-
 .../api/prefer/PreferencesAppliedTest.java      |  67 ++
 .../server/core/requests/DataRequest.java       |   2 +-
 lib/server-core/pom.xml                         |   1 +
 .../olingo/server/core/ODataDispatcher.java     |   8 +-
 .../apache/olingo/server/core/ODataImpl.java    |   8 +
 .../core/batchhandler/BatchPartHandler.java     |  14 +-
 .../FixedFormatDeserializerImpl.java            |  32 +-
 .../json/ODataJsonDeserializer.java             |   8 +-
 .../olingo/server/core/prefer/PreferParser.java | 150 ++++
 .../server/core/prefer/PreferencesImpl.java     | 117 +++
 .../core/uri/UriResourceLambdaAnyImpl.java      |   2 +-
 .../core/uri/UriResourceWithKeysImpl.java       |  17 +-
 .../server-core-exceptions-i18n.properties      |   2 +-
 .../FixedFormatDeserializerTest.java            |  27 +-
 .../server/core/prefer/PreferencesTest.java     | 168 ++++
 .../apache/olingo/server/tecsvc/Encoder.java    | 132 ---
 .../processor/TechnicalActionProcessor.java     | 180 ++--
 .../processor/TechnicalBatchProcessor.java      |  26 +-
 .../processor/TechnicalEntityProcessor.java     |  91 +-
 .../TechnicalPrimitiveComplexProcessor.java     | 234 ++---
 .../ExpandSystemQueryOptionHandler.java         |  17 +-
 .../options/ServerSidePagingHandler.java        | 119 ++-
 .../olingo/server/core/ODataHandlerTest.java    |   6 +-
 .../ODataDeserializerEntityCollectionTest.java  |   2 +-
 .../json/ODataJsonDeserializerEntityTest.java   |   6 +-
 .../json/ODataJsonSerializerTest.java           |  17 +-
 .../server/core/uri/UriResourceImplTest.java    |   2 +-
 .../core/uri/testutil/FilterTreeToText.java     |   2 +-
 .../core/uri/testutil/ResourceValidator.java    |   2 +-
 pom.xml                                         |   1 +
 samples/pom.xml                                 |   7 +
 .../server/sample/processor/CarsProcessor.java  |  16 +
 samples/tutorials/p1_read/pom.xml               |  79 ++
 .../mynamespace/service/DemoEdmProvider.java    | 153 ++++
 .../service/DemoEntityCollectionProcessor.java  | 129 +++
 .../myservice/mynamespace/web/DemoServlet.java  |  67 ++
 .../p1_read/src/main/webapp/WEB-INF/web.xml     |  40 +
 .../tutorials/p1_read/src/main/webapp/index.jsp |  26 +
 samples/tutorials/p2_readep/pom.xml             |  79 ++
 .../myservice/mynamespace/data/Storage.java     | 125 +++
 .../mynamespace/service/DemoEdmProvider.java    | 153 ++++
 .../service/DemoEntityCollectionProcessor.java  |  90 ++
 .../service/DemoEntityProcessor.java            | 126 +++
 .../service/DemoPrimitiveProcessor.java         | 147 ++++
 .../java/myservice/mynamespace/util/Util.java   | 105 +++
 .../myservice/mynamespace/web/DemoServlet.java  |  76 ++
 .../p2_readep/src/main/webapp/WEB-INF/web.xml   |  40 +
 .../p2_readep/src/main/webapp/index.jsp         |  26 +
 samples/tutorials/p3_write/pom.xml              |  79 ++
 .../myservice/mynamespace/data/Storage.java     | 263 ++++++
 .../mynamespace/service/DemoEdmProvider.java    | 157 ++++
 .../service/DemoEntityCollectionProcessor.java  |  93 ++
 .../service/DemoEntityProcessor.java            | 190 ++++
 .../service/DemoPrimitiveProcessor.java         | 146 ++++
 .../java/myservice/mynamespace/util/Util.java   | 121 +++
 .../myservice/mynamespace/web/DemoServlet.java  |  73 ++
 .../p3_write/src/main/webapp/WEB-INF/web.xml    |  40 +
 .../p3_write/src/main/webapp/index.jsp          |  26 +
 samples/tutorials/pom.xml                       |  54 ++
 182 files changed, 9884 insertions(+), 6082 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/74fddd1d/pom.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/74fddd1d/samples/pom.xml
----------------------------------------------------------------------
diff --cc samples/pom.xml
index 2d6b235,95e3ddb..74c1775
--- a/samples/pom.xml
+++ b/samples/pom.xml
@@@ -42,7 -42,13 +42,14 @@@
      <profile>
        <id>samples</id>
        <modules>
 +        <module>osgi/server</module>
+         <module>client</module>
+       </modules>
+     </profile>
+     <profile>
+       <id>tutorials</id>
+       <modules>
+         <module>tutorials</module>
        </modules>
      </profile>
    </profiles>


[39/39] olingo-odata4 git commit: Merge branch 'master' into ieee

Posted by ch...@apache.org.
Merge branch 'master' into ieee

Conflicts:
	fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java
	fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java
	fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
	fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
	lib/client-api/src/main/java/org/apache/olingo/client/api/ODataClient.java
	lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ClientEntitySetIterator.java
	lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataReader.java
	lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataWriter.java
	lib/client-core/src/main/java/org/apache/olingo/client/core/ODataClientImpl.java
	lib/client-core/src/main/java/org/apache/olingo/client/core/communication/header/ODataErrorResponseChecker.java
	lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java
	lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityUpdateRequestImpl.java
	lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataPropertyUpdateRequestImpl.java
	lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
	lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataDeltaRequestImpl.java
	lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntityRequestImpl.java
	lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java
	lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataPropertyRequestImpl.java
	lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataServiceDocumentRequestImpl.java
	lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ClientODataDeserializerImpl.java
	lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonSerializer.java
	lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java
	lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java
	lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataWriterImpl.java
	lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntitySetTest.java
	lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ErrorTest.java
	lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PropertyTest.java
	lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ServiceDocumentTest.java
	lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalActionProcessor.java
	lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
	lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java


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

Branch: refs/heads/IEE754Compatible
Commit: ef1fd77875a48f2594f01c22e8d2b0f5f3b4e4c5
Parents: 9d4cf6a a4288fc
Author: Christian Amend <ch...@sap.com>
Authored: Tue Jun 23 16:33:00 2015 +0200
Committer: Christian Amend <ch...@sap.com>
Committed: Tue Jun 23 16:33:00 2015 +0200

----------------------------------------------------------------------
 ext/karaf/karaf-features/pom.xml                |  81 ++
 .../src/main/resources/features.xml             |  59 ++
 ext/karaf/karaf-fit/pom.xml                     | 152 ++++
 .../apache/olingo/osgi/itests/BundlesTest.java  |  55 ++
 .../osgi/itests/OlingoOSGiTestSupport.java      | 134 +++
 .../osgi/itests/server/CarServiceTest.java      | 105 +++
 ext/karaf/pom.xml                               |  41 +
 ext/pom.xml                                     |   9 +
 fit/pom.xml                                     |  14 +-
 .../org/apache/olingo/fit/AbstractServices.java |  10 +-
 .../fit/serializer/FITAtomDeserializer.java     |   2 +-
 .../olingo/fit/utils/AbstractUtilities.java     |  14 +-
 .../org/apache/olingo/fit/utils/FSManager.java  |   6 +-
 .../olingo/fit/AbstractBaseTestITCase.java      |   2 +-
 .../fit/tecsvc/client/ActionImportITCase.java   | 197 +++--
 .../olingo/fit/tecsvc/client/BasicITCase.java   | 127 +--
 .../fit/tecsvc/client/BatchClientITCase.java    |  64 +-
 .../fit/tecsvc/client/ConditionalITCase.java    |  30 +
 .../tecsvc/client/PrimitiveComplexITCase.java   |  16 +
 .../tecsvc/client/SystemQueryOptionITCase.java  |  23 +-
 lib/client-api/pom.xml                          |   1 +
 .../apache/olingo/client/api/ODataClient.java   |   3 +-
 .../communication/header/ODataPreferences.java  |  33 +-
 .../api/domain/ClientEntitySetIterator.java     |   2 +-
 .../serialization/ClientODataDeserializer.java  |   2 -
 .../api/serialization/ODataDeserializer.java    |  65 ++
 .../ODataDeserializerException.java             |  38 +
 .../client/api/serialization/ODataReader.java   |   2 +-
 .../api/serialization/ODataSerializer.java      |  33 +
 .../serialization/ODataSerializerException.java |  38 +
 .../client/api/serialization/ODataWriter.java   |   1 -
 lib/client-core/pom.xml                         |   1 +
 .../olingo/client/core/ODataClientImpl.java     |   6 +-
 .../header/ODataErrorResponseChecker.java       |  29 +-
 .../cud/ODataEntityCreateRequestImpl.java       |   4 +-
 .../cud/ODataEntityUpdateRequestImpl.java       |   4 +-
 .../cud/ODataPropertyUpdateRequestImpl.java     |   4 +-
 .../cud/ODataReferenceAddingRequestImpl.java    |   2 +-
 .../invoke/AbstractODataInvokeRequest.java      |  12 +-
 .../request/retrieve/ODataDeltaRequestImpl.java |   2 +-
 .../retrieve/ODataEntityRequestImpl.java        |   2 +-
 .../retrieve/ODataEntitySetRequestImpl.java     |   2 +-
 .../retrieve/ODataPropertyRequestImpl.java      |   2 +-
 .../request/retrieve/ODataRawRequestImpl.java   |   2 +-
 .../ODataServiceDocumentRequestImpl.java        |   2 +-
 .../ODataMediaEntityCreateRequestImpl.java      |   2 +-
 .../ODataMediaEntityUpdateRequestImpl.java      |   2 +-
 .../data/JSONServiceDocumentDeserializer.java   |   4 +-
 .../data/XMLServiceDocumentDeserializer.java    |   4 +-
 .../core/serialization/AbstractAtomDealer.java  |  97 +++
 .../core/serialization/AtomDeserializer.java    | 873 +++++++++++++++++++
 .../serialization/AtomGeoValueDeserializer.java | 269 ++++++
 .../serialization/AtomGeoValueSerializer.java   | 223 +++++
 .../core/serialization/AtomSerializer.java      | 570 ++++++++++++
 .../ClientODataDeserializerImpl.java            |   8 +-
 .../core/serialization/ContextURLParser.java    | 118 +++
 .../serialization/JsonDeltaDeserializer.java    | 100 +++
 .../core/serialization/JsonDeserializer.java    | 421 +++++++++
 .../serialization/JsonEntityDeserializer.java   | 229 +++++
 .../serialization/JsonEntitySerializer.java     | 131 +++
 .../JsonEntitySetDeserializer.java              | 120 +++
 .../serialization/JsonEntitySetSerializer.java  |  93 ++
 .../serialization/JsonGeoValueDeserializer.java | 262 ++++++
 .../serialization/JsonGeoValueSerializer.java   | 184 ++++
 .../JsonODataErrorDeserializer.java             |  87 ++
 .../JsonODataErrorDetailDeserializer.java       |  58 ++
 .../serialization/JsonPropertyDeserializer.java | 114 +++
 .../serialization/JsonPropertySerializer.java   |  94 ++
 .../core/serialization/JsonSerializer.java      | 387 ++++++++
 .../core/serialization/ODataBinderImpl.java     |  41 +-
 .../core/serialization/ODataReaderImpl.java     |   2 +-
 .../core/serialization/ODataWriterImpl.java     |   2 +-
 .../serialization/AtomDeserializerTest.java     | 329 +++++++
 .../serialization/ContextURLParserTest.java     | 256 ++++++
 .../olingo/client/core/v4/EntitySetTest.java    |   2 +-
 .../apache/olingo/client/core/v4/ErrorTest.java |   2 +-
 .../olingo/client/core/v4/PropertyTest.java     |   4 +-
 .../client/core/v4/ServiceDocumentTest.java     |   2 +-
 lib/commons-api/pom.xml                         |   1 +
 .../commons/api/ODataPreferenceNames.java       |  46 +
 .../commons/api/edm/provider/CsdlNamed.java     |   3 +-
 .../olingo/commons/api/http/HttpHeader.java     |  15 +-
 .../api/serialization/ODataDeserializer.java    |  65 --
 .../ODataDeserializerException.java             |  38 -
 .../api/serialization/ODataSerializer.java      |  33 -
 .../serialization/ODataSerializerException.java |  38 -
 lib/commons-core/pom.xml                        |   1 +
 .../core/serialization/AbstractAtomDealer.java  |  97 ---
 .../core/serialization/AtomDeserializer.java    | 873 -------------------
 .../serialization/AtomGeoValueDeserializer.java | 269 ------
 .../serialization/AtomGeoValueSerializer.java   | 223 -----
 .../core/serialization/AtomSerializer.java      | 570 ------------
 .../core/serialization/ContextURLParser.java    | 118 ---
 .../serialization/JsonDeltaDeserializer.java    | 100 ---
 .../core/serialization/JsonDeserializer.java    | 421 ---------
 .../serialization/JsonEntityDeserializer.java   | 229 -----
 .../serialization/JsonEntitySerializer.java     | 131 ---
 .../JsonEntitySetDeserializer.java              | 120 ---
 .../serialization/JsonEntitySetSerializer.java  |  93 --
 .../serialization/JsonGeoValueDeserializer.java | 262 ------
 .../serialization/JsonGeoValueSerializer.java   | 184 ----
 .../JsonODataErrorDeserializer.java             |  87 --
 .../JsonODataErrorDetailDeserializer.java       |  58 --
 .../serialization/JsonPropertyDeserializer.java | 114 ---
 .../serialization/JsonPropertySerializer.java   |  94 --
 .../core/serialization/JsonSerializer.java      | 387 --------
 .../serialization/AtomDeserializerTest.java     | 328 -------
 .../serialization/ContextURLParserTest.java     | 255 ------
 lib/server-api/pom.xml                          |   1 +
 .../org/apache/olingo/server/api/OData.java     |   8 +
 .../deserializer/batch/ODataResponsePart.java   |  29 +-
 .../olingo/server/api/prefer/Preferences.java   | 110 +++
 .../server/api/prefer/PreferencesApplied.java   | 169 ++++
 .../apache/olingo/server/api/uri/UriInfo.java   |  19 +-
 .../olingo/server/api/uri/UriInfoEntityId.java  |  13 +-
 .../olingo/server/api/uri/UriInfoMetadata.java  |   4 +-
 .../olingo/server/api/uri/UriParameter.java     |  11 +-
 .../server/api/uri/UriResourceFunction.java     |   2 +-
 .../server/api/uri/UriResourceLambdaAll.java    |   5 +-
 .../server/api/uri/UriResourceLambdaAny.java    |   4 +-
 .../api/uri/UriResourceLambdaVariable.java      |   3 +-
 .../server/api/uri/UriResourceNavigation.java   |   2 +-
 .../api/prefer/PreferencesAppliedTest.java      |  67 ++
 lib/server-core/pom.xml                         |   1 +
 .../olingo/server/core/ODataDispatcher.java     |  59 +-
 .../apache/olingo/server/core/ODataImpl.java    |   8 +
 .../core/batchhandler/BatchPartHandler.java     |  14 +-
 .../core/etag/PreconditionsValidator.java       |  49 +-
 .../olingo/server/core/prefer/PreferParser.java | 150 ++++
 .../server/core/prefer/PreferencesImpl.java     | 108 +++
 .../server/core/uri/UriResourceActionImpl.java  |  13 +-
 .../core/uri/UriResourceLambdaAnyImpl.java      |   2 +-
 .../server/core/uri/UriResourceTypedImpl.java   |   8 +-
 .../core/uri/UriResourceWithKeysImpl.java       |  17 +-
 .../uri/queryoption/expression/MemberImpl.java  |   5 +
 .../server/core/prefer/PreferencesTest.java     | 168 ++++
 .../apache/olingo/server/tecsvc/Encoder.java    | 132 ---
 .../processor/TechnicalActionProcessor.java     | 170 ++--
 .../processor/TechnicalBatchProcessor.java      |  26 +-
 .../processor/TechnicalEntityProcessor.java     |  69 +-
 .../TechnicalPrimitiveComplexProcessor.java     |  27 +-
 .../options/ServerSidePagingHandler.java        | 119 ++-
 .../tecsvc/provider/EntityTypeProvider.java     |   2 +-
 .../tecsvc/provider/PropertyProvider.java       |   4 +-
 .../olingo/server/core/ODataHandlerTest.java    |  60 +-
 .../server/core/PreconditionsValidatorTest.java | 241 ++---
 .../server/core/uri/UriResourceImplTest.java    |   2 +-
 .../core/uri/antlr/TestFullResourcePath.java    |  12 +
 .../core/uri/antlr/TestUriParserImpl.java       |   2 +-
 .../queryoption/expression/ExpressionTest.java  |  20 +-
 .../core/uri/testutil/FilterTreeToText.java     |   2 +-
 .../core/uri/testutil/ResourceValidator.java    |   2 +-
 pom.xml                                         |   9 +
 samples/osgi/server/README.txt                  | 183 ++++
 samples/osgi/server/pom.xml                     | 112 +++
 samples/pom.xml                                 |  17 +-
 samples/tutorials/p1_read/pom.xml               |  79 ++
 .../mynamespace/service/DemoEdmProvider.java    | 153 ++++
 .../service/DemoEntityCollectionProcessor.java  | 129 +++
 .../myservice/mynamespace/web/DemoServlet.java  |  67 ++
 .../p1_read/src/main/webapp/WEB-INF/web.xml     |  40 +
 .../tutorials/p1_read/src/main/webapp/index.jsp |  26 +
 samples/tutorials/p2_readep/pom.xml             |  79 ++
 .../myservice/mynamespace/data/Storage.java     | 125 +++
 .../mynamespace/service/DemoEdmProvider.java    | 153 ++++
 .../service/DemoEntityCollectionProcessor.java  |  90 ++
 .../service/DemoEntityProcessor.java            | 126 +++
 .../service/DemoPrimitiveProcessor.java         | 147 ++++
 .../java/myservice/mynamespace/util/Util.java   | 105 +++
 .../myservice/mynamespace/web/DemoServlet.java  |  76 ++
 .../p2_readep/src/main/webapp/WEB-INF/web.xml   |  40 +
 .../p2_readep/src/main/webapp/index.jsp         |  26 +
 samples/tutorials/p3_write/pom.xml              |  79 ++
 .../myservice/mynamespace/data/Storage.java     | 263 ++++++
 .../mynamespace/service/DemoEdmProvider.java    | 157 ++++
 .../service/DemoEntityCollectionProcessor.java  |  93 ++
 .../service/DemoEntityProcessor.java            | 190 ++++
 .../service/DemoPrimitiveProcessor.java         | 146 ++++
 .../java/myservice/mynamespace/util/Util.java   | 121 +++
 .../myservice/mynamespace/web/DemoServlet.java  |  73 ++
 .../p3_write/src/main/webapp/WEB-INF/web.xml    |  40 +
 .../p3_write/src/main/webapp/index.jsp          |  26 +
 samples/tutorials/pom.xml                       |  54 ++
 183 files changed, 10614 insertions(+), 6125 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java
----------------------------------------------------------------------
diff --cc fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java
index 172e37a,73eae08..0d350d5
--- a/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java
@@@ -48,14 -55,6 +55,7 @@@ import org.apache.olingo.commons.api.da
  import org.apache.olingo.commons.api.data.Property;
  import org.apache.olingo.commons.api.data.ResWrap;
  import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 +import org.apache.olingo.commons.api.format.ContentType;
- import org.apache.olingo.commons.api.serialization.ODataDeserializer;
- import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
- import org.apache.olingo.commons.api.serialization.ODataSerializer;
- import org.apache.olingo.commons.api.serialization.ODataSerializerException;
- import org.apache.olingo.commons.core.serialization.AtomSerializer;
- import org.apache.olingo.commons.core.serialization.JsonDeserializer;
- import org.apache.olingo.commons.core.serialization.JsonSerializer;
  import org.apache.olingo.fit.UnsupportedMediaTypeException;
  import org.apache.olingo.fit.metadata.Metadata;
  import org.apache.olingo.fit.metadata.NavigationProperty;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java
----------------------------------------------------------------------
diff --cc fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java
index 0d0e491,0dad1e6..4e4785d
--- a/fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java
@@@ -41,10 -44,6 +44,7 @@@ import org.apache.olingo.client.core.se
  import org.apache.olingo.commons.api.data.Entity;
  import org.apache.olingo.commons.api.data.ResWrap;
  import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 +import org.apache.olingo.commons.api.format.ContentType;
- import org.apache.olingo.commons.api.serialization.ODataSerializerException;
- import org.apache.olingo.commons.core.serialization.AtomSerializer;
- import org.apache.olingo.commons.core.serialization.JsonSerializer;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
----------------------------------------------------------------------
diff --cc fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
index a838390,58dd2a3..f7d49a1
--- a/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
@@@ -33,10 -33,10 +33,10 @@@ import org.apache.olingo.client.api.ODa
  import org.apache.olingo.client.api.domain.ClientEntity;
  import org.apache.olingo.client.api.domain.ClientProperty;
  import org.apache.olingo.client.api.domain.ClientValue;
+ import org.apache.olingo.client.api.serialization.ODataSerializerException;
  import org.apache.olingo.commons.api.data.Entity;
  import org.apache.olingo.commons.api.data.EntityCollection;
 -import org.apache.olingo.commons.api.format.ODataFormat;
 +import org.apache.olingo.commons.api.format.ContentType;
- import org.apache.olingo.commons.api.serialization.ODataSerializerException;
  import org.apache.olingo.fit.server.TomcatTestServer;
  import org.apache.olingo.server.tecsvc.TechnicalServlet;
  import org.junit.BeforeClass;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
----------------------------------------------------------------------
diff --cc fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
index 8661af4,f29fbe3..316f0ce
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
@@@ -41,7 -44,8 +44,8 @@@ import org.apache.olingo.client.api.dom
  import org.apache.olingo.client.api.domain.ClientValue;
  import org.apache.olingo.client.core.ODataClientFactory;
  import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 -import org.apache.olingo.commons.api.format.ODataFormat;
 +import org.apache.olingo.commons.api.format.ContentType;
+ import org.apache.olingo.commons.api.http.HttpStatusCode;
  import org.apache.olingo.fit.AbstractBaseTestITCase;
  import org.apache.olingo.fit.tecsvc.TecSvcConst;
  import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
----------------------------------------------------------------------
diff --cc fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
index 2073df4,6406241..3466d46
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
@@@ -420,9 -402,27 +421,27 @@@ public class BasicITCase extends Abstra
    }
  
    @Test
+   public void createEntityMinimalResponse() throws Exception {
+     final ODataClient client = getClient();
+     final ClientObjectFactory factory = client.getObjectFactory();
+     ClientEntity newEntity = factory.newEntity(new FullQualifiedName("olingo.odata.test1", "ETTwoPrim"));
+     newEntity.getProperties().add(factory.newPrimitiveProperty("PropertyString",
+         factory.newPrimitiveValueBuilder().buildString("new")));
+     ODataEntityCreateRequest<ClientEntity> request = client.getCUDRequestFactory().getEntityCreateRequest(
+         client.newURIBuilder(SERVICE_URI).appendEntitySetSegment("ESTwoPrim").build(),
+         newEntity);
+     request.setPrefer(getClient().newPreferences().returnMinimal());
+ 
+     final ODataEntityCreateResponse<ClientEntity> response = request.execute();
+     assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
+     assertEquals("return=minimal", response.getHeader(HeaderName.preferenceApplied).iterator().next());
+     assertEquals(SERVICE_URI + "/ESTwoPrim(1)", response.getHeader(HttpHeader.LOCATION).iterator().next());
+   }
+ 
+   @Test
    public void readEntityWithExpandedNavigationProperty() {
      final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
 -    client.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
 +    client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
  
      final URI uri = client.newURIBuilder(SERVICE_URI)
          .appendEntitySetSegment("ESKeyNav")

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ConditionalITCase.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/PrimitiveComplexITCase.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/SystemQueryOptionITCase.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/client-api/src/main/java/org/apache/olingo/client/api/ODataClient.java
----------------------------------------------------------------------
diff --cc lib/client-api/src/main/java/org/apache/olingo/client/api/ODataClient.java
index b3ac39c,b8d5830..842dcf6
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/ODataClient.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/ODataClient.java
@@@ -33,9 -33,9 +34,9 @@@ import org.apache.olingo.client.api.ser
  import org.apache.olingo.client.api.uri.FilterFactory;
  import org.apache.olingo.client.api.uri.SearchFactory;
  import org.apache.olingo.client.api.uri.URIBuilder;
 -import org.apache.olingo.client.api.domain.ClientObjectFactory;
  import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 -import org.apache.olingo.commons.api.format.ODataFormat;
 +import org.apache.olingo.commons.api.format.ContentType;
- import org.apache.olingo.commons.api.serialization.ODataSerializer;
++
  
  public interface ODataClient {
  

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ClientEntitySetIterator.java
----------------------------------------------------------------------
diff --cc lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ClientEntitySetIterator.java
index 30a1caf,801ef1a..added7a
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ClientEntitySetIterator.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ClientEntitySetIterator.java
@@@ -33,8 -34,7 +34,7 @@@ import org.apache.olingo.client.api.ser
  import org.apache.olingo.commons.api.Constants;
  import org.apache.olingo.commons.api.data.Entity;
  import org.apache.olingo.commons.api.data.ResWrap;
 -import org.apache.olingo.commons.api.format.ODataFormat;
 +import org.apache.olingo.commons.api.format.ContentType;
- import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataReader.java
----------------------------------------------------------------------
diff --cc lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataReader.java
index 746d697,4360cd8..07342eb
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataReader.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataReader.java
@@@ -21,16 -21,15 +21,16 @@@ package org.apache.olingo.client.api.se
  import java.io.InputStream;
  import java.util.Map;
  
 -import org.apache.olingo.commons.api.data.ResWrap;
  import org.apache.olingo.client.api.domain.ClientEntity;
  import org.apache.olingo.client.api.domain.ClientEntitySet;
 -import org.apache.olingo.commons.api.ODataError;
  import org.apache.olingo.client.api.domain.ClientProperty;
  import org.apache.olingo.client.api.domain.ClientServiceDocument;
 +import org.apache.olingo.commons.api.ODataError;
 +import org.apache.olingo.commons.api.data.ResWrap;
  import org.apache.olingo.commons.api.edm.Edm;
  import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
 -import org.apache.olingo.commons.api.format.ODataFormat;
 +import org.apache.olingo.commons.api.format.ContentType;
- import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
++
  
  /**
   * OData reader.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataWriter.java
----------------------------------------------------------------------
diff --cc lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataWriter.java
index 4515cdf,7b5dc5b..1a6d65a
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataWriter.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataWriter.java
@@@ -22,12 -22,11 +22,11 @@@ import java.io.InputStream
  import java.net.URI;
  import java.util.Collection;
  
 -import org.apache.olingo.commons.api.data.ResWrap;
  import org.apache.olingo.client.api.domain.ClientEntity;
 -import org.apache.olingo.client.api.domain.ClientProperty;
  import org.apache.olingo.client.api.domain.ClientLink;
 -import org.apache.olingo.commons.api.format.ODataFormat;
 +import org.apache.olingo.client.api.domain.ClientProperty;
 +import org.apache.olingo.commons.api.data.ResWrap;
 +import org.apache.olingo.commons.api.format.ContentType;
- import org.apache.olingo.commons.api.serialization.ODataSerializerException;
  
  /**
   * OData writer.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/client-core/src/main/java/org/apache/olingo/client/core/ODataClientImpl.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/ODataClientImpl.java
index dd9f68e,c490dae..b00d3a8
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/ODataClientImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/ODataClientImpl.java
@@@ -42,18 -42,18 +43,17 @@@ import org.apache.olingo.client.core.co
  import org.apache.olingo.client.core.communication.request.cud.CUDRequestFactoryImpl;
  import org.apache.olingo.client.core.communication.request.invoke.InvokeRequestFactoryImpl;
  import org.apache.olingo.client.core.communication.request.retrieve.RetrieveRequestFactoryImpl;
 +import org.apache.olingo.client.core.domain.ClientObjectFactoryImpl;
+ import org.apache.olingo.client.core.serialization.AtomSerializer;
  import org.apache.olingo.client.core.serialization.ClientODataDeserializerImpl;
+ import org.apache.olingo.client.core.serialization.JsonSerializer;
  import org.apache.olingo.client.core.serialization.ODataBinderImpl;
  import org.apache.olingo.client.core.serialization.ODataReaderImpl;
  import org.apache.olingo.client.core.serialization.ODataWriterImpl;
  import org.apache.olingo.client.core.uri.FilterFactoryImpl;
  import org.apache.olingo.client.core.uri.URIBuilderImpl;
 -import org.apache.olingo.client.api.domain.ClientObjectFactory;
  import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 -import org.apache.olingo.commons.api.format.ODataFormat;
 -import org.apache.olingo.client.core.domain.ClientObjectFactoryImpl;
 +import org.apache.olingo.commons.api.format.ContentType;
- import org.apache.olingo.commons.api.serialization.ODataSerializer;
- import org.apache.olingo.commons.core.serialization.AtomSerializer;
- import org.apache.olingo.commons.core.serialization.JsonSerializer;
  
  public class ODataClientImpl implements ODataClient {
  

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/header/ODataErrorResponseChecker.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/communication/header/ODataErrorResponseChecker.java
index 802e67e,e359e29..53f35d5
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/header/ODataErrorResponseChecker.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/header/ODataErrorResponseChecker.java
@@@ -1,18 -1,18 +1,18 @@@
  /*
   * Licensed to the Apache Software Foundation (ASF) under one
-- * or more contributor license agreements.  See the NOTICE file
++ * or more contributor license agreements. See the NOTICE file
   * distributed with this work for additional information
-- * regarding copyright ownership.  The ASF licenses this file
++ * 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
-- *
++ * 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
++ * KIND, either express or implied. See the License for the
   * specific language governing permissions and limitations
   * under the License.
   */
@@@ -24,10 -24,10 +24,11 @@@ import org.apache.http.StatusLine
  import org.apache.olingo.client.api.ODataClient;
  import org.apache.olingo.client.api.communication.ODataClientErrorException;
  import org.apache.olingo.client.api.communication.ODataServerErrorException;
 -import org.apache.olingo.client.api.serialization.ODataDeserializerException;
 -import org.apache.olingo.commons.api.ODataRuntimeException;
  import org.apache.olingo.commons.api.ODataError;
 -import org.apache.olingo.commons.api.format.ODataFormat;
 +import org.apache.olingo.commons.api.ODataRuntimeException;
 +import org.apache.olingo.commons.api.format.ContentType;
- import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
++import org.apache.olingo.client.api.serialization.ODataDeserializerException;
++
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  
@@@ -43,8 -43,8 +44,8 @@@ public final class ODataErrorResponseCh
    }
  
    public static ODataRuntimeException checkResponse(
--          final ODataClient odataClient, final StatusLine statusLine, final InputStream entity,
--          final String accept) {
++      final ODataClient odataClient, final StatusLine statusLine, final InputStream entity,
++      final String accept) {
  
      ODataRuntimeException result = null;
  
@@@ -59,13 -59,13 +60,13 @@@
        } catch (final RuntimeException e) {
          LOG.warn("Error deserializing error response", e);
          error = getGenericError(
--                statusLine.getStatusCode(),
--                statusLine.getReasonPhrase());
++            statusLine.getStatusCode(),
++            statusLine.getReasonPhrase());
        } catch (final ODataDeserializerException e) {
          LOG.warn("Error deserializing error response", e);
          error = getGenericError(
--                statusLine.getStatusCode(),
--                statusLine.getReasonPhrase());
++            statusLine.getStatusCode(),
++            statusLine.getReasonPhrase());
        }
  
        if (statusLine.getStatusCode() >= 500) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java
index 2d85032,424ff8f..0ae8377
--- 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
@@@ -34,10 -33,11 +34,10 @@@ import org.apache.olingo.client.core.co
  import org.apache.olingo.client.core.uri.URIUtils;
  import org.apache.olingo.commons.api.data.Entity;
  import org.apache.olingo.commons.api.data.ResWrap;
 -import org.apache.olingo.client.api.domain.ClientEntity;
 +import org.apache.olingo.commons.api.format.ContentType;
+ import org.apache.olingo.client.api.serialization.ODataDeserializerException;
+ import org.apache.olingo.client.api.serialization.ODataSerializerException;
 -import org.apache.olingo.commons.api.format.ODataFormat;
  import org.apache.olingo.commons.api.http.HttpMethod;
- import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
- import org.apache.olingo.commons.api.serialization.ODataSerializerException;
  
  /**
   * This class implements an OData create request.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityUpdateRequestImpl.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityUpdateRequestImpl.java
index e0b5d2c,44ff471..8a40e33
--- 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
@@@ -35,10 -34,11 +35,10 @@@ import org.apache.olingo.client.core.co
  import org.apache.olingo.client.core.uri.URIUtils;
  import org.apache.olingo.commons.api.data.Entity;
  import org.apache.olingo.commons.api.data.ResWrap;
 -import org.apache.olingo.client.api.domain.ClientEntity;
 +import org.apache.olingo.commons.api.format.ContentType;
+ import org.apache.olingo.client.api.serialization.ODataDeserializerException;
+ import org.apache.olingo.client.api.serialization.ODataSerializerException;
 -import org.apache.olingo.commons.api.format.ODataFormat;
  import org.apache.olingo.commons.api.http.HttpMethod;
- import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
- import org.apache.olingo.commons.api.serialization.ODataSerializerException;
  
  /**
   * This class implements an OData update request.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataPropertyUpdateRequestImpl.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataPropertyUpdateRequestImpl.java
index 9166a12,33ec73a..038feeb
--- 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
@@@ -34,10 -33,11 +34,10 @@@ import org.apache.olingo.client.core.co
  import org.apache.olingo.client.core.uri.URIUtils;
  import org.apache.olingo.commons.api.data.Property;
  import org.apache.olingo.commons.api.data.ResWrap;
 -import org.apache.olingo.client.api.domain.ClientProperty;
 +import org.apache.olingo.commons.api.format.ContentType;
+ import org.apache.olingo.client.api.serialization.ODataDeserializerException;
+ import org.apache.olingo.client.api.serialization.ODataSerializerException;
 -import org.apache.olingo.commons.api.format.ODataFormat;
  import org.apache.olingo.commons.api.http.HttpMethod;
- import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
- import org.apache.olingo.commons.api.serialization.ODataSerializerException;
  
  /**
   * This class implements an OData update entity property request.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataReferenceAddingRequestImpl.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataReferenceAddingRequestImpl.java
index 592509e,933f223..640b5cf
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataReferenceAddingRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataReferenceAddingRequestImpl.java
@@@ -33,9 -34,8 +34,8 @@@ import org.apache.olingo.client.core.co
  import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
  import org.apache.olingo.client.core.uri.URIUtils;
  import org.apache.olingo.commons.api.data.ResWrap;
 -import org.apache.olingo.commons.api.format.ODataFormat;
 +import org.apache.olingo.commons.api.format.ContentType;
  import org.apache.olingo.commons.api.http.HttpMethod;
- import org.apache.olingo.commons.api.serialization.ODataSerializerException;
  
  /**
   * See {@link ODataReferenceAddingRequest}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
index c721ed8,29ad66e..f28130d
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
@@@ -31,22 -31,22 +31,22 @@@ import org.apache.http.client.methods.H
  import org.apache.http.client.methods.HttpRequestBase;
  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.ClientNoContent;
 +import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest;
  import org.apache.olingo.client.api.communication.response.ODataInvokeResponse;
+ import org.apache.olingo.client.api.http.HttpClientException;
+ import org.apache.olingo.client.api.serialization.ODataDeserializerException;
+ import org.apache.olingo.client.api.serialization.ODataSerializerException;
+ import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
+ import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
+ import org.apache.olingo.client.core.uri.URIUtils;
  import org.apache.olingo.client.api.domain.ClientEntity;
  import org.apache.olingo.client.api.domain.ClientEntitySet;
  import org.apache.olingo.client.api.domain.ClientInvokeResult;
  import org.apache.olingo.client.api.domain.ClientProperty;
  import org.apache.olingo.client.api.domain.ClientValue;
- import org.apache.olingo.client.api.http.HttpClientException;
- import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
- import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
- import org.apache.olingo.client.core.uri.URIUtils;
 -import org.apache.olingo.commons.api.format.ODataFormat;
 +import org.apache.olingo.commons.api.format.ContentType;
  import org.apache.olingo.commons.api.http.HttpMethod;
- import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
- import org.apache.olingo.commons.api.serialization.ODataSerializerException;
  
  /**
   * This class implements an OData invoke operation request.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataDeltaRequestImpl.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataDeltaRequestImpl.java
index 1680940,5eb4d84..1cd6970
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataDeltaRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataDeltaRequestImpl.java
@@@ -26,12 -26,12 +26,12 @@@ import org.apache.http.client.HttpClien
  import org.apache.olingo.client.api.ODataClient;
  import org.apache.olingo.client.api.communication.request.retrieve.ODataDeltaRequest;
  import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
 +import org.apache.olingo.client.api.domain.ClientDelta;
  import org.apache.olingo.client.api.http.HttpClientException;
+ import org.apache.olingo.client.api.serialization.ODataDeserializerException;
  import org.apache.olingo.commons.api.data.Delta;
  import org.apache.olingo.commons.api.data.ResWrap;
 -import org.apache.olingo.client.api.domain.ClientDelta;
 -import org.apache.olingo.commons.api.format.ODataFormat;
 +import org.apache.olingo.commons.api.format.ContentType;
- import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
  
  public class ODataDeltaRequestImpl extends AbstractODataRetrieveRequest<ClientDelta>
      implements ODataDeltaRequest {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntityRequestImpl.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntityRequestImpl.java
index 7e35189,d5a224f..dec56b0
--- 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
@@@ -25,11 -25,11 +25,11 @@@ import org.apache.http.client.HttpClien
  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.ClientEntity;
  import org.apache.olingo.commons.api.data.Entity;
  import org.apache.olingo.commons.api.data.ResWrap;
 -import org.apache.olingo.client.api.domain.ClientEntity;
 +import org.apache.olingo.commons.api.format.ContentType;
- import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+ import org.apache.olingo.client.api.serialization.ODataDeserializerException;
 -import org.apache.olingo.commons.api.format.ODataFormat;
  
  /**
   * This class implements an OData retrieve query request returning a single entity.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java
index 6779f52,7e0164b..a49dd32
--- 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
@@@ -25,11 -25,11 +25,11 @@@ import org.apache.http.client.HttpClien
  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.ClientEntitySet;
  import org.apache.olingo.commons.api.data.EntityCollection;
  import org.apache.olingo.commons.api.data.ResWrap;
 -import org.apache.olingo.client.api.domain.ClientEntitySet;
 +import org.apache.olingo.commons.api.format.ContentType;
- import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+ import org.apache.olingo.client.api.serialization.ODataDeserializerException;
 -import org.apache.olingo.commons.api.format.ODataFormat;
  
  /**
   * This class implements an OData EntitySet query request.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataPropertyRequestImpl.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataPropertyRequestImpl.java
index b48fb85,b5a3d10..5c9dfed
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataPropertyRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataPropertyRequestImpl.java
@@@ -26,12 -26,12 +26,12 @@@ import org.apache.http.client.HttpClien
  import org.apache.olingo.client.api.ODataClient;
  import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
  import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
 +import org.apache.olingo.client.api.domain.ClientProperty;
  import org.apache.olingo.client.api.http.HttpClientException;
+ import org.apache.olingo.client.api.serialization.ODataDeserializerException;
  import org.apache.olingo.commons.api.data.Property;
  import org.apache.olingo.commons.api.data.ResWrap;
 -import org.apache.olingo.client.api.domain.ClientProperty;
 -import org.apache.olingo.commons.api.format.ODataFormat;
 +import org.apache.olingo.commons.api.format.ContentType;
- import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
  
  /**
   * This class implements an OData entity property query request.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataRawRequestImpl.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataRawRequestImpl.java
index 4ea6c61,c29e7ee..79c3e14
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataRawRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataRawRequestImpl.java
@@@ -31,9 -32,8 +32,8 @@@ import org.apache.olingo.client.api.ser
  import org.apache.olingo.client.core.communication.request.AbstractODataRequest;
  import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
  import org.apache.olingo.commons.api.data.ResWrap;
 -import org.apache.olingo.commons.api.format.ODataFormat;
 +import org.apache.olingo.commons.api.format.ContentType;
  import org.apache.olingo.commons.api.http.HttpMethod;
- import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
  
  /**
   * This class implements a generic OData request.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataServiceDocumentRequestImpl.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataServiceDocumentRequestImpl.java
index e8fc2aa,b4888f4..d0b6b1f
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataServiceDocumentRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataServiceDocumentRequestImpl.java
@@@ -26,10 -26,10 +26,10 @@@ import org.apache.olingo.client.api.ODa
  import org.apache.olingo.client.api.communication.request.retrieve.ODataServiceDocumentRequest;
  import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
  import org.apache.olingo.client.api.data.ServiceDocument;
 -import org.apache.olingo.commons.api.data.ResWrap;
  import org.apache.olingo.client.api.domain.ClientServiceDocument;
 +import org.apache.olingo.commons.api.data.ResWrap;
 +import org.apache.olingo.commons.api.format.ContentType;
- import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+ import org.apache.olingo.client.api.serialization.ODataDeserializerException;
 -import org.apache.olingo.commons.api.format.ODataFormat;
  
  /**
   * This class implements an OData service document request.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ClientODataDeserializerImpl.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ClientODataDeserializerImpl.java
index 9bd4c6c,89dea37..b6c233f
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ClientODataDeserializerImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ClientODataDeserializerImpl.java
@@@ -26,24 -26,21 +26,20 @@@ import javax.xml.stream.XMLStreamExcept
  import org.apache.olingo.client.api.data.ServiceDocument;
  import org.apache.olingo.client.api.edm.xml.XMLMetadata;
  import org.apache.olingo.client.api.serialization.ClientODataDeserializer;
+ import org.apache.olingo.client.api.serialization.ODataDeserializer;
+ import org.apache.olingo.client.api.serialization.ODataDeserializerException;
  import org.apache.olingo.client.core.data.JSONServiceDocumentDeserializer;
  import org.apache.olingo.client.core.data.XMLServiceDocumentDeserializer;
 -import org.apache.olingo.client.core.edm.xml.ClientCsdlEdmx;
  import org.apache.olingo.client.core.edm.ClientCsdlXMLMetadata;
 +import org.apache.olingo.client.core.edm.xml.ClientCsdlEdmx;
 +import org.apache.olingo.commons.api.ODataError;
  import org.apache.olingo.commons.api.data.Delta;
  import org.apache.olingo.commons.api.data.Entity;
  import org.apache.olingo.commons.api.data.EntityCollection;
  import org.apache.olingo.commons.api.data.Property;
  import org.apache.olingo.commons.api.data.ResWrap;
 -import org.apache.olingo.commons.api.ODataError;
  import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 -import org.apache.olingo.commons.api.format.ODataFormat;
 -
 +import org.apache.olingo.commons.api.format.ContentType;
- import org.apache.olingo.commons.api.serialization.ODataDeserializer;
- import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
- import org.apache.olingo.commons.core.serialization.AtomDeserializer;
- import org.apache.olingo.commons.core.serialization.JsonDeltaDeserializer;
- import org.apache.olingo.commons.core.serialization.JsonDeserializer;
- 
  import com.fasterxml.aalto.stax.InputFactoryImpl;
  import com.fasterxml.aalto.stax.OutputFactoryImpl;
  import com.fasterxml.jackson.core.JsonParser;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonEntitySerializer.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonEntitySerializer.java
index 0000000,9f2056d..75c7feb
mode 000000,100644..100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonEntitySerializer.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonEntitySerializer.java
@@@ -1,0 -1,135 +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.serialization;
+ 
+ import java.io.IOException;
+ 
+ import org.apache.commons.lang3.StringUtils;
+ import org.apache.olingo.commons.api.Constants;
+ import org.apache.olingo.commons.api.data.Annotation;
+ import org.apache.olingo.commons.api.data.Entity;
+ import org.apache.olingo.commons.api.data.Link;
+ import org.apache.olingo.commons.api.data.Operation;
+ import org.apache.olingo.commons.api.data.Property;
+ import org.apache.olingo.commons.api.data.ResWrap;
+ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 -import org.apache.olingo.commons.api.format.ODataFormat;
++import org.apache.olingo.commons.api.format.ContentType;
+ import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+ 
+ import com.fasterxml.jackson.core.JsonGenerator;
+ 
+ /**
+  * Writes out JSON string from an entity.
+  */
+ public class JsonEntitySerializer extends JsonSerializer {
+ 
 -  public JsonEntitySerializer(final boolean serverMode) {
 -    super(serverMode);
 -  }
 -
 -  public JsonEntitySerializer(final boolean serverMode, final ODataFormat format) {
 -    super(serverMode, format);
++  public JsonEntitySerializer(final boolean serverMode, final ContentType contentType) {
++    super(serverMode, contentType);
+   }
+ 
+   protected void doSerialize(final Entity entity, final JsonGenerator jgen)
+       throws IOException, EdmPrimitiveTypeException {
+ 
+     doContainerSerialize(new ResWrap<Entity>(null, null, entity), jgen);
+   }
+ 
+   protected void doContainerSerialize(final ResWrap<Entity> container, final JsonGenerator jgen)
+       throws IOException, EdmPrimitiveTypeException {
+ 
+     final Entity entity = container.getPayload();
+ 
+     jgen.writeStartObject();
+ 
+     if (serverMode) {
+       if (container.getContextURL() != null) {
+         jgen.writeStringField(Constants.JSON_CONTEXT, container.getContextURL().toASCIIString());
+       }
+       if (StringUtils.isNotBlank(container.getMetadataETag())) {
+         jgen.writeStringField(Constants.JSON_METADATA_ETAG, container.getMetadataETag());
+       }
+ 
+       if (StringUtils.isNotBlank(entity.getETag())) {
+         jgen.writeStringField(Constants.JSON_ETAG, entity.getETag());
+       }
+     }
+ 
 -    if (StringUtils.isNotBlank(entity.getType()) && format != ODataFormat.JSON_NO_METADATA) {
++    if (StringUtils.isNotBlank(entity.getType()) && !isODataMetadataNone(contentType)) {
+       jgen.writeStringField(Constants.JSON_TYPE,
+           new EdmTypeInfo.Builder().setTypeExpression(entity.getType()).build().external());
+     }
+ 
 -    if (entity.getId() != null && format != ODataFormat.JSON_NO_METADATA) {
++    if (entity.getId() != null && !isODataMetadataNone(contentType)) {
+       jgen.writeStringField(Constants.JSON_ID, entity.getId().toASCIIString());
+     }
+ 
+     for (Annotation annotation : entity.getAnnotations()) {
+       valuable(jgen, annotation, "@" + annotation.getTerm());
+     }
+ 
+     for (Property property : entity.getProperties()) {
+       valuable(jgen, property, property.getName());
+     }
+ 
+     if (serverMode && entity.getEditLink() != null && StringUtils.isNotBlank(entity.getEditLink().getHref())) {
+       jgen.writeStringField(Constants.JSON_EDIT_LINK,
+           entity.getEditLink().getHref());
+ 
+       if (entity.isMediaEntity()) {
+         jgen.writeStringField(Constants.JSON_MEDIA_READ_LINK,
+             entity.getEditLink().getHref() + "/$value");
+       }
+     }
+ 
 -    if (format != ODataFormat.JSON_NO_METADATA) {
++    if (!isODataMetadataNone(contentType)) {
+       links(entity, jgen);
+     }
+ 
+     for (Link link : entity.getMediaEditLinks()) {
+       if (link.getTitle() == null) {
+         jgen.writeStringField(Constants.JSON_MEDIA_EDIT_LINK, link.getHref());
+       }
+ 
+       if (link.getInlineEntity() != null) {
+         jgen.writeObjectField(link.getTitle(), link.getInlineEntity());
+       }
+       if (link.getInlineEntitySet() != null) {
+         jgen.writeArrayFieldStart(link.getTitle());
+         for (Entity subEntry : link.getInlineEntitySet().getEntities()) {
+           jgen.writeObject(subEntry);
+         }
+         jgen.writeEndArray();
+       }
+     }
+ 
+     if (serverMode) {
+       for (Operation operation : entity.getOperations()) {
+         jgen.writeObjectFieldStart("#" + StringUtils.substringAfterLast(operation.getMetadataAnchor(), "#"));
+         jgen.writeStringField(Constants.ATTR_TITLE, operation.getTitle());
+         jgen.writeStringField(Constants.ATTR_TARGET, operation.getTarget().toASCIIString());
+         jgen.writeEndObject();
+       }
+     }
+ 
+     jgen.writeEndObject();
+   }
+ }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonEntitySetSerializer.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonEntitySetSerializer.java
index 0000000,6bcf822..edb92d2
mode 000000,100644..100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonEntitySetSerializer.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonEntitySetSerializer.java
@@@ -1,0 -1,92 +1,93 @@@
+ /*
+  * 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.serialization;
+ 
+ import java.io.IOException;
+ 
+ import org.apache.commons.lang3.StringUtils;
+ import org.apache.olingo.commons.api.Constants;
+ import org.apache.olingo.commons.api.data.Annotation;
+ import org.apache.olingo.commons.api.data.Entity;
+ import org.apache.olingo.commons.api.data.EntityCollection;
+ import org.apache.olingo.commons.api.data.ResWrap;
+ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
++import org.apache.olingo.commons.api.format.ContentType;
+ 
+ import com.fasterxml.jackson.core.JsonGenerator;
+ 
+ public class JsonEntitySetSerializer extends JsonSerializer {
+ 
 -  public JsonEntitySetSerializer(final boolean serverMode) {
 -    super(serverMode);
++  public JsonEntitySetSerializer(final boolean serverMode, final ContentType contentType) {
++    super(serverMode, contentType);
+   }
+ 
+   protected void doSerialize(final EntityCollection entitySet, final JsonGenerator jgen)
+       throws IOException, EdmPrimitiveTypeException {
+     doContainerSerialize(new ResWrap<EntityCollection>(null, null, entitySet), jgen);
+   }
+ 
+   protected void doContainerSerialize(final ResWrap<EntityCollection> container, final JsonGenerator jgen)
+       throws IOException, EdmPrimitiveTypeException {
+ 
+     final EntityCollection entitySet = container.getPayload();
+ 
+     jgen.writeStartObject();
+ 
+     if (serverMode) {
+       if (container.getContextURL() != null) {
+         jgen.writeStringField(Constants.JSON_CONTEXT, container.getContextURL().toASCIIString());
+       }
+ 
+       if (StringUtils.isNotBlank(container.getMetadataETag())) {
+         jgen.writeStringField(
+             Constants.JSON_METADATA_ETAG,
+             container.getMetadataETag());
+       }
+     }
+ 
+     if (entitySet.getId() != null) {
+       jgen.writeStringField(Constants.JSON_ID, entitySet.getId().toASCIIString());
+     }
+     jgen.writeNumberField(Constants.JSON_COUNT,
+         entitySet.getCount() == null ? entitySet.getEntities().size() : entitySet.getCount());
+     if (serverMode) {
+       if (entitySet.getNext() != null) {
+         jgen.writeStringField(Constants.JSON_NEXT_LINK,
+             entitySet.getNext().toASCIIString());
+       }
+       if (entitySet.getDeltaLink() != null) {
+         jgen.writeStringField(Constants.JSON_DELTA_LINK,
+             entitySet.getDeltaLink().toASCIIString());
+       }
+     }
+ 
+     for (Annotation annotation : entitySet.getAnnotations()) {
+       valuable(jgen, annotation, "@" + annotation.getTerm());
+     }
+ 
+     jgen.writeArrayFieldStart(Constants.VALUE);
 -    final JsonEntitySerializer entitySerializer = new JsonEntitySerializer(serverMode);
++    final JsonEntitySerializer entitySerializer = new JsonEntitySerializer(serverMode, contentType);
+     for (Entity entity : entitySet.getEntities()) {
+       entitySerializer.doSerialize(entity, jgen);
+     }
+     jgen.writeEndArray();
+ 
+     jgen.writeEndObject();
+   }
+ }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonPropertySerializer.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonPropertySerializer.java
index 0000000,11c6821..9911d49
mode 000000,100644..100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonPropertySerializer.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonPropertySerializer.java
@@@ -1,0 -1,93 +1,94 @@@
+ /*
+  * 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.serialization;
+ 
+ import java.io.IOException;
+ import java.net.URI;
+ 
+ import org.apache.commons.lang3.StringUtils;
+ import org.apache.olingo.commons.api.Constants;
+ import org.apache.olingo.commons.api.data.Annotation;
+ import org.apache.olingo.commons.api.data.Property;
+ import org.apache.olingo.commons.api.data.ResWrap;
+ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
++import org.apache.olingo.commons.api.format.ContentType;
+ import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+ 
+ import com.fasterxml.jackson.core.JsonGenerator;
+ 
+ /**
+  * Writes out JSON string from <tt>PropertyImpl</tt>.
+  */
+ public class JsonPropertySerializer extends JsonSerializer {
+ 
 -  public JsonPropertySerializer(final boolean serverMode) {
 -    super(serverMode);
++  public JsonPropertySerializer(final boolean serverMode, final ContentType contentType) {
++    super(serverMode, contentType);
+   }
+ 
+   protected void doSerialize(final Property property, final JsonGenerator jgen)
+       throws IOException, EdmPrimitiveTypeException {
+     doContainerSerialize(new ResWrap<Property>((URI) null, null, property), jgen);
+   }
+ 
+   protected void doContainerSerialize(final ResWrap<Property> container, final JsonGenerator jgen)
+       throws IOException, EdmPrimitiveTypeException {
+ 
+     final Property property = container.getPayload();
+ 
+     jgen.writeStartObject();
+ 
+     if (serverMode && container.getContextURL() != null) {
+       jgen.writeStringField(Constants.JSON_CONTEXT, container.getContextURL().toASCIIString());
+     }
+ 
+     if (StringUtils.isNotBlank(property.getType())) {
+       jgen.writeStringField(Constants.JSON_TYPE,
+           new EdmTypeInfo.Builder().setTypeExpression(property.getType()).build().external());
+     }
+ 
+     for (Annotation annotation : property.getAnnotations()) {
+       valuable(jgen, annotation, "@" + annotation.getTerm());
+     }
+ 
+     if (property.isNull()) {
+       jgen.writeBooleanField(Constants.JSON_NULL, true);
+     } else if (property.isGeospatial() || property.isCollection()) {
+       valuable(jgen, property, Constants.VALUE);
+     } else if (property.isPrimitive()) {
+       final EdmTypeInfo typeInfo = property.getType() == null
+           ? null
+               : new EdmTypeInfo.Builder().setTypeExpression(property.getType()).build();
+ 
+       jgen.writeFieldName(Constants.VALUE);
+       primitiveValue(jgen, typeInfo, property.asPrimitive());
+     } else if (property.isEnum()) {
+       jgen.writeStringField(Constants.VALUE, property.asEnum().toString());
+     } else if (property.isComplex()) {
+       for (Property cproperty : property.asComplex().getValue()) {
+         valuable(jgen, cproperty, cproperty.getName());
+       }
+     } else if (property.isComplex()) {
+       for (Property cproperty : property.asComplex().getValue()) {
+         valuable(jgen, cproperty, cproperty.getName());
+       }
+     }
+ 
+     jgen.writeEndObject();
+   }
+ }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ef1fd778/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonSerializer.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonSerializer.java
index 0000000,484bbfa..d095793
mode 000000,100644..100755
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonSerializer.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonSerializer.java
@@@ -1,0 -1,376 +1,387 @@@
+ /*
+  * 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.serialization;
+ 
+ import java.io.IOException;
+ import java.io.Writer;
+ import java.net.URI;
+ import java.util.ArrayList;
+ import java.util.HashMap;
+ import java.util.List;
+ import java.util.Map;
+ 
+ import org.apache.commons.lang3.ArrayUtils;
+ import org.apache.commons.lang3.StringUtils;
+ import org.apache.olingo.client.api.serialization.ODataSerializer;
+ import org.apache.olingo.client.api.serialization.ODataSerializerException;
+ import org.apache.olingo.commons.api.Constants;
+ import org.apache.olingo.commons.api.data.Annotatable;
+ import org.apache.olingo.commons.api.data.Annotation;
+ import org.apache.olingo.commons.api.data.ComplexValue;
+ import org.apache.olingo.commons.api.data.Entity;
+ import org.apache.olingo.commons.api.data.EntityCollection;
+ import org.apache.olingo.commons.api.data.Link;
+ import org.apache.olingo.commons.api.data.Linked;
+ import org.apache.olingo.commons.api.data.Property;
+ import org.apache.olingo.commons.api.data.ResWrap;
+ import org.apache.olingo.commons.api.data.Valuable;
+ import org.apache.olingo.commons.api.data.ValueType;
+ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+ import org.apache.olingo.commons.api.edm.geo.Geospatial;
 -import org.apache.olingo.commons.api.format.ODataFormat;
++import org.apache.olingo.commons.api.format.ContentType;
+ import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+ import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
+ 
+ import com.fasterxml.jackson.core.JsonFactory;
+ import com.fasterxml.jackson.core.JsonGenerator;
+ 
+ public class JsonSerializer implements ODataSerializer {
+ 
+   private static final EdmPrimitiveTypeKind[] NUMBER_TYPES = {
+     EdmPrimitiveTypeKind.Byte, EdmPrimitiveTypeKind.SByte,
+     EdmPrimitiveTypeKind.Single, EdmPrimitiveTypeKind.Double,
+     EdmPrimitiveTypeKind.Int16, EdmPrimitiveTypeKind.Int32, EdmPrimitiveTypeKind.Int64,
+     EdmPrimitiveTypeKind.Decimal
+   };
+ 
+   private final JsonGeoValueSerializer geoSerializer = new JsonGeoValueSerializer();
+ 
+   protected boolean serverMode;
++  protected final boolean isIEEE754Compatible;
++  protected ContentType contentType;
+ 
 -  protected ODataFormat format;
 -
 -  public JsonSerializer(final boolean serverMode) {
 -    this(serverMode, ODataFormat.JSON_FULL_METADATA);
 -  }
 -
 -  public JsonSerializer(final boolean serverMode, final ODataFormat format) {
++  public JsonSerializer(final boolean serverMode, final ContentType contentType) {
+     this.serverMode = serverMode;
 -    this.format = format;
++    this.contentType = contentType;
++    this.isIEEE754Compatible = isIEEE754Compatible();
+   }
+ 
+   @Override
+   public <T> void write(final Writer writer, final T obj) throws ODataSerializerException {
+     try {
+       final JsonGenerator json = new JsonFactory().createGenerator(writer);
+       if (obj instanceof EntityCollection) {
 -        new JsonEntitySetSerializer(serverMode).doSerialize((EntityCollection) obj, json);
++        new JsonEntitySetSerializer(serverMode, contentType).doSerialize((EntityCollection) obj, json);
+       } else if (obj instanceof Entity) {
 -        new JsonEntitySerializer(serverMode, format).doSerialize((Entity) obj, json);
++        new JsonEntitySerializer(serverMode, contentType).doSerialize((Entity) obj, json);
+       } else if (obj instanceof Property) {
 -        new JsonPropertySerializer(serverMode).doSerialize((Property) obj, json);
++        new JsonPropertySerializer(serverMode, contentType).doSerialize((Property) obj, json);
+       } else if (obj instanceof Link) {
+         link((Link) obj, json);
+       }
+       json.flush();
+     } catch (final IOException e) {
+       throw new ODataSerializerException(e);
+     } catch (final EdmPrimitiveTypeException e) {
+       throw new ODataSerializerException(e);
+     }
+   }
+ 
+   private void reference(final ResWrap<URI> container, final JsonGenerator json) throws IOException {
+     json.writeStartObject();
+ 
+     json.writeStringField(Constants.JSON_CONTEXT, container.getContextURL().toASCIIString());
+     json.writeStringField(Constants.JSON_ID, container.getPayload().toASCIIString());
+ 
+     json.writeEndObject();
+   }
+ 
+   @SuppressWarnings("unchecked")
+   @Override
+   public <T> void write(final Writer writer, final ResWrap<T> container) throws ODataSerializerException {
+     final T obj = container == null ? null : container.getPayload();
+     try {
+       final JsonGenerator json = new JsonFactory().createGenerator(writer);
+       if (obj instanceof EntityCollection) {
 -        new JsonEntitySetSerializer(serverMode).doContainerSerialize((ResWrap<EntityCollection>) container, json);
++        new JsonEntitySetSerializer(serverMode, contentType).doContainerSerialize(
++            (ResWrap<EntityCollection>) container, json);
+       } else if (obj instanceof Entity) {
 -        new JsonEntitySerializer(serverMode).doContainerSerialize((ResWrap<Entity>) container, json);
++        new JsonEntitySerializer(serverMode, contentType).doContainerSerialize((ResWrap<Entity>) container, json);
+       } else if (obj instanceof Property) {
 -        new JsonPropertySerializer(serverMode).doContainerSerialize((ResWrap<Property>) container, json);
++        new JsonPropertySerializer(serverMode, contentType).doContainerSerialize((ResWrap<Property>) container, json);
+       } else if (obj instanceof Link) {
+         link((Link) obj, json);
+       } else if (obj instanceof URI) {
+         reference((ResWrap<URI>) container, json);
+       }
+       json.flush();
+     } catch (final IOException e) {
+       throw new ODataSerializerException(e);
+     } catch (final EdmPrimitiveTypeException e) {
+       throw new ODataSerializerException(e);
+     }
+   }
+ 
+   protected void link(final Link link, final JsonGenerator jgen) throws IOException {
+     jgen.writeStartObject();
+     jgen.writeStringField(Constants.JSON_URL, link.getHref());
+     jgen.writeEndObject();
+   }
+ 
+   protected void links(final Linked linked, final JsonGenerator jgen)
+       throws IOException, EdmPrimitiveTypeException {
+ 
+     if (serverMode) {
+       serverLinks(linked, jgen);
+     } else {
+       clientLinks(linked, jgen);
+     }
+   }
+ 
+   protected void clientLinks(final Linked linked, final JsonGenerator jgen)
+       throws IOException, EdmPrimitiveTypeException {
+ 
+     final Map<String, List<String>> entitySetLinks = new HashMap<String, List<String>>();
+     for (Link link : linked.getNavigationLinks()) {
+       for (Annotation annotation : link.getAnnotations()) {
+         valuable(jgen, annotation, link.getTitle() + "@" + annotation.getTerm());
+       }
+ 
+       if (isEntitySetNavigation(link)) {
+         final List<String> uris;
+         if (entitySetLinks.containsKey(link.getTitle())) {
+           uris = entitySetLinks.get(link.getTitle());
+         } else {
+           uris = new ArrayList<String>();
+           entitySetLinks.put(link.getTitle(), uris);
+         }
+         if (StringUtils.isNotBlank(link.getHref())) {
+           uris.add(link.getHref());
+         }
+       } else {
+         if (StringUtils.isNotBlank(link.getHref())) {
+           jgen.writeStringField(link.getTitle() + Constants.JSON_BIND_LINK_SUFFIX, link.getHref());
+         }
+       }
+ 
+       if (link.getInlineEntity() != null) {
+         jgen.writeFieldName(link.getTitle());
 -        new JsonEntitySerializer(serverMode).doSerialize(link.getInlineEntity(), jgen);
++        new JsonEntitySerializer(serverMode, contentType).doSerialize(link.getInlineEntity(), jgen);
+       } else if (link.getInlineEntitySet() != null) {
+         jgen.writeArrayFieldStart(link.getTitle());
 -        final JsonEntitySerializer entitySerializer = new JsonEntitySerializer(serverMode);
++        final JsonEntitySerializer entitySerializer = new JsonEntitySerializer(serverMode, contentType);
+         for (Entity subEntry : link.getInlineEntitySet().getEntities()) {
+           entitySerializer.doSerialize(subEntry, jgen);
+         }
+         jgen.writeEndArray();
+       }
+     }
+     for (Map.Entry<String, List<String>> entitySetLink : entitySetLinks.entrySet()) {
+       if (!entitySetLink.getValue().isEmpty()) {
+         jgen.writeArrayFieldStart(entitySetLink.getKey() + Constants.JSON_BIND_LINK_SUFFIX);
+         for (String uri : entitySetLink.getValue()) {
+           jgen.writeString(uri);
+         }
+         jgen.writeEndArray();
+       }
+     }
+   }
+ 
+   private boolean isEntitySetNavigation(final Link link) {
+     return Constants.ENTITY_SET_NAVIGATION_LINK_TYPE.equals(link.getType());
+   }
+ 
+   protected void serverLinks(final Linked linked, final JsonGenerator jgen)
+       throws IOException, EdmPrimitiveTypeException {
+     if (linked instanceof Entity) {
+       for (Link link : ((Entity) linked).getMediaEditLinks()) {
+         if (StringUtils.isNotBlank(link.getHref())) {
+           jgen.writeStringField(
+               link.getTitle() + StringUtils.prependIfMissing(Constants.JSON_MEDIA_EDIT_LINK, "@"),
+               link.getHref());
+         }
+       }
+     }
+ 
+     for (Link link : linked.getAssociationLinks()) {
+       if (StringUtils.isNotBlank(link.getHref())) {
+         jgen.writeStringField(
+             link.getTitle() + Constants.JSON_ASSOCIATION_LINK,
+             link.getHref());
+       }
+     }
+ 
+     for (Link link : linked.getNavigationLinks()) {
+       for (Annotation annotation : link.getAnnotations()) {
+         valuable(jgen, annotation, link.getTitle() + "@" + annotation.getTerm());
+       }
+ 
+       if (StringUtils.isNotBlank(link.getHref())) {
+         jgen.writeStringField(
+             link.getTitle() + Constants.JSON_NAVIGATION_LINK,
+             link.getHref());
+       }
+ 
+       if (link.getInlineEntity() != null) {
+         jgen.writeFieldName(link.getTitle());
 -        new JsonEntitySerializer(serverMode).doSerialize(link.getInlineEntity(), jgen);
++        new JsonEntitySerializer(serverMode, contentType).doSerialize(link.getInlineEntity(), jgen);
+       } else if (link.getInlineEntitySet() != null) {
+         jgen.writeArrayFieldStart(link.getTitle());
 -        JsonEntitySerializer entitySerializer = new JsonEntitySerializer(serverMode);
++        JsonEntitySerializer entitySerializer = new JsonEntitySerializer(serverMode, contentType);
+         for (Entity subEntry : link.getInlineEntitySet().getEntities()) {
+           entitySerializer.doSerialize(subEntry, jgen);
+         }
+         jgen.writeEndArray();
+       }
+     }
+   }
+ 
+   private void collection(final JsonGenerator jgen, final EdmTypeInfo typeInfo,
+       final ValueType valueType, final List<?> value)
+           throws IOException, EdmPrimitiveTypeException {
+ 
+     jgen.writeStartArray();
+ 
+     for (Object item : value) {
+       final EdmTypeInfo itemTypeInfo = typeInfo == null
+           ? null
+               : new EdmTypeInfo.Builder().setTypeExpression(typeInfo.getFullQualifiedName().toString()).build();
+       switch (valueType) {
+       case COLLECTION_PRIMITIVE:
+         primitiveValue(jgen, itemTypeInfo, item);
+         break;
+ 
+       case COLLECTION_GEOSPATIAL:
+         jgen.writeStartObject();
+         geoSerializer.serialize(jgen, (Geospatial) item);
+         jgen.writeEndObject();
+         break;
+ 
+       case COLLECTION_ENUM:
+         jgen.writeString(item.toString());
+         break;
+ 
+       case COLLECTION_COMPLEX:
+         final ComplexValue complexItem2 = (ComplexValue) item;
+         complexValue(jgen, itemTypeInfo, complexItem2.getValue(), complexItem2);
+         break;
+ 
+       default:
+       }
+     }
+ 
+     jgen.writeEndArray();
+   }
+ 
+   protected void primitiveValue(final JsonGenerator jgen, final EdmTypeInfo typeInfo, final Object value)
+       throws IOException, EdmPrimitiveTypeException {
+ 
+     final EdmPrimitiveTypeKind kind = typeInfo == null ? null : typeInfo.getPrimitiveTypeKind();
+     final boolean isNumber = kind == null ? value instanceof Number : ArrayUtils.contains(NUMBER_TYPES, kind);
+     final boolean isBoolean = kind == null ? value instanceof Boolean : kind == EdmPrimitiveTypeKind.Boolean;
+ 
+     if (value == null) {
+       jgen.writeNull();
+     } else if (isBoolean) {
+       jgen.writeBoolean((Boolean) value);
+     } else {
 -      final String serialized = kind == null
++        String serialized = kind == null
+           ? value.toString()
+               // TODO: add facets
+               : EdmPrimitiveTypeFactory.getInstance(kind).
+               valueToString(value, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null);
 -          if (isNumber) {
++          
++          if(isIEEE754Compatible && (kind == EdmPrimitiveTypeKind.Int64 || kind == EdmPrimitiveTypeKind.Decimal)) {
++            jgen.writeString(serialized);
++          } else if(isNumber) {
+             jgen.writeNumber(serialized);
+           } else {
+             jgen.writeString(serialized);
+           }
+     }
+   }
+ 
+   private void complexValue(final JsonGenerator jgen, final EdmTypeInfo typeInfo,
+       final List<Property> value, final Linked linked)
+           throws IOException, EdmPrimitiveTypeException {
+     jgen.writeStartObject();
+ 
 -    if (typeInfo != null && format != ODataFormat.JSON_NO_METADATA) {
++    if (typeInfo != null && !isODataMetadataNone(contentType)) {
+       jgen.writeStringField(Constants.JSON_TYPE, typeInfo.external());
+     }
+ 
+     for (Property property : value) {
+       valuable(jgen, property, property.getName());
+     }
+     if (linked != null) {
+       links(linked, jgen);
+     }
+ 
+     jgen.writeEndObject();
+   }
+ 
+   private void value(final JsonGenerator jgen, final String type, final Valuable value)
+       throws IOException, EdmPrimitiveTypeException {
+     final EdmTypeInfo typeInfo = type == null ? null : new EdmTypeInfo.Builder().setTypeExpression(type).build();
+ 
+     if (value.isNull()) {
+       jgen.writeNull();
+     } else if (value.isCollection()) {
+       collection(jgen, typeInfo, value.getValueType(), value.asCollection());
+     } else if (value.isPrimitive()) {
+       primitiveValue(jgen, typeInfo, value.asPrimitive());
+     } else if (value.isEnum()) {
+       jgen.writeString(value.asEnum().toString());
+     } else if (value.isGeospatial()) {
+       jgen.writeStartObject();
+       geoSerializer.serialize(jgen, value.asGeospatial());
+       jgen.writeEndObject();
+     } else if (value.isComplex()) {
+       complexValue(jgen, typeInfo, value.asComplex().getValue(), value.asComplex());
+     }
+   }
+ 
+   protected void valuable(final JsonGenerator jgen, final Valuable valuable, final String name)
+       throws IOException, EdmPrimitiveTypeException {
+ 
+     if (!Constants.VALUE.equals(name) && !(valuable instanceof Annotation)
+         && !(valuable.isComplex() && !valuable.isCollection())) {
+ 
+       String type = valuable.getType();
+       if ((!valuable.isCollection() &&
+           StringUtils.isBlank(type) &&
+           valuable.isPrimitive()) || valuable.isNull()) {
+         type = EdmPrimitiveTypeKind.String.getFullQualifiedName().toString();
+       }
 -      if (StringUtils.isNotBlank(type) && format != ODataFormat.JSON_NO_METADATA) {
++      if (StringUtils.isNotBlank(type) && !isODataMetadataNone(contentType)) {
+         jgen.writeFieldName(
+             name + StringUtils.prependIfMissing(Constants.JSON_TYPE, "@"));
+         jgen.writeString(new EdmTypeInfo.Builder().setTypeExpression(type).build().external());
+       }
+     }
+ 
+     for (Annotation annotation : ((Annotatable) valuable).getAnnotations()) {
+       valuable(jgen, annotation, name + "@" + annotation.getTerm());
+     }
+ 
+     jgen.writeFieldName(name);
+     value(jgen, valuable.getType(), valuable);
+   }
++  
++  private boolean isIEEE754Compatible() {
++    final String parameter = contentType.getParameters().get(ContentType.PARAMETER_IEEE754_COMPATIBLE);
++    return parameter == null ? false : "true".equals(parameter.toLowerCase());
++  }
++  
++  protected boolean isODataMetadataNone(final ContentType contentType) {
++    return contentType.isCompatible(ContentType.APPLICATION_JSON) 
++       && ContentType.VALUE_ODATA_METADATA_NONE.equals(contentType.getParameter(ContentType.PARAMETER_ODATA_METADATA));
++  }
+ }


[30/39] olingo-odata4 git commit: [OLINGO-698] clean-up preferences support

Posted by ch...@apache.org.
[OLINGO-698] clean-up preferences support

Signed-off-by: Christian Amend <ch...@sap.com>


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

Branch: refs/heads/IEE754Compatible
Commit: 971deb5539affbd8167464d27b36fb39d30a0349
Parents: 23815dc
Author: Klaus Straubinger <kl...@sap.com>
Authored: Fri Jun 19 10:36:19 2015 +0200
Committer: Christian Amend <ch...@sap.com>
Committed: Fri Jun 19 10:52:17 2015 +0200

----------------------------------------------------------------------
 .../fit/tecsvc/client/ActionImportITCase.java   |   2 +-
 .../olingo/fit/tecsvc/client/BasicITCase.java   |   6 +-
 .../tecsvc/client/PrimitiveComplexITCase.java   |   2 +-
 .../tecsvc/client/SystemQueryOptionITCase.java  |   2 +-
 .../communication/header/ODataPreferences.java  |  33 ++-
 .../commons/api/ODataPreferenceNames.java       |  46 +++++
 .../olingo/server/api/prefer/Preferences.java   |   5 +-
 .../server/api/prefer/PreferencesApplied.java   |  49 +++--
 .../api/prefer/PreferencesAppliedTest.java      |  18 +-
 .../server/core/prefer/PreferencesImpl.java     |  35 ++--
 .../processor/TechnicalActionProcessor.java     |  12 +-
 .../processor/TechnicalBatchProcessor.java      |   2 +-
 .../processor/TechnicalEntityProcessor.java     |   8 +-
 .../TechnicalPrimitiveComplexProcessor.java     |   2 +-
 .../server/core/PreconditionsValidatorTest.java | 203 ++++++++-----------
 15 files changed, 211 insertions(+), 214 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/971deb55/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
index 0e68a4a..f29fbe3 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
@@ -80,7 +80,7 @@ public class ActionImportITCase extends AbstractBaseTestITCase {
     request.setPrefer(getClient().newPreferences().returnMinimal());
     final ODataInvokeResponse<ClientProperty> response = request.execute();
     assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
-    assertEquals("return=\"minimal\"", response.getHeader(HeaderName.preferenceApplied).iterator().next());
+    assertEquals("return=minimal", response.getHeader(HeaderName.preferenceApplied).iterator().next());
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/971deb55/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
index 0f3a099..6406241 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
@@ -415,7 +415,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
 
     final ODataEntityCreateResponse<ClientEntity> response = request.execute();
     assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
-    assertEquals("return=\"minimal\"", response.getHeader(HeaderName.preferenceApplied).iterator().next());
+    assertEquals("return=minimal", response.getHeader(HeaderName.preferenceApplied).iterator().next());
     assertEquals(SERVICE_URI + "/ESTwoPrim(1)", response.getHeader(HttpHeader.LOCATION).iterator().next());
   }
 
@@ -696,7 +696,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
     final ODataEntityUpdateResponse<ClientEntity> response = request.execute();
 
     assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
-    assertEquals("return=\"representation\"", response.getHeader(HeaderName.preferenceApplied).iterator().next());
+    assertEquals("return=representation", response.getHeader(HeaderName.preferenceApplied).iterator().next());
     assertTrue(response.getBody().getProperty("PropertyString").hasNullValue());
     assertEquals(34, response.getBody().getProperty("PropertyDecimal").getPrimitiveValue().toValue());
   }
@@ -843,7 +843,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
     request.setPrefer(getClient().newPreferences().returnMinimal());
     final ODataEntityUpdateResponse<ClientEntity> response = request.execute();
     assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
-    assertEquals("return=\"minimal\"", response.getHeader(HeaderName.preferenceApplied).iterator().next());
+    assertEquals("return=minimal", response.getHeader(HeaderName.preferenceApplied).iterator().next());
     final String cookie = response.getHeader(HttpHeader.SET_COOKIE).iterator().next();
 
     final ODataEntityRequest<ClientEntity> entityRequest = client.getRetrieveRequestFactory()

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/971deb55/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/PrimitiveComplexITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/PrimitiveComplexITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/PrimitiveComplexITCase.java
index 485aace..02d7708 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/PrimitiveComplexITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/PrimitiveComplexITCase.java
@@ -380,7 +380,7 @@ public class PrimitiveComplexITCase extends AbstractBaseTestITCase {
 
     final ODataValueUpdateResponse response = request.execute();
     assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
-    assertEquals("return=\"minimal\"", response.getHeader(HeaderName.preferenceApplied).iterator().next());
+    assertEquals("return=minimal", response.getHeader(HeaderName.preferenceApplied).iterator().next());
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/971deb55/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/SystemQueryOptionITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/SystemQueryOptionITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/SystemQueryOptionITCase.java
index 9cd8e34..13ca917 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/SystemQueryOptionITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/SystemQueryOptionITCase.java
@@ -268,7 +268,7 @@ public class SystemQueryOptionITCase extends AbstractBaseTestITCase {
     request.setPrefer(getClient().newPreferences().maxPageSize(7));
 
     final ODataRetrieveResponse<ClientEntitySet> response = request.execute();
-    assertEquals("odata.maxpagesize=\"7\"", response.getHeader(HeaderName.preferenceApplied).iterator().next());
+    assertEquals("odata.maxpagesize=7", response.getHeader(HeaderName.preferenceApplied).iterator().next());
     assertEquals(SERVICE_URI + '/' + ES_SERVER_SIDE_PAGING + "?%24skiptoken=1%2A" + 7,
         response.getBody().getNext().toASCIIString());
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/971deb55/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/ODataPreferences.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/ODataPreferences.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/ODataPreferences.java
index e3e4a22..1a659de 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/ODataPreferences.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/ODataPreferences.java
@@ -18,6 +18,7 @@
  */
 package org.apache.olingo.client.api.communication.header;
 
+import org.apache.olingo.commons.api.ODataPreferenceNames;
 
 /**
  * Values of the Prefer header.
@@ -67,7 +68,7 @@ public class ODataPreferences {
    * @return preference.
    */
   public String allowEntityReferences() {
-    return PreferenceNames.allowEntityReferences.toString();
+    return ODataPreferenceNames.ALLOW_ENTITY_REFERENCES.toString();
   }
 
   /**
@@ -130,7 +131,7 @@ public class ODataPreferences {
    * @return preference.
    */
   public String callback(final String url) {
-    return PreferenceNames.callback.toString() + ";url=\"" + url + "\"";
+    return ODataPreferenceNames.CALLBACK.toString() + ";url=\"" + url + "\"";
   }
 
   /**
@@ -151,7 +152,7 @@ public class ODataPreferences {
    * @return preference.
    */
   public String continueOnError() {
-    return PreferenceNames.continueOnError.toString();
+    return ODataPreferenceNames.CONTINUE_ON_ERROR.toString();
   }
 
   /**
@@ -198,7 +199,7 @@ public class ODataPreferences {
    * @return preference.
    */
   public String includeAnnotations(final String value) {
-    return PreferenceNames.includeAnnotations.toString() + "=" + value;
+    return ODataPreferenceNames.INCLUDE_ANNOTATIONS.toString() + "=" + value;
   }
 
   /**
@@ -231,7 +232,7 @@ public class ODataPreferences {
    * @return preference.
    */
   public String maxPageSize(final int size) {
-    return PreferenceNames.maxPageSize.toString() + "=" + size;
+    return ODataPreferenceNames.MAX_PAGE_SIZE.toString() + "=" + size;
   }
 
   /**
@@ -256,7 +257,7 @@ public class ODataPreferences {
    * @return preference.
    */
   public String trackChanges() {
-    return PreferenceNames.trackChanges.toString();
+    return ODataPreferenceNames.TRACK_CHANGES.toString();
   }
 
   /**
@@ -291,7 +292,7 @@ public class ODataPreferences {
    * @return preference.
    */
   public String respondAsync() {
-    return PreferenceNames.respondAsync.toString();
+    return ODataPreferenceNames.RESPOND_ASYNC.toString();
   }
 
   /**
@@ -311,7 +312,7 @@ public class ODataPreferences {
    * @return preference.
    */
   public String wait(final int value) {
-    return PreferenceNames.wait.toString() + "=" + value;
+    return ODataPreferenceNames.WAIT.toString() + "=" + value;
   }
 
   /**
@@ -341,7 +342,7 @@ public class ODataPreferences {
    * @return preference.
    */
   public String returnMinimal() {
-    return PreferenceNames.odataReturn.toString() + "=minimal";
+    return ODataPreferenceNames.RETURN.toString() + "=minimal";
   }
 
   /**
@@ -371,23 +372,15 @@ public class ODataPreferences {
    * @return preference.
    */
   public String returnRepresentation() {
-    return PreferenceNames.odataReturn.toString() + "=representation";
+    return ODataPreferenceNames.RETURN.toString() + "=representation";
   }
 
+  /** Preferences not in the OData 4.0 standard. */
   private static enum PreferenceNames {
 
     returnContent("return-content"),
     returnNoContent("return-no-content"),
-    keyAsSegment("KeyAsSegment"),
-    allowEntityReferences("odata.allow-entityreferences"),
-    callback("odata.callback"),
-    continueOnError("odata.continue-on-error"),
-    includeAnnotations("odata.include-annotations"),
-    maxPageSize("odata.maxpagesize"),
-    trackChanges("odata.track-changes"),
-    respondAsync("respond-async"),
-    wait("wait"),
-    odataReturn("return");
+    keyAsSegment("KeyAsSegment");
 
     private final String preferenceName;
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/971deb55/lib/commons-api/src/main/java/org/apache/olingo/commons/api/ODataPreferenceNames.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/ODataPreferenceNames.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/ODataPreferenceNames.java
new file mode 100644
index 0000000..cdd489b
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/ODataPreferenceNames.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.api;
+
+/**
+ * Names of preferences defined in the OData standard.
+ */
+public enum ODataPreferenceNames {
+
+  ALLOW_ENTITY_REFERENCES("odata.allow-entityreferences"),
+  CALLBACK("odata.callback"),
+  CONTINUE_ON_ERROR("odata.continue-on-error"),
+  INCLUDE_ANNOTATIONS("odata.include-annotations"),
+  MAX_PAGE_SIZE("odata.maxpagesize"),
+  TRACK_CHANGES("odata.track-changes"),
+  RETURN("return"),
+  RESPOND_ASYNC("respond-async"),
+  WAIT("wait");
+
+  private final String preferenceName;
+
+  private ODataPreferenceNames(final String preferenceName) {
+    this.preferenceName = preferenceName;
+  }
+
+  @Override
+  public String toString() {
+    return preferenceName;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/971deb55/lib/server-api/src/main/java/org/apache/olingo/server/api/prefer/Preferences.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/prefer/Preferences.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/prefer/Preferences.java
index 91f0d45..2050474 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/prefer/Preferences.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/prefer/Preferences.java
@@ -19,6 +19,7 @@
 package org.apache.olingo.server.api.prefer;
 
 import java.net.URI;
+import java.util.Collections;
 import java.util.Map;
 
 /**
@@ -101,7 +102,9 @@ public interface Preferences {
      * @return a map from parameter names to parameter values
      */
     public Map<String, String> getParameters() {
-      return parameters;
+      return parameters == null ?
+          Collections.<String, String> emptyMap() :
+          Collections.unmodifiableMap(parameters);
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/971deb55/lib/server-api/src/main/java/org/apache/olingo/server/api/prefer/PreferencesApplied.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/prefer/PreferencesApplied.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/prefer/PreferencesApplied.java
index fd89a3a..f7a8146 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/prefer/PreferencesApplied.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/prefer/PreferencesApplied.java
@@ -23,6 +23,7 @@ import java.util.LinkedHashMap;
 import java.util.Locale;
 import java.util.Map;
 
+import org.apache.olingo.commons.api.ODataPreferenceNames;
 import org.apache.olingo.server.api.prefer.Preferences.Return;
 
 /**
@@ -46,8 +47,8 @@ public class PreferencesApplied {
     return Collections.unmodifiableMap(applied);
   }
 
-  @Override
-  public String toString() {
+  /** Returns a string representation that can be used as value of a Preference-Applied HTTP response header. */
+  public String toValueString() {
     StringBuilder result = new StringBuilder();
     for (final String name : applied.keySet()) {
       if (result.length() > 0) {
@@ -55,14 +56,28 @@ public class PreferencesApplied {
       }
       result.append(name);
       if (applied.get(name) != null) {
-        result.append('=').append('"')
+        final boolean safe = ODataPreferenceNames.ALLOW_ENTITY_REFERENCES.toString().equals(name)
+            || ODataPreferenceNames.CALLBACK.toString().equals(name)
+            || ODataPreferenceNames.CONTINUE_ON_ERROR.toString().equals(name)
+            || ODataPreferenceNames.MAX_PAGE_SIZE.toString().equals(name)
+            || ODataPreferenceNames.TRACK_CHANGES.toString().equals(name)
+            || ODataPreferenceNames.RETURN.toString().equals(name)
+            || ODataPreferenceNames.RESPOND_ASYNC.toString().equals(name)
+            || ODataPreferenceNames.WAIT.toString().equals(name);
+        result.append('=')
+            .append(safe ? "" : '"')
             .append(applied.get(name).replaceAll("\\\\|\"", "\\\\$0"))
-            .append('"');
+            .append(safe ? "" : '"');
       }
     }
     return result.toString();
   }
 
+  @Override
+  public String toString() {
+    return toValueString();
+  }
+
   /** Initializes the builder. */
   public static Builder with() {
     return new Builder();
@@ -71,16 +86,6 @@ public class PreferencesApplied {
   /** Builder of OData serializer options. */
   public static final class Builder {
 
-    private static final String ALLOW_ENTITY_REFERENCES = "odata.allow-entityreferences";
-    private static final String CALLBACK = "odata.callback";
-    private static final String CONTINUE_ON_ERROR = "odata.continue-on-error";
-    // private static final String INCLUDE_ANNOTATIONS = "odata.include-annotations";
-    private static final String MAX_PAGE_SIZE = "odata.maxpagesize";
-    private static final String TRACK_CHANGES = "odata.track-changes";
-    private static final String RETURN = "return";
-    private static final String RESPOND_ASYNC = "respond-async";
-    private static final String WAIT = "wait";
-
     private final PreferencesApplied preferencesApplied;
 
     private Builder() {
@@ -89,49 +94,49 @@ public class PreferencesApplied {
 
     /** Sets <code>odata.allow-entityreferences</code>. */
     public Builder allowEntityReferences() {
-      add(ALLOW_ENTITY_REFERENCES, null);
+      add(ODataPreferenceNames.ALLOW_ENTITY_REFERENCES.toString(), null);
       return this;
     }
 
     /** Sets <code>odata.callback</code>. */
     public Builder callback() {
-      add(CALLBACK, null);
+      add(ODataPreferenceNames.CALLBACK.toString(), null);
       return this;
     }
 
     /** Sets <code>odata.continue-on-error</code>. */
     public Builder continueOnError() {
-      add(CONTINUE_ON_ERROR, null);
+      add(ODataPreferenceNames.CONTINUE_ON_ERROR.toString(), null);
       return this;
     }
 
     /** Sets the value of the applied preference <code>odata.maxpagesize</code>. */
     public Builder maxPageSize(final Integer maxPageSize) {
-      add(MAX_PAGE_SIZE, Integer.toString(maxPageSize));
+      add(ODataPreferenceNames.MAX_PAGE_SIZE.toString(), Integer.toString(maxPageSize));
       return this;
     }
 
     /** Sets <code>odata.track-changes</code>. */
     public Builder trackChanges() {
-      add(TRACK_CHANGES, null);
+      add(ODataPreferenceNames.TRACK_CHANGES.toString(), null);
       return this;
     }
 
     /** Sets the value of the applied preference <code>return</code>. */
     public Builder returnRepresentation(final Return returnRepresentation) {
-      add(RETURN, returnRepresentation.name().toLowerCase(Locale.ROOT));
+      add(ODataPreferenceNames.RETURN.toString(), returnRepresentation.name().toLowerCase(Locale.ROOT));
       return this;
     }
 
     /** Sets <code>odata.respond-async</code>. */
     public Builder respondAsync() {
-      add(RESPOND_ASYNC, null);
+      add(ODataPreferenceNames.RESPOND_ASYNC.toString(), null);
       return this;
     }
 
     /** Sets the value of the applied preference <code>wait</code>. */
     public Builder waitPreference(final Integer wait) {
-      add(WAIT, Integer.toString(wait));
+      add(ODataPreferenceNames.WAIT.toString(), Integer.toString(wait));
       return this;
     }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/971deb55/lib/server-api/src/test/java/org/apache/olingo/server/api/prefer/PreferencesAppliedTest.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/test/java/org/apache/olingo/server/api/prefer/PreferencesAppliedTest.java b/lib/server-api/src/test/java/org/apache/olingo/server/api/prefer/PreferencesAppliedTest.java
index 0d5edf9..49948dd 100644
--- a/lib/server-api/src/test/java/org/apache/olingo/server/api/prefer/PreferencesAppliedTest.java
+++ b/lib/server-api/src/test/java/org/apache/olingo/server/api/prefer/PreferencesAppliedTest.java
@@ -27,41 +27,41 @@ public class PreferencesAppliedTest {
 
   @Test
   public void empty() {
-    assertEquals("", PreferencesApplied.with().build().toString());
+    assertEquals("", PreferencesApplied.with().build().toValueString());
   }
 
   @Test
   public void all() {
     assertEquals("odata.allow-entityreferences, odata.callback,"
-        + " odata.continue-on-error, odata.include-annotations=\"*\", odata.maxpagesize=\"42\","
-        + " odata.track-changes, return=\"representation\", respond-async, wait=\"12345\"",
+        + " odata.continue-on-error, odata.include-annotations=\"*\", odata.maxpagesize=42,"
+        + " odata.track-changes, return=representation, respond-async, wait=12345",
         PreferencesApplied.with().allowEntityReferences().callback().continueOnError()
             .preference("odata.include-annotations", "*").maxPageSize(42).trackChanges()
             .returnRepresentation(Return.REPRESENTATION).respondAsync().waitPreference(12345)
-            .build().toString());
+            .build().toValueString());
   }
 
   @Test
   public void caseSensitivity() {
-    assertEquals("odata.include-annotations=\"*\", odata.maxpagesize=\"255\"",
+    assertEquals("odata.include-annotations=\"*\", odata.maxpagesize=255",
         PreferencesApplied.with()
             .preference("OData.Include-Annotations", "*").maxPageSize(0xFF)
-            .build().toString());
+            .build().toValueString());
   }
 
   @Test
   public void multipleValues() {
-    assertEquals("return=\"minimal\", wait=\"1\"",
+    assertEquals("return=minimal, wait=1",
         PreferencesApplied.with()
             .returnRepresentation(Return.MINIMAL).returnRepresentation(Return.REPRESENTATION)
             .preference(null, null).preference(null, "nullValue")
             .waitPreference(1).waitPreference(2).waitPreference(3)
-            .build().toString());
+            .build().toValueString());
   }
 
   @Test
   public void quotedValue() {
     assertEquals("strangepreference=\"x\\\\y,\\\"abc\\\"z\"",
-        PreferencesApplied.with().preference("strangePreference", "x\\y,\"abc\"z").build().toString());
+        PreferencesApplied.with().preference("strangePreference", "x\\y,\"abc\"z").build().toValueString());
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/971deb55/lib/server-core/src/main/java/org/apache/olingo/server/core/prefer/PreferencesImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/prefer/PreferencesImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/prefer/PreferencesImpl.java
index 9661cd3..50cf89e 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/prefer/PreferencesImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/prefer/PreferencesImpl.java
@@ -23,6 +23,7 @@ import java.util.Collection;
 import java.util.Locale;
 import java.util.Map;
 
+import org.apache.olingo.commons.api.ODataPreferenceNames;
 import org.apache.olingo.server.api.prefer.Preferences;
 
 /**
@@ -32,16 +33,6 @@ import org.apache.olingo.server.api.prefer.Preferences;
  */
 public class PreferencesImpl implements Preferences {
 
-  private static final String ALLOW_ENTITY_REFERENCES = "odata.allow-entityreferences";
-  private static final String CALLBACK = "odata.callback";
-  private static final String CONTINUE_ON_ERROR = "odata.continue-on-error";
-  // private static final String INCLUDE_ANNOTATIONS = "odata.include-annotations";
-  private static final String MAX_PAGE_SIZE = "odata.maxpagesize";
-  private static final String TRACK_CHANGES = "odata.track-changes";
-  private static final String RETURN = "return";
-  private static final String RESPOND_ASYNC = "respond-async";
-  private static final String WAIT = "wait";
-
   private static final String URL = "url"; // parameter name for odata.callback
 
   private final Map<String, Preference> preferences;
@@ -55,15 +46,15 @@ public class PreferencesImpl implements Preferences {
   }
 
   public boolean hasAllowEntityReferences() {
-    return preferences.containsKey(ALLOW_ENTITY_REFERENCES);
+    return preferences.containsKey(ODataPreferenceNames.ALLOW_ENTITY_REFERENCES.toString());
   }
 
   public URI getCallback() {
-    if (preferences.containsKey(CALLBACK)
-        && preferences.get(CALLBACK).getParameters() != null
-        && preferences.get(CALLBACK).getParameters().get(URL) != null) {
+    if (preferences.containsKey(ODataPreferenceNames.CALLBACK.toString())
+        && preferences.get(ODataPreferenceNames.CALLBACK.toString()).getParameters() != null
+        && preferences.get(ODataPreferenceNames.CALLBACK.toString()).getParameters().get(URL) != null) {
       try {
-        return URI.create(preferences.get(CALLBACK).getParameters().get(URL));
+        return URI.create(preferences.get(ODataPreferenceNames.CALLBACK.toString()).getParameters().get(URL));
       } catch (final IllegalArgumentException e) {
         return null;
       }
@@ -72,20 +63,20 @@ public class PreferencesImpl implements Preferences {
   }
 
   public boolean hasContinueOnError() {
-    return preferences.containsKey(CONTINUE_ON_ERROR);
+    return preferences.containsKey(ODataPreferenceNames.CONTINUE_ON_ERROR.toString());
   }
 
   public Integer getMaxPageSize() {
-    return getNonNegativeIntegerPreference(MAX_PAGE_SIZE);
+    return getNonNegativeIntegerPreference(ODataPreferenceNames.MAX_PAGE_SIZE.toString());
   }
 
   public boolean hasTrackChanges() {
-    return preferences.containsKey(TRACK_CHANGES);
+    return preferences.containsKey(ODataPreferenceNames.TRACK_CHANGES.toString());
   }
 
   public Return getReturn() {
-    if (preferences.containsKey(RETURN)) {
-      final String value = preferences.get(RETURN).getValue();
+    if (preferences.containsKey(ODataPreferenceNames.RETURN.toString())) {
+      final String value = preferences.get(ODataPreferenceNames.RETURN.toString()).getValue();
       if (Return.REPRESENTATION.toString().toLowerCase(Locale.ROOT).equals(value)) {
         return Return.REPRESENTATION;
       } else if (Return.MINIMAL.toString().toLowerCase(Locale.ROOT).equals(value)) {
@@ -96,11 +87,11 @@ public class PreferencesImpl implements Preferences {
   }
 
   public boolean hasRespondAsync() {
-    return preferences.containsKey(RESPOND_ASYNC);
+    return preferences.containsKey(ODataPreferenceNames.RESPOND_ASYNC.toString());
   }
 
   public Integer getWait() {
-    return getNonNegativeIntegerPreference(WAIT);
+    return getNonNegativeIntegerPreference(ODataPreferenceNames.WAIT.toString());
   }
 
   private Integer getNonNegativeIntegerPreference(final String name) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/971deb55/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalActionProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalActionProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalActionProcessor.java
index b2a9ca4..d7fc00f 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalActionProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalActionProcessor.java
@@ -112,7 +112,7 @@ public class TechnicalActionProcessor extends TechnicalProcessor
     }
     if (returnPreference != null) {
       response.setHeader(HttpHeader.PREFERENCE_APPLIED,
-          PreferencesApplied.with().returnRepresentation(returnPreference).build().toString());
+          PreferencesApplied.with().returnRepresentation(returnPreference).build().toValueString());
     }
   }
 
@@ -160,7 +160,7 @@ public class TechnicalActionProcessor extends TechnicalProcessor
       }
       if (returnPreference != null) {
         response.setHeader(HttpHeader.PREFERENCE_APPLIED,
-            PreferencesApplied.with().returnRepresentation(returnPreference).build().toString());
+            PreferencesApplied.with().returnRepresentation(returnPreference).build().toValueString());
       }
       if (entityResult.isCreated()) {
         response.setHeader(HttpHeader.LOCATION,
@@ -213,7 +213,7 @@ public class TechnicalActionProcessor extends TechnicalProcessor
     }
     if (returnPreference != null) {
       response.setHeader(HttpHeader.PREFERENCE_APPLIED,
-          PreferencesApplied.with().returnRepresentation(returnPreference).build().toString());
+          PreferencesApplied.with().returnRepresentation(returnPreference).build().toValueString());
     }
   }
 
@@ -253,7 +253,7 @@ public class TechnicalActionProcessor extends TechnicalProcessor
       }
       if (returnPreference != null) {
         response.setHeader(HttpHeader.PREFERENCE_APPLIED,
-            PreferencesApplied.with().returnRepresentation(returnPreference).build().toString());
+            PreferencesApplied.with().returnRepresentation(returnPreference).build().toValueString());
       }
     }
   }
@@ -298,7 +298,7 @@ public class TechnicalActionProcessor extends TechnicalProcessor
     }
     if (returnPreference != null) {
       response.setHeader(HttpHeader.PREFERENCE_APPLIED,
-          PreferencesApplied.with().returnRepresentation(returnPreference).build().toString());
+          PreferencesApplied.with().returnRepresentation(returnPreference).build().toValueString());
     }
   }
 
@@ -339,7 +339,7 @@ public class TechnicalActionProcessor extends TechnicalProcessor
       }
       if (returnPreference != null) {
         response.setHeader(HttpHeader.PREFERENCE_APPLIED,
-            PreferencesApplied.with().returnRepresentation(returnPreference).build().toString());
+            PreferencesApplied.with().returnRepresentation(returnPreference).build().toValueString());
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/971deb55/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalBatchProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalBatchProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalBatchProcessor.java
index fbdeb90..a2c7629 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalBatchProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalBatchProcessor.java
@@ -80,7 +80,7 @@ public class TechnicalBatchProcessor extends TechnicalProcessor implements Batch
     response.setStatusCode(HttpStatusCode.ACCEPTED.getStatusCode());
     if (continueOnError) {
       response.setHeader(HttpHeader.PREFERENCE_APPLIED,
-          PreferencesApplied.with().continueOnError().build().toString());
+          PreferencesApplied.with().continueOnError().build().toValueString());
     }
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/971deb55/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
index 217d768..ccf8189 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
@@ -176,7 +176,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
     }
     if (returnPreference != null) {
       response.setHeader(HttpHeader.PREFERENCE_APPLIED,
-          PreferencesApplied.with().returnRepresentation(returnPreference).build().toString());
+          PreferencesApplied.with().returnRepresentation(returnPreference).build().toValueString());
     }
     response.setHeader(HttpHeader.LOCATION,
         request.getRawBaseUri() + '/' + odata.createUriHelper().buildCanonicalURL(edmEntitySet, entity));
@@ -232,7 +232,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
     }
     if (returnPreference != null) {
       response.setHeader(HttpHeader.PREFERENCE_APPLIED,
-          PreferencesApplied.with().returnRepresentation(returnPreference).build().toString());
+          PreferencesApplied.with().returnRepresentation(returnPreference).build().toValueString());
     }
     if (entity.getETag() != null) {
       response.setHeader(HttpHeader.ETAG, entity.getETag());
@@ -266,7 +266,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
     }
     if (returnPreference != null) {
       response.setHeader(HttpHeader.PREFERENCE_APPLIED,
-          PreferencesApplied.with().returnRepresentation(returnPreference).build().toString());
+          PreferencesApplied.with().returnRepresentation(returnPreference).build().toValueString());
     }
     if (entity.getETag() != null) {
       response.setHeader(HttpHeader.ETAG, entity.getETag());
@@ -476,7 +476,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
     response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString());
     if (pageSize != null) {
       response.setHeader(HttpHeader.PREFERENCE_APPLIED,
-          PreferencesApplied.with().maxPageSize(serverPageSize).build().toString());
+          PreferencesApplied.with().maxPageSize(serverPageSize).build().toValueString());
     }
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/971deb55/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
index 6a9af47..4d1e834 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
@@ -325,7 +325,7 @@ public class TechnicalPrimitiveComplexProcessor extends TechnicalProcessor
     }
     if (returnPreference != null) {
       response.setHeader(HttpHeader.PREFERENCE_APPLIED,
-          PreferencesApplied.with().returnRepresentation(returnPreference).build().toString());
+          PreferencesApplied.with().returnRepresentation(returnPreference).build().toValueString());
     }
     if (entity.getETag() != null) {
       response.setHeader(HttpHeader.ETAG, entity.getETag());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/971deb55/lib/server-test/src/test/java/org/apache/olingo/server/core/PreconditionsValidatorTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/PreconditionsValidatorTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/PreconditionsValidatorTest.java
index acd578c..a70bbc7 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/PreconditionsValidatorTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/PreconditionsValidatorTest.java
@@ -20,245 +20,204 @@ package org.apache.olingo.server.core;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.List;
 
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.EdmBindingTarget;
-import org.apache.olingo.commons.api.http.HttpMethod;
 import org.apache.olingo.commons.core.edm.EdmProviderImpl;
 import org.apache.olingo.server.api.etag.CustomETagSupport;
 import org.apache.olingo.server.api.etag.PreconditionException;
 import org.apache.olingo.server.api.uri.UriInfo;
+import org.apache.olingo.server.api.uri.UriResource;
+import org.apache.olingo.server.api.uri.UriResourceEntitySet;
+import org.apache.olingo.server.api.uri.UriResourceValue;
 import org.apache.olingo.server.core.etag.PreconditionsValidator;
 import org.apache.olingo.server.core.uri.parser.Parser;
 import org.apache.olingo.server.core.uri.parser.UriParserException;
 import org.apache.olingo.server.core.uri.parser.UriParserSemanticException;
-import org.apache.olingo.server.core.uri.validator.UriValidator;
 import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
 import org.junit.Ignore;
 import org.junit.Test;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
 
 public class PreconditionsValidatorTest {
 
+  private static final Edm edm = new EdmProviderImpl(new EdmTechProvider());
+
   // -------------- POSITIVE TESTS --------------------------------------------------------------------------------
 
   @Test
   public void simpleEntity() throws Exception {
-    UriInfo uriInfo = new Parser().parseUri("ESAllPrim(1)", null, null, getEdm());
-    new PreconditionsValidator(new ETagSupport(), uriInfo, "*", "*").validatePreconditions(false);
+    validate("ESAllPrim(1)", null, "*", "*");
   }
 
   @Test
   public void simpleEntityValue() throws Exception {
-    UriInfo uriInfo = new Parser().parseUri("ESMedia(1)/$value", null, null, getEdm());
-    new PreconditionsValidator(new ETagSupport(), uriInfo, "*", "*").validatePreconditions(true);
+    validate("ESMedia(1)/$value", null, "*", "*");
   }
 
   @Test
   public void EntityAndToOneNavigation() throws Exception {
-    UriInfo uriInfo = new Parser().parseUri("ESAllPrim(1)/NavPropertyETTwoPrimOne", null, null, getEdm());
-    new PreconditionsValidator(new ETagSupport("ESTwoPrim"), uriInfo, "*", "*").validatePreconditions(false);
+    validate("ESAllPrim(1)/NavPropertyETTwoPrimOne", "ESTwoPrim", "*", "*");
   }
 
   @Test
   public void EntityAndToManyNavigationWithKey() throws Exception {
-    UriInfo uriInfo = new Parser().parseUri("ESAllPrim(1)/NavPropertyETTwoPrimMany(1)", null, null, getEdm());
-    new PreconditionsValidator(new ETagSupport("ESTwoPrim"), uriInfo, "*", "*").validatePreconditions(false);
+    validate("ESAllPrim(1)/NavPropertyETTwoPrimMany(1)", "ESTwoPrim", "*", "*");
   }
 
   @Test
   public void EntityAndToOneNavigationValue() throws Exception {
-    UriInfo uriInfo = new Parser().parseUri("ESKeyNav(1)/NavPropertyETMediaOne/$value", null, null, getEdm());
-    new PreconditionsValidator(new ETagSupport("ESMedia"), uriInfo, "*", "*").validatePreconditions(true);
+    validate("ESKeyNav(1)/NavPropertyETMediaOne/$value", "ESMedia", "*", "*");
   }
 
   @Test
   public void boundActionOnEsKeyNav() throws Exception {
-    UriInfo uriInfo =
-        new Parser().parseUri("ESKeyNav(1)/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav", null, null, getEdm());
-    new PreconditionsValidator(new ETagSupport("ESKeyNav"), uriInfo, "*", "*").validatePreconditions(false);
+    validate("ESKeyNav(1)/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav", "ESKeyNav", "*", "*");
   }
 
   @Test
   public void boundActionOnEsKeyNavWithNavigation() throws Exception {
-    UriInfo uriInfo =
-        new Parser().parseUri("ESKeyNav(1)/NavPropertyETKeyNavOne/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav", null,
-            null, getEdm());
-    new PreconditionsValidator(new ETagSupport("ESKeyNav"), uriInfo, "*", "*").validatePreconditions(false);
+    validate("ESKeyNav(1)/NavPropertyETKeyNavOne/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav",
+        "ESKeyNav", "*", "*");
   }
 
   @Test
   public void singleton() throws Exception {
-    UriInfo uriInfo = new Parser().parseUri("SI", null, null, getEdm());
-    new PreconditionsValidator(new ETagSupport("SI"), uriInfo, "*", "*").validatePreconditions(false);
+    validate("SI", "SI", "*", "*");
   }
 
   @Test
   public void singletonWithNavigation() throws Exception {
-    UriInfo uriInfo = new Parser().parseUri("SINav/NavPropertyETKeyNavOne", null, null, getEdm());
-    new PreconditionsValidator(new ETagSupport("ESKeyNav"), uriInfo, "*", "*").validatePreconditions(false);
+    validate("SINav/NavPropertyETKeyNavOne", "ESKeyNav", "*", "*");
   }
 
   @Test
   public void singletonWithNavigationValue() throws Exception {
-    UriInfo uriInfo =
-        new Parser().parseUri("SINav/NavPropertyETKeyNavOne/NavPropertyETMediaOne/$value", null, null, getEdm());
-    new PreconditionsValidator(new ETagSupport("ESMedia"), uriInfo, "*", "*").validatePreconditions(false);
+    validate("SINav/NavPropertyETKeyNavOne/NavPropertyETMediaOne/$value", "ESMedia", "*", "*");
   }
 
   @Test
   public void singletonWithAction() throws Exception {
-    UriInfo uriInfo = new Parser().parseUri("SINav/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav", null, null, getEdm());
-    new PreconditionsValidator(new ETagSupport("SINav"), uriInfo, "*", "*").validatePreconditions(false);
+    validate("SINav/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav", "SINav", "*", "*");
   }
 
   @Test
   public void singletonWithActionAndNavigation() throws Exception {
-    UriInfo uriInfo =
-        new Parser().parseUri("SINav/NavPropertyETKeyNavOne/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav", null, null,
-            getEdm());
-    new PreconditionsValidator(new ETagSupport("ESKeyNav"), uriInfo, "*", "*").validatePreconditions(false);
+    validate("SINav/NavPropertyETKeyNavOne/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav", "ESKeyNav", "*", "*");
   }
 
   @Test
   public void simpleEntityValueValidationNotActiveForMedia() throws Exception {
-    UriInfo uriInfo = new Parser().parseUri("ESMedia(1)/$value", null, null, getEdm());
-    new PreconditionsValidator(new ETagSupport(true, false), uriInfo, null, null).validatePreconditions(true);
+    CustomETagSupport support = mock(CustomETagSupport.class);
+    when(support.hasETag(any(EdmBindingTarget.class))).thenReturn(true);
+    when(support.hasMediaETag(any(EdmBindingTarget.class))).thenReturn(false);
+
+    final UriInfo uriInfo = new Parser().parseUri("ESMedia(1)/$value", null, null, edm);
+    new PreconditionsValidator(support, uriInfo, null, null).validatePreconditions(true);
   }
 
   // -------------- IGNORE VALIDATION TESTS -----------------------------------------------------------------------
 
   @Test
   public void entitySetMustNotLeadToException() throws Exception {
-    UriInfo uriInfo = new Parser().parseUri("ESAllPrim", null, null, getEdm());
-    new PreconditionsValidator(new ETagSupport(), uriInfo, null, null).validatePreconditions(false);
+    validate("ESAllPrim", null, null, null);
   }
 
   @Test
   public void propertyMustNotLeadToException() throws Exception {
-    UriInfo uriInfo = new Parser().parseUri("ESAllPrim(1)/PropertyInt16", null, null, getEdm());
-    new PreconditionsValidator(new ETagSupport(), uriInfo, null, null).validatePreconditions(false);
+    validate("ESAllPrim(1)/PropertyInt16", null, null, null);
   }
 
   @Test
   public void propertyValueMustNotLeadToException() throws Exception {
-    UriInfo uriInfo = new Parser().parseUri("ESAllPrim(1)/PropertyInt16/$value", null, null, getEdm());
-    new PreconditionsValidator(new ETagSupport(), uriInfo, null, null).validatePreconditions(true);
+    validate("ESAllPrim(1)/PropertyInt16/$value", null, null, null);
   }
 
   @Test
   public void navigationToManyMustNotLeadToException() throws Exception {
-    UriInfo uriInfo = new Parser().parseUri("ESAllPrim(1)/NavPropertyETTwoPrimMany", null, null, getEdm());
-    new PreconditionsValidator(new ETagSupport(), uriInfo, null, null).validatePreconditions(false);
+    validate("ESAllPrim(1)/NavPropertyETTwoPrimMany", null, null, null);
   }
 
   @Test
   public void navigationOnPropertyMustNotLeadToException() throws Exception {
-    UriInfo uriInfo = new Parser().parseUri("ESAllPrim(1)/NavPropertyETTwoPrimOne/PropertyInt16", null, null, getEdm());
-    new PreconditionsValidator(new ETagSupport(), uriInfo, null, null).validatePreconditions(false);
+    validate("ESAllPrim(1)/NavPropertyETTwoPrimOne/PropertyInt16", null, null, null);
   }
 
   @Test
   public void navigationToManyOnActionMustNotLeadToException() throws Exception {
-    UriInfo uriInfo =
-        new Parser().parseUri("ESTwoPrim(1)/NavPropertyETAllPrimMany/Namespace1_Alias.BAESAllPrimRTETAllPrim", null,
-            null, getEdm());
-    new PreconditionsValidator(new ETagSupport(), uriInfo, null, null).validatePreconditions(false);
+    validate("ESTwoPrim(1)/NavPropertyETAllPrimMany/Namespace1_Alias.BAESAllPrimRTETAllPrim", null, null, null);
   }
 
   @Test
-  public void navigationWithoutBindingMustNotLeadToAnException() throws Exception {
-    UriInfo uriInfo =
-        new Parser()
-            .parseUri(
-                "ESTwoBaseTwoKeyNav(PropertyInt16=1,PropertyString='test')"
-                    + "/NavPropertyETBaseTwoKeyNavMany(PropertyInt16=1,PropertyString='test')",
-                null, null, getEdm());
-    new PreconditionsValidator(new ETagSupport(), uriInfo, null, null).validatePreconditions(false);
+  public void navigationWithoutBindingMustNotLeadToException() throws Exception {
+    validate("ESTwoBaseTwoKeyNav(PropertyInt16=1,PropertyString='test')"
+        + "/NavPropertyETBaseTwoKeyNavMany(PropertyInt16=1,PropertyString='test')",
+        null, null, null);
   }
 
   // -------------- NEGATIVE TESTS --------------------------------------------------------------------------------
 
   @Test
   public void positiveTestsMustLeadToAnExceptionIfNoHeaderIsPresent() throws Exception {
-    runException("ESAllPrim(1)", null);
-    runException("ESMedia(1)/$value", null);
-    runException("ESAllPrim(1)/NavPropertyETTwoPrimOne", null);
-    runException("ESAllPrim(1)/NavPropertyETTwoPrimMany(1)", null);
-    runException("ESKeyNav(1)/NavPropertyETMediaOne/$value", null);
-    runException("ESKeyNav(1)/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav", null);
-    runException("ESKeyNav(1)/NavPropertyETKeyNavOne/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav", null);
-
-    runException("SI", null);
-    runException("SINav/NavPropertyETKeyNavOne", null);
-    runException("SINav/NavPropertyETKeyNavOne/NavPropertyETMediaOne/$value", null);
-    runException("SINav/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav", null);
-    runException("SINav/NavPropertyETKeyNavOne/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav", null);
+    runException("ESAllPrim(1)");
+    runException("ESMedia(1)/$value");
+    runException("ESAllPrim(1)/NavPropertyETTwoPrimOne");
+    runException("ESAllPrim(1)/NavPropertyETTwoPrimMany(1)");
+    runException("ESKeyNav(1)/NavPropertyETMediaOne/$value");
+    runException("ESKeyNav(1)/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav");
+    runException("ESKeyNav(1)/NavPropertyETKeyNavOne/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav");
+
+    runException("SI");
+    runException("SINav/NavPropertyETKeyNavOne");
+    runException("SINav/NavPropertyETKeyNavOne/NavPropertyETMediaOne/$value");
+    runException("SINav/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav");
+    runException("SINav/NavPropertyETKeyNavOne/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav");
   }
 
   @Ignore
-  @Test
+  @Test(expected = UriParserSemanticException.class)
   public void resourceSegmentAfterActionMustLeadToUriParserException() throws Exception {
-    // TODO: Check with URI Parser
-    UriInfo uriInfo =
-        new Parser().parseUri("ESKeyNav(1)/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav/PropertyInt16", null, null,
-            getEdm());
-    new UriValidator().validate(uriInfo, HttpMethod.GET);
-    new PreconditionsValidator(new ETagSupport("ESKeyNav"), uriInfo, "*", "*").validatePreconditions(false);
+    validate("ESKeyNav(1)/Namespace1_Alias.BAETTwoKeyNavRTETTwoKeyNav/PropertyInt16", "ESKeyNav", "*", "*");
   }
 
   @Test(expected = UriParserSemanticException.class)
   public void valueMustBeLastSegment() throws Exception {
-    new Parser().parseUri("ESMedia(1)/$value/PropertyInt16", null, null, getEdm());
-  }
-
-  private void runException(String uri, String expectedEntitySet) throws UriParserException {
-    UriInfo uriInfo = new Parser().parseUri(uri, null, null, getEdm());
-    try {
-      CustomETagSupport etagSupport =
-          expectedEntitySet == null ? new ETagSupport() : new ETagSupport(expectedEntitySet);
-      boolean isMedia = uri.endsWith("$value");
-      new PreconditionsValidator(etagSupport, uriInfo, null, null).validatePreconditions(isMedia);
-      fail("Expected a PreconditionRequiredException but was not thrown");
-    } catch (PreconditionException e) {
-      assertEquals(PreconditionException.MessageKeys.MISSING_HEADER, e.getMessageKey());
-    }
+    validate("ESMedia(1)/$value/PropertyInt16", null, null, null);
   }
 
-  private Edm getEdm() {
-    return new EdmProviderImpl(new EdmTechProvider());
-  }
-
-  public class ETagSupport implements CustomETagSupport {
-
-    private boolean eTag = true;
-    private boolean mediaETag = true;
-    private String entitySetName;
-
-    public ETagSupport() {}
-
-    public ETagSupport(String entitySetName) {
-      this.entitySetName = entitySetName;
-    }
+  private void validate(final String uri, final String entitySetName, final String ifMatch, final String ifNoneMatch)
+      throws UriParserException, PreconditionException {
+    final UriInfo uriInfo = new Parser().parseUri(uri, null, null, edm);
+    final List<UriResource> parts = uriInfo.getUriResourceParts();
+    final boolean isMedia = parts.get(parts.size() - 1) instanceof UriResourceValue
+        && parts.get(parts.size() - 2) instanceof UriResourceEntitySet;
 
-    public ETagSupport(boolean eTag, boolean mediaETag) {
-      this.eTag = eTag;
-      this.mediaETag = mediaETag;
-    }
+    CustomETagSupport support = mock(CustomETagSupport.class);
+    final Answer<Boolean> answer = new Answer<Boolean>() {
+      public Boolean answer(final InvocationOnMock invocation) throws Throwable {
+        if (entitySetName != null) {
+          assertEquals(entitySetName, ((EdmBindingTarget) invocation.getArguments()[0]).getName());
+        }
+        return true;
+      }};
+    when(support.hasETag(any(EdmBindingTarget.class))).thenAnswer(answer);
+    when(support.hasMediaETag(any(EdmBindingTarget.class))).thenAnswer(answer);
 
-    @Override
-    public boolean hasETag(EdmBindingTarget entitySetOrSingeton) {
-      if (this.entitySetName != null) {
-        assertEquals(this.entitySetName, entitySetOrSingeton.getName());
-      }
-      return eTag;
-    }
+    new PreconditionsValidator(support, uriInfo, ifMatch, ifNoneMatch).validatePreconditions(isMedia);
+  }
 
-    @Override
-    public boolean hasMediaETag(EdmBindingTarget entitySetOrSingelton) {
-      if (this.entitySetName != null) {
-        assertEquals(this.entitySetName, entitySetOrSingelton.getName());
-      }
-      return mediaETag;
+  private void runException(final String uri) throws UriParserException {
+    try {
+      validate(uri, null, null, null);
+      fail("Expected a PreconditionRequiredException but was not thrown");
+    } catch (final PreconditionException e) {
+      assertEquals(PreconditionException.MessageKeys.MISSING_HEADER, e.getMessageKey());
     }
   }
 }


[12/39] olingo-odata4 git commit: [OLINGO-699] Moved serializer code to client module

Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonSerializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonSerializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonSerializer.java
new file mode 100644
index 0000000..484bbfa
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonSerializer.java
@@ -0,0 +1,376 @@
+/*
+ * 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.serialization;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.client.api.serialization.ODataSerializer;
+import org.apache.olingo.client.api.serialization.ODataSerializerException;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.Annotatable;
+import org.apache.olingo.commons.api.data.Annotation;
+import org.apache.olingo.commons.api.data.ComplexValue;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntityCollection;
+import org.apache.olingo.commons.api.data.Link;
+import org.apache.olingo.commons.api.data.Linked;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.data.Valuable;
+import org.apache.olingo.commons.api.data.ValueType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.geo.Geospatial;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
+
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonGenerator;
+
+public class JsonSerializer implements ODataSerializer {
+
+  private static final EdmPrimitiveTypeKind[] NUMBER_TYPES = {
+    EdmPrimitiveTypeKind.Byte, EdmPrimitiveTypeKind.SByte,
+    EdmPrimitiveTypeKind.Single, EdmPrimitiveTypeKind.Double,
+    EdmPrimitiveTypeKind.Int16, EdmPrimitiveTypeKind.Int32, EdmPrimitiveTypeKind.Int64,
+    EdmPrimitiveTypeKind.Decimal
+  };
+
+  private final JsonGeoValueSerializer geoSerializer = new JsonGeoValueSerializer();
+
+  protected boolean serverMode;
+
+  protected ODataFormat format;
+
+  public JsonSerializer(final boolean serverMode) {
+    this(serverMode, ODataFormat.JSON_FULL_METADATA);
+  }
+
+  public JsonSerializer(final boolean serverMode, final ODataFormat format) {
+    this.serverMode = serverMode;
+    this.format = format;
+  }
+
+  @Override
+  public <T> void write(final Writer writer, final T obj) throws ODataSerializerException {
+    try {
+      final JsonGenerator json = new JsonFactory().createGenerator(writer);
+      if (obj instanceof EntityCollection) {
+        new JsonEntitySetSerializer(serverMode).doSerialize((EntityCollection) obj, json);
+      } else if (obj instanceof Entity) {
+        new JsonEntitySerializer(serverMode, format).doSerialize((Entity) obj, json);
+      } else if (obj instanceof Property) {
+        new JsonPropertySerializer(serverMode).doSerialize((Property) obj, json);
+      } else if (obj instanceof Link) {
+        link((Link) obj, json);
+      }
+      json.flush();
+    } catch (final IOException e) {
+      throw new ODataSerializerException(e);
+    } catch (final EdmPrimitiveTypeException e) {
+      throw new ODataSerializerException(e);
+    }
+  }
+
+  private void reference(final ResWrap<URI> container, final JsonGenerator json) throws IOException {
+    json.writeStartObject();
+
+    json.writeStringField(Constants.JSON_CONTEXT, container.getContextURL().toASCIIString());
+    json.writeStringField(Constants.JSON_ID, container.getPayload().toASCIIString());
+
+    json.writeEndObject();
+  }
+
+  @SuppressWarnings("unchecked")
+  @Override
+  public <T> void write(final Writer writer, final ResWrap<T> container) throws ODataSerializerException {
+    final T obj = container == null ? null : container.getPayload();
+    try {
+      final JsonGenerator json = new JsonFactory().createGenerator(writer);
+      if (obj instanceof EntityCollection) {
+        new JsonEntitySetSerializer(serverMode).doContainerSerialize((ResWrap<EntityCollection>) container, json);
+      } else if (obj instanceof Entity) {
+        new JsonEntitySerializer(serverMode).doContainerSerialize((ResWrap<Entity>) container, json);
+      } else if (obj instanceof Property) {
+        new JsonPropertySerializer(serverMode).doContainerSerialize((ResWrap<Property>) container, json);
+      } else if (obj instanceof Link) {
+        link((Link) obj, json);
+      } else if (obj instanceof URI) {
+        reference((ResWrap<URI>) container, json);
+      }
+      json.flush();
+    } catch (final IOException e) {
+      throw new ODataSerializerException(e);
+    } catch (final EdmPrimitiveTypeException e) {
+      throw new ODataSerializerException(e);
+    }
+  }
+
+  protected void link(final Link link, final JsonGenerator jgen) throws IOException {
+    jgen.writeStartObject();
+    jgen.writeStringField(Constants.JSON_URL, link.getHref());
+    jgen.writeEndObject();
+  }
+
+  protected void links(final Linked linked, final JsonGenerator jgen)
+      throws IOException, EdmPrimitiveTypeException {
+
+    if (serverMode) {
+      serverLinks(linked, jgen);
+    } else {
+      clientLinks(linked, jgen);
+    }
+  }
+
+  protected void clientLinks(final Linked linked, final JsonGenerator jgen)
+      throws IOException, EdmPrimitiveTypeException {
+
+    final Map<String, List<String>> entitySetLinks = new HashMap<String, List<String>>();
+    for (Link link : linked.getNavigationLinks()) {
+      for (Annotation annotation : link.getAnnotations()) {
+        valuable(jgen, annotation, link.getTitle() + "@" + annotation.getTerm());
+      }
+
+      if (isEntitySetNavigation(link)) {
+        final List<String> uris;
+        if (entitySetLinks.containsKey(link.getTitle())) {
+          uris = entitySetLinks.get(link.getTitle());
+        } else {
+          uris = new ArrayList<String>();
+          entitySetLinks.put(link.getTitle(), uris);
+        }
+        if (StringUtils.isNotBlank(link.getHref())) {
+          uris.add(link.getHref());
+        }
+      } else {
+        if (StringUtils.isNotBlank(link.getHref())) {
+          jgen.writeStringField(link.getTitle() + Constants.JSON_BIND_LINK_SUFFIX, link.getHref());
+        }
+      }
+
+      if (link.getInlineEntity() != null) {
+        jgen.writeFieldName(link.getTitle());
+        new JsonEntitySerializer(serverMode).doSerialize(link.getInlineEntity(), jgen);
+      } else if (link.getInlineEntitySet() != null) {
+        jgen.writeArrayFieldStart(link.getTitle());
+        final JsonEntitySerializer entitySerializer = new JsonEntitySerializer(serverMode);
+        for (Entity subEntry : link.getInlineEntitySet().getEntities()) {
+          entitySerializer.doSerialize(subEntry, jgen);
+        }
+        jgen.writeEndArray();
+      }
+    }
+    for (Map.Entry<String, List<String>> entitySetLink : entitySetLinks.entrySet()) {
+      if (!entitySetLink.getValue().isEmpty()) {
+        jgen.writeArrayFieldStart(entitySetLink.getKey() + Constants.JSON_BIND_LINK_SUFFIX);
+        for (String uri : entitySetLink.getValue()) {
+          jgen.writeString(uri);
+        }
+        jgen.writeEndArray();
+      }
+    }
+  }
+
+  private boolean isEntitySetNavigation(final Link link) {
+    return Constants.ENTITY_SET_NAVIGATION_LINK_TYPE.equals(link.getType());
+  }
+
+  protected void serverLinks(final Linked linked, final JsonGenerator jgen)
+      throws IOException, EdmPrimitiveTypeException {
+    if (linked instanceof Entity) {
+      for (Link link : ((Entity) linked).getMediaEditLinks()) {
+        if (StringUtils.isNotBlank(link.getHref())) {
+          jgen.writeStringField(
+              link.getTitle() + StringUtils.prependIfMissing(Constants.JSON_MEDIA_EDIT_LINK, "@"),
+              link.getHref());
+        }
+      }
+    }
+
+    for (Link link : linked.getAssociationLinks()) {
+      if (StringUtils.isNotBlank(link.getHref())) {
+        jgen.writeStringField(
+            link.getTitle() + Constants.JSON_ASSOCIATION_LINK,
+            link.getHref());
+      }
+    }
+
+    for (Link link : linked.getNavigationLinks()) {
+      for (Annotation annotation : link.getAnnotations()) {
+        valuable(jgen, annotation, link.getTitle() + "@" + annotation.getTerm());
+      }
+
+      if (StringUtils.isNotBlank(link.getHref())) {
+        jgen.writeStringField(
+            link.getTitle() + Constants.JSON_NAVIGATION_LINK,
+            link.getHref());
+      }
+
+      if (link.getInlineEntity() != null) {
+        jgen.writeFieldName(link.getTitle());
+        new JsonEntitySerializer(serverMode).doSerialize(link.getInlineEntity(), jgen);
+      } else if (link.getInlineEntitySet() != null) {
+        jgen.writeArrayFieldStart(link.getTitle());
+        JsonEntitySerializer entitySerializer = new JsonEntitySerializer(serverMode);
+        for (Entity subEntry : link.getInlineEntitySet().getEntities()) {
+          entitySerializer.doSerialize(subEntry, jgen);
+        }
+        jgen.writeEndArray();
+      }
+    }
+  }
+
+  private void collection(final JsonGenerator jgen, final EdmTypeInfo typeInfo,
+      final ValueType valueType, final List<?> value)
+          throws IOException, EdmPrimitiveTypeException {
+
+    jgen.writeStartArray();
+
+    for (Object item : value) {
+      final EdmTypeInfo itemTypeInfo = typeInfo == null
+          ? null
+              : new EdmTypeInfo.Builder().setTypeExpression(typeInfo.getFullQualifiedName().toString()).build();
+      switch (valueType) {
+      case COLLECTION_PRIMITIVE:
+        primitiveValue(jgen, itemTypeInfo, item);
+        break;
+
+      case COLLECTION_GEOSPATIAL:
+        jgen.writeStartObject();
+        geoSerializer.serialize(jgen, (Geospatial) item);
+        jgen.writeEndObject();
+        break;
+
+      case COLLECTION_ENUM:
+        jgen.writeString(item.toString());
+        break;
+
+      case COLLECTION_COMPLEX:
+        final ComplexValue complexItem2 = (ComplexValue) item;
+        complexValue(jgen, itemTypeInfo, complexItem2.getValue(), complexItem2);
+        break;
+
+      default:
+      }
+    }
+
+    jgen.writeEndArray();
+  }
+
+  protected void primitiveValue(final JsonGenerator jgen, final EdmTypeInfo typeInfo, final Object value)
+      throws IOException, EdmPrimitiveTypeException {
+
+    final EdmPrimitiveTypeKind kind = typeInfo == null ? null : typeInfo.getPrimitiveTypeKind();
+    final boolean isNumber = kind == null ? value instanceof Number : ArrayUtils.contains(NUMBER_TYPES, kind);
+    final boolean isBoolean = kind == null ? value instanceof Boolean : kind == EdmPrimitiveTypeKind.Boolean;
+
+    if (value == null) {
+      jgen.writeNull();
+    } else if (isBoolean) {
+      jgen.writeBoolean((Boolean) value);
+    } else {
+      final String serialized = kind == null
+          ? value.toString()
+              // TODO: add facets
+              : EdmPrimitiveTypeFactory.getInstance(kind).
+              valueToString(value, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null);
+          if (isNumber) {
+            jgen.writeNumber(serialized);
+          } else {
+            jgen.writeString(serialized);
+          }
+    }
+  }
+
+  private void complexValue(final JsonGenerator jgen, final EdmTypeInfo typeInfo,
+      final List<Property> value, final Linked linked)
+          throws IOException, EdmPrimitiveTypeException {
+    jgen.writeStartObject();
+
+    if (typeInfo != null && format != ODataFormat.JSON_NO_METADATA) {
+      jgen.writeStringField(Constants.JSON_TYPE, typeInfo.external());
+    }
+
+    for (Property property : value) {
+      valuable(jgen, property, property.getName());
+    }
+    if (linked != null) {
+      links(linked, jgen);
+    }
+
+    jgen.writeEndObject();
+  }
+
+  private void value(final JsonGenerator jgen, final String type, final Valuable value)
+      throws IOException, EdmPrimitiveTypeException {
+    final EdmTypeInfo typeInfo = type == null ? null : new EdmTypeInfo.Builder().setTypeExpression(type).build();
+
+    if (value.isNull()) {
+      jgen.writeNull();
+    } else if (value.isCollection()) {
+      collection(jgen, typeInfo, value.getValueType(), value.asCollection());
+    } else if (value.isPrimitive()) {
+      primitiveValue(jgen, typeInfo, value.asPrimitive());
+    } else if (value.isEnum()) {
+      jgen.writeString(value.asEnum().toString());
+    } else if (value.isGeospatial()) {
+      jgen.writeStartObject();
+      geoSerializer.serialize(jgen, value.asGeospatial());
+      jgen.writeEndObject();
+    } else if (value.isComplex()) {
+      complexValue(jgen, typeInfo, value.asComplex().getValue(), value.asComplex());
+    }
+  }
+
+  protected void valuable(final JsonGenerator jgen, final Valuable valuable, final String name)
+      throws IOException, EdmPrimitiveTypeException {
+
+    if (!Constants.VALUE.equals(name) && !(valuable instanceof Annotation)
+        && !(valuable.isComplex() && !valuable.isCollection())) {
+
+      String type = valuable.getType();
+      if ((!valuable.isCollection() &&
+          StringUtils.isBlank(type) &&
+          valuable.isPrimitive()) || valuable.isNull()) {
+        type = EdmPrimitiveTypeKind.String.getFullQualifiedName().toString();
+      }
+      if (StringUtils.isNotBlank(type) && format != ODataFormat.JSON_NO_METADATA) {
+        jgen.writeFieldName(
+            name + StringUtils.prependIfMissing(Constants.JSON_TYPE, "@"));
+        jgen.writeString(new EdmTypeInfo.Builder().setTypeExpression(type).build().external());
+      }
+    }
+
+    for (Annotation annotation : ((Annotatable) valuable).getAnnotations()) {
+      valuable(jgen, annotation, name + "@" + annotation.getTerm());
+    }
+
+    jgen.writeFieldName(name);
+    value(jgen, valuable.getType(), valuable);
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java
index adecc20..e953cae 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java
@@ -31,6 +31,7 @@ import org.apache.olingo.client.api.ODataClient;
 import org.apache.olingo.client.api.data.ServiceDocument;
 import org.apache.olingo.client.api.data.ServiceDocumentItem;
 import org.apache.olingo.client.api.serialization.ODataBinder;
+import org.apache.olingo.client.api.serialization.ODataSerializerException;
 import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.data.Annotatable;
@@ -87,14 +88,12 @@ import org.apache.olingo.commons.api.edm.EdmType;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.api.edm.geo.Geospatial;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.serialization.ODataSerializerException;
 import org.apache.olingo.client.core.domain.ClientAnnotationImpl;
 import org.apache.olingo.client.core.domain.ClientDeletedEntityImpl;
 import org.apache.olingo.client.core.domain.ClientDeltaLinkImpl;
 import org.apache.olingo.client.core.domain.ClientPropertyImpl;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
 import org.apache.olingo.commons.core.edm.EdmTypeInfo;
-import org.apache.olingo.commons.core.serialization.ContextURLParser;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java
index 6c97cdb..6153cdb 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java
@@ -27,6 +27,7 @@ import org.apache.olingo.client.api.ODataClient;
 import org.apache.olingo.client.api.data.ServiceDocument;
 import org.apache.olingo.client.api.domain.ClientEntitySetIterator;
 import org.apache.olingo.client.api.edm.xml.XMLMetadata;
+import org.apache.olingo.client.api.serialization.ODataDeserializerException;
 import org.apache.olingo.client.api.serialization.ODataReader;
 import org.apache.olingo.client.core.edm.ClientCsdlEdmProvider;
 import org.apache.olingo.commons.api.data.Entity;
@@ -43,7 +44,6 @@ import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 import org.apache.olingo.commons.core.edm.EdmProviderImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataWriterImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataWriterImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataWriterImpl.java
index c891f1e..584c420 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataWriterImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataWriterImpl.java
@@ -29,6 +29,7 @@ import java.util.Collections;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.serialization.ODataSerializerException;
 import org.apache.olingo.client.api.serialization.ODataWriter;
 import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.data.ResWrap;
@@ -36,7 +37,6 @@ import org.apache.olingo.client.api.domain.ClientEntity;
 import org.apache.olingo.client.api.domain.ClientLink;
 import org.apache.olingo.client.api.domain.ClientProperty;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.serialization.ODataSerializerException;
 
 public class ODataWriterImpl implements ODataWriter {
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/test/java/org/apache/olingo/client/core/serialization/AtomDeserializerTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/serialization/AtomDeserializerTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/serialization/AtomDeserializerTest.java
new file mode 100644
index 0000000..0b793f8
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/serialization/AtomDeserializerTest.java
@@ -0,0 +1,329 @@
+/*
+ * 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.serialization;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import org.apache.olingo.client.core.serialization.AtomDeserializer;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntityCollection;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.junit.Test;
+
+public class AtomDeserializerTest {
+
+  @Test
+  public void emptyInlineEntityOlingo540() throws Exception {
+    final String content = "" +
+        "<entry xmlns=\"http://www.w3.org/2005/Atom\" "
+        + "xmlns:data=\"http://docs.oasis-open.org/odata/ns/data\" "
+        + "xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\" "
+        + "xmlns:georss=\"http://www.georss.org/georss\" xmlns:gml=\"http://www.opengis.net/gml\" "
+        + "xml:base=\"http://services.odata.org/V3/OData/OData.svc/\">\r\n" +
+        "    <id>http://services.odata.org/V3/OData/OData.svc/Products(3)</id>\r\n" +
+        "    <category term=\"ODataDemo.Product\" "
+        + "scheme=\"http://docs.oasis-open.org/odata/ns/scheme\" />\r\n" +
+        "    \r\n" +
+        "    <link rel=\"edit\" title=\"Product\" href=\"Products\" />\r\n" +
+        "    <link rel=\"http://docs.oasis-open.org/odata/ns/related/Categories\" "
+        + "type=\"application/atom+xml;type=feed\" title=\"Categories\" href=\"Products(3)/Categories\" />\r\n" +
+        "    <link rel=\"http://docs.oasis-open.org/odata/ns/related/Supplier\" "
+        + "type=\"application/atom+xml;type=entry\" title=\"Supplier\" href=\"Products(3)/Supplier\">\r\n" +
+        "    <metadata:inline>\r\n" +
+        "    </metadata:inline>\r\n" +
+        "    </link>\r\n" +
+        "    <link rel=\"http://docs.oasis-open.org/odata/ns/related/ProductDetail\""
+        + " type=\"application/atom+xml;type=entry\" title=\"ProductDetail\" "
+        + "href=\"Products(3)/ProductDetail\" />\r\n" +
+        "    <title type=\"text\">Havina Cola</title>\r\n" +
+        "    <summary type=\"text\">The Original Key Lime Cola</summary>\r\n" +
+        "    <updated>2015-01-26T08:57:02Z</updated>\r\n" +
+        "    <author>\r\n" +
+        "        <name />\r\n" +
+        "    </author>\r\n" +
+        "    <link rel=\"http://docs.oasis-open.org/odata/ns/relatedlinks/Categories\" "
+        + "type=\"application/xml\" title=\"Categories\" href=\"Products(3)/$links/Categories\" />\r\n" +
+        "    <link rel=\"http://docs.oasis-open.org/odata/ns/relatedlinks/Supplier\" "
+        + "type=\"application/xml\" title=\"Supplier\" href=\"Products(3)/$links/Supplier\" />\r\n" +
+        "    <link rel=\"http://docs.oasis-open.org/odata/ns/relatedlinks/ProductDetail\""
+        + " type=\"application/xml\" title=\"ProductDetail\" href=\"Products(3)/$links/ProductDetail\" />\r\n" +
+        "    <content type=\"application/xml\">\r\n" +
+        "        <metadata:properties>\r\n" +
+        "            <data:ID metadata:type=\"Edm.Int32\">3</data:ID>\r\n" +
+        "            <data:ReleaseDate metadata:type=\"Edm.DateTime\">2005-10-01T00:00:00</data:ReleaseDate>\r\n" +
+        "  <data:DiscontinuedDate metadata:type=\"Edm.DateTime\">2006-10-01T00:00:00</data:DiscontinuedDate>\r\n" +
+        "            <data:Rating metadata:type=\"Edm.Int16\">3</data:Rating>\r\n" +
+        "            <data:Price metadata:type=\"Edm.Double\">19.9</data:Price>\r\n" +
+        "        </metadata:properties>\r\n" +
+        "    </content>\r\n" +
+        " </entry>";
+
+    final AtomDeserializer deserializer = new AtomDeserializer();
+    final InputStream in = new ByteArrayInputStream(content.getBytes("UTF-8"));
+    final ResWrap<Entity> entity = deserializer.toEntity(in);
+
+    assertNotNull(entity);
+    assertNull(entity.getPayload().getNavigationLink("Supplier").getInlineEntitySet());
+  }
+
+  @Test
+  public void filledInlineEntity() throws Exception {
+    final String content = "" +
+        "<entry xmlns=\"http://www.w3.org/2005/Atom\" "
+        + "xmlns:data=\"http://docs.oasis-open.org/odata/ns/data\" "
+        + "xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\" "
+        + "xmlns:georss=\"http://www.georss.org/georss\" "
+        + "xmlns:gml=\"http://www.opengis.net/gml\" "
+        + "xml:base=\"http://services.odata.org/V4/OData/OData.svc/\">\r\n" +
+        "    <id>http://services.odata.org/V4/OData/OData.svc/Products(3)</id>\r\n" +
+        "    <category term=\"#ODataDemo.Product\" "
+        + "scheme=\"http://docs.oasis-open.org/odata/ns/scheme\" />\r\n" +
+        "    \r\n" +
+        "    <link rel=\"edit\" title=\"Product\" href=\"Products\" />\r\n" +
+        "    <link rel=\"http://docs.oasis-open.org/odata/ns/related/Categories\" "
+        + "type=\"application/atom+xml;type=feed\" title=\"Categories\" href=\"Products(3)/Categories\" />\r\n" +
+        "    <link rel=\"http://docs.oasis-open.org/odata/ns/related/Supplier\" "
+        + "type=\"application/atom+xml;type=entry\" title=\"Supplier\" href=\"Products(3)/Supplier\">\r\n" +
+        "    <metadata:inline>\r\n" +
+        "       <entry>\r\n" +
+        "            <id>http://services.odata.org/V4/OData/OData.svc/Suppliers(0)</id>\r\n" +
+        "            <category term=\"ODataDemo.Supplier\" "
+        + "scheme=\"http://docs.oasis-open.org/odata/ns/scheme\" />\r\n" +
+        "            <link rel=\"edit\" title=\"Supplier\" href=\"Suppliers(0)\" />\r\n" +
+        "            <link rel=\"http://docs.oasis-open.org/odata/ns/related/Products\" "
+        + "type=\"application/atom+xml;type=feed\" title=\"Products\" href=\"Suppliers(0)/Products\" />\r\n" +
+        "            <title type=\"text\">Exotic Liquids</title>\r\n" +
+        "            <updated>2015-01-26T08:57:02Z</updated>\r\n" +
+        "            <author>\r\n" +
+        "                <name />\r\n" +
+        "            </author>\r\n" +
+        "            <link rel=\"http://docs.oasis-open.org/odata/ns/relatedlinks/Products\" "
+        + "type=\"application/xml\" title=\"Products\" href=\"Suppliers(0)/$links/Products\" />\r\n" +
+        "            <content type=\"application/xml\">\r\n" +
+        "                 <metadata:properties>\r\n" +
+        "                    <data:ID metadata:type=\"Edm.Int32\">0</data:ID>\r\n" +
+        "                    <data:Name>Exotic Liquids</data:Name>\r\n" +
+        "                    <data:Address metadata:type=\"ODataDemo.Address\">\r\n" +
+        "                    <data:Street>NE 228th</data:Street>\r\n" +
+        "                    <data:City>Sammamish</data:City>\r\n" +
+        "                    <data:State>WA</data:State>\r\n" +
+        "                    <data:ZipCode>98074</data:ZipCode>\r\n" +
+        "                    <data:Country>USA</data:Country>\r\n" +
+        "                     </data:Address>\r\n" +
+        "                    <data:Location metadata:type=\"Edm.GeographyPoint\">\r\n" +
+        "                    <gml:Point gml:srsName=\"http://www.opengis.net/def/crs/EPSG/0/4326\">\r\n" +
+        "                    <gml:pos>47.6316604614258 -122.03547668457</gml:pos>\r\n" +
+        "                    </gml:Point>\r\n" +
+        "                    </data:Location>\r\n" +
+        "                    <data:Concurrency metadata:type=\"Edm.Int32\">0</data:Concurrency>\r\n" +
+        "                 </metadata:properties>\r\n" +
+        "            </content>\r\n" +
+        "         </entry>" +
+        "    </metadata:inline>\r\n" +
+        "    </link>\r\n" +
+        "    <link rel=\"http://docs.oasis-open.org/odata/ns/related/ProductDetail\" "
+        + "type=\"application/atom+xml;type=entry\" "
+        + "title=\"ProductDetail\" href=\"Products(3)/ProductDetail\" />\r\n" +
+        "    <title type=\"text\">Havina Cola</title>\r\n" +
+        "    <summary type=\"text\">The Original Key Lime Cola</summary>\r\n" +
+        "    <updated>2015-01-26T08:57:02Z</updated>\r\n" +
+        "    <author>\r\n" +
+        "        <name />\r\n" +
+        "    </author>\r\n" +
+        "    <link rel=\"http://docs.oasis-open.org/odata/ns/relatedlinks/Categories\" "
+        + "type=\"application/xml\" title=\"Categories\" href=\"Products(3)/$links/Categories\" />\r\n" +
+        "    <link rel=\"http://docs.oasis-open.org/odata/ns/relatedlinks/Supplier\" "
+        + "type=\"application/xml\" title=\"Supplier\" href=\"Products(3)/$links/Supplier\" />\r\n" +
+        "    <link rel=\"http://docs.oasis-open.org/odata/ns/relatedlinks/ProductDetail\" "
+        + "type=\"application/xml\" title=\"ProductDetail\" href=\"Products(3)/$links/ProductDetail\" />\r\n" +
+        "    <content type=\"application/xml\">\r\n" +
+        "        <metadata:properties>\r\n" +
+        "            <data:ID metadata:type=\"Edm.Int32\">3</data:ID>\r\n" +
+        "            <data:ReleaseDate metadata:type=\"Edm.DateTime\">2005-10-01T00:00:00</data:ReleaseDate>\r\n" +
+        "  <data:DiscontinuedDate metadata:type=\"Edm.DateTime\">2006-10-01T00:00:00</data:DiscontinuedDate>\r\n" +
+        "            <data:Rating metadata:type=\"Edm.Int16\">3</data:Rating>\r\n" +
+        "            <data:Price metadata:type=\"Edm.Double\">19.9</data:Price>\r\n" +
+        "        </metadata:properties>\r\n" +
+        "    </content>\r\n" +
+        " </entry>";
+    final AtomDeserializer deserializer = new AtomDeserializer();
+    final InputStream in = new ByteArrayInputStream(content.getBytes("UTF-8"));
+    final ResWrap<Entity> entity = deserializer.toEntity(in);
+
+    assertNotNull(entity);
+    final Entity inlineEntity = entity.getPayload().getNavigationLink("Supplier").getInlineEntity();
+    assertNotNull(inlineEntity);
+
+    assertEquals(new Integer(0), inlineEntity.getProperty("ID").getValue());
+    assertEquals("Exotic Liquids", inlineEntity.getProperty("Name").getValue());
+  }
+
+  @Test
+  public void emptyInlineEntityCollection() throws Exception {
+    final String content = "" +
+        "<entry xmlns=\"http://www.w3.org/2005/Atom\" "
+        + "xmlns:data=\"http://docs.oasis-open.org/odata/ns/data\" "
+        + "xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\" "
+        + "xmlns:georss=\"http://www.georss.org/georss\" xmlns:gml=\"http://www.opengis.net/gml\" "
+        + "xml:base=\"http://services.odata.org/V3/OData/OData.svc/\">\r\n" +
+        "    <id>http://services.odata.org/V3/OData/OData.svc/Products(3)</id>\r\n" +
+        "    <category term=\"ODataDemo.Product\" "
+        + "scheme=\"http://docs.oasis-open.org/odata/ns/scheme\" />\r\n" +
+        "    \r\n" +
+        "    <link rel=\"edit\" title=\"Product\" href=\"Products(3)\" />\r\n" +
+        "    <link rel=\"http://docs.oasis-open.org/odata/ns/related/Categories\" "
+        + "type=\"application/atom+xml;type=feed\" title=\"Categories\" href=\"Products(3)/Categories\" />\r\n" +
+        "    <link rel=\"http://docs.oasis-open.org/odata/ns/related/Supplier\" "
+        + "type=\"application/atom+xml;type=feed\" title=\"Supplier\" href=\"Products(3)/Supplier\">\r\n" +
+        "    <metadata:inline>\r\n" +
+        "        <feed>\r\n" +
+        "         </feed>\r\n" +
+        "    </metadata:inline>\r\n" +
+        "    </link>\r\n" +
+        "    <link rel=\"http://docs.oasis-open.org/odata/ns/related/ProductDetail\" "
+        + "type=\"application/atom+xml;type=entry\" "
+        + "title=\"ProductDetail\" href=\"Products(3)/ProductDetail\" />\r\n" +
+        "    <title type=\"text\">Havina Cola</title>\r\n" +
+        "    <summary type=\"text\">The Original Key Lime Cola</summary>\r\n" +
+        "    <updated>2015-01-26T08:57:02Z</updated>\r\n" +
+        "    <author>\r\n" +
+        "        <name />\r\n" +
+        "    </author>\r\n" +
+        "    <link rel=\"http://docs.oasis-open.org/odata/ns/relatedlinks/Categories\" "
+        + "type=\"application/xml\" title=\"Categories\" href=\"Products(3)/$links/Categories\" />\r\n" +
+        "    <link rel=\"http://docs.oasis-open.org/odata/ns/relatedlinks/Supplier\" "
+        + "type=\"application/xml\" title=\"Supplier\" href=\"Products(3)/$links/Supplier\" />\r\n" +
+        "    <link rel=\"http://docs.oasis-open.org/odata/ns/relatedlinks/ProductDetail\" "
+        + "type=\"application/xml\" title=\"ProductDetail\" href=\"Products(3)/$links/ProductDetail\" />\r\n" +
+        "    <content type=\"application/xml\">\r\n" +
+        "        <metadata:properties>\r\n" +
+        "            <data:ID metadata:type=\"Edm.Int32\">3</data:ID>\r\n" +
+        "            <data:ReleaseDate metadata:type=\"Edm.DateTime\">2005-10-01T00:00:00</data:ReleaseDate>\r\n" +
+        "  <data:DiscontinuedDate metadata:type=\"Edm.DateTime\">2006-10-01T00:00:00</data:DiscontinuedDate>\r\n" +
+        "            <data:Rating metadata:type=\"Edm.Int16\">3</data:Rating>\r\n" +
+        "            <data:Price metadata:type=\"Edm.Double\">19.9</data:Price>\r\n" +
+        "        </metadata:properties>\r\n" +
+        "    </content>\r\n" +
+        " </entry>";
+    final AtomDeserializer deserializer = new AtomDeserializer();
+    final InputStream in = new ByteArrayInputStream(content.getBytes("UTF-8"));
+    final ResWrap<Entity> entity = deserializer.toEntity(in);
+
+    assertNotNull(entity);
+    final EntityCollection inlineEntitySet = entity.getPayload().getNavigationLink("Supplier").getInlineEntitySet();
+    assertNotNull(inlineEntitySet);
+    assertEquals(0, inlineEntitySet.getEntities().size());
+  }
+
+  @Test
+  public void filledInlineEntityCollection() throws Exception {
+    final String content = "" +
+        "<entry xmlns=\"http://www.w3.org/2005/Atom\" "
+        + "xmlns:data=\"http://docs.oasis-open.org/odata/ns/data\" "
+        + "xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\" "
+        + "xmlns:georss=\"http://www.georss.org/georss\" xmlns:gml=\"http://www.opengis.net/gml\" "
+        + "xml:base=\"http://services.odata.org/V3/OData/OData.svc/\">\r\n" +
+        "    <id>http://services.odata.org/V3/OData/OData.svc/Products(3)</id>\r\n" +
+        "    <category term=\"ODataDemo.Product\" "
+        + "scheme=\"http://docs.oasis-open.org/odata/ns/scheme\" />\r\n" +
+        "    \r\n" +
+        "    <link rel=\"edit\" title=\"Product\" href=\"Products(3)\" />\r\n" +
+        "    <link rel=\"http://docs.oasis-open.org/odata/ns/related/Categories\" "
+        + "type=\"application/atom+xml;type=feed\" title=\"Categories\" href=\"Products(3)/Categories\" />\r\n" +
+        "    <link rel=\"http://docs.oasis-open.org/odata/ns/related/Supplier\" "
+        + "type=\"application/atom+xml;type=feed\" title=\"Supplier\" href=\"Products(3)/Supplier\">\r\n" +
+        "    <metadata:inline>\r\n" +
+        "        <feed>\r\n" +
+        "        <entry>\r\n" +
+        "            <id>http://services.odata.org/V3/OData/OData.svc/Suppliers(0)</id>\r\n" +
+        "            <category term=\"ODataDemo.Supplier\" "
+        + "scheme=\"http://docs.oasis-open.org/odata/ns/scheme\" />\r\n" +
+        "            <link rel=\"edit\" title=\"Supplier\" href=\"Suppliers(0)\" />\r\n" +
+        "            <link rel=\"http://docs.oasis-open.org/odata/ns/related/Products\" "
+        + "type=\"application/atom+xml;type=feed\" title=\"Products\" href=\"Suppliers(0)/Products\" />\r\n" +
+        "            <title type=\"text\">Exotic Liquids</title>\r\n" +
+        "            <updated>2015-01-26T08:57:02Z</updated>\r\n" +
+        "            <author>\r\n" +
+        "                <name />\r\n" +
+        "            </author>\r\n" +
+        "            <link rel=\"http://docs.oasis-open.org/odata/ns/relatedlinks/Products\" "
+        + "type=\"application/xml\" title=\"Products\" href=\"Suppliers(0)/$links/Products\" />\r\n" +
+        "            <content type=\"application/xml\">\r\n" +
+        "                 <metadata:properties>\r\n" +
+        "                    <data:ID metadata:type=\"Edm.Int32\">0</data:ID>\r\n" +
+        "                    <data:Name>Exotic Liquids</data:Name>\r\n" +
+        "                    <data:Address metadata:type=\"ODataDemo.Address\">\r\n" +
+        "                    <data:Street>NE 228th</data:Street>\r\n" +
+        "                    <data:City>Sammamish</data:City>\r\n" +
+        "                    <data:State>WA</data:State>\r\n" +
+        "                    <data:ZipCode>98074</data:ZipCode>\r\n" +
+        "                    <data:Country>USA</data:Country>\r\n" +
+        "                     </data:Address>\r\n" +
+        "                    <data:Location metadata:type=\"Edm.GeographyPoint\">\r\n" +
+        "                    <gml:Point gml:srsName=\"http://www.opengis.net/def/crs/EPSG/0/4326\">\r\n" +
+        "                    <gml:pos>47.6316604614258 -122.03547668457</gml:pos>\r\n" +
+        "                    </gml:Point>\r\n" +
+        "                    </data:Location>\r\n" +
+        "                    <data:Concurrency metadata:type=\"Edm.Int32\">0</data:Concurrency>\r\n" +
+        "                 </metadata:properties>\r\n" +
+        "            </content>\r\n" +
+        "         </entry>\r\n" +
+        "         </feed>\r\n" +
+        "    </metadata:inline>\r\n" +
+        "    </link>\r\n" +
+        "    <link rel=\"http://docs.oasis-open.org/odata/ns/related/ProductDetail\" "
+        + "type=\"application/atom+xml;type=entry\" "
+        + "title=\"ProductDetail\" href=\"Products(3)/ProductDetail\" />\r\n" +
+        "    <title type=\"text\">Havina Cola</title>\r\n" +
+        "    <summary type=\"text\">The Original Key Lime Cola</summary>\r\n" +
+        "    <updated>2015-01-26T08:57:02Z</updated>\r\n" +
+        "    <author>\r\n" +
+        "        <name />\r\n" +
+        "    </author>\r\n" +
+        "    <link rel=\"http://docs.oasis-open.org/odata/ns/relatedlinks/Categories\" "
+        + "type=\"application/xml\" title=\"Categories\" href=\"Products(3)/$links/Categories\" />\r\n" +
+        "    <link rel=\"http://docs.oasis-open.org/odata/ns/relatedlinks/Supplier\" "
+        + "type=\"application/xml\" title=\"Supplier\" href=\"Products(3)/$links/Supplier\" />\r\n" +
+        "    <link rel=\"http://docs.oasis-open.org/odata/ns/relatedlinks/ProductDetail\" "
+        + "type=\"application/xml\" title=\"ProductDetail\" href=\"Products(3)/$links/ProductDetail\" />\r\n" +
+        "    <content type=\"application/xml\">\r\n" +
+        "        <metadata:properties>\r\n" +
+        "            <data:ID metadata:type=\"Edm.Int32\">3</data:ID>\r\n" +
+        "            <data:ReleaseDate metadata:type=\"Edm.DateTime\">2005-10-01T00:00:00</data:ReleaseDate>\r\n" +
+        "  <data:DiscontinuedDate metadata:type=\"Edm.DateTime\">2006-10-01T00:00:00</data:DiscontinuedDate>\r\n" +
+        "            <data:Rating metadata:type=\"Edm.Int16\">3</data:Rating>\r\n" +
+        "            <data:Price metadata:type=\"Edm.Double\">19.9</data:Price>\r\n" +
+        "        </metadata:properties>\r\n" +
+        "    </content>\r\n" +
+        " </entry>";
+    final AtomDeserializer deserializer = new AtomDeserializer();
+    final InputStream in = new ByteArrayInputStream(content.getBytes("UTF-8"));
+    final ResWrap<Entity> entity = deserializer.toEntity(in);
+
+    assertNotNull(entity);
+    final EntityCollection inlineEntitySet = entity.getPayload().getNavigationLink("Supplier").getInlineEntitySet();
+    assertNotNull(inlineEntitySet);
+    assertEquals(1, inlineEntitySet.getEntities().size());
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/test/java/org/apache/olingo/client/core/serialization/ContextURLParserTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/serialization/ContextURLParserTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/serialization/ContextURLParserTest.java
new file mode 100644
index 0000000..009b100
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/serialization/ContextURLParserTest.java
@@ -0,0 +1,256 @@
+/*
+ * 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.serialization;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.net.URI;
+
+import org.apache.olingo.client.core.serialization.ContextURLParser;
+import org.apache.olingo.commons.api.data.ContextURL;
+import org.junit.Test;
+
+public class ContextURLParserTest {
+
+  @Test
+  public void collectionOfEntities() {
+    ContextURL contextURL = ContextURLParser.parse(URI.create("http://host/service/$metadata#Customers"));
+
+    assertEquals(URI.create("http://host/service/"), contextURL.getServiceRoot());
+    assertEquals("Customers", contextURL.getEntitySetOrSingletonOrType());
+    assertNull(contextURL.getDerivedEntity());
+    assertNull(contextURL.getSelectList());
+    assertNull(contextURL.getNavOrPropertyPath());
+    assertFalse(contextURL.isEntity());
+
+    contextURL = ContextURLParser.parse(URI.create("http://host/service/$metadata#Orders(4711)/Items"));
+
+    assertEquals("Orders", contextURL.getEntitySetOrSingletonOrType());
+    assertNull(contextURL.getDerivedEntity());
+    assertNull(contextURL.getSelectList());
+    assertEquals("Items", contextURL.getNavOrPropertyPath());
+    assertFalse(contextURL.isEntity());
+
+    contextURL = ContextURLParser.parse(URI.create("http://host/service/$metadata#Me/Folders('Inbox')/Messages"));
+
+    assertEquals("Me/Folders", contextURL.getEntitySetOrSingletonOrType());
+    assertEquals("Messages", contextURL.getNavOrPropertyPath());
+  }
+
+  @Test
+  public void entity() {
+    ContextURL contextURL = ContextURLParser.parse(URI.create("http://host/service/$metadata#Customers/$entity"));
+
+    assertEquals("Customers", contextURL.getEntitySetOrSingletonOrType());
+    assertNull(contextURL.getDerivedEntity());
+    assertNull(contextURL.getSelectList());
+    assertNull(contextURL.getNavOrPropertyPath());
+    assertTrue(contextURL.isEntity());
+
+    contextURL = ContextURLParser.parse(URI.create("http://host/service/$metadata#Orders(4711)/Items/$entity"));
+
+    assertEquals("Orders/Items", contextURL.getEntitySetOrSingletonOrType());
+    assertNull(contextURL.getDerivedEntity());
+    assertNull(contextURL.getSelectList());
+    assertNull(contextURL.getNavOrPropertyPath());
+    assertTrue(contextURL.isEntity());
+
+    contextURL = ContextURLParser.parse(
+        URI.create("http://host/service/$metadata#Users('user')/Messages('message')/Attachments/$entity"));
+
+    assertEquals("Users/Messages/Attachments", contextURL.getEntitySetOrSingletonOrType());
+    assertNull(contextURL.getDerivedEntity());
+    assertNull(contextURL.getSelectList());
+    assertNull(contextURL.getNavOrPropertyPath());
+    assertTrue(contextURL.isEntity());
+
+    // v3
+    contextURL = ContextURLParser.parse(URI.create("http://host/service/$metadata#Products/@Element"));
+
+    assertEquals("Products", contextURL.getEntitySetOrSingletonOrType());
+    assertNull(contextURL.getDerivedEntity());
+    assertNull(contextURL.getSelectList());
+    assertNull(contextURL.getNavOrPropertyPath());
+    assertTrue(contextURL.isEntity());
+  }
+
+  @Test
+  public void singleton() {
+    ContextURL contextURL = ContextURLParser.parse(URI.create("http://host/service/$metadata#Contoso"));
+
+    assertEquals("Contoso", contextURL.getEntitySetOrSingletonOrType());
+    assertNull(contextURL.getDerivedEntity());
+    assertNull(contextURL.getSelectList());
+    assertNull(contextURL.getNavOrPropertyPath());
+    assertFalse(contextURL.isEntity());
+  }
+
+  @Test
+  public void collectionOfDerivedEntities() {
+    final ContextURL contextURL = ContextURLParser.parse(
+        URI.create("http://host/service/$metadata#Customers/Model.VipCustomer"));
+
+    assertEquals("Customers", contextURL.getEntitySetOrSingletonOrType());
+    assertEquals("Model.VipCustomer", contextURL.getDerivedEntity());
+    assertNull(contextURL.getSelectList());
+    assertNull(contextURL.getNavOrPropertyPath());
+    assertFalse(contextURL.isEntity());
+  }
+
+  @Test
+  public void derivedEntity() {
+    final ContextURL contextURL = ContextURLParser.parse(
+        URI.create("http://host/service/$metadata#Customers/Model.VipCustomer/$entity"));
+
+    assertEquals("Customers", contextURL.getEntitySetOrSingletonOrType());
+    assertEquals("Model.VipCustomer", contextURL.getDerivedEntity());
+    assertNull(contextURL.getSelectList());
+    assertNull(contextURL.getNavOrPropertyPath());
+    assertTrue(contextURL.isEntity());
+  }
+
+  @Test
+  public void collectionOfProjectedEntities() {
+    final ContextURL contextURL = ContextURLParser.parse(
+        URI.create("http://host/service/$metadata#Customers(Address,Orders)"));
+
+    assertEquals("Customers", contextURL.getEntitySetOrSingletonOrType());
+    assertNull(contextURL.getDerivedEntity());
+    assertEquals("Address,Orders", contextURL.getSelectList());
+    assertNull(contextURL.getNavOrPropertyPath());
+    assertFalse(contextURL.isEntity());
+  }
+
+  @Test
+  public void projectedEntity() {
+    ContextURL contextURL = ContextURLParser.parse(
+        URI.create("http://host/service/$metadata#Customers(Name,Rating)/$entity"));
+
+    assertEquals("Customers", contextURL.getEntitySetOrSingletonOrType());
+    assertNull(contextURL.getDerivedEntity());
+    assertEquals("Name,Rating", contextURL.getSelectList());
+    assertNull(contextURL.getNavOrPropertyPath());
+    assertTrue(contextURL.isEntity());
+
+    contextURL = ContextURLParser.parse(
+        URI.create("http://host/service/$metadata#Customers(Name,Address/Country)"));
+
+    assertEquals("Customers", contextURL.getEntitySetOrSingletonOrType());
+    assertNull(contextURL.getDerivedEntity());
+    assertEquals("Name,Address/Country", contextURL.getSelectList());
+    assertNull(contextURL.getNavOrPropertyPath());
+    assertFalse(contextURL.isEntity());
+  }
+
+  @Test
+  public void collectionOfProjectedExpandedEntities() {
+    final ContextURL contextURL = ContextURLParser.parse(
+        URI.create("http://host/service/$metadata#Employees/"
+            + "Sales.Manager(DirectReports,DirectReports+(FirstName,LastName))"));
+
+    assertEquals("Employees", contextURL.getEntitySetOrSingletonOrType());
+    assertEquals("Sales.Manager", contextURL.getDerivedEntity());
+    assertEquals("DirectReports,DirectReports+(FirstName,LastName)", contextURL.getSelectList());
+    assertNull(contextURL.getNavOrPropertyPath());
+    assertFalse(contextURL.isEntity());
+  }
+
+  @Test
+  public void propertyValue() {
+    final ContextURL contextURL = ContextURLParser.parse(
+        URI.create("http://host/service/$metadata#Customers(1)/Addresses"));
+
+    assertEquals("Customers", contextURL.getEntitySetOrSingletonOrType());
+    assertNull(contextURL.getDerivedEntity());
+    assertNull(contextURL.getSelectList());
+    assertEquals("Addresses", contextURL.getNavOrPropertyPath());
+    assertFalse(contextURL.isEntity());
+  }
+
+  @Test
+  public void CollectionOfComplexOrPrimitiveTypes() {
+    final ContextURL contextURL = ContextURLParser.parse(
+        URI.create("http://host/service/$metadata#Collection(Edm.String)"));
+
+    assertEquals("Collection(Edm.String)", contextURL.getEntitySetOrSingletonOrType());
+    assertNull(contextURL.getDerivedEntity());
+    assertNull(contextURL.getSelectList());
+    assertNull(contextURL.getNavOrPropertyPath());
+    assertFalse(contextURL.isEntity());
+  }
+
+  @Test
+  public void complexOrPrimitiveType() {
+    ContextURL contextURL = ContextURLParser.parse(URI.create("http://host/service/$metadata#Edm.String"));
+
+    assertEquals("Edm.String", contextURL.getEntitySetOrSingletonOrType());
+    assertNull(contextURL.getDerivedEntity());
+    assertNull(contextURL.getSelectList());
+    assertNull(contextURL.getNavOrPropertyPath());
+    assertFalse(contextURL.isEntity());
+
+    contextURL = ContextURLParser.parse(URI.create("http://host/service/$metadata#ODataDemo.Address"));
+
+    assertEquals("ODataDemo.Address", contextURL.getEntitySetOrSingletonOrType());
+    assertNull(contextURL.getDerivedEntity());
+    assertNull(contextURL.getSelectList());
+    assertNull(contextURL.getNavOrPropertyPath());
+    assertFalse(contextURL.isEntity());
+  }
+
+  @Test
+  public void reference() {
+    ContextURL contextURL = ContextURLParser.parse(URI.create("http://host/service/$metadata#Customers/$ref"));
+    assertTrue(contextURL.isReference());
+    assertNull(contextURL.getSelectList());
+    assertNull(contextURL.getNavOrPropertyPath());
+    assertFalse(contextURL.isEntity());
+    assertFalse(contextURL.isDelta());
+  }
+
+  @Test
+  public void delta() {
+    ContextURL contextURL = ContextURLParser.parse(URI.create("http://host/service/$metadata#Customers/$delta"));
+    assertTrue(contextURL.isDelta());
+    assertNull(contextURL.getSelectList());
+    assertNull(contextURL.getNavOrPropertyPath());
+    assertFalse(contextURL.isEntity());
+
+    contextURL = ContextURLParser.parse(URI.create("http://host/service/$metadata#Customers/$deletedLink"));
+    assertTrue(contextURL.isDeltaDeletedLink());
+    assertNull(contextURL.getSelectList());
+    assertNull(contextURL.getNavOrPropertyPath());
+    assertFalse(contextURL.isEntity());
+
+    contextURL = ContextURLParser.parse(URI.create("http://host/service/$metadata#Customers/$link"));
+    assertTrue(contextURL.isDeltaLink());
+    assertNull(contextURL.getSelectList());
+    assertNull(contextURL.getNavOrPropertyPath());
+    assertFalse(contextURL.isEntity());
+
+    contextURL = ContextURLParser.parse(URI.create("http://host/service/$metadata#Customers/$deletedEntity"));
+    assertTrue(contextURL.isDeltaDeletedEntity());
+    assertNull(contextURL.getSelectList());
+    assertNull(contextURL.getNavOrPropertyPath());
+    assertFalse(contextURL.isEntity());
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntitySetTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntitySetTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntitySetTest.java
index 5395472..d3746e1 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntitySetTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntitySetTest.java
@@ -24,8 +24,8 @@ import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.client.api.domain.ClientEntity;
 import org.apache.olingo.client.api.domain.ClientEntitySet;
+import org.apache.olingo.client.api.serialization.ODataDeserializerException;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 import org.junit.Test;
 
 import java.io.IOException;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ErrorTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ErrorTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ErrorTest.java
index 057c0de..93b43df 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ErrorTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ErrorTest.java
@@ -19,10 +19,10 @@
 package org.apache.olingo.client.core.v4;
 
 import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.serialization.ODataDeserializerException;
 import org.apache.olingo.client.core.AbstractTest;
 import org.apache.olingo.commons.api.ODataError;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PropertyTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PropertyTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PropertyTest.java
index 46e0d22..b0423e7 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PropertyTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PropertyTest.java
@@ -24,9 +24,9 @@ import org.apache.olingo.client.api.domain.ClientCollectionValue;
 import org.apache.olingo.client.api.domain.ClientComplexValue;
 import org.apache.olingo.client.api.domain.ClientProperty;
 import org.apache.olingo.client.api.domain.ClientValue;
+import org.apache.olingo.client.api.serialization.ODataDeserializerException;
+import org.apache.olingo.client.api.serialization.ODataSerializerException;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
-import org.apache.olingo.commons.api.serialization.ODataSerializerException;
 import org.junit.Test;
 
 import java.io.InputStream;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ServiceDocumentTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ServiceDocumentTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ServiceDocumentTest.java
index 1a2de09..b0a769f 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ServiceDocumentTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ServiceDocumentTest.java
@@ -23,8 +23,8 @@ import org.apache.olingo.client.api.data.ServiceDocument;
 import org.apache.olingo.client.core.AbstractTest;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.client.api.domain.ClientServiceDocument;
+import org.apache.olingo.client.api.serialization.ODataDeserializerException;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 import org.junit.Test;
 
 import java.net.URI;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializer.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializer.java
deleted file mode 100755
index d288cf9..0000000
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializer.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.api.serialization;
-
-import java.io.InputStream;
-
-import org.apache.olingo.commons.api.ODataError;
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntityCollection;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.data.ResWrap;
-
-/**
- * Interface for de-serialization.
- */
-public interface ODataDeserializer {
-
-  /**
-   * Gets an entity set object from the given InputStream.
-   *
-   * @param input stream to be de-serialized.
-   * @return {@link EntityCollection} instance.
-   */
-  ResWrap<EntityCollection> toEntitySet(InputStream input) throws ODataDeserializerException;
-
-  /**
-   * Gets an entity object from the given InputStream.
-   *
-   * @param input stream to be de-serialized.
-   * @return {@link Entity} instance.
-   */
-  ResWrap<Entity> toEntity(InputStream input) throws ODataDeserializerException;
-
-  /**
-   * Gets a property object from the given InputStream.
-   *
-   * @param input stream to be de-serialized.
-   * @return Property instance.
-   */
-  ResWrap<Property> toProperty(InputStream input) throws ODataDeserializerException;
-
-  /**
-   * Gets the ODataError object represented by the given InputStream.
-   *
-   * @param input stream to be parsed and de-serialized.
-   * @return parsed ODataError object represented by the given InputStream
-   */
-  ODataError toError(InputStream input) throws ODataDeserializerException;
-}

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

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataSerializer.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataSerializer.java
deleted file mode 100644
index 0c0f795..0000000
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataSerializer.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.api.serialization;
-
-import java.io.Writer;
-
-import org.apache.olingo.commons.api.data.ResWrap;
-
-/**
- * Interface for serialization.
- */
-public interface ODataSerializer {
-
-  public <T> void write(final Writer writer, final T obj) throws ODataSerializerException;
-
-  public <T> void write(final Writer writer, final ResWrap<T> container) throws ODataSerializerException;
-}

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

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AbstractAtomDealer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AbstractAtomDealer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AbstractAtomDealer.java
deleted file mode 100644
index d73daca..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AbstractAtomDealer.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.serialization;
-
-import javax.xml.XMLConstants;
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.Constants;
-
-abstract class AbstractAtomDealer {
-
-  protected static final String TYPE_TEXT = "text";
-
-  protected final String namespaceMetadata;
-  protected final String namespaceData;
-
-  protected final QName etagQName;
-  protected final QName metadataEtagQName;
-  protected final QName inlineQName;
-  protected final QName actionQName;
-  protected final QName propertiesQName;
-  protected final QName typeQName;
-  protected final QName nullQName;
-  protected final QName elementQName;
-  protected final QName countQName;
-  protected final QName uriQName;
-  protected final QName nextQName;
-  protected final QName annotationQName;
-  protected final QName contextQName;
-  protected final QName entryRefQName;
-  protected final QName propertyValueQName;
-  protected final QName deletedEntryQName;
-  protected final QName reasonQName;
-  protected final QName linkQName;
-  protected final QName deletedLinkQName;
-  protected final QName errorCodeQName;
-  protected final QName errorMessageQName;
-  protected final QName errorTargetQName;
-
-  public AbstractAtomDealer() {
-    namespaceMetadata = Constants.NS_METADATA;
-    namespaceData = Constants.NS_DATASERVICES;
-
-    etagQName = new QName(namespaceMetadata, Constants.ATOM_ATTR_ETAG);
-    metadataEtagQName = new QName(namespaceMetadata, Constants.ATOM_ATTR_METADATAETAG);
-    inlineQName = new QName(namespaceMetadata, Constants.ATOM_ELEM_INLINE);
-    actionQName = new QName(namespaceMetadata, Constants.ATOM_ELEM_ACTION);
-    propertiesQName = new QName(namespaceMetadata, Constants.PROPERTIES);
-    typeQName = new QName(namespaceMetadata, Constants.ATTR_TYPE);
-    nullQName = new QName(namespaceMetadata, Constants.ATTR_NULL);
-    elementQName = new QName(namespaceMetadata, Constants.ELEM_ELEMENT);
-    countQName = new QName(namespaceMetadata, Constants.ATOM_ELEM_COUNT);
-    uriQName = new QName(namespaceData, Constants.ELEM_URI);
-    nextQName = new QName(namespaceData, Constants.NEXT_LINK_REL);
-    annotationQName = new QName(namespaceMetadata, Constants.ANNOTATION);
-    contextQName = new QName(namespaceMetadata, Constants.CONTEXT);
-    entryRefQName = new QName(namespaceMetadata, Constants.ATOM_ELEM_ENTRY_REF);
-    propertyValueQName = new QName(namespaceMetadata, Constants.VALUE);
-
-    deletedEntryQName = new QName(Constants.NS_ATOM_TOMBSTONE, Constants.ATOM_ELEM_DELETED_ENTRY);
-    reasonQName = new QName(namespaceMetadata, Constants.ELEM_REASON);
-    linkQName = new QName(namespaceMetadata, Constants.ATOM_ELEM_LINK);
-    deletedLinkQName = new QName(namespaceMetadata, Constants.ELEM_DELETED_LINK);
-
-    errorCodeQName = new QName(namespaceMetadata, Constants.ERROR_CODE);
-    errorMessageQName = new QName(namespaceMetadata, Constants.ERROR_MESSAGE);
-    errorTargetQName = new QName(namespaceMetadata, Constants.ERROR_TARGET);
-  }
-
-  protected void namespaces(final XMLStreamWriter writer) throws XMLStreamException {
-    writer.writeNamespace(StringUtils.EMPTY, Constants.NS_ATOM);
-    writer.writeNamespace(XMLConstants.XML_NS_PREFIX, XMLConstants.XML_NS_URI);
-    writer.writeNamespace(Constants.PREFIX_METADATA, Constants.NS_METADATA);
-    writer.writeNamespace(Constants.PREFIX_DATASERVICES, Constants.NS_DATASERVICES);
-    writer.writeNamespace(Constants.PREFIX_GML, Constants.NS_GML);
-    writer.writeNamespace(Constants.PREFIX_GEORSS, Constants.NS_GEORSS);
-  }
-}


[18/39] olingo-odata4 git commit: [OLINGO-659] Minor code clean up, javadoc and typo fixes

Posted by ch...@apache.org.
[OLINGO-659] Minor code clean up, javadoc and typo fixes


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

Branch: refs/heads/IEE754Compatible
Commit: 0938f1179df9e22710e60b06c1e240b2ab4d9db0
Parents: e5fe04a
Author: Michael Bolz <mi...@sap.com>
Authored: Tue Jun 16 21:20:02 2015 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Tue Jun 16 21:20:02 2015 +0200

----------------------------------------------------------------------
 .../apache/olingo/server/api/uri/UriInfo.java    | 19 +++++++++----------
 .../olingo/server/api/uri/UriInfoEntityId.java   | 13 ++++++-------
 .../olingo/server/api/uri/UriInfoMetadata.java   |  4 ++--
 .../olingo/server/api/uri/UriParameter.java      | 11 +++++------
 .../server/api/uri/UriResourceFunction.java      |  2 +-
 .../server/api/uri/UriResourceLambdaAll.java     |  5 ++---
 .../server/api/uri/UriResourceLambdaAny.java     |  4 ++--
 .../api/uri/UriResourceLambdaVariable.java       |  3 +--
 .../server/api/uri/UriResourceNavigation.java    |  2 +-
 .../core/uri/UriResourceLambdaAnyImpl.java       |  2 +-
 .../server/core/uri/UriResourceWithKeysImpl.java | 17 +++++++++--------
 .../server/core/uri/UriResourceImplTest.java     |  2 +-
 .../core/uri/testutil/FilterTreeToText.java      |  2 +-
 .../core/uri/testutil/ResourceValidator.java     |  2 +-
 14 files changed, 42 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0938f117/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfo.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfo.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfo.java
index c7f1e7e..ead6113 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfo.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfo.java
@@ -31,22 +31,21 @@ public interface UriInfo extends
 UriInfoService, UriInfoAll, UriInfoBatch, UriInfoCrossjoin,
 UriInfoEntityId, UriInfoMetadata, UriInfoResource {
 
-  public UriInfoKind getKind();
+  UriInfoKind getKind();
 
-  public UriInfoService asUriInfoService();
+  UriInfoService asUriInfoService();
 
-  public UriInfoAll asUriInfoAll();
+  UriInfoAll asUriInfoAll();
 
-  public UriInfoBatch asUriInfoBatch();
+  UriInfoBatch asUriInfoBatch();
 
-  public UriInfoCrossjoin asUriInfoCrossjoin();
+  UriInfoCrossjoin asUriInfoCrossjoin();
 
-  public UriInfoEntityId asUriInfoEntityId();
+  UriInfoEntityId asUriInfoEntityId();
 
-  public UriInfoMetadata asUriInfoMetadata();
+  UriInfoMetadata asUriInfoMetadata();
 
-  public UriInfoResource asUriInfoResource();
-
-  public Collection<SystemQueryOption> getSystemQueryOptions();
+  UriInfoResource asUriInfoResource();
 
+  Collection<SystemQueryOption> getSystemQueryOptions();
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0938f117/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoEntityId.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoEntityId.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoEntityId.java
index 6736ddc..2579b6d 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoEntityId.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoEntityId.java
@@ -36,33 +36,32 @@ public interface UriInfoEntityId {
   /**
    * @return List of custom query options used in the URI
    */
-  public List<CustomQueryOption> getCustomQueryOptions();
+  List<CustomQueryOption> getCustomQueryOptions();
 
   /**
    * Behind $entity a optional type cast can be used in the URI.
    * For example: http://.../serviceroot/$entity/namespace.entitytype
    * @return Type cast if found, otherwise null
    */
-  public EdmEntityType getEntityTypeCast();
+  EdmEntityType getEntityTypeCast();
 
   /**
    * @return Object containing information of the $expand option
    */
-  public ExpandOption getExpandOption();
+  ExpandOption getExpandOption();
 
   /**
    * @return Object containing information of the $format option
    */
-  public FormatOption getFormatOption();
+  FormatOption getFormatOption();
 
   /**
    * @return Object containing information of the $id option
    */
-  public IdOption getIdOption();
+  IdOption getIdOption();
 
   /**
    * @return Object containing information of the $select option
    */
-  public SelectOption getSelectOption();
-
+  SelectOption getSelectOption();
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0938f117/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoMetadata.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoMetadata.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoMetadata.java
index b16f76c..7bf8d91 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoMetadata.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoMetadata.java
@@ -29,11 +29,11 @@ public interface UriInfoMetadata {
   /**
    * @return Object containing information of the $id option
    */
-  public FormatOption getFormatOption();
+  FormatOption getFormatOption();
 
   /**
    * @return Object containing information of the URI fragment
    */
-  public String getFragment();
+  String getFragment();
 
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0938f117/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriParameter.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriParameter.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriParameter.java
index db2f9d0..ab8bfec 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriParameter.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriParameter.java
@@ -28,26 +28,25 @@ public interface UriParameter {
   /**
    * @return Alias name if the parameters values is an alias, otherwise null
    */
-  public String getAlias();
+  String getAlias();
 
   /**
    * @return Text of the parameters value
    */
-  public String getText();
+  String getText();
 
   /**
    * @return If the parameters value is a expression and expression is returned, otherwise null
    */
-  public Expression getExpression();
+  Expression getExpression();
 
   /**
    * @return Name of the parameter
    */
-  public String getName();
+  String getName();
 
   /**
    * @return Name of the referenced property when referential constrains are used
    */
-  public String getReferencedProperty();
-
+  String getReferencedProperty();
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0938f117/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriResourceFunction.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriResourceFunction.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriResourceFunction.java
index d92dd89..f509bd7 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriResourceFunction.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriResourceFunction.java
@@ -45,7 +45,7 @@ public interface UriResourceFunction extends UriResourcePartTyped {
   EdmFunctionImport getFunctionImport();
 
   /**
-   * @return Key predicates if used, otherwise null
+   * @return Key predicates if used, otherwise an empty list
    */
   List<UriParameter> getKeyPredicates();
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0938f117/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriResourceLambdaAll.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriResourceLambdaAll.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriResourceLambdaAll.java
index cbb9edf..2abe93e 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriResourceLambdaAll.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriResourceLambdaAll.java
@@ -29,11 +29,10 @@ public interface UriResourceLambdaAll extends UriResourcePartTyped {
   /**
    * @return Name of the lambda variable
    */
-  public String getLambdaVariable();
+  String getLambdaVariable();
 
   /**
    * @return Lambda expression
    */
-  public Expression getExpression();
-
+  Expression getExpression();
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0938f117/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriResourceLambdaAny.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriResourceLambdaAny.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriResourceLambdaAny.java
index 8908284..198ac3c 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriResourceLambdaAny.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriResourceLambdaAny.java
@@ -29,11 +29,11 @@ public interface UriResourceLambdaAny extends UriResourcePartTyped {
   /**
    * @return Name of the lambda variable
    */
-  public String getLamdaVariable();
+  String getLambdaVariable();
 
   /**
    * @return Lambda expression
    */
-  public Expression getExpression();
+  Expression getExpression();
 
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0938f117/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriResourceLambdaVariable.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriResourceLambdaVariable.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriResourceLambdaVariable.java
index 67a5d3d..376e88f 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriResourceLambdaVariable.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriResourceLambdaVariable.java
@@ -27,6 +27,5 @@ public interface UriResourceLambdaVariable extends UriResourcePartTyped {
   /**
    * @return Name of the lambda variable
    */
-  public String getVariableName();
-
+  String getVariableName();
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0938f117/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriResourceNavigation.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriResourceNavigation.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriResourceNavigation.java
index 3ef4c05..fab09a3 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriResourceNavigation.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriResourceNavigation.java
@@ -35,7 +35,7 @@ public interface UriResourceNavigation extends UriResourcePartTyped {
   EdmNavigationProperty getProperty();
 
   /**
-   * @return Key predicates if used, otherwise null
+   * @return Key predicates if used, otherwise an empty list
    */
   List<UriParameter> getKeyPredicates();
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0938f117/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaAnyImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaAnyImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaAnyImpl.java
index e66a37c..81059dd 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaAnyImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaAnyImpl.java
@@ -50,7 +50,7 @@ public class UriResourceLambdaAnyImpl extends UriResourceTypedImpl implements Ur
   }
 
   @Override
-  public String getLamdaVariable() {
+  public String getLambdaVariable() {
     return lambdaVariable;
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0938f117/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceWithKeysImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceWithKeysImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceWithKeysImpl.java
index aef5800..320ad0d 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceWithKeysImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceWithKeysImpl.java
@@ -73,29 +73,30 @@ public abstract class UriResourceWithKeysImpl extends UriResourceImpl implements
   @Override
   public String toString(final boolean includeFilters) {
 
-    if (includeFilters == true) {
-      String tmp = "";
+    if (includeFilters) {
+      StringBuilder tmp = new StringBuilder();
       if (collectionTypeFilter != null) {
-        tmp += getFQN(collectionTypeFilter).toString();
+        tmp.append(getFQN(collectionTypeFilter));
       }
 
       if (entryTypeFilter != null) {
         if (tmp.length() == 0) {
-          tmp = getFQN(entryTypeFilter).toString();
+          tmp.append(getFQN(entryTypeFilter));
         } else {
-          tmp += "/()" + getFQN(entryTypeFilter).toString();
+          tmp.append("/()").append(getFQN(entryTypeFilter));
         }
       }
+
       if (tmp.length() != 0) {
-        return toString() + "/" + tmp;
+        return toString() + "/" + tmp.toString();
       }
     }
 
     return toString();
   }
 
-  private FullQualifiedName getFQN(final EdmType type) {
-    return new FullQualifiedName(type.getNamespace(), type.getName());
+  private String getFQN(final EdmType type) {
+    return new FullQualifiedName(type.getNamespace(), type.getName()).getFullQualifiedNameAsString();
   }
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0938f117/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/UriResourceImplTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/UriResourceImplTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/UriResourceImplTest.java
index 1945fe5..e9f16ea 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/UriResourceImplTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/UriResourceImplTest.java
@@ -125,7 +125,7 @@ public class UriResourceImplTest {
 
     assertEquals(false, impl.isCollection());
     assertEquals(expression, impl.getExpression());
-    assertEquals("A", impl.getLamdaVariable());
+    assertEquals("A", impl.getLambdaVariable());
     assertEquals(EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Boolean), impl.getType());
     assertEquals("any", impl.toString());
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0938f117/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterTreeToText.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterTreeToText.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterTreeToText.java
index d24c77f..7b0752f 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterTreeToText.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterTreeToText.java
@@ -97,7 +97,7 @@ public class FilterTreeToText implements ExpressionVisitor<String> {
         tmp = visitLambdaExpression("ALL", all.getLambdaVariable(), all.getExpression());
       } else if (item instanceof UriResourceLambdaAny) {
         UriResourceLambdaAny any = (UriResourceLambdaAny) item;
-        tmp = visitLambdaExpression("ANY", any.getLamdaVariable(), any.getExpression());
+        tmp = visitLambdaExpression("ANY", any.getLambdaVariable(), any.getExpression());
       } else if (item instanceof UriResourcePartTyped) {
         UriResourcePartTyped typed = (UriResourcePartTyped) item;
         tmp = typed.toString(true);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0938f117/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java
index 817602a..f6c9937 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java
@@ -224,7 +224,7 @@ public class ResourceValidator implements TestValidator {
     if (uriPathInfo.getKind() == UriResourceKind.lambdaAll) {
       actualVar = ((UriResourceLambdaAllImpl) uriPathInfo).getLambdaVariable();
     } else if (uriPathInfo.getKind() == UriResourceKind.lambdaAny) {
-      actualVar = ((UriResourceLambdaAnyImpl) uriPathInfo).getLamdaVariable();
+      actualVar = ((UriResourceLambdaAnyImpl) uriPathInfo).getLambdaVariable();
     } else {
       fail("invalid resource kind: " + uriPathInfo.getKind().toString());
     }


[13/39] olingo-odata4 git commit: [OLINGO-699] Moved serializer code to client module

Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonDeltaDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonDeltaDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonDeltaDeserializer.java
new file mode 100644
index 0000000..c9b962a
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonDeltaDeserializer.java
@@ -0,0 +1,100 @@
+/*
+ * 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.serialization;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.client.api.serialization.ODataDeserializerException;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.ContextURL;
+import org.apache.olingo.commons.api.data.DeletedEntity;
+import org.apache.olingo.commons.api.data.Delta;
+import org.apache.olingo.commons.api.data.DeltaLink;
+import org.apache.olingo.commons.api.data.ResWrap;
+
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+public class JsonDeltaDeserializer extends JsonDeserializer {
+
+  public JsonDeltaDeserializer(final boolean serverMode) {
+    super(serverMode);
+  }
+
+  protected ResWrap<Delta> doDeserialize(final JsonParser parser) throws IOException {
+
+    final ObjectNode tree = parser.getCodec().readTree(parser);
+
+    final Delta delta = new Delta();
+
+    final URI contextURL = tree.hasNonNull(Constants.JSON_CONTEXT) ?
+        URI.create(tree.get(Constants.JSON_CONTEXT).textValue()) : null;
+    if (contextURL != null) {
+      delta.setBaseURI(URI.create(StringUtils.substringBefore(contextURL.toASCIIString(), Constants.METADATA)));
+    }
+
+    if (tree.hasNonNull(Constants.JSON_COUNT)) {
+      delta.setCount(tree.get(Constants.JSON_COUNT).asInt());
+    }
+    if (tree.hasNonNull(Constants.JSON_NEXT_LINK)) {
+      delta.setNext(URI.create(tree.get(Constants.JSON_NEXT_LINK).textValue()));
+    }
+    if (tree.hasNonNull(Constants.JSON_DELTA_LINK)) {
+      delta.setDeltaLink(URI.create(tree.get(Constants.JSON_DELTA_LINK).textValue()));
+    }
+
+    if (tree.hasNonNull(Constants.VALUE)) {
+      JsonEntityDeserializer entityDeserializer = new JsonEntityDeserializer(serverMode);
+      for (JsonNode jsonNode : tree.get(Constants.VALUE)) {
+        final ObjectNode item = (ObjectNode) jsonNode;
+        final ContextURL itemContextURL = item.hasNonNull(Constants.JSON_CONTEXT) ?
+            ContextURLParser.parse(URI.create(item.get(Constants.JSON_CONTEXT).textValue())) : null;
+        item.remove(Constants.JSON_CONTEXT);
+
+        if (itemContextURL == null || itemContextURL.isEntity()) {
+          delta.getEntities().add(
+              entityDeserializer.doDeserialize(item.traverse(parser.getCodec())).getPayload());
+        } else if (itemContextURL.isDeltaDeletedEntity()) {
+          delta.getDeletedEntities().add(parser.getCodec().treeToValue(item, DeletedEntity.class));
+        } else if (itemContextURL.isDeltaLink()) {
+          delta.getAddedLinks().add(parser.getCodec().treeToValue(item, DeltaLink.class));
+        } else if (itemContextURL.isDeltaDeletedLink()) {
+          delta.getDeletedLinks().add(parser.getCodec().treeToValue(item, DeltaLink.class));
+        }
+      }
+    }
+
+    return new ResWrap<Delta>(contextURL, null, delta);
+  }
+
+  public ResWrap<Delta> toDelta(final InputStream input) throws ODataDeserializerException {
+    try {
+      JsonParser parser = new JsonFactory(new ObjectMapper()).createParser(input);
+      return doDeserialize(parser);
+    } catch (final IOException e) {
+      throw new ODataDeserializerException(e);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonDeserializer.java
new file mode 100644
index 0000000..ab70931
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonDeserializer.java
@@ -0,0 +1,421 @@
+/*
+ * 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.serialization;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.AbstractMap.SimpleEntry;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.client.api.serialization.ODataDeserializer;
+import org.apache.olingo.client.api.serialization.ODataDeserializerException;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.ODataError;
+import org.apache.olingo.commons.api.ODataPropertyType;
+import org.apache.olingo.commons.api.data.Annotatable;
+import org.apache.olingo.commons.api.data.Annotation;
+import org.apache.olingo.commons.api.data.ComplexValue;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntityCollection;
+import org.apache.olingo.commons.api.data.Link;
+import org.apache.olingo.commons.api.data.Linked;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.data.Valuable;
+import org.apache.olingo.commons.api.data.ValueType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.geo.Geospatial;
+import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.ObjectCodec;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+public class JsonDeserializer implements ODataDeserializer {
+
+  protected final Pattern CUSTOM_ANNOTATION = Pattern.compile("(.+)@(.+)\\.(.+)");
+
+  protected final boolean serverMode;
+
+  private JsonGeoValueDeserializer geoDeserializer;
+
+  private JsonParser parser;
+
+  public JsonDeserializer(final boolean serverMode) {
+    this.serverMode = serverMode;
+  }
+
+  private JsonGeoValueDeserializer getGeoDeserializer() {
+    if (geoDeserializer == null) {
+      geoDeserializer = new JsonGeoValueDeserializer();
+    }
+    return geoDeserializer;
+  }
+
+  protected String getJSONAnnotation(final String string) {
+    return StringUtils.prependIfMissing(string, "@");
+  }
+
+  protected String getTitle(final Map.Entry<String, JsonNode> entry) {
+    return entry.getKey().substring(0, entry.getKey().indexOf('@'));
+  }
+
+  protected String setInline(final String name, final String suffix, final JsonNode tree,
+      final ObjectCodec codec, final Link link) throws IOException {
+
+    final String entityNamePrefix = name.substring(0, name.indexOf(suffix));
+    if (tree.has(entityNamePrefix)) {
+      final JsonNode inline = tree.path(entityNamePrefix);
+      JsonEntityDeserializer entityDeserializer = new JsonEntityDeserializer(serverMode);
+
+      if (inline instanceof ObjectNode) {
+        link.setType(Constants.ENTITY_NAVIGATION_LINK_TYPE);
+        link.setInlineEntity(entityDeserializer.doDeserialize(inline.traverse(codec)).getPayload());
+
+      } else if (inline instanceof ArrayNode) {
+        link.setType(Constants.ENTITY_SET_NAVIGATION_LINK_TYPE);
+
+        final EntityCollection entitySet = new EntityCollection();
+        for (final Iterator<JsonNode> entries = inline.elements(); entries.hasNext();) {
+          entitySet.getEntities().add(entityDeserializer.doDeserialize(entries.next().traverse(codec)).getPayload());
+        }
+
+        link.setInlineEntitySet(entitySet);
+      }
+    }
+    return entityNamePrefix;
+  }
+
+  protected void links(final Map.Entry<String, JsonNode> field, final Linked linked, final Set<String> toRemove,
+      final JsonNode tree, final ObjectCodec codec) throws IOException {
+    if (serverMode) {
+      serverLinks(field, linked, toRemove, tree, codec);
+    } else {
+      clientLinks(field, linked, toRemove, tree, codec);
+    }
+  }
+
+  private void clientLinks(final Map.Entry<String, JsonNode> field, final Linked linked, final Set<String> toRemove,
+      final JsonNode tree, final ObjectCodec codec) throws IOException {
+
+    if (field.getKey().endsWith(Constants.JSON_NAVIGATION_LINK)) {
+      final Link link = new Link();
+      link.setTitle(getTitle(field));
+      link.setRel(Constants.NS_NAVIGATION_LINK_REL + getTitle(field));
+
+      if (field.getValue().isValueNode()) {
+        link.setHref(field.getValue().textValue());
+        link.setType(Constants.ENTITY_NAVIGATION_LINK_TYPE);
+      }
+
+      linked.getNavigationLinks().add(link);
+
+      toRemove.add(field.getKey());
+      toRemove.add(setInline(field.getKey(), Constants.JSON_NAVIGATION_LINK, tree, codec, link));
+    } else if (field.getKey().endsWith(Constants.JSON_ASSOCIATION_LINK)) {
+      final Link link = new Link();
+      link.setTitle(getTitle(field));
+      link.setRel(Constants.NS_ASSOCIATION_LINK_REL + getTitle(field));
+      link.setHref(field.getValue().textValue());
+      link.setType(Constants.ASSOCIATION_LINK_TYPE);
+      linked.getAssociationLinks().add(link);
+
+      toRemove.add(field.getKey());
+    }
+  }
+
+  private void serverLinks(final Map.Entry<String, JsonNode> field, final Linked linked, final Set<String> toRemove,
+      final JsonNode tree, final ObjectCodec codec) throws IOException {
+
+    if (field.getKey().endsWith(Constants.JSON_BIND_LINK_SUFFIX)
+        || field.getKey().endsWith(Constants.JSON_NAVIGATION_LINK)) {
+
+      if (field.getValue().isValueNode()) {
+        final String suffix = field.getKey().replaceAll("^.*@", "@");
+
+        final Link link = new Link();
+        link.setTitle(getTitle(field));
+        link.setRel(Constants.NS_NAVIGATION_LINK_REL + getTitle(field));
+        link.setHref(field.getValue().textValue());
+        link.setType(Constants.ENTITY_NAVIGATION_LINK_TYPE);
+        linked.getNavigationLinks().add(link);
+
+        toRemove.add(setInline(field.getKey(), suffix, tree, codec, link));
+      } else if (field.getValue().isArray()) {
+        for (final Iterator<JsonNode> itor = field.getValue().elements(); itor.hasNext();) {
+          final JsonNode node = itor.next();
+
+          final Link link = new Link();
+          link.setTitle(getTitle(field));
+          link.setRel(Constants.NS_NAVIGATION_LINK_REL + getTitle(field));
+          link.setHref(node.asText());
+          link.setType(Constants.ENTITY_SET_NAVIGATION_LINK_TYPE);
+          linked.getNavigationLinks().add(link);
+          toRemove.add(setInline(field.getKey(), Constants.JSON_BIND_LINK_SUFFIX, tree, codec, link));
+        }
+      }
+      toRemove.add(field.getKey());
+    }
+  }
+
+  private Map.Entry<ODataPropertyType, EdmTypeInfo> guessPropertyType(final JsonNode node) {
+    ODataPropertyType type;
+    String typeExpression = null;
+
+    if (node.isValueNode() || node.isNull()) {
+      type = ODataPropertyType.PRIMITIVE;
+      typeExpression = guessPrimitiveTypeKind(node).getFullQualifiedName().toString();
+    } else if (node.isArray()) {
+      type = ODataPropertyType.COLLECTION;
+      if (node.has(0) && node.get(0).isValueNode()) {
+        typeExpression = "Collection(" + guessPrimitiveTypeKind(node.get(0)) + ')';
+      }
+    } else if (node.isObject()) {
+      if (node.has(Constants.ATTR_TYPE)) {
+        type = ODataPropertyType.PRIMITIVE;
+        typeExpression = "Edm.Geography" + node.get(Constants.ATTR_TYPE).asText();
+      } else {
+        type = ODataPropertyType.COMPLEX;
+      }
+    } else {
+      type = ODataPropertyType.EMPTY;
+    }
+
+    final EdmTypeInfo typeInfo = typeExpression == null ? null :
+      new EdmTypeInfo.Builder().setTypeExpression(typeExpression).build();
+    return new SimpleEntry<ODataPropertyType, EdmTypeInfo>(type, typeInfo);
+  }
+
+  private EdmPrimitiveTypeKind guessPrimitiveTypeKind(final JsonNode node) {
+    return node.isShort() ? EdmPrimitiveTypeKind.Int16 :
+      node.isInt() ? EdmPrimitiveTypeKind.Int32 :
+        node.isLong() ? EdmPrimitiveTypeKind.Int64 :
+          node.isBoolean() ? EdmPrimitiveTypeKind.Boolean :
+            node.isFloat() ? EdmPrimitiveTypeKind.Single :
+              node.isDouble() ? EdmPrimitiveTypeKind.Double :
+                node.isBigDecimal() ? EdmPrimitiveTypeKind.Decimal :
+                  EdmPrimitiveTypeKind.String;
+  }
+
+  protected void populate(final Annotatable annotatable, final List<Property> properties,
+      final ObjectNode tree, final ObjectCodec codec)
+          throws IOException, EdmPrimitiveTypeException {
+
+    String type = null;
+    Annotation annotation = null;
+    for (final Iterator<Map.Entry<String, JsonNode>> itor = tree.fields(); itor.hasNext();) {
+      final Map.Entry<String, JsonNode> field = itor.next();
+      final Matcher customAnnotation = CUSTOM_ANNOTATION.matcher(field.getKey());
+
+      if (field.getKey().charAt(0) == '@') {
+        final Annotation entityAnnot = new Annotation();
+        entityAnnot.setTerm(field.getKey().substring(1));
+
+        value(entityAnnot, field.getValue(), codec);
+        if (annotatable != null) {
+          annotatable.getAnnotations().add(entityAnnot);
+        }
+      } else if (type == null && field.getKey().endsWith(getJSONAnnotation(Constants.JSON_TYPE))) {
+        type = field.getValue().asText();
+      } else if (annotation == null && customAnnotation.matches() && !"odata".equals(customAnnotation.group(2))) {
+        annotation = new Annotation();
+        annotation.setTerm(customAnnotation.group(2) + "." + customAnnotation.group(3));
+        value(annotation, field.getValue(), codec);
+      } else {
+        final Property property = new Property();
+        property.setName(field.getKey());
+        property.setType(type == null
+            ? null
+                : new EdmTypeInfo.Builder().setTypeExpression(type).build().internal());
+        type = null;
+
+        value(property, field.getValue(), codec);
+        properties.add(property);
+
+        if (annotation != null) {
+          property.getAnnotations().add(annotation);
+          annotation = null;
+        }
+      }
+    }
+  }
+
+  private Object fromPrimitive(final JsonNode node, final EdmTypeInfo typeInfo) throws EdmPrimitiveTypeException {
+    return node.isNull() ? null
+        : typeInfo == null ? node.asText()
+            : typeInfo.getPrimitiveTypeKind().isGeospatial()
+            ? getGeoDeserializer().deserialize(node, typeInfo)
+                : ((EdmPrimitiveType) typeInfo.getType())
+                .valueOfString(node.asText(), true, null,
+                    Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, true,
+                    ((EdmPrimitiveType) typeInfo.getType()).getDefaultType());
+  }
+
+  private Object fromComplex(final ObjectNode node, final ObjectCodec codec)
+      throws IOException, EdmPrimitiveTypeException {
+
+    final ComplexValue complexValue = new ComplexValue();
+    final Set<String> toRemove = new HashSet<String>();
+    for (final Iterator<Map.Entry<String, JsonNode>> itor = node.fields(); itor.hasNext();) {
+      final Map.Entry<String, JsonNode> field = itor.next();
+
+      links(field, complexValue, toRemove, node, codec);
+    }
+    node.remove(toRemove);
+
+    populate(complexValue, complexValue.getValue(), node, codec);
+    return complexValue;
+  }
+
+  private void fromCollection(final Valuable valuable, final Iterator<JsonNode> nodeItor, final EdmTypeInfo typeInfo,
+      final ObjectCodec codec) throws IOException, EdmPrimitiveTypeException {
+
+    final List<Object> values = new ArrayList<Object>();
+    ValueType valueType = ValueType.COLLECTION_PRIMITIVE;
+
+    final EdmTypeInfo type = typeInfo == null ? null
+        : new EdmTypeInfo.Builder().setTypeExpression(typeInfo.getFullQualifiedName().toString()).build();
+
+    while (nodeItor.hasNext()) {
+      final JsonNode child = nodeItor.next();
+
+      if (child.isValueNode()) {
+        if (typeInfo == null || typeInfo.isPrimitiveType()) {
+          final Object value = fromPrimitive(child, type);
+          valueType = value instanceof Geospatial ? ValueType.COLLECTION_GEOSPATIAL : ValueType.COLLECTION_PRIMITIVE;
+          values.add(value);
+        } else {
+          valueType = ValueType.COLLECTION_ENUM;
+          values.add(child.asText());
+        }
+      } else if (child.isContainerNode()) {
+        if (child.has(Constants.JSON_TYPE)) {
+          ((ObjectNode) child).remove(Constants.JSON_TYPE);
+        }
+        final Object value = fromComplex((ObjectNode) child, codec);
+        valueType = ValueType.COLLECTION_COMPLEX;
+        values.add(value);
+      }
+    }
+    valuable.setValue(valueType, values);
+  }
+
+  protected void value(final Valuable valuable, final JsonNode node, final ObjectCodec codec)
+      throws IOException, EdmPrimitiveTypeException {
+
+    EdmTypeInfo typeInfo = StringUtils.isBlank(valuable.getType()) ? null
+        : new EdmTypeInfo.Builder().setTypeExpression(valuable.getType()).build();
+
+    final Map.Entry<ODataPropertyType, EdmTypeInfo> guessed = guessPropertyType(node);
+    if (typeInfo == null) {
+      typeInfo = guessed.getValue();
+    }
+
+    final ODataPropertyType propType = typeInfo == null ? guessed.getKey()
+        : typeInfo.isCollection() ? ODataPropertyType.COLLECTION
+            : typeInfo.isPrimitiveType() ? ODataPropertyType.PRIMITIVE
+                : node.isValueNode() ? ODataPropertyType.ENUM : ODataPropertyType.COMPLEX;
+
+    switch (propType) {
+    case COLLECTION:
+      fromCollection(valuable, node.elements(), typeInfo, codec);
+      break;
+
+    case COMPLEX:
+      if (node.has(Constants.JSON_TYPE)) {
+        valuable.setType(node.get(Constants.JSON_TYPE).asText());
+        ((ObjectNode) node).remove(Constants.JSON_TYPE);
+      }
+      final Object value = fromComplex((ObjectNode) node, codec);
+      valuable.setValue(ValueType.COMPLEX, value);
+      break;
+
+    case ENUM:
+      valuable.setValue(ValueType.ENUM, node.asText());
+      break;
+
+    case PRIMITIVE:
+      if (valuable.getType() == null && typeInfo != null) {
+        valuable.setType(typeInfo.getFullQualifiedName().toString());
+      }
+      final Object primitiveValue = fromPrimitive(node, typeInfo);
+      valuable.setValue(primitiveValue instanceof Geospatial ? ValueType.GEOSPATIAL : ValueType.PRIMITIVE,
+          primitiveValue);
+      break;
+
+    case EMPTY:
+    default:
+      valuable.setValue(ValueType.PRIMITIVE, StringUtils.EMPTY);
+    }
+  }
+
+  @Override
+  public ResWrap<EntityCollection> toEntitySet(final InputStream input) throws ODataDeserializerException {
+    try {
+      parser = new JsonFactory(new ObjectMapper()).createParser(input);
+      return new JsonEntitySetDeserializer(serverMode).doDeserialize(parser);
+    } catch (final IOException e) {
+      throw new ODataDeserializerException(e);
+    }
+  }
+
+  @Override
+  public ResWrap<Entity> toEntity(final InputStream input) throws ODataDeserializerException {
+    try {
+      parser = new JsonFactory(new ObjectMapper()).createParser(input);
+      return new JsonEntityDeserializer(serverMode).doDeserialize(parser);
+    } catch (final IOException e) {
+      throw new ODataDeserializerException(e);
+    }
+  }
+
+  @Override
+  public ResWrap<Property> toProperty(final InputStream input) throws ODataDeserializerException {
+    try {
+      parser = new JsonFactory(new ObjectMapper()).createParser(input);
+      return new JsonPropertyDeserializer(serverMode).doDeserialize(parser);
+    } catch (final IOException e) {
+      throw new ODataDeserializerException(e);
+    }
+  }
+
+  @Override
+  public ODataError toError(final InputStream input) throws ODataDeserializerException {
+    try {
+      parser = new JsonFactory(new ObjectMapper()).createParser(input);
+      return new JsonODataErrorDeserializer(serverMode).doDeserialize(parser);
+    } catch (final IOException e) {
+      throw new ODataDeserializerException(e);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonEntityDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonEntityDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonEntityDeserializer.java
new file mode 100644
index 0000000..258c028
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonEntityDeserializer.java
@@ -0,0 +1,229 @@
+/*
+ * 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.serialization;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.Annotation;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.Link;
+import org.apache.olingo.commons.api.data.Operation;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * Reads JSON string into an entity.
+ * <br/>
+ * If metadata information is available, the corresponding entity fields and content will be populated.
+ */
+public class JsonEntityDeserializer extends JsonDeserializer {
+
+  public JsonEntityDeserializer(final boolean serverMode) {
+    super(serverMode);
+  }
+
+  protected ResWrap<Entity> doDeserialize(final JsonParser parser) throws IOException {
+
+    final ObjectNode tree = parser.getCodec().readTree(parser);
+
+    if (tree.has(Constants.VALUE) && tree.get(Constants.VALUE).isArray()) {
+      throw new JsonParseException("Expected OData Entity, found EntitySet", parser.getCurrentLocation());
+    }
+
+    final Entity entity = new Entity();
+
+    final URI contextURL;
+    if (tree.hasNonNull(Constants.JSON_CONTEXT)) {
+      contextURL = URI.create(tree.get(Constants.JSON_CONTEXT).textValue());
+      tree.remove(Constants.JSON_CONTEXT);
+    } else if (tree.hasNonNull(Constants.JSON_METADATA)) {
+      contextURL = URI.create(tree.get(Constants.JSON_METADATA).textValue());
+      tree.remove(Constants.JSON_METADATA);
+    } else {
+      contextURL = null;
+    }
+    if (contextURL != null) {
+      entity.setBaseURI(URI.create(StringUtils.substringBefore(contextURL.toASCIIString(), Constants.METADATA)));
+    }
+
+    final String metadataETag;
+    if (tree.hasNonNull(Constants.JSON_METADATA_ETAG)) {
+      metadataETag = tree.get(Constants.JSON_METADATA_ETAG).textValue();
+      tree.remove(Constants.JSON_METADATA_ETAG);
+    } else {
+      metadataETag = null;
+    }
+
+    if (tree.hasNonNull(Constants.JSON_ETAG)) {
+      entity.setETag(tree.get(Constants.JSON_ETAG).textValue());
+      tree.remove(Constants.JSON_ETAG);
+    }
+
+    if (tree.hasNonNull(Constants.JSON_TYPE)) {
+      entity.setType(new EdmTypeInfo.Builder().setTypeExpression(tree.get(Constants.JSON_TYPE).textValue()).build()
+          .internal());
+      tree.remove(Constants.JSON_TYPE);
+    }
+
+    if (tree.hasNonNull(Constants.JSON_ID)) {
+      entity.setId(URI.create(tree.get(Constants.JSON_ID).textValue()));
+      tree.remove(Constants.JSON_ID);
+    }
+
+    if (tree.hasNonNull(Constants.JSON_READ_LINK)) {
+      final Link link = new Link();
+      link.setRel(Constants.SELF_LINK_REL);
+      link.setHref(tree.get(Constants.JSON_READ_LINK).textValue());
+      entity.setSelfLink(link);
+
+      tree.remove(Constants.JSON_READ_LINK);
+    }
+
+    if (tree.hasNonNull(Constants.JSON_EDIT_LINK)) {
+      final Link link = new Link();
+      if (serverMode) {
+        link.setRel(Constants.EDIT_LINK_REL);
+      }
+      link.setHref(tree.get(Constants.JSON_EDIT_LINK).textValue());
+      entity.setEditLink(link);
+
+      tree.remove(Constants.JSON_EDIT_LINK);
+    }
+
+    if (tree.hasNonNull(Constants.JSON_MEDIA_READ_LINK)) {
+      entity.setMediaContentSource(URI.create(tree.get(Constants.JSON_MEDIA_READ_LINK).textValue()));
+      tree.remove(Constants.JSON_MEDIA_READ_LINK);
+    }
+    if (tree.hasNonNull(Constants.JSON_MEDIA_EDIT_LINK)) {
+      entity.setMediaContentSource(URI.create(tree.get(Constants.JSON_MEDIA_EDIT_LINK).textValue()));
+      tree.remove(Constants.JSON_MEDIA_EDIT_LINK);
+    }
+    if (tree.hasNonNull(Constants.JSON_MEDIA_CONTENT_TYPE)) {
+      entity.setMediaContentType(tree.get(Constants.JSON_MEDIA_CONTENT_TYPE).textValue());
+      tree.remove(Constants.JSON_MEDIA_CONTENT_TYPE);
+    }
+    if (tree.hasNonNull(Constants.JSON_MEDIA_ETAG)) {
+      entity.setMediaETag(tree.get(Constants.JSON_MEDIA_ETAG).textValue());
+      tree.remove(Constants.JSON_MEDIA_ETAG);
+    }
+
+    final Set<String> toRemove = new HashSet<String>();
+
+    final Map<String, List<Annotation>> annotations = new HashMap<String, List<Annotation>>();
+    for (final Iterator<Map.Entry<String, JsonNode>> itor = tree.fields(); itor.hasNext();) {
+      final Map.Entry<String, JsonNode> field = itor.next();
+      final Matcher customAnnotation = CUSTOM_ANNOTATION.matcher(field.getKey());
+
+      links(field, entity, toRemove, tree, parser.getCodec());
+      if (field.getKey().endsWith(getJSONAnnotation(Constants.JSON_MEDIA_EDIT_LINK))) {
+        final Link link = new Link();
+        link.setTitle(getTitle(field));
+        link.setRel(Constants.NS_MEDIA_EDIT_LINK_REL + getTitle(field));
+        link.setHref(field.getValue().textValue());
+        link.setType(Constants.MEDIA_EDIT_LINK_TYPE);
+        entity.getMediaEditLinks().add(link);
+
+        if (tree.has(link.getTitle() + getJSONAnnotation(Constants.JSON_MEDIA_ETAG))) {
+          link.setMediaETag(tree.get(link.getTitle() + getJSONAnnotation(Constants.JSON_MEDIA_ETAG)).asText());
+          toRemove.add(link.getTitle() + getJSONAnnotation(Constants.JSON_MEDIA_ETAG));
+        }
+
+        toRemove.add(field.getKey());
+        toRemove.add(setInline(field.getKey(), getJSONAnnotation(Constants.JSON_MEDIA_EDIT_LINK), tree, parser
+            .getCodec(), link));
+      } else if (field.getKey().endsWith(getJSONAnnotation(Constants.JSON_MEDIA_CONTENT_TYPE))) {
+        final String linkTitle = getTitle(field);
+        for (Link link : entity.getMediaEditLinks()) {
+          if (linkTitle.equals(link.getTitle())) {
+            link.setType(field.getValue().asText());
+          }
+        }
+        toRemove.add(field.getKey());
+      } else if (field.getKey().charAt(0) == '#') {
+        final Operation operation = new Operation();
+        operation.setMetadataAnchor(field.getKey());
+
+        final ObjectNode opNode = (ObjectNode) tree.get(field.getKey());
+        operation.setTitle(opNode.get(Constants.ATTR_TITLE).asText());
+        operation.setTarget(URI.create(opNode.get(Constants.ATTR_TARGET).asText()));
+
+        entity.getOperations().add(operation);
+
+        toRemove.add(field.getKey());
+      } else if (customAnnotation.matches() && !"odata".equals(customAnnotation.group(2))) {
+        final Annotation annotation = new Annotation();
+        annotation.setTerm(customAnnotation.group(2) + "." + customAnnotation.group(3));
+        try {
+          value(annotation, field.getValue(), parser.getCodec());
+        } catch (final EdmPrimitiveTypeException e) {
+          throw new IOException(e);
+        }
+
+        if (!annotations.containsKey(customAnnotation.group(1))) {
+          annotations.put(customAnnotation.group(1), new ArrayList<Annotation>());
+        }
+        annotations.get(customAnnotation.group(1)).add(annotation);
+      }
+    }
+
+    for (Link link : entity.getNavigationLinks()) {
+      if (annotations.containsKey(link.getTitle())) {
+        link.getAnnotations().addAll(annotations.get(link.getTitle()));
+        for (Annotation annotation : annotations.get(link.getTitle())) {
+          toRemove.add(link.getTitle() + "@" + annotation.getTerm());
+        }
+      }
+    }
+    for (Link link : entity.getMediaEditLinks()) {
+      if (annotations.containsKey(link.getTitle())) {
+        link.getAnnotations().addAll(annotations.get(link.getTitle()));
+        for (Annotation annotation : annotations.get(link.getTitle())) {
+          toRemove.add(link.getTitle() + "@" + annotation.getTerm());
+        }
+      }
+    }
+
+    tree.remove(toRemove);
+
+    try {
+      populate(entity, entity.getProperties(), tree, parser.getCodec());
+    } catch (final EdmPrimitiveTypeException e) {
+      throw new IOException(e);
+    }
+
+    return new ResWrap<Entity>(contextURL, metadataETag, entity);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonEntitySerializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonEntitySerializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonEntitySerializer.java
new file mode 100644
index 0000000..9f2056d
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonEntitySerializer.java
@@ -0,0 +1,135 @@
+/*
+ * 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.serialization;
+
+import java.io.IOException;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.Annotation;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.Link;
+import org.apache.olingo.commons.api.data.Operation;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+
+/**
+ * Writes out JSON string from an entity.
+ */
+public class JsonEntitySerializer extends JsonSerializer {
+
+  public JsonEntitySerializer(final boolean serverMode) {
+    super(serverMode);
+  }
+
+  public JsonEntitySerializer(final boolean serverMode, final ODataFormat format) {
+    super(serverMode, format);
+  }
+
+  protected void doSerialize(final Entity entity, final JsonGenerator jgen)
+      throws IOException, EdmPrimitiveTypeException {
+
+    doContainerSerialize(new ResWrap<Entity>(null, null, entity), jgen);
+  }
+
+  protected void doContainerSerialize(final ResWrap<Entity> container, final JsonGenerator jgen)
+      throws IOException, EdmPrimitiveTypeException {
+
+    final Entity entity = container.getPayload();
+
+    jgen.writeStartObject();
+
+    if (serverMode) {
+      if (container.getContextURL() != null) {
+        jgen.writeStringField(Constants.JSON_CONTEXT, container.getContextURL().toASCIIString());
+      }
+      if (StringUtils.isNotBlank(container.getMetadataETag())) {
+        jgen.writeStringField(Constants.JSON_METADATA_ETAG, container.getMetadataETag());
+      }
+
+      if (StringUtils.isNotBlank(entity.getETag())) {
+        jgen.writeStringField(Constants.JSON_ETAG, entity.getETag());
+      }
+    }
+
+    if (StringUtils.isNotBlank(entity.getType()) && format != ODataFormat.JSON_NO_METADATA) {
+      jgen.writeStringField(Constants.JSON_TYPE,
+          new EdmTypeInfo.Builder().setTypeExpression(entity.getType()).build().external());
+    }
+
+    if (entity.getId() != null && format != ODataFormat.JSON_NO_METADATA) {
+      jgen.writeStringField(Constants.JSON_ID, entity.getId().toASCIIString());
+    }
+
+    for (Annotation annotation : entity.getAnnotations()) {
+      valuable(jgen, annotation, "@" + annotation.getTerm());
+    }
+
+    for (Property property : entity.getProperties()) {
+      valuable(jgen, property, property.getName());
+    }
+
+    if (serverMode && entity.getEditLink() != null && StringUtils.isNotBlank(entity.getEditLink().getHref())) {
+      jgen.writeStringField(Constants.JSON_EDIT_LINK,
+          entity.getEditLink().getHref());
+
+      if (entity.isMediaEntity()) {
+        jgen.writeStringField(Constants.JSON_MEDIA_READ_LINK,
+            entity.getEditLink().getHref() + "/$value");
+      }
+    }
+
+    if (format != ODataFormat.JSON_NO_METADATA) {
+      links(entity, jgen);
+    }
+
+    for (Link link : entity.getMediaEditLinks()) {
+      if (link.getTitle() == null) {
+        jgen.writeStringField(Constants.JSON_MEDIA_EDIT_LINK, link.getHref());
+      }
+
+      if (link.getInlineEntity() != null) {
+        jgen.writeObjectField(link.getTitle(), link.getInlineEntity());
+      }
+      if (link.getInlineEntitySet() != null) {
+        jgen.writeArrayFieldStart(link.getTitle());
+        for (Entity subEntry : link.getInlineEntitySet().getEntities()) {
+          jgen.writeObject(subEntry);
+        }
+        jgen.writeEndArray();
+      }
+    }
+
+    if (serverMode) {
+      for (Operation operation : entity.getOperations()) {
+        jgen.writeObjectFieldStart("#" + StringUtils.substringAfterLast(operation.getMetadataAnchor(), "#"));
+        jgen.writeStringField(Constants.ATTR_TITLE, operation.getTitle());
+        jgen.writeStringField(Constants.ATTR_TARGET, operation.getTarget().toASCIIString());
+        jgen.writeEndObject();
+      }
+    }
+
+    jgen.writeEndObject();
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonEntitySetDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonEntitySetDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonEntitySetDeserializer.java
new file mode 100644
index 0000000..2fb7b25
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonEntitySetDeserializer.java
@@ -0,0 +1,120 @@
+/*
+ * 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.serialization;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.Annotation;
+import org.apache.olingo.commons.api.data.EntityCollection;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * Reads JSON string into an entity set.
+ * <br/>
+ * If metadata information is available, the corresponding entity fields and content will be populated.
+ */
+public class JsonEntitySetDeserializer extends JsonDeserializer {
+
+  public JsonEntitySetDeserializer(final boolean serverMode) {
+    super(serverMode);
+  }
+
+  protected ResWrap<EntityCollection> doDeserialize(final JsonParser parser) throws IOException {
+
+    final ObjectNode tree = (ObjectNode) parser.getCodec().readTree(parser);
+
+    if (!tree.has(Constants.VALUE)) {
+      return null;
+    }
+
+    final EntityCollection entitySet = new EntityCollection();
+
+    URI contextURL;
+    if (tree.hasNonNull(Constants.JSON_CONTEXT)) {
+      contextURL = URI.create(tree.get(Constants.JSON_CONTEXT).textValue());
+      tree.remove(Constants.JSON_CONTEXT);
+    } else if (tree.hasNonNull(Constants.JSON_METADATA)) {
+      contextURL = URI.create(tree.get(Constants.JSON_METADATA).textValue());
+      tree.remove(Constants.JSON_METADATA);
+    } else {
+      contextURL = null;
+    }
+    if (contextURL != null) {
+      entitySet.setBaseURI(URI.create(StringUtils.substringBefore(contextURL.toASCIIString(), Constants.METADATA)));
+    }
+
+    final String metadataETag;
+    if (tree.hasNonNull(Constants.JSON_METADATA_ETAG)) {
+      metadataETag = tree.get(Constants.JSON_METADATA_ETAG).textValue();
+      tree.remove(Constants.JSON_METADATA_ETAG);
+    } else {
+      metadataETag = null;
+    }
+
+    if (tree.hasNonNull(Constants.JSON_COUNT)) {
+      entitySet.setCount(tree.get(Constants.JSON_COUNT).asInt());
+      tree.remove(Constants.JSON_COUNT);
+    }
+    if (tree.hasNonNull(Constants.JSON_NEXT_LINK)) {
+      entitySet.setNext(URI.create(tree.get(Constants.JSON_NEXT_LINK).textValue()));
+      tree.remove(Constants.JSON_NEXT_LINK);
+    }
+    if (tree.hasNonNull(Constants.JSON_DELTA_LINK)) {
+      entitySet.setDeltaLink(URI.create(tree.get(Constants.JSON_DELTA_LINK).textValue()));
+      tree.remove(Constants.JSON_DELTA_LINK);
+    }
+
+    if (tree.hasNonNull(Constants.VALUE)) {
+      final JsonEntityDeserializer entityDeserializer = new JsonEntityDeserializer(serverMode);
+      for (JsonNode jsonNode : tree.get(Constants.VALUE)) {
+        entitySet.getEntities().add(
+            entityDeserializer.doDeserialize(jsonNode.traverse(parser.getCodec())).getPayload());
+      }
+      tree.remove(Constants.VALUE);
+    }
+
+    // any remaining entry is supposed to be an annotation or is ignored
+    for (final Iterator<Map.Entry<String, JsonNode>> itor = tree.fields(); itor.hasNext();) {
+      final Map.Entry<String, JsonNode> field = itor.next();
+      if (field.getKey().charAt(0) == '@') {
+        final Annotation annotation = new Annotation();
+        annotation.setTerm(field.getKey().substring(1));
+
+        try {
+          value(annotation, field.getValue(), parser.getCodec());
+        } catch (final EdmPrimitiveTypeException e) {
+          throw new IOException(e);
+        }
+        entitySet.getAnnotations().add(annotation);
+      }
+    }
+
+    return new ResWrap<EntityCollection>(contextURL, metadataETag, entitySet);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonEntitySetSerializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonEntitySetSerializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonEntitySetSerializer.java
new file mode 100644
index 0000000..6bcf822
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonEntitySetSerializer.java
@@ -0,0 +1,92 @@
+/*
+ * 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.serialization;
+
+import java.io.IOException;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.Annotation;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntityCollection;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+
+public class JsonEntitySetSerializer extends JsonSerializer {
+
+  public JsonEntitySetSerializer(final boolean serverMode) {
+    super(serverMode);
+  }
+
+  protected void doSerialize(final EntityCollection entitySet, final JsonGenerator jgen)
+      throws IOException, EdmPrimitiveTypeException {
+    doContainerSerialize(new ResWrap<EntityCollection>(null, null, entitySet), jgen);
+  }
+
+  protected void doContainerSerialize(final ResWrap<EntityCollection> container, final JsonGenerator jgen)
+      throws IOException, EdmPrimitiveTypeException {
+
+    final EntityCollection entitySet = container.getPayload();
+
+    jgen.writeStartObject();
+
+    if (serverMode) {
+      if (container.getContextURL() != null) {
+        jgen.writeStringField(Constants.JSON_CONTEXT, container.getContextURL().toASCIIString());
+      }
+
+      if (StringUtils.isNotBlank(container.getMetadataETag())) {
+        jgen.writeStringField(
+            Constants.JSON_METADATA_ETAG,
+            container.getMetadataETag());
+      }
+    }
+
+    if (entitySet.getId() != null) {
+      jgen.writeStringField(Constants.JSON_ID, entitySet.getId().toASCIIString());
+    }
+    jgen.writeNumberField(Constants.JSON_COUNT,
+        entitySet.getCount() == null ? entitySet.getEntities().size() : entitySet.getCount());
+    if (serverMode) {
+      if (entitySet.getNext() != null) {
+        jgen.writeStringField(Constants.JSON_NEXT_LINK,
+            entitySet.getNext().toASCIIString());
+      }
+      if (entitySet.getDeltaLink() != null) {
+        jgen.writeStringField(Constants.JSON_DELTA_LINK,
+            entitySet.getDeltaLink().toASCIIString());
+      }
+    }
+
+    for (Annotation annotation : entitySet.getAnnotations()) {
+      valuable(jgen, annotation, "@" + annotation.getTerm());
+    }
+
+    jgen.writeArrayFieldStart(Constants.VALUE);
+    final JsonEntitySerializer entitySerializer = new JsonEntitySerializer(serverMode);
+    for (Entity entity : entitySet.getEntities()) {
+      entitySerializer.doSerialize(entity, jgen);
+    }
+    jgen.writeEndArray();
+
+    jgen.writeEndObject();
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonGeoValueDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonGeoValueDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonGeoValueDeserializer.java
new file mode 100644
index 0000000..75aab4a
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonGeoValueDeserializer.java
@@ -0,0 +1,262 @@
+/*
+ * 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.serialization;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.GeoUtils;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.geo.Geospatial;
+import org.apache.olingo.commons.api.edm.geo.GeospatialCollection;
+import org.apache.olingo.commons.api.edm.geo.LineString;
+import org.apache.olingo.commons.api.edm.geo.MultiLineString;
+import org.apache.olingo.commons.api.edm.geo.MultiPoint;
+import org.apache.olingo.commons.api.edm.geo.MultiPolygon;
+import org.apache.olingo.commons.api.edm.geo.Point;
+import org.apache.olingo.commons.api.edm.geo.Polygon;
+import org.apache.olingo.commons.api.edm.geo.SRID;
+import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+import org.apache.olingo.commons.core.edm.primitivetype.EdmDouble;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+class JsonGeoValueDeserializer {
+
+  private Point point(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type, final SRID srid) {
+    Point point = null;
+
+    if (itor.hasNext()) {
+      point = new Point(GeoUtils.getDimension(type), srid);
+      try {
+        point.setX(EdmDouble.getInstance().valueOfString(itor.next().asText(), null, null,
+            Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, Double.class));
+        point.setY(EdmDouble.getInstance().valueOfString(itor.next().asText(), null, null,
+            Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, Double.class));
+      } catch (EdmPrimitiveTypeException e) {
+        throw new IllegalArgumentException("While deserializing point coordinates as double", e);
+      }
+    }
+
+    return point;
+  }
+
+  private MultiPoint multipoint(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type, final SRID srid) {
+    final MultiPoint multiPoint;
+
+    if (itor.hasNext()) {
+      final List<Point> points = new ArrayList<Point>();
+      while (itor.hasNext()) {
+        final Iterator<JsonNode> mpItor = itor.next().elements();
+        points.add(point(mpItor, type, srid));
+      }
+      multiPoint = new MultiPoint(GeoUtils.getDimension(type), srid, points);
+    } else {
+      multiPoint = new MultiPoint(GeoUtils.getDimension(type), srid, Collections.<Point> emptyList());
+    }
+
+    return multiPoint;
+  }
+
+  private LineString lineString(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type, final SRID srid) {
+    final LineString lineString;
+
+    if (itor.hasNext()) {
+      final List<Point> points = new ArrayList<Point>();
+      while (itor.hasNext()) {
+        final Iterator<JsonNode> mpItor = itor.next().elements();
+        points.add(point(mpItor, type, srid));
+      }
+      lineString = new LineString(GeoUtils.getDimension(type), srid, points);
+    } else {
+      lineString = new LineString(GeoUtils.getDimension(type), srid, Collections.<Point> emptyList());
+    }
+
+    return lineString;
+  }
+
+  private MultiLineString multiLineString(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type,
+      final SRID srid) {
+
+    final MultiLineString multiLineString;
+
+    if (itor.hasNext()) {
+      final List<LineString> lineStrings = new ArrayList<LineString>();
+      while (itor.hasNext()) {
+        final Iterator<JsonNode> mlsItor = itor.next().elements();
+        lineStrings.add(lineString(mlsItor, type, srid));
+      }
+      multiLineString = new MultiLineString(GeoUtils.getDimension(type), srid, lineStrings);
+    } else {
+      multiLineString = new MultiLineString(GeoUtils.getDimension(type), srid, Collections.<LineString> emptyList());
+    }
+
+    return multiLineString;
+  }
+
+  private Polygon polygon(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type, final SRID srid) {
+    List<Point> extPoints = null;
+    if (itor.hasNext()) {
+      final Iterator<JsonNode> extItor = itor.next().elements();
+      if (extItor.hasNext()) {
+        extPoints = new ArrayList<Point>();
+        while (extItor.hasNext()) {
+          final Iterator<JsonNode> mpItor = extItor.next().elements();
+          extPoints.add(point(mpItor, type, srid));
+        }
+      }
+    }
+
+    List<Point> intPoints = null;
+    if (itor.hasNext()) {
+      final Iterator<JsonNode> intItor = itor.next().elements();
+      if (intItor.hasNext()) {
+        intPoints = new ArrayList<Point>();
+        while (intItor.hasNext()) {
+          final Iterator<JsonNode> mpItor = intItor.next().elements();
+          intPoints.add(point(mpItor, type, srid));
+        }
+      }
+    }
+
+    return new Polygon(GeoUtils.getDimension(type), srid, intPoints, extPoints);
+  }
+
+  private MultiPolygon multiPolygon(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type, final SRID srid) {
+    final MultiPolygon multiPolygon;
+
+    if (itor.hasNext()) {
+      final List<Polygon> polygons = new ArrayList<Polygon>();
+      while (itor.hasNext()) {
+        final Iterator<JsonNode> mpItor = itor.next().elements();
+        polygons.add(polygon(mpItor, type, srid));
+      }
+      multiPolygon = new MultiPolygon(GeoUtils.getDimension(type), srid, polygons);
+    } else {
+      multiPolygon = new MultiPolygon(GeoUtils.getDimension(type), srid, Collections.<Polygon> emptyList());
+    }
+
+    return multiPolygon;
+  }
+
+  private GeospatialCollection collection(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type,
+      final SRID srid) {
+
+    final GeospatialCollection collection;
+
+    if (itor.hasNext()) {
+      final List<Geospatial> geospatials = new ArrayList<Geospatial>();
+
+      while (itor.hasNext()) {
+        final JsonNode geo = itor.next();
+        final String collItemType = geo.get(Constants.ATTR_TYPE).asText();
+        final String callAsType;
+        if (EdmPrimitiveTypeKind.GeographyCollection.name().equals(collItemType)
+            || EdmPrimitiveTypeKind.GeometryCollection.name().equals(collItemType)) {
+
+          callAsType = collItemType;
+        } else {
+          callAsType = (type == EdmPrimitiveTypeKind.GeographyCollection ? "Geography" : "Geometry")
+              + collItemType;
+        }
+
+        geospatials.add(deserialize(geo, new EdmTypeInfo.Builder().setTypeExpression(callAsType).build()));
+      }
+
+      collection = new GeospatialCollection(GeoUtils.getDimension(type), srid, geospatials);
+    } else {
+      collection = new GeospatialCollection(GeoUtils.getDimension(type), srid, Collections.<Geospatial> emptyList());
+    }
+
+    return collection;
+  }
+
+  public Geospatial deserialize(final JsonNode node, final EdmTypeInfo typeInfo) {
+    final EdmPrimitiveTypeKind actualType;
+    if ((typeInfo.getPrimitiveTypeKind() == EdmPrimitiveTypeKind.Geography
+        || typeInfo.getPrimitiveTypeKind() == EdmPrimitiveTypeKind.Geometry)
+        && node.has(Constants.ATTR_TYPE)) {
+
+      String nodeType = node.get(Constants.ATTR_TYPE).asText();
+      if (nodeType.startsWith("Geo")) {
+        final int yIdx = nodeType.indexOf('y');
+        nodeType = nodeType.substring(yIdx + 1);
+      }
+      actualType = EdmPrimitiveTypeKind.valueOfFQN(typeInfo.getFullQualifiedName().toString() + nodeType);
+    } else {
+      actualType = typeInfo.getPrimitiveTypeKind();
+    }
+
+    final Iterator<JsonNode> cooItor = node.has(Constants.JSON_COORDINATES)
+        ? node.get(Constants.JSON_COORDINATES).elements()
+            : Collections.<JsonNode> emptyList().iterator();
+
+        SRID srid = null;
+        if (node.has(Constants.JSON_CRS)) {
+          srid = SRID.valueOf(
+              node.get(Constants.JSON_CRS).get(Constants.PROPERTIES).get(Constants.JSON_NAME).asText().split(":")[1]);
+        }
+
+        Geospatial value = null;
+        switch (actualType) {
+        case GeographyPoint:
+        case GeometryPoint:
+          value = point(cooItor, actualType, srid);
+          break;
+
+        case GeographyMultiPoint:
+        case GeometryMultiPoint:
+          value = multipoint(cooItor, actualType, srid);
+          break;
+
+        case GeographyLineString:
+        case GeometryLineString:
+          value = lineString(cooItor, actualType, srid);
+          break;
+
+        case GeographyMultiLineString:
+        case GeometryMultiLineString:
+          value = multiLineString(cooItor, actualType, srid);
+          break;
+
+        case GeographyPolygon:
+        case GeometryPolygon:
+          value = polygon(cooItor, actualType, srid);
+          break;
+
+        case GeographyMultiPolygon:
+        case GeometryMultiPolygon:
+          value = multiPolygon(cooItor, actualType, srid);
+          break;
+
+        case GeographyCollection:
+        case GeometryCollection:
+          value = collection(node.get(Constants.JSON_GEOMETRIES).elements(), actualType, srid);
+          break;
+
+        default:
+        }
+
+        return value;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonGeoValueSerializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonGeoValueSerializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonGeoValueSerializer.java
new file mode 100644
index 0000000..12ac4f5
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonGeoValueSerializer.java
@@ -0,0 +1,184 @@
+/*
+ * 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.serialization;
+
+import java.io.IOException;
+
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.geo.ComposedGeospatial;
+import org.apache.olingo.commons.api.edm.geo.Geospatial;
+import org.apache.olingo.commons.api.edm.geo.GeospatialCollection;
+import org.apache.olingo.commons.api.edm.geo.LineString;
+import org.apache.olingo.commons.api.edm.geo.MultiLineString;
+import org.apache.olingo.commons.api.edm.geo.MultiPoint;
+import org.apache.olingo.commons.api.edm.geo.MultiPolygon;
+import org.apache.olingo.commons.api.edm.geo.Point;
+import org.apache.olingo.commons.api.edm.geo.Polygon;
+import org.apache.olingo.commons.api.edm.geo.SRID;
+import org.apache.olingo.commons.core.edm.primitivetype.EdmDouble;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+
+class JsonGeoValueSerializer {
+
+  private void srid(final JsonGenerator jgen, final SRID srid) throws IOException {
+    jgen.writeObjectFieldStart(Constants.JSON_CRS);
+    jgen.writeStringField(Constants.ATTR_TYPE, Constants.JSON_NAME);
+    jgen.writeObjectFieldStart(Constants.PROPERTIES);
+    jgen.writeStringField(Constants.JSON_NAME, "EPSG:" + srid.toString());
+    jgen.writeEndObject();
+    jgen.writeEndObject();
+  }
+
+  private void point(final JsonGenerator jgen, final Point point) throws IOException {
+    try {
+      jgen.writeNumber(EdmDouble.getInstance().valueToString(point.getX(), null, null,
+          Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null));
+      jgen.writeNumber(EdmDouble.getInstance().valueToString(point.getY(), null, null,
+          Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null));
+    } catch (EdmPrimitiveTypeException e) {
+      throw new IllegalArgumentException("While serializing point coordinates as double", e);
+    }
+  }
+
+  private void multipoint(final JsonGenerator jgen, final MultiPoint multiPoint) throws IOException {
+    for (Point point : multiPoint) {
+      jgen.writeStartArray();
+      point(jgen, point);
+      jgen.writeEndArray();
+    }
+  }
+
+  private void lineString(final JsonGenerator jgen, final ComposedGeospatial<Point> lineString) throws IOException {
+    for (Point point : lineString) {
+      jgen.writeStartArray();
+      point(jgen, point);
+      jgen.writeEndArray();
+    }
+  }
+
+  private void multiLineString(final JsonGenerator jgen, final MultiLineString multiLineString) throws IOException {
+    for (LineString lineString : multiLineString) {
+      jgen.writeStartArray();
+      lineString(jgen, lineString);
+      jgen.writeEndArray();
+    }
+  }
+
+  private void polygon(final JsonGenerator jgen, final Polygon polygon) throws IOException {
+    if (!polygon.getExterior().isEmpty()) {
+      jgen.writeStartArray();
+      lineString(jgen, polygon.getExterior());
+      jgen.writeEndArray();
+    }
+    if (!polygon.getInterior().isEmpty()) {
+      jgen.writeStartArray();
+      lineString(jgen, polygon.getInterior());
+      jgen.writeEndArray();
+    }
+  }
+
+  private void multiPolygon(final JsonGenerator jgen, final MultiPolygon multiPolygon) throws IOException {
+    for (Polygon polygon : multiPolygon) {
+      jgen.writeStartArray();
+      polygon(jgen, polygon);
+      jgen.writeEndArray();
+    }
+  }
+
+  private void collection(final JsonGenerator jgen, final GeospatialCollection collection) throws IOException {
+    jgen.writeArrayFieldStart(Constants.JSON_GEOMETRIES);
+    for (Geospatial geospatial : collection) {
+      jgen.writeStartObject();
+      serialize(jgen, geospatial);
+      jgen.writeEndObject();
+    }
+    jgen.writeEndArray();
+  }
+
+  public void serialize(final JsonGenerator jgen, final Geospatial value) throws IOException {
+    if (value.getEdmPrimitiveTypeKind().equals(EdmPrimitiveTypeKind.GeographyCollection)
+        || value.getEdmPrimitiveTypeKind().equals(EdmPrimitiveTypeKind.GeometryCollection)) {
+
+      jgen.writeStringField(Constants.ATTR_TYPE, EdmPrimitiveTypeKind.GeometryCollection.name());
+    } else {
+      final int yIdx = value.getEdmPrimitiveTypeKind().name().indexOf('y');
+      final String itemType = value.getEdmPrimitiveTypeKind().name().substring(yIdx + 1);
+      jgen.writeStringField(Constants.ATTR_TYPE, itemType);
+    }
+
+    switch (value.getEdmPrimitiveTypeKind()) {
+    case GeographyPoint:
+    case GeometryPoint:
+      jgen.writeArrayFieldStart(Constants.JSON_COORDINATES);
+      point(jgen, (Point) value);
+      jgen.writeEndArray();
+      break;
+
+    case GeographyMultiPoint:
+    case GeometryMultiPoint:
+      jgen.writeArrayFieldStart(Constants.JSON_COORDINATES);
+      multipoint(jgen, (MultiPoint) value);
+      jgen.writeEndArray();
+      break;
+
+    case GeographyLineString:
+    case GeometryLineString:
+      jgen.writeArrayFieldStart(Constants.JSON_COORDINATES);
+      lineString(jgen, (LineString) value);
+      jgen.writeEndArray();
+      break;
+
+    case GeographyMultiLineString:
+    case GeometryMultiLineString:
+      jgen.writeArrayFieldStart(Constants.JSON_COORDINATES);
+      multiLineString(jgen, (MultiLineString) value);
+      jgen.writeEndArray();
+      break;
+
+    case GeographyPolygon:
+    case GeometryPolygon:
+      jgen.writeArrayFieldStart(Constants.JSON_COORDINATES);
+      polygon(jgen, (Polygon) value);
+      jgen.writeEndArray();
+      break;
+
+    case GeographyMultiPolygon:
+    case GeometryMultiPolygon:
+      jgen.writeArrayFieldStart(Constants.JSON_COORDINATES);
+      multiPolygon(jgen, (MultiPolygon) value);
+      jgen.writeEndArray();
+      break;
+
+    case GeographyCollection:
+    case GeometryCollection:
+      collection(jgen, (GeospatialCollection) value);
+      break;
+
+    default:
+    }
+
+    if (value.getSrid() != null && value.getSrid().isNotDefault()) {
+      srid(jgen, value.getSrid());
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonODataErrorDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonODataErrorDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonODataErrorDeserializer.java
new file mode 100644
index 0000000..2d1f59f
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonODataErrorDeserializer.java
@@ -0,0 +1,87 @@
+/*
+ * 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.serialization;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.ODataError;
+import org.apache.olingo.commons.api.ODataErrorDetail;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+public class JsonODataErrorDeserializer extends JsonDeserializer {
+
+  public JsonODataErrorDeserializer(final boolean serverMode) {
+    super(serverMode);
+  }
+
+  protected ODataError doDeserialize(final JsonParser parser) throws IOException {
+
+    final ODataError error = new ODataError();
+
+    final ObjectNode tree = parser.getCodec().readTree(parser);
+    if (tree.has(Constants.JSON_ERROR)) {
+      final JsonNode errorNode = tree.get(Constants.JSON_ERROR);
+
+      if (errorNode.has(Constants.ERROR_CODE)) {
+        error.setCode(errorNode.get(Constants.ERROR_CODE).textValue());
+      }
+      if (errorNode.has(Constants.ERROR_MESSAGE)) {
+        final JsonNode message = errorNode.get(Constants.ERROR_MESSAGE);
+        if (message.isValueNode()) {
+          error.setMessage(message.textValue());
+        } else if (message.isObject()) {
+          error.setMessage(message.get(Constants.VALUE).asText());
+        }
+      }
+      if (errorNode.has(Constants.ERROR_TARGET)) {
+        error.setTarget(errorNode.get(Constants.ERROR_TARGET).textValue());
+      }
+      if (errorNode.hasNonNull(Constants.ERROR_DETAILS)) {
+        List<ODataErrorDetail> details = new ArrayList<ODataErrorDetail>();
+        JsonODataErrorDetailDeserializer detailDeserializer = new JsonODataErrorDetailDeserializer(serverMode);
+        for (JsonNode jsonNode : errorNode.get(Constants.ERROR_DETAILS)) {
+          details.add(detailDeserializer.doDeserialize(jsonNode.traverse(parser.getCodec()))
+              .getPayload());
+        }
+
+        error.setDetails(details);
+      }
+      if (errorNode.hasNonNull(Constants.ERROR_INNERERROR)) {
+        HashMap<String, String> innerErrorMap = new HashMap<String, String>();
+        final JsonNode innerError = errorNode.get(Constants.ERROR_INNERERROR);
+        for (final Iterator<String> itor = innerError.fieldNames(); itor.hasNext();) {
+          final String keyTmp = itor.next();
+          final String val = innerError.get(keyTmp).toString();
+          innerErrorMap.put(keyTmp, val);
+        }
+        error.setInnerError(innerErrorMap);
+      }
+    }
+
+    return error;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonODataErrorDetailDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonODataErrorDetailDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonODataErrorDetailDeserializer.java
new file mode 100644
index 0000000..27a8eb9
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonODataErrorDetailDeserializer.java
@@ -0,0 +1,58 @@
+/*
+ * 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.serialization;
+
+import java.io.IOException;
+import java.net.URI;
+
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.ODataErrorDetail;
+import org.apache.olingo.commons.api.data.ResWrap;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.JsonNode;
+
+public class JsonODataErrorDetailDeserializer extends JsonDeserializer {
+
+  public JsonODataErrorDetailDeserializer(final boolean serverMode) {
+    super(serverMode);
+  }
+
+  protected ResWrap<ODataErrorDetail> doDeserialize(final JsonParser parser) throws IOException {
+
+    final ODataErrorDetail error = new ODataErrorDetail();
+    final JsonNode errorNode = parser.getCodec().readTree(parser);
+    if (errorNode.has(Constants.ERROR_CODE)) {
+      error.setCode(errorNode.get(Constants.ERROR_CODE).textValue());
+    }
+    if (errorNode.has(Constants.ERROR_MESSAGE)) {
+      final JsonNode message = errorNode.get(Constants.ERROR_MESSAGE);
+      if (message.isValueNode()) {
+        error.setMessage(message.textValue());
+      } else if (message.isObject()) {
+        error.setMessage(message.get(Constants.VALUE).asText());
+      }
+    }
+    if (errorNode.has(Constants.ERROR_TARGET)) {
+      error.setTarget(errorNode.get(Constants.ERROR_TARGET).textValue());
+    }
+
+    return new ResWrap<ODataErrorDetail>((URI) null, null, error);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonPropertyDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonPropertyDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonPropertyDeserializer.java
new file mode 100644
index 0000000..3a59650
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonPropertyDeserializer.java
@@ -0,0 +1,114 @@
+/*
+ * 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.serialization;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.Annotation;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.data.ValueType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * Parse JSON string into <tt>Property</tt>.
+ */
+public class JsonPropertyDeserializer extends JsonDeserializer {
+
+  public JsonPropertyDeserializer(final boolean serverMode) {
+    super(serverMode);
+  }
+
+  protected ResWrap<Property> doDeserialize(final JsonParser parser) throws IOException {
+
+    final ObjectNode tree = parser.getCodec().readTree(parser);
+
+    final String metadataETag;
+    final URI contextURL;
+    final Property property = new Property();
+
+    if (tree.hasNonNull(Constants.JSON_METADATA_ETAG)) {
+      metadataETag = tree.get(Constants.JSON_METADATA_ETAG).textValue();
+      tree.remove(Constants.JSON_METADATA_ETAG);
+    } else {
+      metadataETag = null;
+    }
+
+    if (tree.hasNonNull(Constants.JSON_CONTEXT)) {
+      contextURL = URI.create(tree.get(Constants.JSON_CONTEXT).textValue());
+      property.setName(StringUtils.substringAfterLast(contextURL.toASCIIString(), "/"));
+      tree.remove(Constants.JSON_CONTEXT);
+    } else if (tree.hasNonNull(Constants.JSON_METADATA)) {
+      contextURL = URI.create(tree.get(Constants.JSON_METADATA).textValue());
+      property.setType(new EdmTypeInfo.Builder().
+          setTypeExpression(StringUtils.substringAfterLast(contextURL.toASCIIString(), "#")).build().internal());
+      tree.remove(Constants.JSON_METADATA);
+    } else {
+      contextURL = null;
+    }
+
+    if (tree.has(Constants.JSON_TYPE)) {
+      property.setType(new EdmTypeInfo.Builder().setTypeExpression(tree.get(Constants.JSON_TYPE).textValue()).build()
+          .internal());
+      tree.remove(Constants.JSON_TYPE);
+    }
+
+    if (tree.has(Constants.JSON_NULL) && tree.get(Constants.JSON_NULL).asBoolean()) {
+      property.setValue(ValueType.PRIMITIVE, null);
+      tree.remove(Constants.JSON_NULL);
+    }
+
+    if (property.getValue() == null) {
+      try {
+        value(property, tree.has(Constants.VALUE) ? tree.get(Constants.VALUE) : tree, parser.getCodec());
+      } catch (final EdmPrimitiveTypeException e) {
+        throw new IOException(e);
+      }
+      tree.remove(Constants.VALUE);
+    }
+
+    // any remaining entry is supposed to be an annotation or is ignored
+    for (final Iterator<Map.Entry<String, JsonNode>> itor = tree.fields(); itor.hasNext();) {
+      final Map.Entry<String, JsonNode> field = itor.next();
+      if (field.getKey().charAt(0) == '@') {
+        final Annotation annotation = new Annotation();
+        annotation.setTerm(field.getKey().substring(1));
+
+        try {
+          value(annotation, field.getValue(), parser.getCodec());
+        } catch (final EdmPrimitiveTypeException e) {
+          throw new IOException(e);
+        }
+        property.getAnnotations().add(annotation);
+      }
+    }
+
+    return new ResWrap<Property>(contextURL, metadataETag, property);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonPropertySerializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonPropertySerializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonPropertySerializer.java
new file mode 100644
index 0000000..11c6821
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonPropertySerializer.java
@@ -0,0 +1,93 @@
+/*
+ * 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.serialization;
+
+import java.io.IOException;
+import java.net.URI;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.Annotation;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+
+/**
+ * Writes out JSON string from <tt>PropertyImpl</tt>.
+ */
+public class JsonPropertySerializer extends JsonSerializer {
+
+  public JsonPropertySerializer(final boolean serverMode) {
+    super(serverMode);
+  }
+
+  protected void doSerialize(final Property property, final JsonGenerator jgen)
+      throws IOException, EdmPrimitiveTypeException {
+    doContainerSerialize(new ResWrap<Property>((URI) null, null, property), jgen);
+  }
+
+  protected void doContainerSerialize(final ResWrap<Property> container, final JsonGenerator jgen)
+      throws IOException, EdmPrimitiveTypeException {
+
+    final Property property = container.getPayload();
+
+    jgen.writeStartObject();
+
+    if (serverMode && container.getContextURL() != null) {
+      jgen.writeStringField(Constants.JSON_CONTEXT, container.getContextURL().toASCIIString());
+    }
+
+    if (StringUtils.isNotBlank(property.getType())) {
+      jgen.writeStringField(Constants.JSON_TYPE,
+          new EdmTypeInfo.Builder().setTypeExpression(property.getType()).build().external());
+    }
+
+    for (Annotation annotation : property.getAnnotations()) {
+      valuable(jgen, annotation, "@" + annotation.getTerm());
+    }
+
+    if (property.isNull()) {
+      jgen.writeBooleanField(Constants.JSON_NULL, true);
+    } else if (property.isGeospatial() || property.isCollection()) {
+      valuable(jgen, property, Constants.VALUE);
+    } else if (property.isPrimitive()) {
+      final EdmTypeInfo typeInfo = property.getType() == null
+          ? null
+              : new EdmTypeInfo.Builder().setTypeExpression(property.getType()).build();
+
+      jgen.writeFieldName(Constants.VALUE);
+      primitiveValue(jgen, typeInfo, property.asPrimitive());
+    } else if (property.isEnum()) {
+      jgen.writeStringField(Constants.VALUE, property.asEnum().toString());
+    } else if (property.isComplex()) {
+      for (Property cproperty : property.asComplex().getValue()) {
+        valuable(jgen, cproperty, cproperty.getName());
+      }
+    } else if (property.isComplex()) {
+      for (Property cproperty : property.asComplex().getValue()) {
+        valuable(jgen, cproperty, cproperty.getName());
+      }
+    }
+
+    jgen.writeEndObject();
+  }
+}


[06/39] olingo-odata4 git commit: [OLINGO-642] an OSGI server sample using build-helper-maven-plugin

Posted by ch...@apache.org.
[OLINGO-642] an OSGI server sample using build-helper-maven-plugin


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

Branch: refs/heads/IEE754Compatible
Commit: 9e755634d7ba9f1abc8b23302498bb519adfeab5
Parents: d53574d
Author: Michael Bolz <mi...@sap.com>
Authored: Wed Jun 10 22:02:36 2015 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Wed Jun 10 22:02:39 2015 +0200

----------------------------------------------------------------------
 samples/osgi/server/pom.xml                     | 175 +++++----
 .../olingo/server/sample/CarsServlet.java       |  67 ----
 .../olingo/server/sample/data/DataProvider.java | 171 ---------
 .../sample/edmprovider/CarsEdmProvider.java     | 183 ----------
 .../server/sample/processor/CarsProcessor.java  | 355 -------------------
 .../server/src/main/resources/META-INF/LICENSE  | 331 -----------------
 .../src/main/resources/simplelogger.properties  |  20 --
 .../osgi/server/src/main/webapp/WEB-INF/web.xml |  42 ---
 .../osgi/server/src/main/webapp/css/olingo.css  |  91 -----
 .../src/main/webapp/img/OlingoOrangeTM.png      | Bin 113360 -> 0 bytes
 samples/osgi/server/src/main/webapp/index.jsp   |  56 ---
 11 files changed, 97 insertions(+), 1394 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/9e755634/samples/osgi/server/pom.xml
----------------------------------------------------------------------
diff --git a/samples/osgi/server/pom.xml b/samples/osgi/server/pom.xml
index cb1afc0..5f2a931 100644
--- a/samples/osgi/server/pom.xml
+++ b/samples/osgi/server/pom.xml
@@ -1,93 +1,112 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements. See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership. The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License. You may obtain a copy of the License at
+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
+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.
+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.
 
 -->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
 
-    <artifactId>odata-server-osgi-sample</artifactId>
-    <packaging>bundle</packaging>
-    <name>${project.artifactId}</name>
+  <artifactId>odata-server-osgi-sample</artifactId>
+  <packaging>bundle</packaging>
+  <name>${project.artifactId}</name>
 
-    <parent>
-        <groupId>org.apache.olingo</groupId>
-        <artifactId>odata-samples</artifactId>
-        <version>4.0.0-SNAPSHOT</version>
-        <relativePath>../..</relativePath>
-    </parent>
+  <parent>
+    <groupId>org.apache.olingo</groupId>
+    <artifactId>odata-samples</artifactId>
+    <version>4.0.0-SNAPSHOT</version>
+    <relativePath>../..</relativePath>
+  </parent>
 
-    <dependencies>
-        <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-servlet_3.0_spec</artifactId>
-            <version>1.0</version>
-        </dependency>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-servlet_3.0_spec</artifactId>
+      <version>1.0</version>
+    </dependency>
 
-        <dependency>
-            <groupId>org.apache.olingo</groupId>
-            <artifactId>odata-server-api</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.olingo</groupId>
-            <artifactId>odata-server-core</artifactId>
-            <version>${project.version}</version>
-        </dependency>
+    <dependency>
+      <groupId>org.apache.olingo</groupId>
+      <artifactId>odata-server-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.olingo</groupId>
+      <artifactId>odata-server-core</artifactId>
+      <version>${project.version}</version>
+    </dependency>
 
-        <dependency>
-            <groupId>org.apache.olingo</groupId>
-            <artifactId>odata-commons-api</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.olingo</groupId>
-            <artifactId>odata-commons-core</artifactId>
-            <version>${project.version}</version>
-        </dependency>
+    <dependency>
+      <groupId>org.apache.olingo</groupId>
+      <artifactId>odata-commons-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.olingo</groupId>
+      <artifactId>odata-commons-core</artifactId>
+      <version>${project.version}</version>
+    </dependency>
 
-    </dependencies>
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-                <extensions>true</extensions>
-                <configuration>
-                    <instructions>
-                        <Export-Package>
-                        </Export-Package>
-                        <Import-Package>
-                            org.apache.olingo.server.api*,
-                            org.apache.catalina;resolution:=optional,
-                            org.apache.catalina.comet;resolution:=optional,
-                            org.eclipse.jetty.continuation;resolution:=optional,
-                            org.eclipse.jetty.server;resolution:=optional,
-                            org.eclipse.jetty.util.ssl;resolution:=optional,
-                            *
-                        </Import-Package>
-                        <_wab>src/main/webapp/</_wab>
-                        <Web-ContextPath>olingo-cars</Web-ContextPath>
-                    </instructions>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>add-source</id>
+            <phase>generate-sources</phase>
+            <goals>
+              <goal>add-source</goal>
+            </goals>
+            <configuration>
+              <sources>
+                <source>${basedir}/../../server/src/main</source>
+              </sources>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Export-Package>
+            </Export-Package>
+            <Import-Package>
+              org.apache.olingo.server.api*,
+              org.apache.catalina;resolution:=optional,
+              org.apache.catalina.comet;resolution:=optional,
+              org.eclipse.jetty.continuation;resolution:=optional,
+              org.eclipse.jetty.server;resolution:=optional,
+              org.eclipse.jetty.util.ssl;resolution:=optional,
+              *
+            </Import-Package>
+            <_wab>${basedir}/../../server/src/main/webapp/</_wab>
+            <Web-ContextPath>olingo-cars</Web-ContextPath>
+          </instructions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
 </project>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/9e755634/samples/osgi/server/src/main/java/org/apache/olingo/server/sample/CarsServlet.java
----------------------------------------------------------------------
diff --git a/samples/osgi/server/src/main/java/org/apache/olingo/server/sample/CarsServlet.java b/samples/osgi/server/src/main/java/org/apache/olingo/server/sample/CarsServlet.java
deleted file mode 100644
index f6a17dc..0000000
--- a/samples/osgi/server/src/main/java/org/apache/olingo/server/sample/CarsServlet.java
+++ /dev/null
@@ -1,67 +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.server.sample;
-
-import java.io.IOException;
-import java.util.ArrayList;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-
-import org.apache.olingo.server.api.OData;
-import org.apache.olingo.server.api.ODataHttpHandler;
-import org.apache.olingo.server.api.ServiceMetadata;
-import org.apache.olingo.server.api.edmx.EdmxReference;
-import org.apache.olingo.server.sample.data.DataProvider;
-import org.apache.olingo.server.sample.edmprovider.CarsEdmProvider;
-import org.apache.olingo.server.sample.processor.CarsProcessor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class CarsServlet extends HttpServlet {
-
-  private static final long serialVersionUID = 1L;
-  private static final Logger LOG = LoggerFactory.getLogger(CarsServlet.class);
-
-  @Override
-  protected void service(final HttpServletRequest req, final HttpServletResponse resp)
-      throws ServletException, IOException {
-    try {
-      HttpSession session = req.getSession(true);
-      DataProvider dataProvider = (DataProvider) session.getAttribute(DataProvider.class.getName());
-      if (dataProvider == null) {
-        dataProvider = new DataProvider();
-        session.setAttribute(DataProvider.class.getName(), dataProvider);
-        LOG.info("Created new data provider.");
-      }
-
-      OData odata = OData.newInstance();
-      ServiceMetadata edm = odata.createServiceMetadata(new CarsEdmProvider(), new ArrayList<EdmxReference>());
-      ODataHttpHandler handler = odata.createHandler(edm);
-      handler.register(new CarsProcessor(dataProvider));
-      handler.process(req, resp);
-    } catch (RuntimeException e) {
-      LOG.error("Server Error", e);
-      throw new ServletException(e);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/9e755634/samples/osgi/server/src/main/java/org/apache/olingo/server/sample/data/DataProvider.java
----------------------------------------------------------------------
diff --git a/samples/osgi/server/src/main/java/org/apache/olingo/server/sample/data/DataProvider.java b/samples/osgi/server/src/main/java/org/apache/olingo/server/sample/data/DataProvider.java
deleted file mode 100644
index 69a4530..0000000
--- a/samples/osgi/server/src/main/java/org/apache/olingo/server/sample/data/DataProvider.java
+++ /dev/null
@@ -1,171 +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.server.sample.data;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.apache.olingo.commons.api.ODataException;
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntityCollection;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.data.ValueType;
-import org.apache.olingo.commons.api.data.ComplexValue;
-import org.apache.olingo.commons.api.edm.EdmEntitySet;
-import org.apache.olingo.commons.api.edm.EdmEntityType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.edm.EdmProperty;
-import org.apache.olingo.server.api.uri.UriParameter;
-import org.apache.olingo.server.sample.edmprovider.CarsEdmProvider;
-
-public class DataProvider {
-
-  private final Map<String, EntityCollection> data;
-
-  public DataProvider() {
-    data = new HashMap<String, EntityCollection>();
-    data.put("Cars", createCars());
-    data.put("Manufacturers", createManufacturers());
-  }
-
-  public EntityCollection readAll(EdmEntitySet edmEntitySet) {
-    return data.get(edmEntitySet.getName());
-  }
-
-  public Entity read(final EdmEntitySet edmEntitySet, final List<UriParameter> keys) throws DataProviderException {
-    final EdmEntityType entityType = edmEntitySet.getEntityType();
-    final EntityCollection entitySet = data.get(edmEntitySet.getName());
-    if (entitySet == null) {
-      return null;
-    } else {
-      try {
-        for (final Entity entity : entitySet.getEntities()) {
-          boolean found = true;
-          for (final UriParameter key : keys) {
-            final EdmProperty property = (EdmProperty) entityType.getProperty(key.getName());
-            final EdmPrimitiveType type = (EdmPrimitiveType) property.getType();
-            if (!type.valueToString(entity.getProperty(key.getName()).getValue(),
-                property.isNullable(), property.getMaxLength(), property.getPrecision(), property.getScale(),
-                property.isUnicode())
-                .equals(key.getText())) {
-              found = false;
-              break;
-            }
-          }
-          if (found) {
-            return entity;
-          }
-        }
-        return null;
-      } catch (final EdmPrimitiveTypeException e) {
-        throw new DataProviderException("Wrong key!", e);
-      }
-    }
-  }
-
-  public static class DataProviderException extends ODataException {
-    private static final long serialVersionUID = 5098059649321796156L;
-
-    public DataProviderException(String message, Throwable throwable) {
-      super(message, throwable);
-    }
-
-    public DataProviderException(String message) {
-      super(message);
-    }
-  }
-
-  private EntityCollection createCars() {
-    EntityCollection entitySet = new EntityCollection();
-
-    entitySet.getEntities().add(new Entity()
-        .addProperty(createPrimitive("Id", 1))
-        .addProperty(createPrimitive("Model", "F1 W03"))
-        .addProperty(createPrimitive("ModelYear", "2012"))
-        .addProperty(createPrimitive("Price", 189189.43))
-        .addProperty(createPrimitive("Currency", "EUR")));
-
-    entitySet.getEntities().add(new Entity()
-        .addProperty(createPrimitive("Id", 2))
-        .addProperty(createPrimitive("Model", "F1 W04"))
-        .addProperty(createPrimitive("ModelYear", "2013"))
-        .addProperty(createPrimitive("Price", 199999.99))
-        .addProperty(createPrimitive("Currency", "EUR")));
-
-    entitySet.getEntities().add(new Entity()
-        .addProperty(createPrimitive("Id", 3))
-        .addProperty(createPrimitive("Model", "F2012"))
-        .addProperty(createPrimitive("ModelYear", "2012"))
-        .addProperty(createPrimitive("Price", 137285.33))
-        .addProperty(createPrimitive("Currency", "EUR")));
-
-    entitySet.getEntities().add(new Entity()
-        .addProperty(createPrimitive("Id", 4))
-        .addProperty(createPrimitive("Model", "F2013"))
-        .addProperty(createPrimitive("ModelYear", "2013"))
-        .addProperty(createPrimitive("Price", 145285.00))
-        .addProperty(createPrimitive("Currency", "EUR")));
-
-    entitySet.getEntities().add(new Entity()
-        .addProperty(createPrimitive("Id", 5))
-        .addProperty(createPrimitive("Model", "F1 W02"))
-        .addProperty(createPrimitive("ModelYear", "2011"))
-        .addProperty(createPrimitive("Price", 167189.00))
-        .addProperty(createPrimitive("Currency", "EUR")));
-
-    for (Entity entity:entitySet.getEntities()) {
-      entity.setType(CarsEdmProvider.ET_CAR.getFullQualifiedNameAsString());
-    }
-    return entitySet;
-  }
-
-  private EntityCollection createManufacturers() {
-    EntityCollection entitySet = new EntityCollection();
-
-    entitySet.getEntities().add(new Entity()
-        .addProperty(createPrimitive("Id", 1))
-        .addProperty(createPrimitive("Name", "Star Powered Racing"))
-        .addProperty(createAddress("Star Street 137", "Stuttgart", "70173", "Germany")));
-
-    entitySet.getEntities().add(new Entity()
-        .addProperty(createPrimitive("Id", 2))
-        .addProperty(createPrimitive("Name", "Horse Powered Racing"))
-        .addProperty(createAddress("Horse Street 1", "Maranello", "41053", "Italy")));
-
-    for (Entity entity:entitySet.getEntities()) {
-      entity.setType(CarsEdmProvider.ET_MANUFACTURER.getFullQualifiedNameAsString());
-    }
-    return entitySet;
-  }
-
-  private Property createAddress(final String street, final String city, final String zipCode, final String country) {
-    ComplexValue complexValue=new ComplexValue();
-    List<Property> addressProperties = complexValue.getValue();
-    addressProperties.add(createPrimitive("Street", street));
-    addressProperties.add(createPrimitive("City", city));
-    addressProperties.add(createPrimitive("ZipCode", zipCode));
-    addressProperties.add(createPrimitive("Country", country));
-    return new Property(null, "Address", ValueType.COMPLEX, complexValue);
-  }
-
-  private Property createPrimitive(final String name, final Object value) {
-    return new Property(null, name, ValueType.PRIMITIVE, value);
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/9e755634/samples/osgi/server/src/main/java/org/apache/olingo/server/sample/edmprovider/CarsEdmProvider.java
----------------------------------------------------------------------
diff --git a/samples/osgi/server/src/main/java/org/apache/olingo/server/sample/edmprovider/CarsEdmProvider.java b/samples/osgi/server/src/main/java/org/apache/olingo/server/sample/edmprovider/CarsEdmProvider.java
deleted file mode 100644
index 4d3ba9d..0000000
--- a/samples/osgi/server/src/main/java/org/apache/olingo/server/sample/edmprovider/CarsEdmProvider.java
+++ /dev/null
@@ -1,183 +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.server.sample.edmprovider;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.olingo.commons.api.ODataException;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.edm.provider.CsdlAbstractEdmProvider;
-import org.apache.olingo.commons.api.edm.provider.CsdlComplexType;
-import org.apache.olingo.commons.api.edm.provider.CsdlEntityContainer;
-import org.apache.olingo.commons.api.edm.provider.CsdlEntityContainerInfo;
-import org.apache.olingo.commons.api.edm.provider.CsdlEntitySet;
-import org.apache.olingo.commons.api.edm.provider.CsdlEntityType;
-import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty;
-import org.apache.olingo.commons.api.edm.provider.CsdlNavigationPropertyBinding;
-import org.apache.olingo.commons.api.edm.provider.CsdlProperty;
-import org.apache.olingo.commons.api.edm.provider.CsdlPropertyRef;
-import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
-
-public class CarsEdmProvider extends CsdlAbstractEdmProvider {
-
-  // Service Namespace
-  public static final String NAMESPACE = "olingo.odata.sample";
-
-  // EDM Container
-  public static final String CONTAINER_NAME = "Container";
-  public static final FullQualifiedName CONTAINER_FQN = new FullQualifiedName(NAMESPACE, CONTAINER_NAME);
-
-  // Entity Types Names
-  public static final FullQualifiedName ET_CAR = new FullQualifiedName(NAMESPACE, "Car");
-  public static final FullQualifiedName ET_MANUFACTURER = new FullQualifiedName(NAMESPACE, "Manufacturer");
-
-  // Complex Type Names
-  public static final FullQualifiedName CT_ADDRESS = new FullQualifiedName(NAMESPACE, "Address");
-
-  // Entity Set Names
-  public static final String ES_CARS_NAME = "Cars";
-  public static final String ES_MANUFACTURER_NAME = "Manufacturers";
-
-  @Override
-  public CsdlEntityType getEntityType(final FullQualifiedName entityTypeName) throws ODataException {
-    if (ET_CAR.equals(entityTypeName)) {
-      return new CsdlEntityType()
-          .setName(ET_CAR.getName())
-          .setKey(Arrays.asList(
-              new CsdlPropertyRef().setName("Id")))
-          .setProperties(
-              Arrays.asList(
-                  new CsdlProperty().setName("Id").setType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName()),
-                  new CsdlProperty().setName("Model").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()),
-                  new CsdlProperty().setName("ModelYear").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName())
-                      .setMaxLength(4),
-                  new CsdlProperty().setName("Price").setType(EdmPrimitiveTypeKind.Decimal.getFullQualifiedName())
-                      .setScale(2),
-                  new CsdlProperty().setName("Currency").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName())
-                      .setMaxLength(3)
-                  )
-          ).setNavigationProperties(Arrays.asList(
-              new CsdlNavigationProperty().setName("Manufacturer").setType(ET_MANUFACTURER)
-              )
-          );
-
-    } else if (ET_MANUFACTURER.equals(entityTypeName)) {
-      return new CsdlEntityType()
-          .setName(ET_MANUFACTURER.getName())
-          .setKey(Arrays.asList(
-              new CsdlPropertyRef().setName("Id")))
-          .setProperties(Arrays.asList(
-              new CsdlProperty().setName("Id").setType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName()),
-              new CsdlProperty().setName("Name").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()),
-              new CsdlProperty().setName("Address").setType(CT_ADDRESS))
-          ).setNavigationProperties(Arrays.asList(
-              new CsdlNavigationProperty().setName("Cars").setType(ET_CAR).setCollection(true)
-              )
-          );
-    }
-
-    return null;
-  }
-
-  public CsdlComplexType getComplexType(final FullQualifiedName complexTypeName) throws ODataException {
-    if (CT_ADDRESS.equals(complexTypeName)) {
-      return new CsdlComplexType().setName(CT_ADDRESS.getName()).setProperties(Arrays.asList(
-          new CsdlProperty().setName("Street").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()),
-          new CsdlProperty().setName("City").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()),
-          new CsdlProperty().setName("ZipCode").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()),
-          new CsdlProperty().setName("Country").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName())
-          ));
-    }
-    return null;
-  }
-
-  @Override
-  public CsdlEntitySet getEntitySet(final FullQualifiedName entityContainer, final String entitySetName)
-      throws ODataException {
-    if (CONTAINER_FQN.equals(entityContainer)) {
-      if (ES_CARS_NAME.equals(entitySetName)) {
-        return new CsdlEntitySet()
-            .setName(ES_CARS_NAME)
-            .setType(ET_CAR)
-            .setNavigationPropertyBindings(
-                Arrays.asList(
-                    new CsdlNavigationPropertyBinding().setPath("Manufacturer").setTarget(
-                        CONTAINER_FQN.getFullQualifiedNameAsString() + "/" + ES_MANUFACTURER_NAME)));
-      } else if (ES_MANUFACTURER_NAME.equals(entitySetName)) {
-        return new CsdlEntitySet()
-            .setName(ES_MANUFACTURER_NAME)
-            .setType(ET_MANUFACTURER).setNavigationPropertyBindings(
-                Arrays.asList(
-                    new CsdlNavigationPropertyBinding().setPath("Cars")
-                        .setTarget(CONTAINER_FQN.getFullQualifiedNameAsString() + "/" + ES_CARS_NAME)));
-      }
-    }
-
-    return null;
-  }
-
-  @Override
-  public List<CsdlSchema> getSchemas() throws ODataException {
-    List<CsdlSchema> schemas = new ArrayList<CsdlSchema>();
-    CsdlSchema schema = new CsdlSchema();
-    schema.setNamespace(NAMESPACE);
-    // EntityTypes
-    List<CsdlEntityType> entityTypes = new ArrayList<CsdlEntityType>();
-    entityTypes.add(getEntityType(ET_CAR));
-    entityTypes.add(getEntityType(ET_MANUFACTURER));
-    schema.setEntityTypes(entityTypes);
-
-    // ComplexTypes
-    List<CsdlComplexType> complexTypes = new ArrayList<CsdlComplexType>();
-    complexTypes.add(getComplexType(CT_ADDRESS));
-    schema.setComplexTypes(complexTypes);
-
-    // EntityContainer
-    schema.setEntityContainer(getEntityContainer());
-    schemas.add(schema);
-
-    return schemas;
-  }
-
-  @Override
-  public CsdlEntityContainer getEntityContainer() throws ODataException {
-    CsdlEntityContainer container = new CsdlEntityContainer();
-    container.setName(CONTAINER_FQN.getName());
-
-    // EntitySets
-    List<CsdlEntitySet> entitySets = new ArrayList<CsdlEntitySet>();
-    container.setEntitySets(entitySets);
-    entitySets.add(getEntitySet(CONTAINER_FQN, ES_CARS_NAME));
-    entitySets.add(getEntitySet(CONTAINER_FQN, ES_MANUFACTURER_NAME));
-
-    return container;
-  }
-
-  @Override
-  public CsdlEntityContainerInfo getEntityContainerInfo(final FullQualifiedName entityContainerName)
-          throws ODataException {
-    if (entityContainerName == null || CONTAINER_FQN.equals(entityContainerName)) {
-      return new CsdlEntityContainerInfo().setContainerName(CONTAINER_FQN);
-    }
-    return null;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/9e755634/samples/osgi/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java
----------------------------------------------------------------------
diff --git a/samples/osgi/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java b/samples/osgi/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java
deleted file mode 100644
index 4305415..0000000
--- a/samples/osgi/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java
+++ /dev/null
@@ -1,355 +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.server.sample.processor;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.nio.charset.Charset;
-import java.util.List;
-import java.util.Locale;
-
-import org.apache.olingo.commons.api.data.ContextURL;
-import org.apache.olingo.commons.api.data.ContextURL.Suffix;
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntityCollection;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.edm.EdmComplexType;
-import org.apache.olingo.commons.api.edm.EdmEntitySet;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
-import org.apache.olingo.commons.api.edm.EdmProperty;
-import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.http.HttpContentType;
-import org.apache.olingo.commons.api.http.HttpHeader;
-import org.apache.olingo.commons.api.http.HttpStatusCode;
-import org.apache.olingo.server.api.OData;
-import org.apache.olingo.server.api.ODataApplicationException;
-import org.apache.olingo.server.api.ODataRequest;
-import org.apache.olingo.server.api.ODataResponse;
-import org.apache.olingo.server.api.ServiceMetadata;
-import org.apache.olingo.server.api.deserializer.DeserializerException;
-import org.apache.olingo.server.api.processor.ComplexProcessor;
-import org.apache.olingo.server.api.processor.EntityCollectionProcessor;
-import org.apache.olingo.server.api.processor.EntityProcessor;
-import org.apache.olingo.server.api.processor.PrimitiveProcessor;
-import org.apache.olingo.server.api.processor.PrimitiveValueProcessor;
-import org.apache.olingo.server.api.serializer.ComplexSerializerOptions;
-import org.apache.olingo.server.api.serializer.EntityCollectionSerializerOptions;
-import org.apache.olingo.server.api.serializer.EntitySerializerOptions;
-import org.apache.olingo.server.api.serializer.ODataSerializer;
-import org.apache.olingo.server.api.serializer.PrimitiveSerializerOptions;
-import org.apache.olingo.server.api.serializer.SerializerException;
-import org.apache.olingo.server.api.uri.UriInfo;
-import org.apache.olingo.server.api.uri.UriInfoResource;
-import org.apache.olingo.server.api.uri.UriResource;
-import org.apache.olingo.server.api.uri.UriResourceEntitySet;
-import org.apache.olingo.server.api.uri.UriResourceProperty;
-import org.apache.olingo.server.api.uri.queryoption.ExpandOption;
-import org.apache.olingo.server.api.uri.queryoption.SelectOption;
-import org.apache.olingo.server.sample.data.DataProvider;
-import org.apache.olingo.server.sample.data.DataProvider.DataProviderException;
-
-/**
- * This processor will deliver entity collections, single entities as well as properties of an entity.
- * This is a very simple example which should give you a rough guideline on how to implement such an processor.
- * See the JavaDoc of the server.api interfaces for more information.
- */
-public class CarsProcessor implements EntityCollectionProcessor, EntityProcessor,
-    PrimitiveProcessor, PrimitiveValueProcessor, ComplexProcessor {
-
-  private OData odata;
-  private final DataProvider dataProvider;
-  private ServiceMetadata edm;
-
-  // This constructor is application specific and not mandatory for the Olingo library. We use it here to simulate the
-  // database access
-  public CarsProcessor(final DataProvider dataProvider) {
-    this.dataProvider = dataProvider;
-  }
-
-  @Override
-  public void init(OData odata, ServiceMetadata edm) {
-    this.odata = odata;
-    this.edm = edm;
-  }
-
-  @Override
-  public void readEntityCollection(final ODataRequest request, ODataResponse response, final UriInfo uriInfo,
-      final ContentType requestedContentType) throws ODataApplicationException, SerializerException {
-    // First we have to figure out which entity set to use
-    final EdmEntitySet edmEntitySet = getEdmEntitySet(uriInfo.asUriInfoResource());
-
-    // Second we fetch the data for this specific entity set from the mock database and transform it into an EntitySet
-    // object which is understood by our serialization
-    EntityCollection entitySet = dataProvider.readAll(edmEntitySet);
-
-    // Next we create a serializer based on the requested format. This could also be a custom format but we do not
-    // support them in this example
-    final ODataFormat format = ODataFormat.fromContentType(requestedContentType);
-    ODataSerializer serializer = odata.createSerializer(format);
-
-    // Now the content is serialized using the serializer.
-    final ExpandOption expand = uriInfo.getExpandOption();
-    final SelectOption select = uriInfo.getSelectOption();
-    InputStream serializedContent = serializer.entityCollection(edm, edmEntitySet.getEntityType(), entitySet,
-        EntityCollectionSerializerOptions.with()
-            .contextURL(format == ODataFormat.JSON_NO_METADATA ? null :
-                getContextUrl(edmEntitySet, false, expand, select, null))
-            .count(uriInfo.getCountOption())
-            .expand(expand).select(select)
-            .build()).getContent();
-
-    // Finally we set the response data, headers and status code
-    response.setContent(serializedContent);
-    response.setStatusCode(HttpStatusCode.OK.getStatusCode());
-    response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString());
-  }
-
-  @Override
-  public void readEntity(final ODataRequest request, ODataResponse response, final UriInfo uriInfo,
-      final ContentType requestedContentType) throws ODataApplicationException, SerializerException {
-    // First we have to figure out which entity set the requested entity is in
-    final EdmEntitySet edmEntitySet = getEdmEntitySet(uriInfo.asUriInfoResource());
-
-    // Next we fetch the requested entity from the database
-    Entity entity;
-    try {
-      entity = readEntityInternal(uriInfo.asUriInfoResource(), edmEntitySet);
-    } catch (DataProviderException e) {
-      throw new ODataApplicationException(e.getMessage(), 500, Locale.ENGLISH);
-    }
-
-    if (entity == null) {
-      // If no entity was found for the given key we throw an exception.
-      throw new ODataApplicationException("No entity found for this key", HttpStatusCode.NOT_FOUND
-          .getStatusCode(), Locale.ENGLISH);
-    } else {
-      // If an entity was found we proceed by serializing it and sending it to the client.
-      final ODataFormat format = ODataFormat.fromContentType(requestedContentType);
-      ODataSerializer serializer = odata.createSerializer(format);
-      final ExpandOption expand = uriInfo.getExpandOption();
-      final SelectOption select = uriInfo.getSelectOption();
-      InputStream serializedContent = serializer.entity(edm, edmEntitySet.getEntityType(), entity,
-          EntitySerializerOptions.with()
-              .contextURL(format == ODataFormat.JSON_NO_METADATA ? null :
-                  getContextUrl(edmEntitySet, true, expand, select, null))
-              .expand(expand).select(select)
-              .build()).getContent();
-      response.setContent(serializedContent);
-      response.setStatusCode(HttpStatusCode.OK.getStatusCode());
-      response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString());
-    }
-  }
-
-  @Override
-  public void createEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo,
-                           ContentType requestFormat, ContentType responseFormat)
-          throws ODataApplicationException, DeserializerException, SerializerException {
-    throw new ODataApplicationException("Entity create is not supported yet.",
-            HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ENGLISH);
-  }
-
-  @Override
-  public void deleteEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo)
-          throws ODataApplicationException {
-    throw new ODataApplicationException("Entity delete is not supported yet.",
-            HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ENGLISH);
-  }
-
-  @Override
-  public void readPrimitive(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType format)
-          throws ODataApplicationException, SerializerException {
-    readProperty(response, uriInfo, format, false);
-  }
-
-  @Override
-  public void readComplex(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType format)
-          throws ODataApplicationException, SerializerException {
-    readProperty(response, uriInfo, format, true);
-  }
-
-  @Override
-  public void readPrimitiveValue(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType format)
-          throws ODataApplicationException, SerializerException {
-    // First we have to figure out which entity set the requested entity is in
-    final EdmEntitySet edmEntitySet = getEdmEntitySet(uriInfo.asUriInfoResource());
-    // Next we fetch the requested entity from the database
-    final Entity entity;
-    try {
-      entity = readEntityInternal(uriInfo.asUriInfoResource(), edmEntitySet);
-    } catch (DataProviderException e) {
-      throw new ODataApplicationException(e.getMessage(), 500, Locale.ENGLISH);
-    }
-    if (entity == null) {
-      // If no entity was found for the given key we throw an exception.
-      throw new ODataApplicationException("No entity found for this key", HttpStatusCode.NOT_FOUND
-              .getStatusCode(), Locale.ENGLISH);
-    } else {
-      // Next we get the property value from the entity and pass the value to serialization
-      UriResourceProperty uriProperty = (UriResourceProperty) uriInfo
-              .getUriResourceParts().get(uriInfo.getUriResourceParts().size() - 1);
-      EdmProperty edmProperty = uriProperty.getProperty();
-      Property property = entity.getProperty(edmProperty.getName());
-      if (property == null) {
-        throw new ODataApplicationException("No property found", HttpStatusCode.NOT_FOUND
-                .getStatusCode(), Locale.ENGLISH);
-      } else {
-        if (property.getValue() == null) {
-          response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
-        } else {
-          String value = String.valueOf(property.getValue());
-          ByteArrayInputStream serializerContent = new ByteArrayInputStream(
-                  value.getBytes(Charset.forName("UTF-8")));
-          response.setContent(serializerContent);
-          response.setStatusCode(HttpStatusCode.OK.getStatusCode());
-          response.setHeader(HttpHeader.CONTENT_TYPE, HttpContentType.TEXT_PLAIN);
-        }
-      }
-    }
-  }
-
-  private void readProperty(ODataResponse response, UriInfo uriInfo, ContentType contentType,
-      boolean complex) throws ODataApplicationException, SerializerException {
-    // To read a property we have to first get the entity out of the entity set
-    final EdmEntitySet edmEntitySet = getEdmEntitySet(uriInfo.asUriInfoResource());
-    Entity entity;
-    try {
-      entity = readEntityInternal(uriInfo.asUriInfoResource(), edmEntitySet);
-    } catch (DataProviderException e) {
-      throw new ODataApplicationException(e.getMessage(),
-              HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), Locale.ENGLISH);
-    }
-
-    if (entity == null) {
-      // If no entity was found for the given key we throw an exception.
-      throw new ODataApplicationException("No entity found for this key",
-              HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
-    } else {
-      // Next we get the property value from the entity and pass the value to serialization
-      UriResourceProperty uriProperty = (UriResourceProperty) uriInfo
-          .getUriResourceParts().get(uriInfo.getUriResourceParts().size() - 1);
-      EdmProperty edmProperty = uriProperty.getProperty();
-      Property property = entity.getProperty(edmProperty.getName());
-      if (property == null) {
-        throw new ODataApplicationException("No property found",
-                HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
-      } else {
-        if (property.getValue() == null) {
-          response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
-        } else {
-          final ODataFormat format = ODataFormat.fromContentType(contentType);
-          ODataSerializer serializer = odata.createSerializer(format);
-          final ContextURL contextURL = format == ODataFormat.JSON_NO_METADATA ? null :
-              getContextUrl(edmEntitySet, true, null, null, edmProperty.getName());
-          InputStream serializerContent = complex ?
-              serializer.complex(edm, (EdmComplexType) edmProperty.getType(), property,
-                  ComplexSerializerOptions.with().contextURL(contextURL).build()).getContent() :
-              serializer.primitive((EdmPrimitiveType) edmProperty.getType(), property,
-                                    PrimitiveSerializerOptions.with()
-                                    .contextURL(contextURL)
-                                    .scale(edmProperty.getScale())
-                                    .nullable(edmProperty.isNullable())
-                                    .precision(edmProperty.getPrecision())
-                                    .maxLength(edmProperty.getMaxLength())
-                                    .unicode(edmProperty.isUnicode()).build()).getContent();
-          response.setContent(serializerContent);
-          response.setStatusCode(HttpStatusCode.OK.getStatusCode());
-          response.setHeader(HttpHeader.CONTENT_TYPE, contentType.toContentTypeString());
-        }
-      }
-    }
-  }
-
-  private Entity readEntityInternal(final UriInfoResource uriInfo, final EdmEntitySet entitySet)
-      throws DataProvider.DataProviderException {
-    // This method will extract the key values and pass them to the data provider
-    final UriResourceEntitySet resourceEntitySet = (UriResourceEntitySet) uriInfo.getUriResourceParts().get(0);
-    return dataProvider.read(entitySet, resourceEntitySet.getKeyPredicates());
-  }
-
-  private EdmEntitySet getEdmEntitySet(final UriInfoResource uriInfo) throws ODataApplicationException {
-    final List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
-    /*
-     * To get the entity set we have to interpret all URI segments
-     */
-    if (!(resourcePaths.get(0) instanceof UriResourceEntitySet)) {
-      throw new ODataApplicationException("Invalid resource type for first segment.",
-          HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ENGLISH);
-    }
-
-    /*
-     * Here we should interpret the whole URI but in this example we do not support navigation so we throw an exception
-     */
-
-    final UriResourceEntitySet uriResource = (UriResourceEntitySet) resourcePaths.get(0);
-    return uriResource.getEntitySet();
-  }
-
-  private ContextURL getContextUrl(final EdmEntitySet entitySet, final boolean isSingleEntity,
-      final ExpandOption expand, final SelectOption select, final String navOrPropertyPath)
-      throws SerializerException {
-
-    return ContextURL.with().entitySet(entitySet)
-        .selectList(odata.createUriHelper().buildContextURLSelectList(entitySet.getEntityType(), expand, select))
-        .suffix(isSingleEntity ? Suffix.ENTITY : null)
-        .navOrPropertyPath(navOrPropertyPath)
-        .build();
-  }
-
-  @Override
-  public void updatePrimitive(final ODataRequest request, final ODataResponse response,
-                              final UriInfo uriInfo, final ContentType requestFormat,
-                              final ContentType responseFormat)
-          throws ODataApplicationException, DeserializerException, SerializerException {
-    throw new ODataApplicationException("Primitive property update is not supported yet.",
-            HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ENGLISH);
-  }
-
-  @Override
-  public void deletePrimitive(ODataRequest request, ODataResponse response, UriInfo uriInfo) throws
-          ODataApplicationException {
-    throw new ODataApplicationException("Primitive property delete is not supported yet.",
-            HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ENGLISH);
-  }
-
-  @Override
-  public void updateComplex(final ODataRequest request, final ODataResponse response,
-                            final UriInfo uriInfo, final ContentType requestFormat,
-                            final ContentType responseFormat)
-          throws ODataApplicationException, DeserializerException, SerializerException {
-    throw new ODataApplicationException("Complex property update is not supported yet.",
-            HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ENGLISH);
-  }
-
-  @Override
-  public void deleteComplex(final ODataRequest request, final ODataResponse response, final UriInfo uriInfo)
-          throws ODataApplicationException {
-    throw new ODataApplicationException("Complex property delete is not supported yet.",
-            HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ENGLISH);
-  }
-
-  @Override
-  public void updateEntity(final ODataRequest request, final ODataResponse response,
-                           final UriInfo uriInfo, final ContentType requestFormat,
-                           final ContentType responseFormat)
-          throws ODataApplicationException, DeserializerException, SerializerException {
-    throw new ODataApplicationException("Entity update is not supported yet.",
-            HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ENGLISH);
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/9e755634/samples/osgi/server/src/main/resources/META-INF/LICENSE
----------------------------------------------------------------------
diff --git a/samples/osgi/server/src/main/resources/META-INF/LICENSE b/samples/osgi/server/src/main/resources/META-INF/LICENSE
deleted file mode 100644
index 715ff30..0000000
--- a/samples/osgi/server/src/main/resources/META-INF/LICENSE
+++ /dev/null
@@ -1,331 +0,0 @@
-Licenses for TecSvc artifact
-
-
-                              Apache License
-                        Version 2.0, January 2004
-                     http://www.apache.org/licenses/
-
-TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-1. Definitions.
-
-   "License" shall mean the terms and conditions for use, reproduction,
-   and distribution as defined by Sections 1 through 9 of this document.
-
-   "Licensor" shall mean the copyright owner or entity authorized by
-   the copyright owner that is granting the License.
-
-   "Legal Entity" shall mean the union of the acting entity and all
-   other entities that control, are controlled by, or are under common
-   control with that entity. For the purposes of this definition,
-   "control" means (i) the power, direct or indirect, to cause the
-   direction or management of such entity, whether by contract or
-   otherwise, or (ii) ownership of fifty percent (50%) or more of the
-   outstanding shares, or (iii) beneficial ownership of such entity.
-
-   "You" (or "Your") shall mean an individual or Legal Entity
-   exercising permissions granted by this License.
-
-   "Source" form shall mean the preferred form for making modifications,
-   including but not limited to software source code, documentation
-   source, and configuration files.
-
-   "Object" form shall mean any form resulting from mechanical
-   transformation or translation of a Source form, including but
-   not limited to compiled object code, generated documentation,
-   and conversions to other media types.
-
-   "Work" shall mean the work of authorship, whether in Source or
-   Object form, made available under the License, as indicated by a
-   copyright notice that is included in or attached to the work
-   (an example is provided in the Appendix below).
-
-   "Derivative Works" shall mean any work, whether in Source or Object
-   form, that is based on (or derived from) the Work and for which the
-   editorial revisions, annotations, elaborations, or other modifications
-   represent, as a whole, an original work of authorship. For the purposes
-   of this License, Derivative Works shall not include works that remain
-   separable from, or merely link (or bind by name) to the interfaces of,
-   the Work and Derivative Works thereof.
-
-   "Contribution" shall mean any work of authorship, including
-   the original version of the Work and any modifications or additions
-   to that Work or Derivative Works thereof, that is intentionally
-   submitted to Licensor for inclusion in the Work by the copyright owner
-   or by an individual or Legal Entity authorized to submit on behalf of
-   the copyright owner. For the purposes of this definition, "submitted"
-   means any form of electronic, verbal, or written communication sent
-   to the Licensor or its representatives, including but not limited to
-   communication on electronic mailing lists, source code control systems,
-   and issue tracking systems that are managed by, or on behalf of, the
-   Licensor for the purpose of discussing and improving the Work, but
-   excluding communication that is conspicuously marked or otherwise
-   designated in writing by the copyright owner as "Not a Contribution."
-
-   "Contributor" shall mean Licensor and any individual or Legal Entity
-   on behalf of whom a Contribution has been received by Licensor and
-   subsequently incorporated within the Work.
-
-2. Grant of Copyright License. Subject to the terms and conditions of
-   this License, each Contributor hereby grants to You a perpetual,
-   worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-   copyright license to reproduce, prepare Derivative Works of,
-   publicly display, publicly perform, sublicense, and distribute the
-   Work and such Derivative Works in Source or Object form.
-
-3. Grant of Patent License. Subject to the terms and conditions of
-   this License, each Contributor hereby grants to You a perpetual,
-   worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-   (except as stated in this section) patent license to make, have made,
-   use, offer to sell, sell, import, and otherwise transfer the Work,
-   where such license applies only to those patent claims licensable
-   by such Contributor that are necessarily infringed by their
-   Contribution(s) alone or by combination of their Contribution(s)
-   with the Work to which such Contribution(s) was submitted. If You
-   institute patent litigation against any entity (including a
-   cross-claim or counterclaim in a lawsuit) alleging that the Work
-   or a Contribution incorporated within the Work constitutes direct
-   or contributory patent infringement, then any patent licenses
-   granted to You under this License for that Work shall terminate
-   as of the date such litigation is filed.
-
-4. Redistribution. You may reproduce and distribute copies of the
-   Work or Derivative Works thereof in any medium, with or without
-   modifications, and in Source or Object form, provided that You
-   meet the following conditions:
-
-   (a) You must give any other recipients of the Work or
-       Derivative Works a copy of this License; and
-
-   (b) You must cause any modified files to carry prominent notices
-       stating that You changed the files; and
-
-   (c) You must retain, in the Source form of any Derivative Works
-       that You distribute, all copyright, patent, trademark, and
-       attribution notices from the Source form of the Work,
-       excluding those notices that do not pertain to any part of
-       the Derivative Works; and
-
-   (d) If the Work includes a "NOTICE" text file as part of its
-       distribution, then any Derivative Works that You distribute must
-       include a readable copy of the attribution notices contained
-       within such NOTICE file, excluding those notices that do not
-       pertain to any part of the Derivative Works, in at least one
-       of the following places: within a NOTICE text file distributed
-       as part of the Derivative Works; within the Source form or
-       documentation, if provided along with the Derivative Works; or,
-       within a display generated by the Derivative Works, if and
-       wherever such third-party notices normally appear. The contents
-       of the NOTICE file are for informational purposes only and
-       do not modify the License. You may add Your own attribution
-       notices within Derivative Works that You distribute, alongside
-       or as an addendum to the NOTICE text from the Work, provided
-       that such additional attribution notices cannot be construed
-       as modifying the License.
-
-   You may add Your own copyright statement to Your modifications and
-   may provide additional or different license terms and conditions
-   for use, reproduction, or distribution of Your modifications, or
-   for any such Derivative Works as a whole, provided Your use,
-   reproduction, and distribution of the Work otherwise complies with
-   the conditions stated in this License.
-
-5. Submission of Contributions. Unless You explicitly state otherwise,
-   any Contribution intentionally submitted for inclusion in the Work
-   by You to the Licensor shall be under the terms and conditions of
-   this License, without any additional terms or conditions.
-   Notwithstanding the above, nothing herein shall supersede or modify
-   the terms of any separate license agreement you may have executed
-   with Licensor regarding such Contributions.
-
-6. Trademarks. This License does not grant permission to use the trade
-   names, trademarks, service marks, or product names of the Licensor,
-   except as required for reasonable and customary use in describing the
-   origin of the Work and reproducing the content of the NOTICE file.
-
-7. Disclaimer of Warranty. Unless required by applicable law or
-   agreed to in writing, Licensor provides the Work (and each
-   Contributor provides its Contributions) on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-   implied, including, without limitation, any warranties or conditions
-   of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-   PARTICULAR PURPOSE. You are solely responsible for determining the
-   appropriateness of using or redistributing the Work and assume any
-   risks associated with Your exercise of permissions under this License.
-
-8. Limitation of Liability. In no event and under no legal theory,
-   whether in tort (including negligence), contract, or otherwise,
-   unless required by applicable law (such as deliberate and grossly
-   negligent acts) or agreed to in writing, shall any Contributor be
-   liable to You for damages, including any direct, indirect, special,
-   incidental, or consequential damages of any character arising as a
-   result of this License or out of the use or inability to use the
-   Work (including but not limited to damages for loss of goodwill,
-   work stoppage, computer failure or malfunction, or any and all
-   other commercial damages or losses), even if such Contributor
-   has been advised of the possibility of such damages.
-
-9. Accepting Warranty or Additional Liability. While redistributing
-   the Work or Derivative Works thereof, You may choose to offer,
-   and charge a fee for, acceptance of support, warranty, indemnity,
-   or other liability obligations and/or rights consistent with this
-   License. However, in accepting such obligations, You may act only
-   on Your own behalf and on Your sole responsibility, not on behalf
-   of any other Contributor, and only if You agree to indemnify,
-   defend, and hold each Contributor harmless for any liability
-   incurred by, or claims asserted against, such Contributor by reason
-   of your accepting any such warranty or additional liability.
-
-END OF TERMS AND CONDITIONS
-
-APPENDIX: How to apply the Apache License to your work.
-
-   To apply the Apache License to your work, attach the following
-   boilerplate notice, with the fields enclosed by brackets "[]"
-   replaced with your own identifying information. (Don't include
-   the brackets!)  The text should be enclosed in the appropriate
-   comment syntax for the file format. We also recommend that a
-   file or class name and description of purpose be included on the
-   same "printed page" as the copyright notice for easier
-   identification within third-party archives.
-
-Copyright [yyyy] [name of copyright owner]
-
-Licensed 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.
-
-
-From: 'abego Software GmbH, Germany' (http://abego-software.de) - abego
-TreeLayout Core (http://code.google.com/p/treelayout/)
-org.abego.treelayout:org.abego.treelayout.core:jar:1.0.1 License: BSD 3-Clause
-"New" or "Revised" License (BSD-3-Clause)
-(http://treelayout.googlecode.com/files/LICENSE.TXT)
-
-[The "BSD license"]
-Copyright (c) 2011, abego Software GmbH, Germany (http://www.abego.org)
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without 
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice, 
-   this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright notice, 
-   this list of conditions and the following disclaimer in the documentation 
-   and/or other materials provided with the distribution.
-3. Neither the name of the abego Software GmbH nor the names of its 
-   contributors may be used to endorse or promote products derived from this 
-   software without specific prior written permission.
-   
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
-POSSIBILITY OF SUCH DAMAGE.
-
-
-From: 'ANTLR' (http://www.antlr.org) - ANTLR 4 Runtime
-(http://www.antlr.org/antlr4-runtime) org.antlr:antlr4-runtime:jar:4.1 License:
-The BSD License (http://www.antlr.org/license.html)
-
-[The BSD License]
-Copyright (c) 2012 Terence Parr and Sam Harwell
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-    Redistributions of source code must retain the above copyright notice, this
-    list of conditions and the following disclaimer. Redistributions in binary
-    form must reproduce the above copyright notice, this list of conditions and
-    the following disclaimer in the documentation and/or other materials
-    provided with the distribution. Neither the name of the author nor the
-    names of its contributors may be used to endorse or promote products
-    derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-From: 'fasterxml.com' (http://fasterxml.com) - Stax2 API
-(http://wiki.fasterxml.com/WoodstoxStax2)
-org.codehaus.woodstox:stax2-api:bundle:3.1.4 License: The BSD License
-(http://www.opensource.org/licenses/bsd-license.php)
-
-Copyright (c) 2004-2010, Woodstox Project (http://woodstox.codehaus.org/)
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice,
-   this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright notice,
-   this list of conditions and the following disclaimer in the documentation
-   and/or other materials provided with the distribution.
-3. Neither the name of the Woodstox XML Processor nor the names
-   of its contributors may be used to endorse or promote products derived
-   from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
-
-
-From: 'QOS.ch' (http://www.qos.ch)
-  - SLF4J API Module (http://www.slf4j.org) org.slf4j:slf4j-api:jar:1.7.7
-    License: MIT License  (http://www.opensource.org/licenses/mit-license.php)
-  - SLF4J Simple Binding (http://www.slf4j.org) org.slf4j:slf4j-simple:jar:1.7.7
-    License: MIT License  (http://www.opensource.org/licenses/mit-license.php)
-
-
-Copyright (c) 2004-2013 QOS.ch 
-
-All rights reserved. Permission is hereby granted, free of charge, to any
-person obtaining a copy of this software and associated documentation files
-(the "Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish, distribute,
-sublicense, and/or sell copies of the Software, and to permit persons to whom
-the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/9e755634/samples/osgi/server/src/main/resources/simplelogger.properties
----------------------------------------------------------------------
diff --git a/samples/osgi/server/src/main/resources/simplelogger.properties b/samples/osgi/server/src/main/resources/simplelogger.properties
deleted file mode 100644
index 2a3350c..0000000
--- a/samples/osgi/server/src/main/resources/simplelogger.properties
+++ /dev/null
@@ -1,20 +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.
-#
-org.slf4j.simpleLogger.defaultLogLevel=debug
-org.slf4j.simpleLogger.logFile=System.out
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/9e755634/samples/osgi/server/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/samples/osgi/server/src/main/webapp/WEB-INF/web.xml b/samples/osgi/server/src/main/webapp/WEB-INF/web.xml
deleted file mode 100644
index 6245ae2..0000000
--- a/samples/osgi/server/src/main/webapp/WEB-INF/web.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  Licensed to the Apache Software Foundation (ASF) under one
-         or more contributor license agreements.  See the NOTICE file
-         distributed with this work for additional information
-         regarding copyright ownership.  The ASF licenses this file
-         to you under the Apache License, Version 2.0 (the
-         "License"); you may not use this file except in compliance
-         with the License.  You may obtain a copy of the License at
-
-           http://www.apache.org/licenses/LICENSE-2.0
-
-         Unless required by applicable law or agreed to in writing,
-         software distributed under the License is distributed on an
-         "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-         KIND, either express or implied.  See the License for the
-         specific language governing permissions and limitations
-         under the License.
--->
-<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
-	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
-	id="WebApp_ID" version="2.5">
-
-	<display-name>Apache Olingo OData 4.0 Sample Service</display-name>
-
-	<welcome-file-list>
-		<welcome-file>index.jsp</welcome-file>
-	</welcome-file-list>
-
-	<servlet>
-		<servlet-name>CarsServlet</servlet-name>
-		<servlet-class>org.apache.olingo.server.sample.CarsServlet</servlet-class>
-		<load-on-startup>1</load-on-startup>
-	</servlet>
-
-    <servlet-mapping>
-        <servlet-name>CarsServlet</servlet-name>
-        <url-pattern>/cars.svc/*</url-pattern>
-    </servlet-mapping>
-
-</web-app>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/9e755634/samples/osgi/server/src/main/webapp/css/olingo.css
----------------------------------------------------------------------
diff --git a/samples/osgi/server/src/main/webapp/css/olingo.css b/samples/osgi/server/src/main/webapp/css/olingo.css
deleted file mode 100644
index 5b9deec..0000000
--- a/samples/osgi/server/src/main/webapp/css/olingo.css
+++ /dev/null
@@ -1,91 +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.
-*/
-body {
-	font-family: Arial, sans-serif;
-	font-size: 13px;
-	line-height: 18px;
-	color: #8904B1;
-	background-color: #ffffff;
-}
-
-a {
-	color: #8904B1;
-}
-
-a:VISITED {
-	color: #D358F7;
-}
-
-td {
-	padding: 5px;
-}
-
-h1,h2,h3,h4,h5,h6 {
-	font-family: inherit;
-	font-weight: bold;
-	line-height: 1;
-	color: #8904B1;
-}
-
-h1 {
-	font-size: 36px;
-	line-height: 40px;
-}
-
-h2 {
-	font-size: 30px;
-	line-height: 40px;
-}
-
-h3 {
-	font-size: 24px;
-	line-height: 40px;
-}
-
-h4 {
-	font-size: 18px;
-	line-height: 20px;
-}
-
-h5 {
-	font-size: 14px;
-	line-height: 20px;
-}
-
-h6 {
-	font-size: 12px;
-	line-height: 20px;
-}
-
-.logo {
-	float: right;
-}
-
-hr, thead, tfoot {
-	margin: 9px 0;
-	border-top: 1px solid #8904B1;
-	border-bottom: 1px solid #8904B1;
-}
-
-table { border-collapse: collapse; border: 1px solid #8904B1; }
-
-.version {
-	font-family: "Courier New", monospace;
-	font-size: 10px;
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/9e755634/samples/osgi/server/src/main/webapp/img/OlingoOrangeTM.png
----------------------------------------------------------------------
diff --git a/samples/osgi/server/src/main/webapp/img/OlingoOrangeTM.png b/samples/osgi/server/src/main/webapp/img/OlingoOrangeTM.png
deleted file mode 100644
index 4878e8a..0000000
Binary files a/samples/osgi/server/src/main/webapp/img/OlingoOrangeTM.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/9e755634/samples/osgi/server/src/main/webapp/index.jsp
----------------------------------------------------------------------
diff --git a/samples/osgi/server/src/main/webapp/index.jsp b/samples/osgi/server/src/main/webapp/index.jsp
deleted file mode 100644
index 2940a76..0000000
--- a/samples/osgi/server/src/main/webapp/index.jsp
+++ /dev/null
@@ -1,56 +0,0 @@
-<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
-
-<!--
-  Licensed to the Apache Software Foundation (ASF) under one
-         or more contributor license agreements.  See the NOTICE file
-         distributed with this work for additional information
-         regarding copyright ownership.  The ASF licenses this file
-         to you under the Apache License, Version 2.0 (the
-         "License"); you may not use this file except in compliance
-         with the License.  You may obtain a copy of the License at
-  
-           http://www.apache.org/licenses/LICENSE-2.0
-  
-         Unless required by applicable law or agreed to in writing,
-         software distributed under the License is distributed on an
-         "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-         KIND, either express or implied.  See the License for the
-         specific language governing permissions and limitations
-         under the License.
--->
-
-<!DOCTYPE html>
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title>Apache Olingo - OData 4.0</title>
- <link type="text/css" rel="stylesheet" href="css/olingo.css">
-</head>
-
-<body>
-  <div class="logo">
-    <img height="40" src="img/OlingoOrangeTM.png" />
-  </div>
-  <h1>Olingo OData 4.0</h1>
-  <hr>
-  <h2>Cars Sample Service</h2>
-  <ul>
-    <li><a href="cars.svc/">Service Document</a></li>
-    <li><a href="cars.svc/$metadata">Metadata</a></li>
-    <li>Entity Set: <a href="cars.svc/Cars">Cars</a></li>
-    <li>Entity: <a href="cars.svc/Cars(1)">Cars(1)</a></li>
-    <li>Primitive Property: <a href="cars.svc/Cars(1)/Price">Cars(1)/Price</a></li>
-  </ul>
-  <hr>
-  <div class="version">
-    <% String version = "gen/version.html";
-      try {
-     %>
-    <jsp:include page='<%=version%>' />
-    <%} catch (Exception e) {
-     %>
-    <p>IDE Build</p>
-    <%}%>
-  </div>
-</body>
-</html>


[02/39] olingo-odata4 git commit: Add Karaf features for Olingo

Posted by ch...@apache.org.
Add Karaf features for Olingo


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

Branch: refs/heads/IEE754Compatible
Commit: 0b8d46fc6a3479b1ed05bd53ba5549e05e8b26df
Parents: 5727d05
Author: Aki Yoshida <el...@gmail.com>
Authored: Thu May 28 16:34:48 2015 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Wed Jun 10 06:14:19 2015 +0200

----------------------------------------------------------------------
 ext/karaf/features/pom.xml                      | 81 ++++++++++++++++++++
 .../features/src/main/resources/features.xml    | 59 ++++++++++++++
 ext/pom.xml                                     |  1 +
 pom.xml                                         |  2 +
 4 files changed, 143 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0b8d46fc/ext/karaf/features/pom.xml
----------------------------------------------------------------------
diff --git a/ext/karaf/features/pom.xml b/ext/karaf/features/pom.xml
new file mode 100644
index 0000000..921eac2
--- /dev/null
+++ b/ext/karaf/features/pom.xml
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>odata-karaf-features</artifactId>
+  <packaging>pom</packaging>
+  <name>${project.artifactId}</name>
+
+  <parent>
+    <groupId>org.apache.olingo</groupId>
+    <artifactId>odata-ext</artifactId>
+    <version>4.0.0-SNAPSHOT</version>
+    <relativePath>../..</relativePath>
+  </parent>
+    <build>
+        <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+                <filtering>true</filtering>
+            </resource>
+        </resources>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-resources-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>filter</id>
+                        <phase>generate-resources</phase>
+                        <goals>
+                            <goal>resources</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>attach-artifacts</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>attach-artifact</goal>
+                        </goals>
+                        <configuration>
+                            <artifacts>
+                                <artifact>
+                                    <file>target/classes/features.xml</file>
+                                    <type>xml</type>
+                                    <classifier>features</classifier>
+                                </artifact>
+                            </artifacts>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0b8d46fc/ext/karaf/features/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/ext/karaf/features/src/main/resources/features.xml b/ext/karaf/features/src/main/resources/features.xml
new file mode 100644
index 0000000..0a433c5
--- /dev/null
+++ b/ext/karaf/features/src/main/resources/features.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 
+      Licensed to the Apache Software Foundation (ASF) under one or more
+      contributor license agreements.  See the NOTICE file distributed with
+      this work for additional information regarding copyright ownership.
+      The ASF licenses this file to You under the Apache License, Version 2.0
+      (the "License"); you may not use this file except in compliance with
+      the License.  You may obtain a copy of the License at
+ 
+         http://www.apache.org/licenses/LICENSE-2.0
+ 
+      Unless required by applicable law or agreed to in writing, software
+      distributed under the License is distributed on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+      See the License for the specific language governing permissions and
+      limitations under the License.
+-->
+<features xmlns="http://karaf.apache.org/xmlns/features/v1.0.0" name="olingo-${project.version}">
+
+    <feature name="olingo-server" version="${project.version}" resolver="(obr)" start-level="50">
+      <feature>war</feature>
+	  <bundle>mvn:commons-codec/commons-codec/${commons.codec.version}</bundle>
+	  <bundle>mvn:org.apache.commons/commons-lang3/${commons.lang3.version}</bundle>
+	  <bundle>mvn:org.codehaus.woodstox/stax2-api/${woodstox.stax2-api.version}</bundle>
+	  <bundle>mvn:com.fasterxml/aalto-xml/${aalto-xml.version}</bundle>
+	  <bundle>wrap:mvn:org.antlr/antlr4-runtime/${antlr.version}/$Bundle-SymbolicName=antlr4-runtime&amp;Bundle-Version=${antlr.version}&amp;Export-Package=org.antlr.v4.runtime*</bundle>
+
+	  <bundle>mvn:com.fasterxml.jackson.core/jackson-core/${jackson.version}</bundle>
+	  <bundle>mvn:com.fasterxml.jackson.core/jackson-annotations/${jackson.version}</bundle>
+	  <bundle>mvn:com.fasterxml.jackson.core/jackson-databind/${jackson.version}</bundle>
+
+	  <bundle>mvn:org.apache.olingo/odata-commons-api/${project.version}</bundle>
+	  <bundle>mvn:org.apache.olingo/odata-commons-core/${project.version}</bundle>
+	  <bundle>mvn:org.apache.olingo/odata-server-api/${project.version}</bundle>
+	  <bundle>mvn:org.apache.olingo/odata-server-core/${project.version}</bundle>
+    </feature>
+
+    <feature name="olingo-client" version="${project.version}" resolver="(obr)" start-level="50">
+	  <bundle>mvn:commons-codec/commons-codec/${commons.codec.version}</bundle>
+	  <bundle>mvn:commons-io/commons-io/${commons.io.version}</bundle>
+	  <bundle>mvn:org.apache.commons/commons-lang3/${commons.lang3.version}</bundle>
+	  <bundle>mvn:org.codehaus.woodstox/stax2-api/${woodstox.stax2-api.version}</bundle>
+	  <bundle>mvn:com.fasterxml/aalto-xml/${aalto-xml.version}</bundle>
+	  <bundle>mvn:org.apache.httpcomponents/httpcore-osgi/${hc.core.version}</bundle>
+	  <bundle>mvn:org.apache.httpcomponents/httpclient-osgi/${hc.client.version}</bundle>
+
+	  <bundle>mvn:com.fasterxml.jackson.core/jackson-core/${jackson.version}</bundle>
+	  <bundle>mvn:com.fasterxml.jackson.core/jackson-annotations/${jackson.version}</bundle>
+	  <bundle>mvn:com.fasterxml.jackson.core/jackson-databind/${jackson.version}</bundle>
+	  <bundle>mvn:com.fasterxml.jackson.module/jackson-module-jaxb-annotations/${jackson.version}</bundle>
+	  <bundle>mvn:com.fasterxml.jackson.dataformat/jackson-dataformat-xml/${jackson.version}</bundle>
+
+	  <bundle>mvn:org.apache.olingo/odata-commons-api/${project.version}</bundle>
+	  <bundle>mvn:org.apache.olingo/odata-commons-core/${project.version}</bundle>
+	  <bundle>mvn:org.apache.olingo/odata-client-api/${project.version}</bundle>
+	  <bundle>mvn:org.apache.olingo/odata-client-core/${project.version}</bundle>
+    </feature>
+</features>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0b8d46fc/ext/pom.xml
----------------------------------------------------------------------
diff --git a/ext/pom.xml b/ext/pom.xml
index b31bf67..93a78e3 100644
--- a/ext/pom.xml
+++ b/ext/pom.xml
@@ -39,5 +39,6 @@
     <module>pojogen-maven-plugin</module>
     <module>client-proxy</module>
     <module>client-android</module>
+    <module>karaf/features</module>
   </modules>
 </project>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0b8d46fc/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 84ae718..e4d2b76 100644
--- a/pom.xml
+++ b/pom.xml
@@ -82,6 +82,7 @@
     <maven.plugin.tools.version>3.3</maven.plugin.tools.version>
     <maven.bundle.plugin.version>2.3.4</maven.bundle.plugin.version>
     <hc.client.version>4.2.6</hc.client.version>
+    <hc.core.version>4.2.5</hc.core.version>
     <jackson.version>2.4.2</jackson.version>
     <aalto-xml.version>0.9.10</aalto-xml.version>
 
@@ -89,6 +90,7 @@
 
     <android.platform.version>4.1.1.4</android.platform.version>
     <stax.api.version>1.0-2</stax.api.version>
+    <woodstox.stax2-api.version>3.1.4</woodstox.stax2-api.version>
 
     <sl4j.version>1.7.7</sl4j.version>
 


[03/39] olingo-odata4 git commit: Adding olingo-server side OSGi tests

Posted by ch...@apache.org.
Adding olingo-server side OSGi tests


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

Branch: refs/heads/IEE754Compatible
Commit: 7ab54a2b852a396fc34e5c0a1c781d7b2d78c6cb
Parents: 0b8d46f
Author: Aki Yoshida <el...@gmail.com>
Authored: Tue Jun 9 18:33:36 2015 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Wed Jun 10 06:14:26 2015 +0200

----------------------------------------------------------------------
 ext/karaf/itests/pom.xml                        | 152 +++++++++++++++++++
 .../apache/olingo/osgi/itests/BundlesTest.java  |  56 +++++++
 .../osgi/itests/OlingoOSGiTestSupport.java      | 137 +++++++++++++++++
 .../osgi/itests/server/CarServiceTest.java      | 105 +++++++++++++
 pom.xml                                         |   5 +
 5 files changed, 455 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/7ab54a2b/ext/karaf/itests/pom.xml
----------------------------------------------------------------------
diff --git a/ext/karaf/itests/pom.xml b/ext/karaf/itests/pom.xml
new file mode 100644
index 0000000..989a7bd
--- /dev/null
+++ b/ext/karaf/itests/pom.xml
@@ -0,0 +1,152 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>odata-karaf-itests</artifactId>
+  <packaging>jar</packaging>
+  <name>${project.artifactId}</name>
+
+  <parent>
+    <groupId>org.apache.olingo</groupId>
+    <artifactId>odata-ext</artifactId>
+    <version>4.0.0-SNAPSHOT</version>
+    <relativePath>../..</relativePath>
+  </parent>
+  <dependencies>
+    <!-- Karaf features -->
+    <dependency>
+      <groupId>org.apache.olingo</groupId>
+      <artifactId>odata-karaf-features</artifactId>
+      <version>${project.version}</version>
+      <type>xml</type>
+      <classifier>features</classifier>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.karaf.features</groupId>
+      <artifactId>org.apache.karaf.features.core</artifactId>
+      <version>${karaf.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.karaf.shell</groupId>
+      <artifactId>org.apache.karaf.shell.console</artifactId>
+      <version>${karaf.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <version>${osgi.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.compendium</artifactId>
+      <version>${osgi.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-atinject_1.0_spec</artifactId>
+      <version>1.0</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <!-- pax-exam -->
+    <dependency>
+      <groupId>org.ops4j.pax.exam</groupId>
+      <artifactId>pax-exam-junit4</artifactId>
+      <version>${pax.exam.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.ops4j.pax.exam</groupId>
+      <artifactId>pax-exam</artifactId>
+      <version>${pax.exam.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.ops4j.pax.exam</groupId>
+      <artifactId>pax-exam-container-karaf</artifactId>
+      <version>${pax.exam.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.ops4j.pax.exam</groupId>
+      <artifactId>pax-exam-link-mvn</artifactId>
+      <version>${pax.exam.version}</version>
+      <scope>test</scope>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.apache.karaf</groupId>
+      <artifactId>apache-karaf</artifactId>
+      <version>${karaf.version}</version>
+      <type>tar.gz</type>
+      <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>org.apache.karaf.shell</groupId>
+          <artifactId>org.apache.karaf.shell.dev</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.eclipse</groupId>
+          <artifactId>osgi</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.eclipse</groupId>
+          <artifactId>org.eclipse.osgi</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.apache.karaf</groupId>
+          <artifactId>org.apache.karaf.client</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.apache.felix</groupId>
+          <artifactId>org.apache.felix.framework</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <!-- generate dependencies versions that are needed -->
+      <plugin>
+        <groupId>org.apache.servicemix.tooling</groupId>
+        <artifactId>depends-maven-plugin</artifactId>
+        <version>1.2</version>
+        <executions>
+          <execution>
+            <id>generate-depends-file</id>
+            <goals>
+              <goal>generate-depends-file</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/7ab54a2b/ext/karaf/itests/src/test/java/org/apache/olingo/osgi/itests/BundlesTest.java
----------------------------------------------------------------------
diff --git a/ext/karaf/itests/src/test/java/org/apache/olingo/osgi/itests/BundlesTest.java b/ext/karaf/itests/src/test/java/org/apache/olingo/osgi/itests/BundlesTest.java
new file mode 100644
index 0000000..4b542a1
--- /dev/null
+++ b/ext/karaf/itests/src/test/java/org/apache/olingo/osgi/itests/BundlesTest.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * 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.osgi.itests;
+
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;
+
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class BundlesTest extends OlingoOSGiTestSupport {
+    @Test
+    public void test() throws Exception {
+        // check the server-api and server-core
+        assertBundleStarted("org.apache.olingo.odata-server-api");
+        assertBundleStarted("org.apache.olingo.odata-server-core");
+
+        // check the client-api and client-core
+        assertBundleStarted("org.apache.olingo.odata-client-api");
+        assertBundleStarted("org.apache.olingo.odata-client-core");
+    }
+
+    @Configuration
+    public Option[] config() {
+        return new Option[]{
+            olingoBaseConfig(),
+            features(olingoUrl, "olingo-server", "olingo-client"),
+            logLevel(LogLevel.INFO)};
+    }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/7ab54a2b/ext/karaf/itests/src/test/java/org/apache/olingo/osgi/itests/OlingoOSGiTestSupport.java
----------------------------------------------------------------------
diff --git a/ext/karaf/itests/src/test/java/org/apache/olingo/osgi/itests/OlingoOSGiTestSupport.java b/ext/karaf/itests/src/test/java/org/apache/olingo/osgi/itests/OlingoOSGiTestSupport.java
new file mode 100644
index 0000000..e882736
--- /dev/null
+++ b/ext/karaf/itests/src/test/java/org/apache/olingo/osgi/itests/OlingoOSGiTestSupport.java
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * 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.osgi.itests;
+
+
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.Properties;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import javax.inject.Inject;
+
+import org.apache.karaf.features.FeaturesService;
+import org.junit.Assert;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.ProbeBuilder;
+import org.ops4j.pax.exam.TestProbeBuilder;
+import org.ops4j.pax.exam.options.MavenUrlReference;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import static org.ops4j.pax.exam.CoreOptions.composite;
+import static org.ops4j.pax.exam.CoreOptions.maven;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+import static org.ops4j.pax.exam.CoreOptions.when;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
+
+/**
+ * 
+ */
+public class OlingoOSGiTestSupport {
+    private static final String MAVEN_DEPENDENCIES_PROPERTIES = "/META-INF/maven/dependencies.properties";
+
+    @Inject
+    protected BundleContext bundleContext;
+
+    @Inject
+    protected FeaturesService featureService;
+
+    protected ExecutorService executor = Executors.newCachedThreadPool();
+
+    protected MavenUrlReference olingoUrl;
+    protected MavenUrlReference karafUrl;
+
+    /**
+     * @param probe
+     * @return
+     */
+    @ProbeBuilder
+    public TestProbeBuilder probeConfiguration(TestProbeBuilder probe) {
+        probe.setHeader(Constants.DYNAMICIMPORT_PACKAGE, "*,org.apache.felix.service.*;status=provisional");
+        return probe;
+    }
+
+    private static String getKarafVersion() {
+        String karafVersion = getVersionFromPom("org.apache.karaf/apache-karaf/version");
+        if (karafVersion == null) {
+            karafVersion = System.getProperty("karaf.version");
+        }
+        if (karafVersion == null) {
+            // setup the default version of it
+            karafVersion = "3.0.3";
+        }
+        return karafVersion;
+    }
+
+    private static String getVersionFromPom(String key) {
+        try {
+            InputStream ins = OlingoOSGiTestSupport.class.getResourceAsStream(MAVEN_DEPENDENCIES_PROPERTIES);
+            Properties p = new Properties();
+            p.load(ins);
+            return p.getProperty(key);
+        } catch (Exception t) {
+            throw new IllegalStateException(MAVEN_DEPENDENCIES_PROPERTIES + " can not be found", t);
+        }
+    }    
+    /**
+     * Create an {@link org.ops4j.pax.exam.Option} for using a .
+     * 
+     * @return
+     */
+    protected Option olingoBaseConfig() {
+        karafUrl = maven().groupId("org.apache.karaf").artifactId("apache-karaf").version(getKarafVersion())
+            .type("tar.gz");
+        olingoUrl = maven().groupId("org.apache.olingo").artifactId("odata-karaf-features").versionAsInProject()
+            .type("xml").classifier("features");
+        String localRepo = System.getProperty("localRepository");
+        return composite(karafDistributionConfiguration()
+                             .frameworkUrl(karafUrl)
+                             .karafVersion(getKarafVersion())
+                             .name("Apache Karaf")
+                             .useDeployFolder(false)
+                             .unpackDirectory(new File("target/paxexam/")),
+                         //DO NOT COMMIT WITH THIS LINE ENABLED!!!    
+                         //KarafDistributionOption.keepRuntimeFolder(),                         
+                         systemProperty("java.awt.headless").value("true"),
+                         when(localRepo != null)
+                             .useOptions(editConfigurationFilePut("etc/org.ops4j.pax.url.mvn.cfg",
+                                                                  "org.ops4j.pax.url.mvn.localRepository",
+                                                                  localRepo)));
+    }
+
+    protected void assertBundleStarted(String name) {
+        Bundle bundle = findBundleByName(name);
+        Assert.assertNotNull("Bundle " + name + " should be installed", bundle);
+        Assert.assertEquals("Bundle " + name + " should be started", Bundle.ACTIVE, bundle.getState());
+    }
+
+    protected Bundle findBundleByName(String symbolicName) {
+        for (Bundle bundle : bundleContext.getBundles()) {
+            if (bundle.getSymbolicName().equals(symbolicName)) {
+                return bundle;
+            }
+        }
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/7ab54a2b/ext/karaf/itests/src/test/java/org/apache/olingo/osgi/itests/server/CarServiceTest.java
----------------------------------------------------------------------
diff --git a/ext/karaf/itests/src/test/java/org/apache/olingo/osgi/itests/server/CarServiceTest.java b/ext/karaf/itests/src/test/java/org/apache/olingo/osgi/itests/server/CarServiceTest.java
new file mode 100644
index 0000000..d727253
--- /dev/null
+++ b/ext/karaf/itests/src/test/java/org/apache/olingo/osgi/itests/server/CarServiceTest.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.osgi.itests.server;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+
+import org.apache.olingo.osgi.itests.OlingoOSGiTestSupport;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
+
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;
+
+/**
+ *
+ */
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerMethod.class)
+public class CarServiceTest extends OlingoOSGiTestSupport {
+    private static final String SERVICE_URL = "http://localhost:8181/olingo-cars/cars.svc/";
+
+    @Test
+    public void testServiceStarted() throws Exception {
+        // check if the bundle is started
+        assertBundleStarted("org.apache.olingo.odata-server-osgi-sample");
+        
+        // use the jdk http client to verify the server side
+        verifyContent(getContent(SERVICE_URL));
+        
+        verifyContent(getContent(SERVICE_URL + "$metadata"));
+        
+        verifyContent(getContent(SERVICE_URL + "Cars"));
+        
+        verifyContent(getContent(SERVICE_URL + "Cars(1)"));
+        
+        verifyContent(getContent(SERVICE_URL + "Cars(1)/Price"));
+    }    
+
+    private static void verifyContent(String content) {
+        // this is currently a simple test to check if there is no error
+        Assert.assertNotNull(content);
+        Assert.assertTrue(content.indexOf("error") < 0);
+    }
+
+    private static String getContent(String target) throws Exception {
+        InputStream in = null;
+        try {
+            URL url = new URL(target);
+            URLConnection urlConnection = url.openConnection();
+            urlConnection.setRequestProperty("Accept", "*/*");
+            in = urlConnection.getInputStream();
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            byte[] buf = new byte[4096];
+            int n = 0;
+            while ((n = in.read(buf, 0, buf.length)) != -1) {
+                baos.write(buf, 0, n);
+            }
+            return new String(baos.toByteArray(), "utf-8");
+        } finally {
+            if (in != null) {
+                in.close();
+            }
+        }
+        
+    }
+
+    @Configuration
+    public Option[] config() {
+        return new Option[] {
+            olingoBaseConfig(),
+            features(olingoUrl, "olingo-server", "olingo-client"),
+            mavenBundle("org.apache.olingo", "odata-server-osgi-sample", "4.0.0-SNAPSHOT"),
+            logLevel(LogLevel.INFO)
+        };
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/7ab54a2b/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index e4d2b76..1544783 100644
--- a/pom.xml
+++ b/pom.xml
@@ -97,6 +97,11 @@
     <tomcat.servlet.port>9080</tomcat.servlet.port>
     <tomcat.version>7.0.55</tomcat.version>
 
+    <!-- for osgi integration testing -->
+    <osgi.version>4.2.0</osgi.version>
+    <karaf.version>3.0.3</karaf.version>
+    <pax.exam.version>4.5.0</pax.exam.version>
+
     <!-- Project build settings -->
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <project.build.source>1.6</project.build.source>


[14/39] olingo-odata4 git commit: [OLINGO-699] Moved serializer code to client module

Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AtomDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AtomDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AtomDeserializer.java
new file mode 100644
index 0000000..df88d27
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AtomDeserializer.java
@@ -0,0 +1,873 @@
+/*
+ * 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.serialization;
+
+import java.io.InputStream;
+import java.net.URI;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Attribute;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.client.api.serialization.ODataDeserializer;
+import org.apache.olingo.client.api.serialization.ODataDeserializerException;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.ODataError;
+import org.apache.olingo.commons.api.ODataPropertyType;
+import org.apache.olingo.commons.api.data.AbstractODataObject;
+import org.apache.olingo.commons.api.data.Annotation;
+import org.apache.olingo.commons.api.data.ComplexValue;
+import org.apache.olingo.commons.api.data.DeletedEntity;
+import org.apache.olingo.commons.api.data.DeletedEntity.Reason;
+import org.apache.olingo.commons.api.data.Delta;
+import org.apache.olingo.commons.api.data.DeltaLink;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntityCollection;
+import org.apache.olingo.commons.api.data.Link;
+import org.apache.olingo.commons.api.data.Operation;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.data.Valuable;
+import org.apache.olingo.commons.api.data.ValueType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.geo.Geospatial;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+
+import com.fasterxml.aalto.stax.InputFactoryImpl;
+
+public class AtomDeserializer extends AbstractAtomDealer implements ODataDeserializer {
+
+  protected static final XMLInputFactory FACTORY = new InputFactoryImpl();
+
+  private final AtomGeoValueDeserializer geoDeserializer;
+
+  protected XMLEventReader getReader(final InputStream input) throws XMLStreamException {
+    return FACTORY.createXMLEventReader(input);
+  }
+
+  public AtomDeserializer() {
+    geoDeserializer = new AtomGeoValueDeserializer();
+  }
+
+  private Object fromPrimitive(final XMLEventReader reader, final StartElement start,
+      final EdmTypeInfo typeInfo) throws XMLStreamException, EdmPrimitiveTypeException {
+
+    Object value = null;
+
+    boolean foundEndProperty = false;
+    while (reader.hasNext() && !foundEndProperty) {
+      final XMLEvent event = reader.nextEvent();
+
+      if (event.isStartElement() && typeInfo != null && typeInfo.getPrimitiveTypeKind().isGeospatial()) {
+        final EdmPrimitiveTypeKind geoType =
+            EdmPrimitiveTypeKind.valueOfFQN(typeInfo.getFullQualifiedName().toString());
+        value = geoDeserializer.deserialize(reader, event.asStartElement(), geoType);
+      }
+
+      if (event.isCharacters() && !event.asCharacters().isWhiteSpace()
+          && (typeInfo == null || !typeInfo.getPrimitiveTypeKind().isGeospatial())) {
+
+        final String stringValue = event.asCharacters().getData();
+        value = typeInfo == null ? stringValue : // TODO: add facets
+          ((EdmPrimitiveType) typeInfo.getType()).valueOfString(stringValue, true, null,
+              Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, true,
+              ((EdmPrimitiveType) typeInfo.getType()).getDefaultType());
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndProperty = true;
+      }
+    }
+
+    return value;
+  }
+
+  private Object fromComplexOrEnum(final XMLEventReader reader, final StartElement start)
+      throws XMLStreamException, EdmPrimitiveTypeException {
+
+    Object value = null;
+
+    boolean foundEndProperty = false;
+    while (reader.hasNext() && !foundEndProperty) {
+      final XMLEvent event = reader.nextEvent();
+
+      if (event.isStartElement()) {
+        if (value == null) {
+          value = new ComplexValue();
+        }
+
+        if (Constants.QNAME_ATOM_ELEM_LINK.equals(event.asStartElement().getName())) {
+          final Link link = new Link();
+          final Attribute rel = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REL));
+          if (rel != null) {
+            link.setRel(rel.getValue());
+          }
+          final Attribute title = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TITLE));
+          if (title != null) {
+            link.setTitle(title.getValue());
+          }
+          final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
+          if (href != null) {
+            link.setHref(href.getValue());
+          }
+          final Attribute type = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TYPE));
+          if (type != null) {
+            link.setType(type.getValue());
+          }
+
+          if (link.getRel().startsWith(Constants.NS_NAVIGATION_LINK_REL)) {
+
+            ((ComplexValue) value).getNavigationLinks().add(link);
+            inline(reader, event.asStartElement(), link);
+          } else if (link.getRel().startsWith(Constants.NS_ASSOCIATION_LINK_REL)) {
+
+            ((Valuable) value).asComplex().getAssociationLinks().add(link);
+          }
+        } else {
+          ((ComplexValue) value).getValue().add(property(reader, event.asStartElement()));
+        }
+      }
+
+      if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
+        value = event.asCharacters().getData();
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndProperty = true;
+      }
+    }
+
+    return value;
+  }
+
+  private void fromCollection(final Valuable valuable, final XMLEventReader reader, final StartElement start,
+      final EdmTypeInfo typeInfo) throws XMLStreamException, EdmPrimitiveTypeException {
+
+    List<Object> values = new ArrayList<Object>();
+    ValueType valueType = ValueType.COLLECTION_PRIMITIVE;
+
+    final EdmTypeInfo type = typeInfo == null ? null :
+      new EdmTypeInfo.Builder().setTypeExpression(typeInfo.getFullQualifiedName().toString()).build();
+
+    boolean foundEndProperty = false;
+    while (reader.hasNext() && !foundEndProperty) {
+      final XMLEvent event = reader.nextEvent();
+
+      if (event.isStartElement()) {
+        switch (guessPropertyType(reader, typeInfo)) {
+        case COMPLEX:
+          final Object complexValue = fromComplexOrEnum(reader, event.asStartElement());
+          valueType = ValueType.COLLECTION_COMPLEX;
+          values.add(complexValue);
+          break;
+
+        case ENUM:
+          valueType = ValueType.COLLECTION_ENUM;
+          values.add(fromComplexOrEnum(reader, event.asStartElement()));
+          break;
+
+        case PRIMITIVE:
+          final Object value = fromPrimitive(reader, event.asStartElement(), type);
+          valueType = value instanceof Geospatial ?
+              ValueType.COLLECTION_GEOSPATIAL : ValueType.COLLECTION_PRIMITIVE;
+          values.add(value);
+          break;
+
+        default:
+          // do not add null or empty values
+        }
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndProperty = true;
+      }
+    }
+    valuable.setValue(valueType, values);
+  }
+
+  private ODataPropertyType guessPropertyType(final XMLEventReader reader, final EdmTypeInfo typeInfo)
+      throws XMLStreamException {
+
+    XMLEvent child = null;
+    while (reader.hasNext() && child == null) {
+      final XMLEvent event = reader.peek();
+      if (event.isCharacters() && event.asCharacters().isWhiteSpace()) {
+        reader.nextEvent();
+      } else {
+        child = event;
+      }
+    }
+
+    final ODataPropertyType type;
+    if (child == null) {
+      type = typeInfo == null || typeInfo.isPrimitiveType() ? ODataPropertyType.PRIMITIVE : ODataPropertyType.ENUM;
+    } else {
+      if (child.isStartElement()) {
+        if (Constants.NS_GML.equals(child.asStartElement().getName().getNamespaceURI())) {
+          type = ODataPropertyType.PRIMITIVE;
+        } else if (elementQName.equals(child.asStartElement().getName())) {
+          type = ODataPropertyType.COLLECTION;
+        } else {
+          type = ODataPropertyType.COMPLEX;
+        }
+      } else if (child.isCharacters()) {
+        type = typeInfo == null || typeInfo.isPrimitiveType()
+            ? ODataPropertyType.PRIMITIVE
+                : ODataPropertyType.ENUM;
+      } else {
+        type = ODataPropertyType.EMPTY;
+      }
+    }
+
+    return type;
+  }
+
+  private Property property(final XMLEventReader reader, final StartElement start)
+      throws XMLStreamException, EdmPrimitiveTypeException {
+
+    final Property property = new Property();
+
+    if (propertyValueQName.equals(start.getName())) {
+      // retrieve name from context
+      final Attribute context = start.getAttributeByName(contextQName);
+      if (context != null) {
+        property.setName(StringUtils.substringAfterLast(context.getValue(), "/"));
+      }
+    } else {
+      property.setName(start.getName().getLocalPart());
+    }
+
+    valuable(property, reader, start);
+
+    return property;
+  }
+
+  private void valuable(final Valuable valuable, final XMLEventReader reader, final StartElement start)
+      throws XMLStreamException, EdmPrimitiveTypeException {
+
+    final Attribute nullAttr = start.getAttributeByName(nullQName);
+
+    final Attribute typeAttr = start.getAttributeByName(typeQName);
+    final String typeAttrValue = typeAttr == null ? null : typeAttr.getValue();
+
+    final EdmTypeInfo typeInfo = StringUtils.isBlank(typeAttrValue) ? null :
+      new EdmTypeInfo.Builder().setTypeExpression(typeAttrValue).build();
+
+    if (typeInfo != null) {
+      valuable.setType(typeInfo.internal());
+    }
+
+    final ODataPropertyType propType = typeInfo == null ? guessPropertyType(reader, typeInfo) :
+      typeInfo.isCollection() ? ODataPropertyType.COLLECTION :
+        typeInfo.isPrimitiveType() ? ODataPropertyType.PRIMITIVE : ODataPropertyType.COMPLEX;
+
+    if (nullAttr == null) {
+      switch (propType) {
+      case COLLECTION:
+        fromCollection(valuable, reader, start, typeInfo);
+        break;
+
+      case COMPLEX:
+        final Object complexValue = fromComplexOrEnum(reader, start);
+        valuable.setValue(complexValue instanceof ComplexValue ? ValueType.COMPLEX : ValueType.ENUM,
+            complexValue);
+        break;
+
+      case PRIMITIVE:
+        // No type specified? Defaults to Edm.String
+        if (typeInfo == null) {
+          valuable.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName().toString());
+        }
+        final Object value = fromPrimitive(reader, start, typeInfo);
+        valuable.setValue(value instanceof Geospatial ? ValueType.GEOSPATIAL : ValueType.PRIMITIVE, value);
+        break;
+
+      case EMPTY:
+      default:
+        valuable.setValue(ValueType.PRIMITIVE, StringUtils.EMPTY);
+      }
+    } else {
+      valuable.setValue(propType == ODataPropertyType.PRIMITIVE ? ValueType.PRIMITIVE :
+        propType == ODataPropertyType.ENUM ? ValueType.ENUM :
+          propType == ODataPropertyType.COMPLEX ? ValueType.COMPLEX :
+            propType == ODataPropertyType.COLLECTION ? ValueType.COLLECTION_PRIMITIVE : ValueType.PRIMITIVE,
+                null);
+    }
+  }
+
+  @Override
+  public ResWrap<Property> toProperty(final InputStream input) throws ODataDeserializerException {
+    try {
+      final XMLEventReader reader = getReader(input);
+      final StartElement start = skipBeforeFirstStartElement(reader);
+      return getContainer(start, property(reader, start));
+    } catch (XMLStreamException e) {
+      throw new ODataDeserializerException(e);
+    } catch (final EdmPrimitiveTypeException e) {
+      throw new ODataDeserializerException(e);
+    }
+  }
+
+  private StartElement skipBeforeFirstStartElement(final XMLEventReader reader) throws XMLStreamException {
+    StartElement startEvent = null;
+    while (reader.hasNext() && startEvent == null) {
+      final XMLEvent event = reader.nextEvent();
+      if (event.isStartElement()) {
+        startEvent = event.asStartElement();
+      }
+    }
+    if (startEvent == null) {
+      throw new IllegalArgumentException("Cannot find any XML start element");
+    }
+
+    return startEvent;
+  }
+
+  private void common(final XMLEventReader reader, final StartElement start,
+      final AbstractODataObject object, final String key) throws XMLStreamException {
+
+    boolean foundEndElement = false;
+    while (reader.hasNext() && !foundEndElement) {
+      final XMLEvent event = reader.nextEvent();
+
+      if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
+        try {
+          object.setCommonProperty(key, event.asCharacters().getData());
+        } catch (ParseException e) {
+          throw new XMLStreamException("While parsing Atom entry or feed common elements", e);
+        }
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndElement = true;
+      }
+    }
+  }
+
+  private void inline(final XMLEventReader reader, final StartElement start, final Link link)
+      throws XMLStreamException, EdmPrimitiveTypeException {
+
+    boolean foundEndElement = false;
+    while (reader.hasNext() && !foundEndElement) {
+      final XMLEvent event = reader.nextEvent();
+
+      if (event.isStartElement()) {
+        if (inlineQName.equals(event.asStartElement().getName())) {
+          StartElement inline = getStartElement(reader);
+          if (inline != null) {
+            if (Constants.QNAME_ATOM_ELEM_ENTRY.equals(inline.getName())) {
+              link.setInlineEntity(entity(reader, inline));
+            }
+            if (Constants.QNAME_ATOM_ELEM_FEED.equals(inline.getName())) {
+              link.setInlineEntitySet(entitySet(reader, inline));
+            }
+          }
+        } else if (annotationQName.equals(event.asStartElement().getName())) {
+          link.getAnnotations().add(annotation(reader, event.asStartElement()));
+        }
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndElement = true;
+      }
+    }
+  }
+
+  private StartElement getStartElement(final XMLEventReader reader) throws XMLStreamException {
+    while (reader.hasNext()) {
+      final XMLEvent innerEvent = reader.peek();
+      if (innerEvent.isCharacters() && innerEvent.asCharacters().isWhiteSpace()) {
+        reader.nextEvent();
+      } else if (innerEvent.isStartElement()) {
+        return innerEvent.asStartElement();
+      } else if (innerEvent.isEndElement() && inlineQName.equals(innerEvent.asEndElement().getName())) {
+        return null;
+      }
+    }
+    return null;
+  }
+
+  public ResWrap<Delta> delta(final InputStream input)
+      throws XMLStreamException, EdmPrimitiveTypeException {
+    final XMLEventReader reader = getReader(input);
+    final StartElement start = skipBeforeFirstStartElement(reader);
+    return getContainer(start, delta(reader, start));
+  }
+
+  private Delta delta(final XMLEventReader reader, final StartElement start)
+      throws XMLStreamException, EdmPrimitiveTypeException {
+    if (!Constants.QNAME_ATOM_ELEM_FEED.equals(start.getName())) {
+      return null;
+    }
+    final Delta delta = new Delta();
+    final Attribute xmlBase = start.getAttributeByName(Constants.QNAME_ATTR_XML_BASE);
+    if (xmlBase != null) {
+      delta.setBaseURI(URI.create(xmlBase.getValue()));
+    }
+
+    boolean foundEndFeed = false;
+    while (reader.hasNext() && !foundEndFeed) {
+      final XMLEvent event = reader.nextEvent();
+      if (event.isStartElement()) {
+        if (countQName.equals(event.asStartElement().getName())) {
+          count(reader, event.asStartElement(), delta);
+        } else if (Constants.QNAME_ATOM_ELEM_ID.equals(event.asStartElement().getName())) {
+          common(reader, event.asStartElement(), delta, "id");
+        } else if (Constants.QNAME_ATOM_ELEM_TITLE.equals(event.asStartElement().getName())) {
+          common(reader, event.asStartElement(), delta, "title");
+        } else if (Constants.QNAME_ATOM_ELEM_SUMMARY.equals(event.asStartElement().getName())) {
+          common(reader, event.asStartElement(), delta, "summary");
+        } else if (Constants.QNAME_ATOM_ELEM_UPDATED.equals(event.asStartElement().getName())) {
+          common(reader, event.asStartElement(), delta, "updated");
+        } else if (Constants.QNAME_ATOM_ELEM_LINK.equals(event.asStartElement().getName())) {
+          final Attribute rel = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REL));
+          if (rel != null) {
+            if (Constants.NEXT_LINK_REL.equals(rel.getValue())) {
+              final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
+              if (href != null) {
+                delta.setNext(URI.create(href.getValue()));
+              }
+            }
+            if (Constants.NS_DELTA_LINK_REL.equals(rel.getValue())) {
+              final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
+              if (href != null) {
+                delta.setDeltaLink(URI.create(href.getValue()));
+              }
+            }
+          }
+        } else if (Constants.QNAME_ATOM_ELEM_ENTRY.equals(event.asStartElement().getName())) {
+          delta.getEntities().add(entity(reader, event.asStartElement()));
+        } else if (deletedEntryQName.equals(event.asStartElement().getName())) {
+          final DeletedEntity deletedEntity = new DeletedEntity();
+
+          final Attribute ref = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REF));
+          if (ref != null) {
+            deletedEntity.setId(URI.create(ref.getValue()));
+          }
+          final Attribute reason = event.asStartElement().getAttributeByName(reasonQName);
+          if (reason != null) {
+            deletedEntity.setReason(Reason.valueOf(reason.getValue()));
+          }
+
+          delta.getDeletedEntities().add(deletedEntity);
+        } else if (linkQName.equals(event.asStartElement().getName())
+            || deletedLinkQName.equals(event.asStartElement().getName())) {
+
+          final DeltaLink link = new DeltaLink();
+
+          final Attribute source = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_SOURCE));
+          if (source != null) {
+            link.setSource(URI.create(source.getValue()));
+          }
+          final Attribute relationship =
+              event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_RELATIONSHIP));
+          if (relationship != null) {
+            link.setRelationship(relationship.getValue());
+          }
+          final Attribute target = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TARGET));
+          if (target != null) {
+            link.setTarget(URI.create(target.getValue()));
+          }
+
+          if (linkQName.equals(event.asStartElement().getName())) {
+            delta.getAddedLinks().add(link);
+          } else {
+            delta.getDeletedLinks().add(link);
+          }
+        }
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndFeed = true;
+      }
+    }
+
+    return delta;
+  }
+
+  private void properties(final XMLEventReader reader, final StartElement start, final Entity entity)
+      throws XMLStreamException, EdmPrimitiveTypeException {
+
+    final Map<String, List<Annotation>> annotations = new HashMap<String, List<Annotation>>();
+
+    boolean foundEndProperties = false;
+    while (reader.hasNext() && !foundEndProperties) {
+      final XMLEvent event = reader.nextEvent();
+
+      if (event.isStartElement()) {
+        if (annotationQName.equals(event.asStartElement().getName())) {
+          final String target = event.asStartElement().
+              getAttributeByName(QName.valueOf(Constants.ATTR_TARGET)).getValue();
+          if (!annotations.containsKey(target)) {
+            annotations.put(target, new ArrayList<Annotation>());
+          }
+          annotations.get(target).add(annotation(reader, event.asStartElement()));
+        } else {
+          entity.getProperties().add(property(reader, event.asStartElement()));
+        }
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndProperties = true;
+      }
+    }
+
+    for (Property property : entity.getProperties()) {
+      if (annotations.containsKey(property.getName())) {
+        property.getAnnotations().addAll(annotations.get(property.getName()));
+      }
+    }
+  }
+
+  private Annotation annotation(final XMLEventReader reader, final StartElement start)
+      throws XMLStreamException, EdmPrimitiveTypeException {
+
+    final Annotation annotation = new Annotation();
+
+    annotation.setTerm(start.getAttributeByName(QName.valueOf(Constants.ATOM_ATTR_TERM)).getValue());
+    valuable(annotation, reader, start);
+
+    return annotation;
+  }
+
+  private Entity entityRef(final StartElement start) throws XMLStreamException {
+    final Entity entity = new Entity();
+
+    final Attribute entityRefId = start.getAttributeByName(Constants.QNAME_ATOM_ATTR_ID);
+    if (entityRefId != null) {
+      entity.setId(URI.create(entityRefId.getValue()));
+    }
+
+    return entity;
+  }
+
+  private Entity entity(final XMLEventReader reader, final StartElement start)
+      throws XMLStreamException, EdmPrimitiveTypeException {
+    final Entity entity;
+    if (entryRefQName.equals(start.getName())) {
+      entity = entityRef(start);
+    } else if (Constants.QNAME_ATOM_ELEM_ENTRY.equals(start.getName())) {
+      entity = new Entity();
+      final Attribute xmlBase = start.getAttributeByName(Constants.QNAME_ATTR_XML_BASE);
+      if (xmlBase != null) {
+        entity.setBaseURI(URI.create(xmlBase.getValue()));
+      }
+
+      final Attribute etag = start.getAttributeByName(etagQName);
+      if (etag != null) {
+        entity.setETag(etag.getValue());
+      }
+
+      boolean foundEndEntry = false;
+      while (reader.hasNext() && !foundEndEntry) {
+        final XMLEvent event = reader.nextEvent();
+
+        if (event.isStartElement()) {
+          if (Constants.QNAME_ATOM_ELEM_ID.equals(event.asStartElement().getName())) {
+            common(reader, event.asStartElement(), entity, "id");
+          } else if (Constants.QNAME_ATOM_ELEM_TITLE.equals(event.asStartElement().getName())) {
+            common(reader, event.asStartElement(), entity, "title");
+          } else if (Constants.QNAME_ATOM_ELEM_SUMMARY.equals(event.asStartElement().getName())) {
+            common(reader, event.asStartElement(), entity, "summary");
+          } else if (Constants.QNAME_ATOM_ELEM_UPDATED.equals(event.asStartElement().getName())) {
+            common(reader, event.asStartElement(), entity, "updated");
+          } else if (Constants.QNAME_ATOM_ELEM_CATEGORY.equals(event.asStartElement().getName())) {
+            final Attribute term = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATOM_ATTR_TERM));
+            if (term != null) {
+              entity.setType(new EdmTypeInfo.Builder().setTypeExpression(term.getValue()).build().internal());
+            }
+          } else if (Constants.QNAME_ATOM_ELEM_LINK.equals(event.asStartElement().getName())) {
+            final Link link = new Link();
+            final Attribute rel = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REL));
+            if (rel != null) {
+              link.setRel(rel.getValue());
+            }
+            final Attribute title = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TITLE));
+            if (title != null) {
+              link.setTitle(title.getValue());
+            }
+            final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
+            if (href != null) {
+              link.setHref(href.getValue());
+            }
+            final Attribute type = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TYPE));
+            if (type != null) {
+              link.setType(type.getValue());
+            }
+
+            if (Constants.SELF_LINK_REL.equals(link.getRel())) {
+              entity.setSelfLink(link);
+            } else if (Constants.EDIT_LINK_REL.equals(link.getRel())) {
+              entity.setEditLink(link);
+            } else if (Constants.EDITMEDIA_LINK_REL.equals(link.getRel())) {
+              final Attribute mediaETag = event.asStartElement().getAttributeByName(etagQName);
+              if (mediaETag != null) {
+                entity.setMediaETag(mediaETag.getValue());
+              }
+            } else if (link.getRel().startsWith(Constants.NS_NAVIGATION_LINK_REL)) {
+
+              entity.getNavigationLinks().add(link);
+              inline(reader, event.asStartElement(), link);
+            } else if (link.getRel().startsWith(Constants.NS_ASSOCIATION_LINK_REL)) {
+
+              entity.getAssociationLinks().add(link);
+            } else if (link.getRel().startsWith(Constants.NS_MEDIA_EDIT_LINK_REL)) {
+
+              final Attribute metag = event.asStartElement().getAttributeByName(etagQName);
+              if (metag != null) {
+                link.setMediaETag(metag.getValue());
+              }
+              entity.getMediaEditLinks().add(link);
+            }
+          } else if (actionQName.equals(event.asStartElement().getName())) {
+            final Operation operation = new Operation();
+            final Attribute metadata =
+                event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_METADATA));
+            if (metadata != null) {
+              operation.setMetadataAnchor(metadata.getValue());
+            }
+            final Attribute title = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TITLE));
+            if (title != null) {
+              operation.setTitle(title.getValue());
+            }
+            final Attribute target = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TARGET));
+            if (target != null) {
+              operation.setTarget(URI.create(target.getValue()));
+            }
+
+            entity.getOperations().add(operation);
+          } else if (Constants.QNAME_ATOM_ELEM_CONTENT.equals(event.asStartElement().getName())) {
+            final Attribute type = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TYPE));
+            if (type == null || ContentType.APPLICATION_XML.toContentTypeString().equals(type.getValue())) {
+              properties(reader, skipBeforeFirstStartElement(reader), entity);
+            } else {
+              entity.setMediaContentType(type.getValue());
+              final Attribute src = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATOM_ATTR_SRC));
+              if (src != null) {
+                entity.setMediaContentSource(URI.create(src.getValue()));
+              }
+            }
+          } else if (propertiesQName.equals(event.asStartElement().getName())) {
+            properties(reader, event.asStartElement(), entity);
+          } else if (annotationQName.equals(event.asStartElement().getName())) {
+            entity.getAnnotations().add(annotation(reader, event.asStartElement()));
+          }
+        }
+
+        if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+          foundEndEntry = true;
+        }
+      }
+    } else {
+      entity = null;
+    }
+
+    return entity;
+  }
+
+  @Override
+  public ResWrap<Entity> toEntity(final InputStream input) throws ODataDeserializerException {
+    try {
+      final XMLEventReader reader = getReader(input);
+      final StartElement start = skipBeforeFirstStartElement(reader);
+      final Entity entity = entity(reader, start);
+      if (entity == null) {
+        throw new ODataDeserializerException("No entity found!");
+      } else {
+        return getContainer(start, entity);
+      }
+    } catch (XMLStreamException e) {
+      throw new ODataDeserializerException(e);
+    } catch (final EdmPrimitiveTypeException e) {
+      throw new ODataDeserializerException(e);
+    }
+  }
+
+  private void count(final XMLEventReader reader, final StartElement start, final EntityCollection entitySet)
+      throws XMLStreamException {
+
+    boolean foundEndElement = false;
+    while (reader.hasNext() && !foundEndElement) {
+      final XMLEvent event = reader.nextEvent();
+
+      if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
+        entitySet.setCount(Integer.valueOf(event.asCharacters().getData()));
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndElement = true;
+      }
+    }
+  }
+
+  private EntityCollection entitySet(final XMLEventReader reader, final StartElement start)
+      throws XMLStreamException, EdmPrimitiveTypeException {
+    if (!Constants.QNAME_ATOM_ELEM_FEED.equals(start.getName())) {
+      return null;
+    }
+    final EntityCollection entitySet = new EntityCollection();
+    final Attribute xmlBase = start.getAttributeByName(Constants.QNAME_ATTR_XML_BASE);
+    if (xmlBase != null) {
+      entitySet.setBaseURI(URI.create(xmlBase.getValue()));
+    }
+
+    boolean foundEndFeed = false;
+    while (reader.hasNext() && !foundEndFeed) {
+      final XMLEvent event = reader.nextEvent();
+      if (event.isStartElement()) {
+        if (countQName.equals(event.asStartElement().getName())) {
+          count(reader, event.asStartElement(), entitySet);
+        } else if (Constants.QNAME_ATOM_ELEM_ID.equals(event.asStartElement().getName())) {
+          common(reader, event.asStartElement(), entitySet, "id");
+        } else if (Constants.QNAME_ATOM_ELEM_TITLE.equals(event.asStartElement().getName())) {
+          common(reader, event.asStartElement(), entitySet, "title");
+        } else if (Constants.QNAME_ATOM_ELEM_SUMMARY.equals(event.asStartElement().getName())) {
+          common(reader, event.asStartElement(), entitySet, "summary");
+        } else if (Constants.QNAME_ATOM_ELEM_UPDATED.equals(event.asStartElement().getName())) {
+          common(reader, event.asStartElement(), entitySet, "updated");
+        } else if (Constants.QNAME_ATOM_ELEM_LINK.equals(event.asStartElement().getName())) {
+          final Attribute rel = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REL));
+          if (rel != null) {
+            if (Constants.NEXT_LINK_REL.equals(rel.getValue())) {
+              final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
+              if (href != null) {
+                entitySet.setNext(URI.create(href.getValue()));
+              }
+            }
+            if (Constants.NS_DELTA_LINK_REL.equals(rel.getValue())) {
+              final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
+              if (href != null) {
+                entitySet.setDeltaLink(URI.create(href.getValue()));
+              }
+            }
+          }
+        } else if (Constants.QNAME_ATOM_ELEM_ENTRY.equals(event.asStartElement().getName())) {
+          entitySet.getEntities().add(entity(reader, event.asStartElement()));
+        } else if (entryRefQName.equals(event.asStartElement().getName())) {
+          entitySet.getEntities().add(entityRef(event.asStartElement()));
+        } else if (annotationQName.equals(event.asStartElement().getName())) {
+          entitySet.getAnnotations().add(annotation(reader, event.asStartElement()));
+        }
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndFeed = true;
+      }
+    }
+
+    return entitySet;
+  }
+
+  @Override
+  public ResWrap<EntityCollection> toEntitySet(final InputStream input) throws ODataDeserializerException {
+    try {
+      final XMLEventReader reader = getReader(input);
+      final StartElement start = skipBeforeFirstStartElement(reader);
+      return getContainer(start, entitySet(reader, start));
+    } catch (XMLStreamException e) {
+      throw new ODataDeserializerException(e);
+    } catch (final EdmPrimitiveTypeException e) {
+      throw new ODataDeserializerException(e);
+    }
+  }
+
+  private ODataError error(final XMLEventReader reader, final StartElement start) throws XMLStreamException {
+    final ODataError error = new ODataError();
+
+    boolean setCode = false;
+    boolean codeSet = false;
+    boolean setMessage = false;
+    boolean messageSet = false;
+    boolean setTarget = false;
+    boolean targetSet = false;
+
+    boolean foundEndElement = false;
+    while (reader.hasNext() && !foundEndElement) {
+      final XMLEvent event = reader.nextEvent();
+
+      if (event.isStartElement()) {
+        if (errorCodeQName.equals(event.asStartElement().getName())) {
+          setCode = true;
+        } else if (errorMessageQName.equals(event.asStartElement().getName())) {
+          setMessage = true;
+        } else if (errorTargetQName.equals(event.asStartElement().getName())) {
+          setTarget = true;
+        }
+      }
+
+      if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
+        if (setCode && !codeSet) {
+          error.setCode(event.asCharacters().getData());
+          setCode = false;
+          codeSet = true;
+        }
+        if (setMessage && !messageSet) {
+          error.setMessage(event.asCharacters().getData());
+          setMessage = false;
+          messageSet = true;
+        }
+        if (setTarget && !targetSet) {
+          error.setTarget(event.asCharacters().getData());
+          setTarget = false;
+          targetSet = true;
+        }
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndElement = true;
+      }
+    }
+
+    return error;
+  }
+
+  @Override
+  public ODataError toError(final InputStream input) throws ODataDeserializerException {
+    try {
+      final XMLEventReader reader = getReader(input);
+      final StartElement start = skipBeforeFirstStartElement(reader);
+      return error(reader, start);
+    } catch (XMLStreamException e) {
+      throw new ODataDeserializerException(e);
+    }
+  }
+
+  private <T> ResWrap<T> getContainer(final StartElement start, final T object) {
+    final Attribute context = start.getAttributeByName(contextQName);
+    final Attribute metadataETag = start.getAttributeByName(metadataEtagQName);
+
+    return new ResWrap<T>(
+        context == null ? null : URI.create(context.getValue()),
+            metadataETag == null ? null : metadataETag.getValue(),
+                object);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AtomGeoValueDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AtomGeoValueDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AtomGeoValueDeserializer.java
new file mode 100644
index 0000000..38add8d
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AtomGeoValueDeserializer.java
@@ -0,0 +1,269 @@
+/*
+ * 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.serialization;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Attribute;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.GeoUtils;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.geo.Geospatial;
+import org.apache.olingo.commons.api.edm.geo.GeospatialCollection;
+import org.apache.olingo.commons.api.edm.geo.LineString;
+import org.apache.olingo.commons.api.edm.geo.MultiLineString;
+import org.apache.olingo.commons.api.edm.geo.MultiPoint;
+import org.apache.olingo.commons.api.edm.geo.MultiPolygon;
+import org.apache.olingo.commons.api.edm.geo.Point;
+import org.apache.olingo.commons.api.edm.geo.Polygon;
+import org.apache.olingo.commons.api.edm.geo.SRID;
+import org.apache.olingo.commons.core.edm.primitivetype.EdmDouble;
+
+class AtomGeoValueDeserializer {
+
+  private List<Point> points(final XMLEventReader reader, final StartElement start,
+      final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
+
+    final List<Point> result = new ArrayList<Point>();
+
+    boolean foundEndProperty = false;
+    while (reader.hasNext() && !foundEndProperty) {
+      final XMLEvent event = reader.nextEvent();
+
+      if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
+        final String[] pointInfo = event.asCharacters().getData().split(" ");
+
+        final Point point = new Point(GeoUtils.getDimension(type), srid);
+        try {
+          point.setX(EdmDouble.getInstance().valueOfString(pointInfo[0], null, null,
+              Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, Double.class));
+          point.setY(EdmDouble.getInstance().valueOfString(pointInfo[1], null, null,
+              Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, Double.class));
+        } catch (EdmPrimitiveTypeException e) {
+          throw new XMLStreamException("While deserializing point coordinates as double", e);
+        }
+        result.add(point);
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndProperty = true;
+      }
+    }
+
+    // handles bad input, e.g. things like <gml:pos/>
+    if (result.isEmpty()) {
+      result.add(new Point(GeoUtils.getDimension(type), srid));
+    }
+
+    return result;
+  }
+
+  private MultiPoint multipoint(final XMLEventReader reader, final StartElement start,
+      final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
+
+    List<Point> points = Collections.<Point> emptyList();
+
+    boolean foundEndProperty = false;
+    while (reader.hasNext() && !foundEndProperty) {
+      final XMLEvent event = reader.nextEvent();
+
+      if (event.isStartElement() && event.asStartElement().getName().equals(Constants.QNAME_POINTMEMBERS)) {
+        points = points(reader, event.asStartElement(), type, null);
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndProperty = true;
+      }
+    }
+
+    return new MultiPoint(GeoUtils.getDimension(type), srid, points);
+  }
+
+  private LineString lineString(final XMLEventReader reader, final StartElement start,
+      final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
+
+    return new LineString(GeoUtils.getDimension(type), srid, points(reader, start, type, null));
+  }
+
+  private Polygon polygon(final XMLEventReader reader, final StartElement start,
+      final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
+
+    List<Point> extPoints = null;
+    List<Point> intPoints = null;
+
+    boolean foundEndProperty = false;
+    while (reader.hasNext() && !foundEndProperty) {
+      final XMLEvent event = reader.nextEvent();
+
+      if (event.isStartElement()) {
+        if (event.asStartElement().getName().equals(Constants.QNAME_POLYGON_EXTERIOR)) {
+          extPoints = points(reader, event.asStartElement(), type, null);
+        }
+        if (event.asStartElement().getName().equals(Constants.QNAME_POLYGON_INTERIOR)) {
+          intPoints = points(reader, event.asStartElement(), type, null);
+        }
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndProperty = true;
+      }
+    }
+
+    return new Polygon(GeoUtils.getDimension(type), srid, intPoints, extPoints);
+  }
+
+  private MultiLineString multiLineString(final XMLEventReader reader, final StartElement start,
+      final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
+
+    final List<LineString> lineStrings = new ArrayList<LineString>();
+
+    boolean foundEndProperty = false;
+    while (reader.hasNext() && !foundEndProperty) {
+      final XMLEvent event = reader.nextEvent();
+
+      if (event.isStartElement() && event.asStartElement().getName().equals(Constants.QNAME_LINESTRING)) {
+        lineStrings.add(lineString(reader, event.asStartElement(), type, null));
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndProperty = true;
+      }
+    }
+
+    return new MultiLineString(GeoUtils.getDimension(type), srid, lineStrings);
+  }
+
+  private MultiPolygon multiPolygon(final XMLEventReader reader, final StartElement start,
+      final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
+
+    final List<Polygon> polygons = new ArrayList<Polygon>();
+
+    boolean foundEndProperty = false;
+    while (reader.hasNext() && !foundEndProperty) {
+      final XMLEvent event = reader.nextEvent();
+
+      if (event.isStartElement() && event.asStartElement().getName().equals(Constants.QNAME_POLYGON)) {
+        polygons.add(polygon(reader, event.asStartElement(), type, null));
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndProperty = true;
+      }
+    }
+
+    return new MultiPolygon(GeoUtils.getDimension(type), srid, polygons);
+  }
+
+  private GeospatialCollection collection(final XMLEventReader reader, final StartElement start,
+      final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
+
+    final List<Geospatial> geospatials = new ArrayList<Geospatial>();
+
+    boolean foundEndCollection = false;
+    while (reader.hasNext() && !foundEndCollection) {
+      final XMLEvent event = reader.nextEvent();
+
+      if (event.isStartElement() && event.asStartElement().getName().equals(Constants.QNAME_GEOMEMBERS)) {
+        boolean foundEndMembers = false;
+        while (reader.hasNext() && !foundEndMembers) {
+          final XMLEvent subevent = reader.nextEvent();
+
+          if (subevent.isStartElement()) {
+            geospatials.add(deserialize(reader, subevent.asStartElement(),
+                GeoUtils.getType(GeoUtils.getDimension(type), subevent.asStartElement().getName().getLocalPart())));
+          }
+
+          if (subevent.isEndElement() && Constants.QNAME_GEOMEMBERS.equals(subevent.asEndElement().getName())) {
+            foundEndMembers = true;
+          }
+        }
+      }
+
+      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+        foundEndCollection = true;
+      }
+    }
+
+    return new GeospatialCollection(GeoUtils.getDimension(type), srid, geospatials);
+  }
+
+  public Geospatial deserialize(final XMLEventReader reader, final StartElement start,
+      final EdmPrimitiveTypeKind type) throws XMLStreamException {
+
+    SRID srid = null;
+    final Attribute srsName = start.getAttributeByName(Constants.QNAME_ATTR_SRSNAME);
+    if (srsName != null) {
+      srid = SRID.valueOf(StringUtils.substringAfterLast(srsName.getValue(), "/"));
+    }
+
+    Geospatial value;
+
+    switch (type) {
+    case GeographyPoint:
+    case GeometryPoint:
+      value = points(reader, start, type, srid).get(0);
+      break;
+
+    case GeographyMultiPoint:
+    case GeometryMultiPoint:
+      value = multipoint(reader, start, type, srid);
+      break;
+
+    case GeographyLineString:
+    case GeometryLineString:
+      value = lineString(reader, start, type, srid);
+      break;
+
+    case GeographyMultiLineString:
+    case GeometryMultiLineString:
+      value = multiLineString(reader, start, type, srid);
+      break;
+
+    case GeographyPolygon:
+    case GeometryPolygon:
+      value = polygon(reader, start, type, srid);
+      break;
+
+    case GeographyMultiPolygon:
+    case GeometryMultiPolygon:
+      value = multiPolygon(reader, start, type, srid);
+      break;
+
+    case GeographyCollection:
+    case GeometryCollection:
+      value = collection(reader, start, type, srid);
+      break;
+
+    default:
+      value = null;
+    }
+
+    return value;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AtomGeoValueSerializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AtomGeoValueSerializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AtomGeoValueSerializer.java
new file mode 100644
index 0000000..1030597
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AtomGeoValueSerializer.java
@@ -0,0 +1,223 @@
+/*
+ * 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.serialization;
+
+import java.util.Collections;
+import java.util.Iterator;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.edm.geo.Geospatial;
+import org.apache.olingo.commons.api.edm.geo.GeospatialCollection;
+import org.apache.olingo.commons.api.edm.geo.LineString;
+import org.apache.olingo.commons.api.edm.geo.MultiLineString;
+import org.apache.olingo.commons.api.edm.geo.MultiPoint;
+import org.apache.olingo.commons.api.edm.geo.MultiPolygon;
+import org.apache.olingo.commons.api.edm.geo.Point;
+import org.apache.olingo.commons.api.edm.geo.Polygon;
+import org.apache.olingo.commons.core.edm.primitivetype.EdmDouble;
+
+class AtomGeoValueSerializer {
+
+  private void points(final XMLStreamWriter writer, final Iterator<Point> itor, final boolean wrap)
+      throws XMLStreamException {
+
+    while (itor.hasNext()) {
+      final Point point = itor.next();
+
+      if (wrap) {
+        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POINT, Constants.NS_GML);
+      }
+
+      writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POS, Constants.NS_GML);
+      try {
+        writer.writeCharacters(EdmDouble.getInstance().valueToString(point.getX(), null, null,
+            Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null)
+            + " "
+            + EdmDouble.getInstance().valueToString(point.getY(), null, null,
+                Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null));
+      } catch (EdmPrimitiveTypeException e) {
+        throw new XMLStreamException("While serializing point coordinates as double", e);
+      }
+      writer.writeEndElement();
+
+      if (wrap) {
+        writer.writeEndElement();
+      }
+    }
+  }
+
+  private void lineStrings(final XMLStreamWriter writer, final Iterator<LineString> itor, final boolean wrap)
+      throws XMLStreamException {
+
+    while (itor.hasNext()) {
+      final LineString lineString = itor.next();
+
+      if (wrap) {
+        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_LINESTRING, Constants.NS_GML);
+      }
+
+      points(writer, lineString.iterator(), false);
+
+      if (wrap) {
+        writer.writeEndElement();
+      }
+    }
+  }
+
+  private void polygons(final XMLStreamWriter writer, final Iterator<Polygon> itor, final boolean wrap)
+      throws XMLStreamException {
+
+    while (itor.hasNext()) {
+      final Polygon polygon = itor.next();
+
+      if (wrap) {
+        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POLYGON, Constants.NS_GML);
+      }
+
+      if (!polygon.getExterior().isEmpty()) {
+        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POLYGON_EXTERIOR, Constants.NS_GML);
+        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POLYGON_LINEARRING, Constants.NS_GML);
+
+        points(writer, polygon.getExterior().iterator(), false);
+
+        writer.writeEndElement();
+        writer.writeEndElement();
+      }
+      if (!polygon.getInterior().isEmpty()) {
+        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POLYGON_INTERIOR, Constants.NS_GML);
+        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POLYGON_LINEARRING, Constants.NS_GML);
+
+        points(writer, polygon.getInterior().iterator(), false);
+
+        writer.writeEndElement();
+        writer.writeEndElement();
+      }
+
+      if (wrap) {
+        writer.writeEndElement();
+      }
+    }
+  }
+
+  private void writeSrsName(final XMLStreamWriter writer, final Geospatial value) throws XMLStreamException {
+    if (value.getSrid() != null && value.getSrid().isNotDefault()) {
+      writer.writeAttribute(Constants.PREFIX_GML, Constants.NS_GML, Constants.ATTR_SRSNAME,
+          Constants.SRS_URLPREFIX + value.getSrid().toString());
+    }
+  }
+
+  public void serialize(final XMLStreamWriter writer, final Geospatial value) throws XMLStreamException {
+    switch (value.getEdmPrimitiveTypeKind()) {
+    case GeographyPoint:
+    case GeometryPoint:
+      writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POINT, Constants.NS_GML);
+      writeSrsName(writer, value);
+
+      points(writer, Collections.singleton((Point) value).iterator(), false);
+
+      writer.writeEndElement();
+      break;
+
+    case GeometryMultiPoint:
+    case GeographyMultiPoint:
+      writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_MULTIPOINT, Constants.NS_GML);
+      writeSrsName(writer, value);
+
+      if (!((MultiPoint) value).isEmpty()) {
+        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POINTMEMBERS, Constants.NS_GML);
+        points(writer, ((MultiPoint) value).iterator(), true);
+        writer.writeEndElement();
+      }
+
+      writer.writeEndElement();
+      break;
+
+    case GeometryLineString:
+    case GeographyLineString:
+      writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_LINESTRING, Constants.NS_GML);
+      writeSrsName(writer, value);
+
+      lineStrings(writer, Collections.singleton((LineString) value).iterator(), false);
+
+      writer.writeEndElement();
+      break;
+
+    case GeometryMultiLineString:
+    case GeographyMultiLineString:
+      writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_MULTILINESTRING, Constants.NS_GML);
+      writeSrsName(writer, value);
+
+      if (!((MultiLineString) value).isEmpty()) {
+        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_LINESTRINGMEMBERS, Constants.NS_GML);
+        lineStrings(writer, ((MultiLineString) value).iterator(), true);
+        writer.writeEndElement();
+      }
+
+      writer.writeEndElement();
+      break;
+
+    case GeographyPolygon:
+    case GeometryPolygon:
+      writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POLYGON, Constants.NS_GML);
+      writeSrsName(writer, value);
+
+      polygons(writer, Collections.singleton(((Polygon) value)).iterator(), false);
+
+      writer.writeEndElement();
+      break;
+
+    case GeographyMultiPolygon:
+    case GeometryMultiPolygon:
+      writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_MULTIPOLYGON, Constants.NS_GML);
+      writeSrsName(writer, value);
+
+      if (!((MultiPolygon) value).isEmpty()) {
+        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_SURFACEMEMBERS, Constants.NS_GML);
+        polygons(writer, ((MultiPolygon) value).iterator(), true);
+        writer.writeEndElement();
+      }
+
+      writer.writeEndElement();
+      break;
+
+    case GeographyCollection:
+    case GeometryCollection:
+      writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_GEOCOLLECTION, Constants.NS_GML);
+      writeSrsName(writer, value);
+
+      if (!((GeospatialCollection) value).isEmpty()) {
+        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_GEOMEMBERS, Constants.NS_GML);
+        for (Geospatial geospatial : ((GeospatialCollection) value)) {
+          serialize(writer, geospatial);
+        }
+        writer.writeEndElement();
+      }
+
+      writer.writeEndElement();
+      break;
+
+    default:
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AtomSerializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AtomSerializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AtomSerializer.java
new file mode 100644
index 0000000..bc56e48
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AtomSerializer.java
@@ -0,0 +1,570 @@
+/*
+ * 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.serialization;
+
+import java.io.Writer;
+import java.net.URI;
+import java.util.Collections;
+import java.util.List;
+
+import javax.xml.XMLConstants;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.client.api.serialization.ODataSerializer;
+import org.apache.olingo.client.api.serialization.ODataSerializerException;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.ODataRuntimeException;
+import org.apache.olingo.commons.api.data.AbstractODataObject;
+import org.apache.olingo.commons.api.data.Annotation;
+import org.apache.olingo.commons.api.data.ComplexValue;
+import org.apache.olingo.commons.api.data.ContextURL;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntityCollection;
+import org.apache.olingo.commons.api.data.Link;
+import org.apache.olingo.commons.api.data.Operation;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.data.ValueType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.geo.Geospatial;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
+
+import com.fasterxml.aalto.stax.OutputFactoryImpl;
+
+public class AtomSerializer extends AbstractAtomDealer implements ODataSerializer {
+
+  private static final XMLOutputFactory FACTORY = new OutputFactoryImpl();
+
+  private final AtomGeoValueSerializer geoSerializer;
+
+  private final boolean serverMode;
+
+  public AtomSerializer() {
+    this(false);
+  }
+
+  public AtomSerializer(final boolean serverMode) {
+    geoSerializer = new AtomGeoValueSerializer();
+    this.serverMode = serverMode;
+  }
+
+  private void collection(final XMLStreamWriter writer,
+      final ValueType valueType, final EdmPrimitiveTypeKind kind, final List<?> value)
+          throws XMLStreamException, EdmPrimitiveTypeException {
+    for (Object item : value) {
+      writer.writeStartElement(Constants.PREFIX_METADATA, Constants.ELEM_ELEMENT, namespaceMetadata);
+      value(writer, valueType, kind, item);
+      writer.writeEndElement();
+    }
+  }
+
+  private void value(final XMLStreamWriter writer,
+      final ValueType valueType, final EdmPrimitiveTypeKind kind, final Object value)
+          throws XMLStreamException, EdmPrimitiveTypeException {
+    if (value == null) {
+      writer.writeAttribute(Constants.PREFIX_METADATA, namespaceMetadata,
+          Constants.ATTR_NULL, Boolean.TRUE.toString());
+      return;
+    }
+    switch (valueType) {
+    case PRIMITIVE:
+      writer.writeCharacters(kind == null ? value.toString() :
+        EdmPrimitiveTypeFactory.getInstance(kind) // TODO: add facets
+        .valueToString(value, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null));
+      break;
+    case ENUM:
+      writer.writeCharacters(value.toString());
+      break;
+    case GEOSPATIAL:
+      geoSerializer.serialize(writer, (Geospatial) value);
+      break;
+    case COLLECTION_PRIMITIVE:
+    case COLLECTION_GEOSPATIAL:
+    case COLLECTION_ENUM:
+    case COLLECTION_COMPLEX:
+      collection(writer, valueType.getBaseType(), kind, (List<?>) value);
+      break;
+    case COMPLEX:
+      for (Property property : ((ComplexValue) value).getValue()) {
+        property(writer, property, false);
+      }
+      break;
+    case ENTITY:
+    case COLLECTION_ENTITY:
+      throw new ODataRuntimeException("Entities cannot appear in this payload");
+    }
+  }
+
+  public void property(final XMLStreamWriter writer, final Property property, final boolean standalone)
+      throws XMLStreamException, EdmPrimitiveTypeException {
+
+    if (standalone) {
+      writer.writeStartElement(Constants.PREFIX_METADATA, Constants.VALUE, namespaceData);
+      namespaces(writer);
+    } else {
+      writer.writeStartElement(Constants.PREFIX_DATASERVICES, property.getName(), namespaceData);
+    }
+
+    EdmTypeInfo typeInfo = null;
+    if (StringUtils.isNotBlank(property.getType())) {
+      typeInfo = new EdmTypeInfo.Builder().setTypeExpression(property.getType()).build();
+      if (!EdmPrimitiveTypeKind.String.getFullQualifiedName().toString().equals(typeInfo.internal())) {
+        writer.writeAttribute(Constants.PREFIX_METADATA, namespaceMetadata,
+            Constants.ATTR_TYPE, typeInfo.external());
+      }
+    }
+
+    value(writer, property.getValueType(), typeInfo == null ? null : typeInfo.getPrimitiveTypeKind(),
+        property.getValue());
+    if (!property.isNull() && property.isComplex() && !property.isCollection()) {
+      links(writer, property.asComplex().getAssociationLinks());
+      links(writer, property.asComplex().getNavigationLinks());
+    }
+
+    writer.writeEndElement();
+
+    for (Annotation annotation : property.getAnnotations()) {
+      annotation(writer, annotation, property.getName());
+    }
+  }
+
+  private void property(final XMLStreamWriter writer, final Property property)
+      throws XMLStreamException, EdmPrimitiveTypeException {
+    property(writer, property, true);
+  }
+
+  private void startDocument(final XMLStreamWriter writer, final String rootElement) throws XMLStreamException {
+    writer.writeStartDocument();
+    writer.setDefaultNamespace(Constants.NS_ATOM);
+
+    writer.writeStartElement(rootElement);
+
+    namespaces(writer);
+  }
+
+  private void property(final Writer outWriter, final Property property)
+      throws XMLStreamException, EdmPrimitiveTypeException {
+    final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
+
+    writer.writeStartDocument();
+
+    property(writer, property);
+
+    writer.writeEndDocument();
+    writer.flush();
+  }
+
+  private void links(final XMLStreamWriter writer, final List<Link> links)
+      throws XMLStreamException, EdmPrimitiveTypeException {
+    for (Link link : links) {
+      writer.writeStartElement(Constants.ATOM_ELEM_LINK);
+
+      if (StringUtils.isNotBlank(link.getRel())) {
+        writer.writeAttribute(Constants.ATTR_REL, link.getRel());
+      }
+      if (StringUtils.isNotBlank(link.getTitle())) {
+        writer.writeAttribute(Constants.ATTR_TITLE, link.getTitle());
+      }
+      if (StringUtils.isNotBlank(link.getHref())) {
+        writer.writeAttribute(Constants.ATTR_HREF, link.getHref());
+      }
+      if (StringUtils.isNotBlank(link.getType())) {
+        writer.writeAttribute(Constants.ATTR_TYPE, link.getType());
+      }
+
+      if (link.getInlineEntity() != null || link.getInlineEntitySet() != null) {
+        writer.writeStartElement(Constants.PREFIX_METADATA, Constants.ATOM_ELEM_INLINE, namespaceMetadata);
+
+        if (link.getInlineEntity() != null) {
+          writer.writeStartElement(Constants.ATOM_ELEM_ENTRY);
+          entity(writer, link.getInlineEntity());
+          writer.writeEndElement();
+        }
+        if (link.getInlineEntitySet() != null) {
+          writer.writeStartElement(Constants.ATOM_ELEM_FEED);
+          entitySet(writer, link.getInlineEntitySet());
+          writer.writeEndElement();
+        }
+
+        writer.writeEndElement();
+      }
+
+      for (Annotation annotation : link.getAnnotations()) {
+        annotation(writer, annotation, null);
+      }
+
+      writer.writeEndElement();
+    }
+  }
+
+  private void common(final XMLStreamWriter writer, final AbstractODataObject object) throws XMLStreamException {
+    if (StringUtils.isNotBlank(object.getTitle())) {
+      writer.writeStartElement(Constants.ATOM_ELEM_TITLE);
+      writer.writeAttribute(Constants.ATTR_TYPE, TYPE_TEXT);
+      writer.writeCharacters(object.getTitle());
+      writer.writeEndElement();
+    }
+  }
+
+  private void properties(final XMLStreamWriter writer, final List<Property> properties)
+      throws XMLStreamException, EdmPrimitiveTypeException {
+    for (Property property : properties) {
+      property(writer, property, false);
+    }
+  }
+
+  private void annotation(final XMLStreamWriter writer, final Annotation annotation, final String target)
+      throws XMLStreamException, EdmPrimitiveTypeException {
+
+    writer.writeStartElement(Constants.PREFIX_METADATA, Constants.ANNOTATION, namespaceMetadata);
+
+    writer.writeAttribute(Constants.ATOM_ATTR_TERM, annotation.getTerm());
+
+    if (target != null) {
+      writer.writeAttribute(Constants.ATTR_TARGET, target);
+    }
+
+    EdmTypeInfo typeInfo = null;
+    if (StringUtils.isNotBlank(annotation.getType())) {
+      typeInfo = new EdmTypeInfo.Builder().setTypeExpression(annotation.getType()).build();
+      if (!EdmPrimitiveTypeKind.String.getFullQualifiedName().toString().equals(typeInfo.internal())) {
+        writer.writeAttribute(Constants.PREFIX_METADATA, namespaceMetadata,
+            Constants.ATTR_TYPE, typeInfo.external());
+      }
+    }
+
+    value(writer, annotation.getValueType(), typeInfo == null ? null : typeInfo.getPrimitiveTypeKind(),
+        annotation.getValue());
+
+    writer.writeEndElement();
+  }
+
+  private void entity(final XMLStreamWriter writer, final Entity entity)
+      throws XMLStreamException, EdmPrimitiveTypeException {
+    if (entity.getBaseURI() != null) {
+      writer.writeAttribute(XMLConstants.XML_NS_URI, Constants.ATTR_XML_BASE, entity.getBaseURI().toASCIIString());
+    }
+
+    if (serverMode && StringUtils.isNotBlank(entity.getETag())) {
+      writer.writeAttribute(namespaceMetadata, Constants.ATOM_ATTR_ETAG, entity.getETag());
+    }
+
+    if (entity.getId() != null) {
+      writer.writeStartElement(Constants.ATOM_ELEM_ID);
+      writer.writeCharacters(entity.getId().toASCIIString());
+      writer.writeEndElement();
+    }
+
+    writer.writeStartElement(Constants.ATOM_ELEM_CATEGORY);
+    writer.writeAttribute(Constants.ATOM_ATTR_SCHEME, Constants.NS_SCHEME);
+    if (StringUtils.isNotBlank(entity.getType())) {
+      writer.writeAttribute(Constants.ATOM_ATTR_TERM,
+          new EdmTypeInfo.Builder().setTypeExpression(entity.getType()).build().external());
+    }
+    writer.writeEndElement();
+
+    common(writer, entity);
+
+    if (serverMode) {
+      if (entity.getEditLink() != null) {
+        links(writer, Collections.singletonList(entity.getEditLink()));
+      }
+
+      if (entity.getSelfLink() != null) {
+        links(writer, Collections.singletonList(entity.getSelfLink()));
+      }
+    }
+
+    links(writer, entity.getAssociationLinks());
+    links(writer, entity.getNavigationLinks());
+    links(writer, entity.getMediaEditLinks());
+
+    if (serverMode) {
+      for (Operation operation : entity.getOperations()) {
+        writer.writeStartElement(namespaceMetadata, Constants.ATOM_ELEM_ACTION);
+        writer.writeAttribute(Constants.ATTR_METADATA, operation.getMetadataAnchor());
+        writer.writeAttribute(Constants.ATTR_TITLE, operation.getTitle());
+        writer.writeAttribute(Constants.ATTR_TARGET, operation.getTarget().toASCIIString());
+        writer.writeEndElement();
+      }
+    }
+
+    writer.writeStartElement(Constants.ATOM_ELEM_CONTENT);
+    if (entity.isMediaEntity()) {
+      if (StringUtils.isNotBlank(entity.getMediaContentType())) {
+        writer.writeAttribute(Constants.ATTR_TYPE, entity.getMediaContentType());
+      }
+      if (entity.getMediaContentSource() != null) {
+        writer.writeAttribute(Constants.ATOM_ATTR_SRC, entity.getMediaContentSource().toASCIIString());
+      }
+      writer.writeEndElement();
+
+      writer.writeStartElement(namespaceMetadata, Constants.PROPERTIES);
+      properties(writer, entity.getProperties());
+    } else {
+      writer.writeAttribute(Constants.ATTR_TYPE, ContentType.APPLICATION_XML.toContentTypeString());
+      writer.writeStartElement(namespaceMetadata, Constants.PROPERTIES);
+      properties(writer, entity.getProperties());
+      writer.writeEndElement();
+    }
+    writer.writeEndElement();
+
+    for (Annotation annotation : entity.getAnnotations()) {
+      annotation(writer, annotation, null);
+    }
+  }
+
+  private void entityRef(final XMLStreamWriter writer, final Entity entity) throws XMLStreamException {
+    writer.writeStartElement(Constants.ATOM_ELEM_ENTRY_REF);
+    writer.writeNamespace(StringUtils.EMPTY, namespaceMetadata);
+    writer.writeAttribute(Constants.ATOM_ATTR_ID, entity.getId().toASCIIString());
+  }
+
+  private void entityRef(final XMLStreamWriter writer, final ResWrap<Entity> container) throws XMLStreamException {
+    writer.writeStartElement(Constants.ATOM_ELEM_ENTRY_REF);
+    writer.writeNamespace(StringUtils.EMPTY, namespaceMetadata);
+    addContextInfo(writer, container);
+    writer.writeAttribute(Constants.ATOM_ATTR_ID, container.getPayload().getId().toASCIIString());
+  }
+
+  private void entity(final Writer outWriter, final Entity entity)
+      throws XMLStreamException, EdmPrimitiveTypeException {
+    final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
+
+    if (entity.getType() == null && entity.getProperties().isEmpty()) {
+      writer.writeStartDocument();
+      writer.setDefaultNamespace(namespaceMetadata);
+
+      entityRef(writer, entity);
+    } else {
+      startDocument(writer, Constants.ATOM_ELEM_ENTRY);
+
+      entity(writer, entity);
+    }
+
+    writer.writeEndElement();
+    writer.writeEndDocument();
+    writer.flush();
+  }
+
+  private void entity(final Writer outWriter, final ResWrap<Entity> container)
+      throws XMLStreamException, EdmPrimitiveTypeException {
+    final Entity entity = container.getPayload();
+
+    final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
+
+    if (entity.getType() == null && entity.getProperties().isEmpty()) {
+      writer.writeStartDocument();
+      writer.setDefaultNamespace(namespaceMetadata);
+
+      entityRef(writer, container);
+    } else {
+      startDocument(writer, Constants.ATOM_ELEM_ENTRY);
+
+      addContextInfo(writer, container);
+
+      entity(writer, entity);
+    }
+
+    writer.writeEndElement();
+    writer.writeEndDocument();
+    writer.flush();
+  }
+
+  private void entitySet(final XMLStreamWriter writer, final EntityCollection entitySet)
+      throws XMLStreamException, EdmPrimitiveTypeException {
+    if (entitySet.getBaseURI() != null) {
+      writer.writeAttribute(XMLConstants.XML_NS_URI, Constants.ATTR_XML_BASE, entitySet.getBaseURI().toASCIIString());
+    }
+
+    if (entitySet.getCount() != null) {
+      writer.writeStartElement(namespaceMetadata, Constants.ATOM_ELEM_COUNT);
+      writer.writeCharacters(Integer.toString(entitySet.getCount()));
+      writer.writeEndElement();
+    }
+
+    if (entitySet.getId() != null) {
+      writer.writeStartElement(Constants.ATOM_ELEM_ID);
+      writer.writeCharacters(entitySet.getId().toASCIIString());
+      writer.writeEndElement();
+    }
+
+    common(writer, entitySet);
+
+    for (Entity entity : entitySet.getEntities()) {
+      if (entity.getType() == null && entity.getProperties().isEmpty()) {
+        entityRef(writer, entity);
+        writer.writeEndElement();
+      } else {
+        writer.writeStartElement(Constants.ATOM_ELEM_ENTRY);
+        entity(writer, entity);
+        writer.writeEndElement();
+      }
+    }
+
+    if (serverMode) {
+      if (entitySet.getNext() != null) {
+        final Link next = new Link();
+        next.setRel(Constants.NEXT_LINK_REL);
+        next.setHref(entitySet.getNext().toASCIIString());
+
+        links(writer, Collections.<Link> singletonList(next));
+      }
+      if (entitySet.getDeltaLink() != null) {
+        final Link next = new Link();
+        next.setRel(Constants.NS_DELTA_LINK_REL);
+        next.setHref(entitySet.getDeltaLink().toASCIIString());
+
+        links(writer, Collections.<Link> singletonList(next));
+      }
+    }
+  }
+
+  private void entitySet(final Writer outWriter, final EntityCollection entitySet)
+      throws XMLStreamException, EdmPrimitiveTypeException {
+    final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
+
+    startDocument(writer, Constants.ATOM_ELEM_FEED);
+
+    entitySet(writer, entitySet);
+
+    writer.writeEndElement();
+    writer.writeEndDocument();
+    writer.flush();
+  }
+
+  private void entitySet(final Writer outWriter, final ResWrap<EntityCollection> entitySet)
+      throws XMLStreamException, EdmPrimitiveTypeException {
+    final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
+
+    startDocument(writer, Constants.ATOM_ELEM_FEED);
+
+    addContextInfo(writer, entitySet);
+
+    entitySet(writer, entitySet.getPayload());
+
+    writer.writeEndElement();
+    writer.writeEndDocument();
+    writer.flush();
+  }
+
+  private void link(final Writer outWriter, final Link link) throws XMLStreamException {
+    final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
+
+    writer.writeStartDocument();
+
+    writer.writeStartElement(Constants.ELEM_LINKS);
+    writer.writeDefaultNamespace(namespaceData);
+
+    writer.writeStartElement(Constants.ELEM_URI);
+    writer.writeCharacters(link.getHref());
+    writer.writeEndElement();
+
+    writer.writeEndElement();
+
+    writer.writeEndDocument();
+    writer.flush();
+  }
+
+  @Override
+  public <T> void write(final Writer writer, final T obj) throws ODataSerializerException {
+    try {
+      if (obj instanceof EntityCollection) {
+        entitySet(writer, (EntityCollection) obj);
+      } else if (obj instanceof Entity) {
+        entity(writer, (Entity) obj);
+      } else if (obj instanceof Property) {
+        property(writer, (Property) obj);
+      } else if (obj instanceof Link) {
+        link(writer, (Link) obj);
+      }
+    } catch (final XMLStreamException e) {
+      throw new ODataSerializerException(e);
+    } catch (final EdmPrimitiveTypeException e) {
+      throw new ODataSerializerException(e);
+    }
+  }
+
+  private void reference(final Writer outWriter, final ResWrap<URI> container) throws XMLStreamException {
+    final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
+
+    writer.writeStartDocument();
+
+    writer.writeStartElement(Constants.ATTR_METADATA, Constants.ATTR_REF);
+    writer.writeNamespace(Constants.ATTR_METADATA, Constants.NS_METADATA);
+    writer.writeAttribute(Constants.ATTR_METADATA, Constants.CONTEXT, container.getContextURL().toASCIIString());
+    writer.writeAttribute(Constants.ATOM_ATTR_ID, container.getPayload().toASCIIString());
+    writer.writeEndElement();
+
+    writer.writeEndDocument();
+  }
+
+  @Override
+  @SuppressWarnings("unchecked")
+  public <T> void write(final Writer writer, final ResWrap<T> container) throws ODataSerializerException {
+    final T obj = container == null ? null : container.getPayload();
+
+    try {
+      if (obj instanceof EntityCollection) {
+        this.entitySet(writer, (ResWrap<EntityCollection>) container);
+      } else if (obj instanceof Entity) {
+        entity(writer, (ResWrap<Entity>) container);
+      } else if (obj instanceof Property) {
+        property(writer, (Property) obj);
+      } else if (obj instanceof Link) {
+        link(writer, (Link) obj);
+      } else if (obj instanceof URI) {
+        reference(writer, (ResWrap<URI>) container);
+      }
+    } catch (final XMLStreamException e) {
+      throw new ODataSerializerException(e);
+    } catch (final EdmPrimitiveTypeException e) {
+      throw new ODataSerializerException(e);
+    }
+  }
+
+  private <T> void addContextInfo(
+      final XMLStreamWriter writer, final ResWrap<T> container) throws XMLStreamException {
+
+    if (container.getContextURL() != null) {
+      final ContextURL contextURL = ContextURLParser.parse(container.getContextURL());
+      final URI base = contextURL.getServiceRoot();
+      if (container.getPayload() instanceof EntityCollection) {
+        ((EntityCollection) container.getPayload()).setBaseURI(base);
+      }
+      if (container.getPayload() instanceof Entity) {
+        ((Entity) container.getPayload()).setBaseURI(base);
+      }
+
+      writer.writeAttribute(namespaceMetadata, Constants.CONTEXT,
+          container.getContextURL().toASCIIString());
+    }
+
+    if (StringUtils.isNotBlank(container.getMetadataETag())) {
+      writer.writeAttribute(namespaceMetadata, Constants.ATOM_ATTR_METADATAETAG,
+          container.getMetadataETag());
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ClientODataDeserializerImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ClientODataDeserializerImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ClientODataDeserializerImpl.java
index 92bd57b..89dea37 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ClientODataDeserializerImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ClientODataDeserializerImpl.java
@@ -26,6 +26,8 @@ import javax.xml.stream.XMLStreamException;
 import org.apache.olingo.client.api.data.ServiceDocument;
 import org.apache.olingo.client.api.edm.xml.XMLMetadata;
 import org.apache.olingo.client.api.serialization.ClientODataDeserializer;
+import org.apache.olingo.client.api.serialization.ODataDeserializer;
+import org.apache.olingo.client.api.serialization.ODataDeserializerException;
 import org.apache.olingo.client.core.data.JSONServiceDocumentDeserializer;
 import org.apache.olingo.client.core.data.XMLServiceDocumentDeserializer;
 import org.apache.olingo.client.core.edm.xml.ClientCsdlEdmx;
@@ -38,11 +40,6 @@ import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.ODataError;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.serialization.ODataDeserializer;
-import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
-import org.apache.olingo.commons.core.serialization.AtomDeserializer;
-import org.apache.olingo.commons.core.serialization.JsonDeltaDeserializer;
-import org.apache.olingo.commons.core.serialization.JsonDeserializer;
 
 import com.fasterxml.aalto.stax.InputFactoryImpl;
 import com.fasterxml.aalto.stax.OutputFactoryImpl;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ContextURLParser.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ContextURLParser.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ContextURLParser.java
new file mode 100644
index 0000000..873ca4c
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ContextURLParser.java
@@ -0,0 +1,118 @@
+/*
+ * 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.serialization;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.ContextURL;
+import org.apache.olingo.commons.api.data.ContextURL.Suffix;
+
+public class ContextURLParser {
+
+  public static ContextURL parse(final URI contextURL) {
+    if (contextURL == null) {
+      return null;
+    }
+
+    final ContextURL.Builder contextUrl = ContextURL.with();
+
+    String contextURLasString = contextURL.toASCIIString();
+
+    boolean isEntity = false;
+    if (contextURLasString.endsWith("/$entity") || contextURLasString.endsWith("/@Element")) {
+      isEntity = true;
+      contextUrl.suffix(Suffix.ENTITY);
+      contextURLasString = contextURLasString.replace("/$entity", StringUtils.EMPTY).
+          replace("/@Element", StringUtils.EMPTY);
+    } else if (contextURLasString.endsWith("/$ref")) {
+      contextUrl.suffix(Suffix.REFERENCE);
+      contextURLasString = contextURLasString.replace("/$ref", StringUtils.EMPTY);
+    } else if (contextURLasString.endsWith("/$delta")) {
+      contextUrl.suffix(Suffix.DELTA);
+      contextURLasString = contextURLasString.replace("/$delta", StringUtils.EMPTY);
+    } else if (contextURLasString.endsWith("/$deletedEntity")) {
+      contextUrl.suffix(Suffix.DELTA_DELETED_ENTITY);
+      contextURLasString = contextURLasString.replace("/$deletedEntity", StringUtils.EMPTY);
+    } else if (contextURLasString.endsWith("/$link")) {
+      contextUrl.suffix(Suffix.DELTA_LINK);
+      contextURLasString = contextURLasString.replace("/$link", StringUtils.EMPTY);
+    } else if (contextURLasString.endsWith("/$deletedLink")) {
+      contextUrl.suffix(Suffix.DELTA_DELETED_LINK);
+      contextURLasString = contextURLasString.replace("/$deletedLink", StringUtils.EMPTY);
+    }
+
+    contextUrl.serviceRoot(URI.create(StringUtils.substringBefore(contextURLasString, Constants.METADATA)));
+
+    final String rest = StringUtils.substringAfter(contextURLasString, Constants.METADATA + "#");
+
+    String firstToken;
+    String entitySetOrSingletonOrType;
+    if (rest.startsWith("Collection(")) {
+      firstToken = rest.substring(0, rest.indexOf(')') + 1);
+      entitySetOrSingletonOrType = firstToken;
+    } else {
+      final int openParIdx = rest.indexOf('(');
+      if (openParIdx == -1) {
+        firstToken = StringUtils.substringBeforeLast(rest, "/");
+
+        entitySetOrSingletonOrType = firstToken;
+      } else {
+        firstToken = isEntity ? rest : StringUtils.substringBeforeLast(rest, ")") + ")";
+
+        final List<String> parts = new ArrayList<String>();
+        for (String split : firstToken.split("\\)/")) {
+          parts.add(split.replaceAll("\\(.*", ""));
+        }
+        entitySetOrSingletonOrType = StringUtils.join(parts, '/');
+        final int commaIdx = firstToken.indexOf(',');
+        if (commaIdx != -1) {
+          contextUrl.selectList(firstToken.substring(openParIdx + 1, firstToken.length() - 1));
+        }
+      }
+    }
+    contextUrl.entitySetOrSingletonOrType(entitySetOrSingletonOrType);
+
+    final int slashIdx = entitySetOrSingletonOrType.lastIndexOf('/');
+    if (slashIdx != -1 && entitySetOrSingletonOrType.substring(slashIdx + 1).indexOf('.') != -1) {
+      contextUrl.entitySetOrSingletonOrType(entitySetOrSingletonOrType.substring(0, slashIdx));
+      contextUrl.derivedEntity(entitySetOrSingletonOrType.substring(slashIdx + 1));
+    }
+
+    if (!firstToken.equals(rest)) {
+      final String[] pathElems = StringUtils.substringAfter(rest, "/").split("/");
+      if (pathElems.length > 0 && pathElems[0].length() > 0) {
+        if (pathElems[0].indexOf('.') == -1) {
+          contextUrl.navOrPropertyPath(pathElems[0]);
+        } else {
+          contextUrl.derivedEntity(pathElems[0]);
+        }
+
+        if (pathElems.length > 1) {
+          contextUrl.navOrPropertyPath(pathElems[1]);
+        }
+      }
+    }
+
+    return contextUrl.build();
+  }
+}


[29/39] olingo-odata4 git commit: [OLINGO-659] clean-up dispatcher tests

Posted by ch...@apache.org.
[OLINGO-659] clean-up dispatcher tests

Change-Id: I271f84b065a476a0dcf9c13480280e41bf9dfce5

Signed-off-by: Christian Amend <ch...@sap.com>


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

Branch: refs/heads/IEE754Compatible
Commit: 23815dc61c5d6c8d1070c1fd5cf7a40a9d8b1a5c
Parents: 431938c
Author: Klaus Straubinger <kl...@sap.com>
Authored: Fri Jun 19 10:29:37 2015 +0200
Committer: Christian Amend <ch...@sap.com>
Committed: Fri Jun 19 10:51:14 2015 +0200

----------------------------------------------------------------------
 .../olingo/server/core/ODataHandlerTest.java    | 62 ++++++--------------
 1 file changed, 19 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/23815dc6/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
index 755c4f1..ec5a33d 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
@@ -29,12 +29,8 @@ import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyZeroInteractions;
 
-import java.util.Arrays;
 import java.util.Collections;
-import java.util.List;
 import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.olingo.commons.api.ODataException;
@@ -48,12 +44,13 @@ import org.apache.olingo.commons.api.http.HttpContentType;
 import org.apache.olingo.commons.api.http.HttpHeader;
 import org.apache.olingo.commons.api.http.HttpMethod;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
-import org.apache.olingo.server.api.ODataServerError;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
+import org.apache.olingo.server.api.ODataServerError;
 import org.apache.olingo.server.api.ServiceMetadata;
+import org.apache.olingo.server.api.batch.BatchFacade;
 import org.apache.olingo.server.api.edmx.EdmxReference;
 import org.apache.olingo.server.api.processor.ActionComplexCollectionProcessor;
 import org.apache.olingo.server.api.processor.ActionComplexProcessor;
@@ -247,8 +244,9 @@ public class ODataHandlerTest {
     final String uri = "$batch";
     final BatchProcessor processor = mock(BatchProcessor.class);
 
-    dispatch(HttpMethod.POST, uri, processor);
-    // TODO: Verify that batch processing has been called.
+    dispatch(HttpMethod.POST, uri, null, HttpHeader.CONTENT_TYPE, ContentType.MULTIPART_MIXED.toContentTypeString(),
+        processor);
+    verify(processor).processBatch(any(BatchFacade.class), any(ODataRequest.class), any(ODataResponse.class));
 
     dispatchMethodNotAllowed(HttpMethod.GET, uri, processor);
     dispatchMethodNotAllowed(HttpMethod.PATCH, uri, processor);
@@ -650,7 +648,7 @@ public class ODataHandlerTest {
   @Test
   public void dispatchReference() throws Exception {
     final String uri = "ESAllPrim(0)/NavPropertyETTwoPrimOne/$ref";
-    final String uriDeleteMany = "ESAllPrim(0)/NavPropertyETTwoPrimMany/$ref";
+    final String uriMany = "ESAllPrim(0)/NavPropertyETTwoPrimMany/$ref";
     final ReferenceProcessor processor = mock(ReferenceProcessor.class);
 
     dispatch(HttpMethod.GET, uri, processor);
@@ -665,29 +663,25 @@ public class ODataHandlerTest {
     verify(processor, times(2)).updateReference(any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class),
         any(ContentType.class));
 
-    dispatch(HttpMethod.POST, uri.replace("One", "Many"), processor);
+    dispatchMethodNotAllowed(HttpMethod.POST, uri, processor);
+
+    dispatch(HttpMethod.POST, uriMany, processor);
     verify(processor).createReference(any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class),
         any(ContentType.class));
-    
-    dispatch(HttpMethod.DELETE, uriDeleteMany, "$id=ESTwoPrim(1)", null, Arrays.asList(new Processor[] { processor }));
+
+    dispatch(HttpMethod.DELETE, uriMany, "$id=ESTwoPrim(1)", null, null, processor);
     verify(processor).deleteReference(any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class));
-    
-    dispatchMethodNotAllowed(HttpMethod.POST, uri, processor);
   }
-  
+
   @Test
   public void dispatchReferenceCollection() throws Exception {
     final String uri = "ESAllPrim(0)/NavPropertyETTwoPrimMany/$ref";
     final ReferenceCollectionProcessor processor = mock(ReferenceCollectionProcessor.class);
-    final ReferenceProcessor singleProcessor = mock(ReferenceProcessor.class);
-    
+
     dispatch(HttpMethod.GET, uri, processor);
     verify(processor).readReferenceCollection(any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class),
         any(ContentType.class));
 
-    dispatch(HttpMethod.DELETE, uri, singleProcessor);
-    verify(singleProcessor).deleteReference(any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class));
-    
     dispatchMethodNotAllowed(HttpMethod.PATCH, uri, processor);
     dispatchMethodNotAllowed(HttpMethod.PUT, uri, processor);
   }
@@ -696,7 +690,7 @@ public class ODataHandlerTest {
   public void unsupportedRequestContentType() throws Exception {
     EntityProcessor processor = mock(EntityProcessor.class);
     ErrorProcessor errorProcessor = mock(ErrorProcessor.class);
-    dispatch(HttpMethod.POST, "ESAllPrim", "", HttpHeader.CONTENT_TYPE, "some/unsupported", errorProcessor);
+    dispatch(HttpMethod.POST, "ESAllPrim", null, HttpHeader.CONTENT_TYPE, "some/unsupported", errorProcessor);
     verifyZeroInteractions(processor);
     verify(errorProcessor).processError(any(ODataRequest.class), any(ODataResponse.class),
         any(ODataServerError.class),
@@ -705,19 +699,6 @@ public class ODataHandlerTest {
 
   private ODataResponse dispatch(final HttpMethod method, final String path, final String query,
       final String headerName, final String headerValue, final Processor processor) {
-    Map<String, List<String>> headers = null;
-    if (headerName != null) {
-      headers = Collections.singletonMap(headerName, Collections.singletonList(headerValue));
-    }
-    List<Processor> processors = null;
-    if (processor != null) {
-      processors = Collections.singletonList(processor);
-    }
-    return dispatch(method, path, query, headers, processors);
-  }
-
-  private ODataResponse dispatch(final HttpMethod method, final String path, final String query,
-      final Map<String, List<String>> headers, final List<Processor> processors) {
     ODataRequest request = new ODataRequest();
     request.setMethod(method);
     request.setRawBaseUri(BASE_URI);
@@ -727,14 +708,11 @@ public class ODataHandlerTest {
     request.setRawODataPath(path);
     request.setRawQueryPath(query);
 
-    if (headers != null) {
-      Set<Map.Entry<String, List<String>>> headerSet = headers.entrySet();
-      for (Map.Entry<String, List<String>> headerItem : headerSet) {
-        request.addHeader(headerItem.getKey(), headerItem.getValue());
-      }
+    if (headerName != null) {
+      request.addHeader(headerName, Collections.singletonList(headerValue));
     }
 
-    if (request.getHeaders(HttpHeader.CONTENT_TYPE) == null) {
+    if (headerName != HttpHeader.CONTENT_TYPE) {
       request.addHeader(HttpHeader.CONTENT_TYPE, Collections.singletonList(
           ODataFormat.JSON.getContentType().toContentTypeString()));
     }
@@ -745,10 +723,8 @@ public class ODataHandlerTest {
 
     ODataHandler handler = new ODataHandler(odata, metadata);
 
-    if (processors != null && !processors.isEmpty()) {
-      for (Processor p : processors) {
-        handler.register(p);
-      }
+    if (processor != null) {
+      handler.register(processor);
     }
 
     final ODataResponse response = handler.process(request);


[11/39] olingo-odata4 git commit: [OLINGO-699] Moved serializer code to client module

Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java
deleted file mode 100644
index b8b5167..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java
+++ /dev/null
@@ -1,873 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.serialization;
-
-import java.io.InputStream;
-import java.net.URI;
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLEventReader;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.events.Attribute;
-import javax.xml.stream.events.StartElement;
-import javax.xml.stream.events.XMLEvent;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.ODataError;
-import org.apache.olingo.commons.api.ODataPropertyType;
-import org.apache.olingo.commons.api.data.AbstractODataObject;
-import org.apache.olingo.commons.api.data.Annotation;
-import org.apache.olingo.commons.api.data.ComplexValue;
-import org.apache.olingo.commons.api.data.DeletedEntity;
-import org.apache.olingo.commons.api.data.DeletedEntity.Reason;
-import org.apache.olingo.commons.api.data.Delta;
-import org.apache.olingo.commons.api.data.DeltaLink;
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntityCollection;
-import org.apache.olingo.commons.api.data.Link;
-import org.apache.olingo.commons.api.data.Operation;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.data.Valuable;
-import org.apache.olingo.commons.api.data.ValueType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.geo.Geospatial;
-import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.commons.api.serialization.ODataDeserializer;
-import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
-import org.apache.olingo.commons.core.edm.EdmTypeInfo;
-
-import com.fasterxml.aalto.stax.InputFactoryImpl;
-
-public class AtomDeserializer extends AbstractAtomDealer implements ODataDeserializer {
-
-  protected static final XMLInputFactory FACTORY = new InputFactoryImpl();
-
-  private final AtomGeoValueDeserializer geoDeserializer;
-
-  protected XMLEventReader getReader(final InputStream input) throws XMLStreamException {
-    return FACTORY.createXMLEventReader(input);
-  }
-
-  public AtomDeserializer() {
-    geoDeserializer = new AtomGeoValueDeserializer();
-  }
-
-  private Object fromPrimitive(final XMLEventReader reader, final StartElement start,
-      final EdmTypeInfo typeInfo) throws XMLStreamException, EdmPrimitiveTypeException {
-
-    Object value = null;
-
-    boolean foundEndProperty = false;
-    while (reader.hasNext() && !foundEndProperty) {
-      final XMLEvent event = reader.nextEvent();
-
-      if (event.isStartElement() && typeInfo != null && typeInfo.getPrimitiveTypeKind().isGeospatial()) {
-        final EdmPrimitiveTypeKind geoType =
-            EdmPrimitiveTypeKind.valueOfFQN(typeInfo.getFullQualifiedName().toString());
-        value = geoDeserializer.deserialize(reader, event.asStartElement(), geoType);
-      }
-
-      if (event.isCharacters() && !event.asCharacters().isWhiteSpace()
-          && (typeInfo == null || !typeInfo.getPrimitiveTypeKind().isGeospatial())) {
-
-        final String stringValue = event.asCharacters().getData();
-        value = typeInfo == null ? stringValue : // TODO: add facets
-          ((EdmPrimitiveType) typeInfo.getType()).valueOfString(stringValue, true, null,
-              Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, true,
-              ((EdmPrimitiveType) typeInfo.getType()).getDefaultType());
-      }
-
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndProperty = true;
-      }
-    }
-
-    return value;
-  }
-
-  private Object fromComplexOrEnum(final XMLEventReader reader, final StartElement start)
-      throws XMLStreamException, EdmPrimitiveTypeException {
-
-    Object value = null;
-
-    boolean foundEndProperty = false;
-    while (reader.hasNext() && !foundEndProperty) {
-      final XMLEvent event = reader.nextEvent();
-
-      if (event.isStartElement()) {
-        if (value == null) {
-          value = new ComplexValue();
-        }
-
-        if (Constants.QNAME_ATOM_ELEM_LINK.equals(event.asStartElement().getName())) {
-          final Link link = new Link();
-          final Attribute rel = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REL));
-          if (rel != null) {
-            link.setRel(rel.getValue());
-          }
-          final Attribute title = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TITLE));
-          if (title != null) {
-            link.setTitle(title.getValue());
-          }
-          final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
-          if (href != null) {
-            link.setHref(href.getValue());
-          }
-          final Attribute type = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TYPE));
-          if (type != null) {
-            link.setType(type.getValue());
-          }
-
-          if (link.getRel().startsWith(Constants.NS_NAVIGATION_LINK_REL)) {
-
-            ((ComplexValue) value).getNavigationLinks().add(link);
-            inline(reader, event.asStartElement(), link);
-          } else if (link.getRel().startsWith(Constants.NS_ASSOCIATION_LINK_REL)) {
-
-            ((Valuable) value).asComplex().getAssociationLinks().add(link);
-          }
-        } else {
-          ((ComplexValue) value).getValue().add(property(reader, event.asStartElement()));
-        }
-      }
-
-      if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
-        value = event.asCharacters().getData();
-      }
-
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndProperty = true;
-      }
-    }
-
-    return value;
-  }
-
-  private void fromCollection(final Valuable valuable, final XMLEventReader reader, final StartElement start,
-      final EdmTypeInfo typeInfo) throws XMLStreamException, EdmPrimitiveTypeException {
-
-    List<Object> values = new ArrayList<Object>();
-    ValueType valueType = ValueType.COLLECTION_PRIMITIVE;
-
-    final EdmTypeInfo type = typeInfo == null ? null :
-      new EdmTypeInfo.Builder().setTypeExpression(typeInfo.getFullQualifiedName().toString()).build();
-
-    boolean foundEndProperty = false;
-    while (reader.hasNext() && !foundEndProperty) {
-      final XMLEvent event = reader.nextEvent();
-
-      if (event.isStartElement()) {
-        switch (guessPropertyType(reader, typeInfo)) {
-        case COMPLEX:
-          final Object complexValue = fromComplexOrEnum(reader, event.asStartElement());
-          valueType = ValueType.COLLECTION_COMPLEX;
-          values.add(complexValue);
-          break;
-
-        case ENUM:
-          valueType = ValueType.COLLECTION_ENUM;
-          values.add(fromComplexOrEnum(reader, event.asStartElement()));
-          break;
-
-        case PRIMITIVE:
-          final Object value = fromPrimitive(reader, event.asStartElement(), type);
-          valueType = value instanceof Geospatial ?
-              ValueType.COLLECTION_GEOSPATIAL : ValueType.COLLECTION_PRIMITIVE;
-          values.add(value);
-          break;
-
-        default:
-          // do not add null or empty values
-        }
-      }
-
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndProperty = true;
-      }
-    }
-    valuable.setValue(valueType, values);
-  }
-
-  private ODataPropertyType guessPropertyType(final XMLEventReader reader, final EdmTypeInfo typeInfo)
-      throws XMLStreamException {
-
-    XMLEvent child = null;
-    while (reader.hasNext() && child == null) {
-      final XMLEvent event = reader.peek();
-      if (event.isCharacters() && event.asCharacters().isWhiteSpace()) {
-        reader.nextEvent();
-      } else {
-        child = event;
-      }
-    }
-
-    final ODataPropertyType type;
-    if (child == null) {
-      type = typeInfo == null || typeInfo.isPrimitiveType() ? ODataPropertyType.PRIMITIVE : ODataPropertyType.ENUM;
-    } else {
-      if (child.isStartElement()) {
-        if (Constants.NS_GML.equals(child.asStartElement().getName().getNamespaceURI())) {
-          type = ODataPropertyType.PRIMITIVE;
-        } else if (elementQName.equals(child.asStartElement().getName())) {
-          type = ODataPropertyType.COLLECTION;
-        } else {
-          type = ODataPropertyType.COMPLEX;
-        }
-      } else if (child.isCharacters()) {
-        type = typeInfo == null || typeInfo.isPrimitiveType()
-            ? ODataPropertyType.PRIMITIVE
-                : ODataPropertyType.ENUM;
-      } else {
-        type = ODataPropertyType.EMPTY;
-      }
-    }
-
-    return type;
-  }
-
-  private Property property(final XMLEventReader reader, final StartElement start)
-      throws XMLStreamException, EdmPrimitiveTypeException {
-
-    final Property property = new Property();
-
-    if (propertyValueQName.equals(start.getName())) {
-      // retrieve name from context
-      final Attribute context = start.getAttributeByName(contextQName);
-      if (context != null) {
-        property.setName(StringUtils.substringAfterLast(context.getValue(), "/"));
-      }
-    } else {
-      property.setName(start.getName().getLocalPart());
-    }
-
-    valuable(property, reader, start);
-
-    return property;
-  }
-
-  private void valuable(final Valuable valuable, final XMLEventReader reader, final StartElement start)
-      throws XMLStreamException, EdmPrimitiveTypeException {
-
-    final Attribute nullAttr = start.getAttributeByName(nullQName);
-
-    final Attribute typeAttr = start.getAttributeByName(typeQName);
-    final String typeAttrValue = typeAttr == null ? null : typeAttr.getValue();
-
-    final EdmTypeInfo typeInfo = StringUtils.isBlank(typeAttrValue) ? null :
-      new EdmTypeInfo.Builder().setTypeExpression(typeAttrValue).build();
-
-    if (typeInfo != null) {
-      valuable.setType(typeInfo.internal());
-    }
-
-    final ODataPropertyType propType = typeInfo == null ? guessPropertyType(reader, typeInfo) :
-      typeInfo.isCollection() ? ODataPropertyType.COLLECTION :
-        typeInfo.isPrimitiveType() ? ODataPropertyType.PRIMITIVE : ODataPropertyType.COMPLEX;
-
-    if (nullAttr == null) {
-      switch (propType) {
-      case COLLECTION:
-        fromCollection(valuable, reader, start, typeInfo);
-        break;
-
-      case COMPLEX:
-        final Object complexValue = fromComplexOrEnum(reader, start);
-        valuable.setValue(complexValue instanceof ComplexValue ? ValueType.COMPLEX : ValueType.ENUM,
-            complexValue);
-        break;
-
-      case PRIMITIVE:
-        // No type specified? Defaults to Edm.String
-        if (typeInfo == null) {
-          valuable.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName().toString());
-        }
-        final Object value = fromPrimitive(reader, start, typeInfo);
-        valuable.setValue(value instanceof Geospatial ? ValueType.GEOSPATIAL : ValueType.PRIMITIVE, value);
-        break;
-
-      case EMPTY:
-      default:
-        valuable.setValue(ValueType.PRIMITIVE, StringUtils.EMPTY);
-      }
-    } else {
-      valuable.setValue(propType == ODataPropertyType.PRIMITIVE ? ValueType.PRIMITIVE :
-        propType == ODataPropertyType.ENUM ? ValueType.ENUM :
-          propType == ODataPropertyType.COMPLEX ? ValueType.COMPLEX :
-            propType == ODataPropertyType.COLLECTION ? ValueType.COLLECTION_PRIMITIVE : ValueType.PRIMITIVE,
-                null);
-    }
-  }
-
-  @Override
-  public ResWrap<Property> toProperty(final InputStream input) throws ODataDeserializerException {
-    try {
-      final XMLEventReader reader = getReader(input);
-      final StartElement start = skipBeforeFirstStartElement(reader);
-      return getContainer(start, property(reader, start));
-    } catch (XMLStreamException e) {
-      throw new ODataDeserializerException(e);
-    } catch (final EdmPrimitiveTypeException e) {
-      throw new ODataDeserializerException(e);
-    }
-  }
-
-  private StartElement skipBeforeFirstStartElement(final XMLEventReader reader) throws XMLStreamException {
-    StartElement startEvent = null;
-    while (reader.hasNext() && startEvent == null) {
-      final XMLEvent event = reader.nextEvent();
-      if (event.isStartElement()) {
-        startEvent = event.asStartElement();
-      }
-    }
-    if (startEvent == null) {
-      throw new IllegalArgumentException("Cannot find any XML start element");
-    }
-
-    return startEvent;
-  }
-
-  private void common(final XMLEventReader reader, final StartElement start,
-      final AbstractODataObject object, final String key) throws XMLStreamException {
-
-    boolean foundEndElement = false;
-    while (reader.hasNext() && !foundEndElement) {
-      final XMLEvent event = reader.nextEvent();
-
-      if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
-        try {
-          object.setCommonProperty(key, event.asCharacters().getData());
-        } catch (ParseException e) {
-          throw new XMLStreamException("While parsing Atom entry or feed common elements", e);
-        }
-      }
-
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndElement = true;
-      }
-    }
-  }
-
-  private void inline(final XMLEventReader reader, final StartElement start, final Link link)
-      throws XMLStreamException, EdmPrimitiveTypeException {
-
-    boolean foundEndElement = false;
-    while (reader.hasNext() && !foundEndElement) {
-      final XMLEvent event = reader.nextEvent();
-
-      if (event.isStartElement()) {
-        if (inlineQName.equals(event.asStartElement().getName())) {
-          StartElement inline = getStartElement(reader);
-          if (inline != null) {
-            if (Constants.QNAME_ATOM_ELEM_ENTRY.equals(inline.getName())) {
-              link.setInlineEntity(entity(reader, inline));
-            }
-            if (Constants.QNAME_ATOM_ELEM_FEED.equals(inline.getName())) {
-              link.setInlineEntitySet(entitySet(reader, inline));
-            }
-          }
-        } else if (annotationQName.equals(event.asStartElement().getName())) {
-          link.getAnnotations().add(annotation(reader, event.asStartElement()));
-        }
-      }
-
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndElement = true;
-      }
-    }
-  }
-
-  private StartElement getStartElement(final XMLEventReader reader) throws XMLStreamException {
-    while (reader.hasNext()) {
-      final XMLEvent innerEvent = reader.peek();
-      if (innerEvent.isCharacters() && innerEvent.asCharacters().isWhiteSpace()) {
-        reader.nextEvent();
-      } else if (innerEvent.isStartElement()) {
-        return innerEvent.asStartElement();
-      } else if (innerEvent.isEndElement() && inlineQName.equals(innerEvent.asEndElement().getName())) {
-        return null;
-      }
-    }
-    return null;
-  }
-
-  public ResWrap<Delta> delta(final InputStream input)
-      throws XMLStreamException, EdmPrimitiveTypeException {
-    final XMLEventReader reader = getReader(input);
-    final StartElement start = skipBeforeFirstStartElement(reader);
-    return getContainer(start, delta(reader, start));
-  }
-
-  private Delta delta(final XMLEventReader reader, final StartElement start)
-      throws XMLStreamException, EdmPrimitiveTypeException {
-    if (!Constants.QNAME_ATOM_ELEM_FEED.equals(start.getName())) {
-      return null;
-    }
-    final Delta delta = new Delta();
-    final Attribute xmlBase = start.getAttributeByName(Constants.QNAME_ATTR_XML_BASE);
-    if (xmlBase != null) {
-      delta.setBaseURI(URI.create(xmlBase.getValue()));
-    }
-
-    boolean foundEndFeed = false;
-    while (reader.hasNext() && !foundEndFeed) {
-      final XMLEvent event = reader.nextEvent();
-      if (event.isStartElement()) {
-        if (countQName.equals(event.asStartElement().getName())) {
-          count(reader, event.asStartElement(), delta);
-        } else if (Constants.QNAME_ATOM_ELEM_ID.equals(event.asStartElement().getName())) {
-          common(reader, event.asStartElement(), delta, "id");
-        } else if (Constants.QNAME_ATOM_ELEM_TITLE.equals(event.asStartElement().getName())) {
-          common(reader, event.asStartElement(), delta, "title");
-        } else if (Constants.QNAME_ATOM_ELEM_SUMMARY.equals(event.asStartElement().getName())) {
-          common(reader, event.asStartElement(), delta, "summary");
-        } else if (Constants.QNAME_ATOM_ELEM_UPDATED.equals(event.asStartElement().getName())) {
-          common(reader, event.asStartElement(), delta, "updated");
-        } else if (Constants.QNAME_ATOM_ELEM_LINK.equals(event.asStartElement().getName())) {
-          final Attribute rel = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REL));
-          if (rel != null) {
-            if (Constants.NEXT_LINK_REL.equals(rel.getValue())) {
-              final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
-              if (href != null) {
-                delta.setNext(URI.create(href.getValue()));
-              }
-            }
-            if (Constants.NS_DELTA_LINK_REL.equals(rel.getValue())) {
-              final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
-              if (href != null) {
-                delta.setDeltaLink(URI.create(href.getValue()));
-              }
-            }
-          }
-        } else if (Constants.QNAME_ATOM_ELEM_ENTRY.equals(event.asStartElement().getName())) {
-          delta.getEntities().add(entity(reader, event.asStartElement()));
-        } else if (deletedEntryQName.equals(event.asStartElement().getName())) {
-          final DeletedEntity deletedEntity = new DeletedEntity();
-
-          final Attribute ref = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REF));
-          if (ref != null) {
-            deletedEntity.setId(URI.create(ref.getValue()));
-          }
-          final Attribute reason = event.asStartElement().getAttributeByName(reasonQName);
-          if (reason != null) {
-            deletedEntity.setReason(Reason.valueOf(reason.getValue()));
-          }
-
-          delta.getDeletedEntities().add(deletedEntity);
-        } else if (linkQName.equals(event.asStartElement().getName())
-            || deletedLinkQName.equals(event.asStartElement().getName())) {
-
-          final DeltaLink link = new DeltaLink();
-
-          final Attribute source = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_SOURCE));
-          if (source != null) {
-            link.setSource(URI.create(source.getValue()));
-          }
-          final Attribute relationship =
-              event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_RELATIONSHIP));
-          if (relationship != null) {
-            link.setRelationship(relationship.getValue());
-          }
-          final Attribute target = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TARGET));
-          if (target != null) {
-            link.setTarget(URI.create(target.getValue()));
-          }
-
-          if (linkQName.equals(event.asStartElement().getName())) {
-            delta.getAddedLinks().add(link);
-          } else {
-            delta.getDeletedLinks().add(link);
-          }
-        }
-      }
-
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndFeed = true;
-      }
-    }
-
-    return delta;
-  }
-
-  private void properties(final XMLEventReader reader, final StartElement start, final Entity entity)
-      throws XMLStreamException, EdmPrimitiveTypeException {
-
-    final Map<String, List<Annotation>> annotations = new HashMap<String, List<Annotation>>();
-
-    boolean foundEndProperties = false;
-    while (reader.hasNext() && !foundEndProperties) {
-      final XMLEvent event = reader.nextEvent();
-
-      if (event.isStartElement()) {
-        if (annotationQName.equals(event.asStartElement().getName())) {
-          final String target = event.asStartElement().
-              getAttributeByName(QName.valueOf(Constants.ATTR_TARGET)).getValue();
-          if (!annotations.containsKey(target)) {
-            annotations.put(target, new ArrayList<Annotation>());
-          }
-          annotations.get(target).add(annotation(reader, event.asStartElement()));
-        } else {
-          entity.getProperties().add(property(reader, event.asStartElement()));
-        }
-      }
-
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndProperties = true;
-      }
-    }
-
-    for (Property property : entity.getProperties()) {
-      if (annotations.containsKey(property.getName())) {
-        property.getAnnotations().addAll(annotations.get(property.getName()));
-      }
-    }
-  }
-
-  private Annotation annotation(final XMLEventReader reader, final StartElement start)
-      throws XMLStreamException, EdmPrimitiveTypeException {
-
-    final Annotation annotation = new Annotation();
-
-    annotation.setTerm(start.getAttributeByName(QName.valueOf(Constants.ATOM_ATTR_TERM)).getValue());
-    valuable(annotation, reader, start);
-
-    return annotation;
-  }
-
-  private Entity entityRef(final StartElement start) throws XMLStreamException {
-    final Entity entity = new Entity();
-
-    final Attribute entityRefId = start.getAttributeByName(Constants.QNAME_ATOM_ATTR_ID);
-    if (entityRefId != null) {
-      entity.setId(URI.create(entityRefId.getValue()));
-    }
-
-    return entity;
-  }
-
-  private Entity entity(final XMLEventReader reader, final StartElement start)
-      throws XMLStreamException, EdmPrimitiveTypeException {
-    final Entity entity;
-    if (entryRefQName.equals(start.getName())) {
-      entity = entityRef(start);
-    } else if (Constants.QNAME_ATOM_ELEM_ENTRY.equals(start.getName())) {
-      entity = new Entity();
-      final Attribute xmlBase = start.getAttributeByName(Constants.QNAME_ATTR_XML_BASE);
-      if (xmlBase != null) {
-        entity.setBaseURI(URI.create(xmlBase.getValue()));
-      }
-
-      final Attribute etag = start.getAttributeByName(etagQName);
-      if (etag != null) {
-        entity.setETag(etag.getValue());
-      }
-
-      boolean foundEndEntry = false;
-      while (reader.hasNext() && !foundEndEntry) {
-        final XMLEvent event = reader.nextEvent();
-
-        if (event.isStartElement()) {
-          if (Constants.QNAME_ATOM_ELEM_ID.equals(event.asStartElement().getName())) {
-            common(reader, event.asStartElement(), entity, "id");
-          } else if (Constants.QNAME_ATOM_ELEM_TITLE.equals(event.asStartElement().getName())) {
-            common(reader, event.asStartElement(), entity, "title");
-          } else if (Constants.QNAME_ATOM_ELEM_SUMMARY.equals(event.asStartElement().getName())) {
-            common(reader, event.asStartElement(), entity, "summary");
-          } else if (Constants.QNAME_ATOM_ELEM_UPDATED.equals(event.asStartElement().getName())) {
-            common(reader, event.asStartElement(), entity, "updated");
-          } else if (Constants.QNAME_ATOM_ELEM_CATEGORY.equals(event.asStartElement().getName())) {
-            final Attribute term = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATOM_ATTR_TERM));
-            if (term != null) {
-              entity.setType(new EdmTypeInfo.Builder().setTypeExpression(term.getValue()).build().internal());
-            }
-          } else if (Constants.QNAME_ATOM_ELEM_LINK.equals(event.asStartElement().getName())) {
-            final Link link = new Link();
-            final Attribute rel = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REL));
-            if (rel != null) {
-              link.setRel(rel.getValue());
-            }
-            final Attribute title = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TITLE));
-            if (title != null) {
-              link.setTitle(title.getValue());
-            }
-            final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
-            if (href != null) {
-              link.setHref(href.getValue());
-            }
-            final Attribute type = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TYPE));
-            if (type != null) {
-              link.setType(type.getValue());
-            }
-
-            if (Constants.SELF_LINK_REL.equals(link.getRel())) {
-              entity.setSelfLink(link);
-            } else if (Constants.EDIT_LINK_REL.equals(link.getRel())) {
-              entity.setEditLink(link);
-            } else if (Constants.EDITMEDIA_LINK_REL.equals(link.getRel())) {
-              final Attribute mediaETag = event.asStartElement().getAttributeByName(etagQName);
-              if (mediaETag != null) {
-                entity.setMediaETag(mediaETag.getValue());
-              }
-            } else if (link.getRel().startsWith(Constants.NS_NAVIGATION_LINK_REL)) {
-
-              entity.getNavigationLinks().add(link);
-              inline(reader, event.asStartElement(), link);
-            } else if (link.getRel().startsWith(Constants.NS_ASSOCIATION_LINK_REL)) {
-
-              entity.getAssociationLinks().add(link);
-            } else if (link.getRel().startsWith(Constants.NS_MEDIA_EDIT_LINK_REL)) {
-
-              final Attribute metag = event.asStartElement().getAttributeByName(etagQName);
-              if (metag != null) {
-                link.setMediaETag(metag.getValue());
-              }
-              entity.getMediaEditLinks().add(link);
-            }
-          } else if (actionQName.equals(event.asStartElement().getName())) {
-            final Operation operation = new Operation();
-            final Attribute metadata =
-                event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_METADATA));
-            if (metadata != null) {
-              operation.setMetadataAnchor(metadata.getValue());
-            }
-            final Attribute title = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TITLE));
-            if (title != null) {
-              operation.setTitle(title.getValue());
-            }
-            final Attribute target = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TARGET));
-            if (target != null) {
-              operation.setTarget(URI.create(target.getValue()));
-            }
-
-            entity.getOperations().add(operation);
-          } else if (Constants.QNAME_ATOM_ELEM_CONTENT.equals(event.asStartElement().getName())) {
-            final Attribute type = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TYPE));
-            if (type == null || ContentType.APPLICATION_XML.toContentTypeString().equals(type.getValue())) {
-              properties(reader, skipBeforeFirstStartElement(reader), entity);
-            } else {
-              entity.setMediaContentType(type.getValue());
-              final Attribute src = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATOM_ATTR_SRC));
-              if (src != null) {
-                entity.setMediaContentSource(URI.create(src.getValue()));
-              }
-            }
-          } else if (propertiesQName.equals(event.asStartElement().getName())) {
-            properties(reader, event.asStartElement(), entity);
-          } else if (annotationQName.equals(event.asStartElement().getName())) {
-            entity.getAnnotations().add(annotation(reader, event.asStartElement()));
-          }
-        }
-
-        if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-          foundEndEntry = true;
-        }
-      }
-    } else {
-      entity = null;
-    }
-
-    return entity;
-  }
-
-  @Override
-  public ResWrap<Entity> toEntity(final InputStream input) throws ODataDeserializerException {
-    try {
-      final XMLEventReader reader = getReader(input);
-      final StartElement start = skipBeforeFirstStartElement(reader);
-      final Entity entity = entity(reader, start);
-      if (entity == null) {
-        throw new ODataDeserializerException("No entity found!");
-      } else {
-        return getContainer(start, entity);
-      }
-    } catch (XMLStreamException e) {
-      throw new ODataDeserializerException(e);
-    } catch (final EdmPrimitiveTypeException e) {
-      throw new ODataDeserializerException(e);
-    }
-  }
-
-  private void count(final XMLEventReader reader, final StartElement start, final EntityCollection entitySet)
-      throws XMLStreamException {
-
-    boolean foundEndElement = false;
-    while (reader.hasNext() && !foundEndElement) {
-      final XMLEvent event = reader.nextEvent();
-
-      if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
-        entitySet.setCount(Integer.valueOf(event.asCharacters().getData()));
-      }
-
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndElement = true;
-      }
-    }
-  }
-
-  private EntityCollection entitySet(final XMLEventReader reader, final StartElement start)
-      throws XMLStreamException, EdmPrimitiveTypeException {
-    if (!Constants.QNAME_ATOM_ELEM_FEED.equals(start.getName())) {
-      return null;
-    }
-    final EntityCollection entitySet = new EntityCollection();
-    final Attribute xmlBase = start.getAttributeByName(Constants.QNAME_ATTR_XML_BASE);
-    if (xmlBase != null) {
-      entitySet.setBaseURI(URI.create(xmlBase.getValue()));
-    }
-
-    boolean foundEndFeed = false;
-    while (reader.hasNext() && !foundEndFeed) {
-      final XMLEvent event = reader.nextEvent();
-      if (event.isStartElement()) {
-        if (countQName.equals(event.asStartElement().getName())) {
-          count(reader, event.asStartElement(), entitySet);
-        } else if (Constants.QNAME_ATOM_ELEM_ID.equals(event.asStartElement().getName())) {
-          common(reader, event.asStartElement(), entitySet, "id");
-        } else if (Constants.QNAME_ATOM_ELEM_TITLE.equals(event.asStartElement().getName())) {
-          common(reader, event.asStartElement(), entitySet, "title");
-        } else if (Constants.QNAME_ATOM_ELEM_SUMMARY.equals(event.asStartElement().getName())) {
-          common(reader, event.asStartElement(), entitySet, "summary");
-        } else if (Constants.QNAME_ATOM_ELEM_UPDATED.equals(event.asStartElement().getName())) {
-          common(reader, event.asStartElement(), entitySet, "updated");
-        } else if (Constants.QNAME_ATOM_ELEM_LINK.equals(event.asStartElement().getName())) {
-          final Attribute rel = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REL));
-          if (rel != null) {
-            if (Constants.NEXT_LINK_REL.equals(rel.getValue())) {
-              final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
-              if (href != null) {
-                entitySet.setNext(URI.create(href.getValue()));
-              }
-            }
-            if (Constants.NS_DELTA_LINK_REL.equals(rel.getValue())) {
-              final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
-              if (href != null) {
-                entitySet.setDeltaLink(URI.create(href.getValue()));
-              }
-            }
-          }
-        } else if (Constants.QNAME_ATOM_ELEM_ENTRY.equals(event.asStartElement().getName())) {
-          entitySet.getEntities().add(entity(reader, event.asStartElement()));
-        } else if (entryRefQName.equals(event.asStartElement().getName())) {
-          entitySet.getEntities().add(entityRef(event.asStartElement()));
-        } else if (annotationQName.equals(event.asStartElement().getName())) {
-          entitySet.getAnnotations().add(annotation(reader, event.asStartElement()));
-        }
-      }
-
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndFeed = true;
-      }
-    }
-
-    return entitySet;
-  }
-
-  @Override
-  public ResWrap<EntityCollection> toEntitySet(final InputStream input) throws ODataDeserializerException {
-    try {
-      final XMLEventReader reader = getReader(input);
-      final StartElement start = skipBeforeFirstStartElement(reader);
-      return getContainer(start, entitySet(reader, start));
-    } catch (XMLStreamException e) {
-      throw new ODataDeserializerException(e);
-    } catch (final EdmPrimitiveTypeException e) {
-      throw new ODataDeserializerException(e);
-    }
-  }
-
-  private ODataError error(final XMLEventReader reader, final StartElement start) throws XMLStreamException {
-    final ODataError error = new ODataError();
-
-    boolean setCode = false;
-    boolean codeSet = false;
-    boolean setMessage = false;
-    boolean messageSet = false;
-    boolean setTarget = false;
-    boolean targetSet = false;
-
-    boolean foundEndElement = false;
-    while (reader.hasNext() && !foundEndElement) {
-      final XMLEvent event = reader.nextEvent();
-
-      if (event.isStartElement()) {
-        if (errorCodeQName.equals(event.asStartElement().getName())) {
-          setCode = true;
-        } else if (errorMessageQName.equals(event.asStartElement().getName())) {
-          setMessage = true;
-        } else if (errorTargetQName.equals(event.asStartElement().getName())) {
-          setTarget = true;
-        }
-      }
-
-      if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
-        if (setCode && !codeSet) {
-          error.setCode(event.asCharacters().getData());
-          setCode = false;
-          codeSet = true;
-        }
-        if (setMessage && !messageSet) {
-          error.setMessage(event.asCharacters().getData());
-          setMessage = false;
-          messageSet = true;
-        }
-        if (setTarget && !targetSet) {
-          error.setTarget(event.asCharacters().getData());
-          setTarget = false;
-          targetSet = true;
-        }
-      }
-
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndElement = true;
-      }
-    }
-
-    return error;
-  }
-
-  @Override
-  public ODataError toError(final InputStream input) throws ODataDeserializerException {
-    try {
-      final XMLEventReader reader = getReader(input);
-      final StartElement start = skipBeforeFirstStartElement(reader);
-      return error(reader, start);
-    } catch (XMLStreamException e) {
-      throw new ODataDeserializerException(e);
-    }
-  }
-
-  private <T> ResWrap<T> getContainer(final StartElement start, final T object) {
-    final Attribute context = start.getAttributeByName(contextQName);
-    final Attribute metadataETag = start.getAttributeByName(metadataEtagQName);
-
-    return new ResWrap<T>(
-        context == null ? null : URI.create(context.getValue()),
-            metadataETag == null ? null : metadataETag.getValue(),
-                object);
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomGeoValueDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomGeoValueDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomGeoValueDeserializer.java
deleted file mode 100644
index 743b78c..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomGeoValueDeserializer.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.serialization;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import javax.xml.stream.XMLEventReader;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.events.Attribute;
-import javax.xml.stream.events.StartElement;
-import javax.xml.stream.events.XMLEvent;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.GeoUtils;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.geo.Geospatial;
-import org.apache.olingo.commons.api.edm.geo.GeospatialCollection;
-import org.apache.olingo.commons.api.edm.geo.LineString;
-import org.apache.olingo.commons.api.edm.geo.MultiLineString;
-import org.apache.olingo.commons.api.edm.geo.MultiPoint;
-import org.apache.olingo.commons.api.edm.geo.MultiPolygon;
-import org.apache.olingo.commons.api.edm.geo.Point;
-import org.apache.olingo.commons.api.edm.geo.Polygon;
-import org.apache.olingo.commons.api.edm.geo.SRID;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmDouble;
-
-class AtomGeoValueDeserializer {
-
-  private List<Point> points(final XMLEventReader reader, final StartElement start,
-      final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
-
-    final List<Point> result = new ArrayList<Point>();
-
-    boolean foundEndProperty = false;
-    while (reader.hasNext() && !foundEndProperty) {
-      final XMLEvent event = reader.nextEvent();
-
-      if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
-        final String[] pointInfo = event.asCharacters().getData().split(" ");
-
-        final Point point = new Point(GeoUtils.getDimension(type), srid);
-        try {
-          point.setX(EdmDouble.getInstance().valueOfString(pointInfo[0], null, null,
-              Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, Double.class));
-          point.setY(EdmDouble.getInstance().valueOfString(pointInfo[1], null, null,
-              Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, Double.class));
-        } catch (EdmPrimitiveTypeException e) {
-          throw new XMLStreamException("While deserializing point coordinates as double", e);
-        }
-        result.add(point);
-      }
-
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndProperty = true;
-      }
-    }
-
-    // handles bad input, e.g. things like <gml:pos/>
-    if (result.isEmpty()) {
-      result.add(new Point(GeoUtils.getDimension(type), srid));
-    }
-
-    return result;
-  }
-
-  private MultiPoint multipoint(final XMLEventReader reader, final StartElement start,
-      final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
-
-    List<Point> points = Collections.<Point> emptyList();
-
-    boolean foundEndProperty = false;
-    while (reader.hasNext() && !foundEndProperty) {
-      final XMLEvent event = reader.nextEvent();
-
-      if (event.isStartElement() && event.asStartElement().getName().equals(Constants.QNAME_POINTMEMBERS)) {
-        points = points(reader, event.asStartElement(), type, null);
-      }
-
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndProperty = true;
-      }
-    }
-
-    return new MultiPoint(GeoUtils.getDimension(type), srid, points);
-  }
-
-  private LineString lineString(final XMLEventReader reader, final StartElement start,
-      final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
-
-    return new LineString(GeoUtils.getDimension(type), srid, points(reader, start, type, null));
-  }
-
-  private Polygon polygon(final XMLEventReader reader, final StartElement start,
-      final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
-
-    List<Point> extPoints = null;
-    List<Point> intPoints = null;
-
-    boolean foundEndProperty = false;
-    while (reader.hasNext() && !foundEndProperty) {
-      final XMLEvent event = reader.nextEvent();
-
-      if (event.isStartElement()) {
-        if (event.asStartElement().getName().equals(Constants.QNAME_POLYGON_EXTERIOR)) {
-          extPoints = points(reader, event.asStartElement(), type, null);
-        }
-        if (event.asStartElement().getName().equals(Constants.QNAME_POLYGON_INTERIOR)) {
-          intPoints = points(reader, event.asStartElement(), type, null);
-        }
-      }
-
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndProperty = true;
-      }
-    }
-
-    return new Polygon(GeoUtils.getDimension(type), srid, intPoints, extPoints);
-  }
-
-  private MultiLineString multiLineString(final XMLEventReader reader, final StartElement start,
-      final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
-
-    final List<LineString> lineStrings = new ArrayList<LineString>();
-
-    boolean foundEndProperty = false;
-    while (reader.hasNext() && !foundEndProperty) {
-      final XMLEvent event = reader.nextEvent();
-
-      if (event.isStartElement() && event.asStartElement().getName().equals(Constants.QNAME_LINESTRING)) {
-        lineStrings.add(lineString(reader, event.asStartElement(), type, null));
-      }
-
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndProperty = true;
-      }
-    }
-
-    return new MultiLineString(GeoUtils.getDimension(type), srid, lineStrings);
-  }
-
-  private MultiPolygon multiPolygon(final XMLEventReader reader, final StartElement start,
-      final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
-
-    final List<Polygon> polygons = new ArrayList<Polygon>();
-
-    boolean foundEndProperty = false;
-    while (reader.hasNext() && !foundEndProperty) {
-      final XMLEvent event = reader.nextEvent();
-
-      if (event.isStartElement() && event.asStartElement().getName().equals(Constants.QNAME_POLYGON)) {
-        polygons.add(polygon(reader, event.asStartElement(), type, null));
-      }
-
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndProperty = true;
-      }
-    }
-
-    return new MultiPolygon(GeoUtils.getDimension(type), srid, polygons);
-  }
-
-  private GeospatialCollection collection(final XMLEventReader reader, final StartElement start,
-      final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
-
-    final List<Geospatial> geospatials = new ArrayList<Geospatial>();
-
-    boolean foundEndCollection = false;
-    while (reader.hasNext() && !foundEndCollection) {
-      final XMLEvent event = reader.nextEvent();
-
-      if (event.isStartElement() && event.asStartElement().getName().equals(Constants.QNAME_GEOMEMBERS)) {
-        boolean foundEndMembers = false;
-        while (reader.hasNext() && !foundEndMembers) {
-          final XMLEvent subevent = reader.nextEvent();
-
-          if (subevent.isStartElement()) {
-            geospatials.add(deserialize(reader, subevent.asStartElement(),
-                GeoUtils.getType(GeoUtils.getDimension(type), subevent.asStartElement().getName().getLocalPart())));
-          }
-
-          if (subevent.isEndElement() && Constants.QNAME_GEOMEMBERS.equals(subevent.asEndElement().getName())) {
-            foundEndMembers = true;
-          }
-        }
-      }
-
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndCollection = true;
-      }
-    }
-
-    return new GeospatialCollection(GeoUtils.getDimension(type), srid, geospatials);
-  }
-
-  public Geospatial deserialize(final XMLEventReader reader, final StartElement start,
-      final EdmPrimitiveTypeKind type) throws XMLStreamException {
-
-    SRID srid = null;
-    final Attribute srsName = start.getAttributeByName(Constants.QNAME_ATTR_SRSNAME);
-    if (srsName != null) {
-      srid = SRID.valueOf(StringUtils.substringAfterLast(srsName.getValue(), "/"));
-    }
-
-    Geospatial value;
-
-    switch (type) {
-    case GeographyPoint:
-    case GeometryPoint:
-      value = points(reader, start, type, srid).get(0);
-      break;
-
-    case GeographyMultiPoint:
-    case GeometryMultiPoint:
-      value = multipoint(reader, start, type, srid);
-      break;
-
-    case GeographyLineString:
-    case GeometryLineString:
-      value = lineString(reader, start, type, srid);
-      break;
-
-    case GeographyMultiLineString:
-    case GeometryMultiLineString:
-      value = multiLineString(reader, start, type, srid);
-      break;
-
-    case GeographyPolygon:
-    case GeometryPolygon:
-      value = polygon(reader, start, type, srid);
-      break;
-
-    case GeographyMultiPolygon:
-    case GeometryMultiPolygon:
-      value = multiPolygon(reader, start, type, srid);
-      break;
-
-    case GeographyCollection:
-    case GeometryCollection:
-      value = collection(reader, start, type, srid);
-      break;
-
-    default:
-      value = null;
-    }
-
-    return value;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomGeoValueSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomGeoValueSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomGeoValueSerializer.java
deleted file mode 100644
index 8254559..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomGeoValueSerializer.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.serialization;
-
-import java.util.Collections;
-import java.util.Iterator;
-
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.edm.geo.Geospatial;
-import org.apache.olingo.commons.api.edm.geo.GeospatialCollection;
-import org.apache.olingo.commons.api.edm.geo.LineString;
-import org.apache.olingo.commons.api.edm.geo.MultiLineString;
-import org.apache.olingo.commons.api.edm.geo.MultiPoint;
-import org.apache.olingo.commons.api.edm.geo.MultiPolygon;
-import org.apache.olingo.commons.api.edm.geo.Point;
-import org.apache.olingo.commons.api.edm.geo.Polygon;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmDouble;
-
-class AtomGeoValueSerializer {
-
-  private void points(final XMLStreamWriter writer, final Iterator<Point> itor, final boolean wrap)
-      throws XMLStreamException {
-
-    while (itor.hasNext()) {
-      final Point point = itor.next();
-
-      if (wrap) {
-        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POINT, Constants.NS_GML);
-      }
-
-      writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POS, Constants.NS_GML);
-      try {
-        writer.writeCharacters(EdmDouble.getInstance().valueToString(point.getX(), null, null,
-            Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null)
-            + " "
-            + EdmDouble.getInstance().valueToString(point.getY(), null, null,
-                Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null));
-      } catch (EdmPrimitiveTypeException e) {
-        throw new XMLStreamException("While serializing point coordinates as double", e);
-      }
-      writer.writeEndElement();
-
-      if (wrap) {
-        writer.writeEndElement();
-      }
-    }
-  }
-
-  private void lineStrings(final XMLStreamWriter writer, final Iterator<LineString> itor, final boolean wrap)
-      throws XMLStreamException {
-
-    while (itor.hasNext()) {
-      final LineString lineString = itor.next();
-
-      if (wrap) {
-        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_LINESTRING, Constants.NS_GML);
-      }
-
-      points(writer, lineString.iterator(), false);
-
-      if (wrap) {
-        writer.writeEndElement();
-      }
-    }
-  }
-
-  private void polygons(final XMLStreamWriter writer, final Iterator<Polygon> itor, final boolean wrap)
-      throws XMLStreamException {
-
-    while (itor.hasNext()) {
-      final Polygon polygon = itor.next();
-
-      if (wrap) {
-        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POLYGON, Constants.NS_GML);
-      }
-
-      if (!polygon.getExterior().isEmpty()) {
-        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POLYGON_EXTERIOR, Constants.NS_GML);
-        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POLYGON_LINEARRING, Constants.NS_GML);
-
-        points(writer, polygon.getExterior().iterator(), false);
-
-        writer.writeEndElement();
-        writer.writeEndElement();
-      }
-      if (!polygon.getInterior().isEmpty()) {
-        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POLYGON_INTERIOR, Constants.NS_GML);
-        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POLYGON_LINEARRING, Constants.NS_GML);
-
-        points(writer, polygon.getInterior().iterator(), false);
-
-        writer.writeEndElement();
-        writer.writeEndElement();
-      }
-
-      if (wrap) {
-        writer.writeEndElement();
-      }
-    }
-  }
-
-  private void writeSrsName(final XMLStreamWriter writer, final Geospatial value) throws XMLStreamException {
-    if (value.getSrid() != null && value.getSrid().isNotDefault()) {
-      writer.writeAttribute(Constants.PREFIX_GML, Constants.NS_GML, Constants.ATTR_SRSNAME,
-          Constants.SRS_URLPREFIX + value.getSrid().toString());
-    }
-  }
-
-  public void serialize(final XMLStreamWriter writer, final Geospatial value) throws XMLStreamException {
-    switch (value.getEdmPrimitiveTypeKind()) {
-    case GeographyPoint:
-    case GeometryPoint:
-      writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POINT, Constants.NS_GML);
-      writeSrsName(writer, value);
-
-      points(writer, Collections.singleton((Point) value).iterator(), false);
-
-      writer.writeEndElement();
-      break;
-
-    case GeometryMultiPoint:
-    case GeographyMultiPoint:
-      writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_MULTIPOINT, Constants.NS_GML);
-      writeSrsName(writer, value);
-
-      if (!((MultiPoint) value).isEmpty()) {
-        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POINTMEMBERS, Constants.NS_GML);
-        points(writer, ((MultiPoint) value).iterator(), true);
-        writer.writeEndElement();
-      }
-
-      writer.writeEndElement();
-      break;
-
-    case GeometryLineString:
-    case GeographyLineString:
-      writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_LINESTRING, Constants.NS_GML);
-      writeSrsName(writer, value);
-
-      lineStrings(writer, Collections.singleton((LineString) value).iterator(), false);
-
-      writer.writeEndElement();
-      break;
-
-    case GeometryMultiLineString:
-    case GeographyMultiLineString:
-      writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_MULTILINESTRING, Constants.NS_GML);
-      writeSrsName(writer, value);
-
-      if (!((MultiLineString) value).isEmpty()) {
-        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_LINESTRINGMEMBERS, Constants.NS_GML);
-        lineStrings(writer, ((MultiLineString) value).iterator(), true);
-        writer.writeEndElement();
-      }
-
-      writer.writeEndElement();
-      break;
-
-    case GeographyPolygon:
-    case GeometryPolygon:
-      writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POLYGON, Constants.NS_GML);
-      writeSrsName(writer, value);
-
-      polygons(writer, Collections.singleton(((Polygon) value)).iterator(), false);
-
-      writer.writeEndElement();
-      break;
-
-    case GeographyMultiPolygon:
-    case GeometryMultiPolygon:
-      writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_MULTIPOLYGON, Constants.NS_GML);
-      writeSrsName(writer, value);
-
-      if (!((MultiPolygon) value).isEmpty()) {
-        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_SURFACEMEMBERS, Constants.NS_GML);
-        polygons(writer, ((MultiPolygon) value).iterator(), true);
-        writer.writeEndElement();
-      }
-
-      writer.writeEndElement();
-      break;
-
-    case GeographyCollection:
-    case GeometryCollection:
-      writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_GEOCOLLECTION, Constants.NS_GML);
-      writeSrsName(writer, value);
-
-      if (!((GeospatialCollection) value).isEmpty()) {
-        writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_GEOMEMBERS, Constants.NS_GML);
-        for (Geospatial geospatial : ((GeospatialCollection) value)) {
-          serialize(writer, geospatial);
-        }
-        writer.writeEndElement();
-      }
-
-      writer.writeEndElement();
-      break;
-
-    default:
-    }
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java
deleted file mode 100644
index ecd7be0..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java
+++ /dev/null
@@ -1,570 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.serialization;
-
-import java.io.Writer;
-import java.net.URI;
-import java.util.Collections;
-import java.util.List;
-
-import javax.xml.XMLConstants;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.ODataRuntimeException;
-import org.apache.olingo.commons.api.data.AbstractODataObject;
-import org.apache.olingo.commons.api.data.Annotation;
-import org.apache.olingo.commons.api.data.ComplexValue;
-import org.apache.olingo.commons.api.data.ContextURL;
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntityCollection;
-import org.apache.olingo.commons.api.data.Link;
-import org.apache.olingo.commons.api.data.Operation;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.data.ValueType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.geo.Geospatial;
-import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.commons.api.serialization.ODataSerializer;
-import org.apache.olingo.commons.api.serialization.ODataSerializerException;
-import org.apache.olingo.commons.core.edm.EdmTypeInfo;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
-
-import com.fasterxml.aalto.stax.OutputFactoryImpl;
-
-public class AtomSerializer extends AbstractAtomDealer implements ODataSerializer {
-
-  private static final XMLOutputFactory FACTORY = new OutputFactoryImpl();
-
-  private final AtomGeoValueSerializer geoSerializer;
-
-  private final boolean serverMode;
-
-  public AtomSerializer() {
-    this(false);
-  }
-
-  public AtomSerializer(final boolean serverMode) {
-    geoSerializer = new AtomGeoValueSerializer();
-    this.serverMode = serverMode;
-  }
-
-  private void collection(final XMLStreamWriter writer,
-      final ValueType valueType, final EdmPrimitiveTypeKind kind, final List<?> value)
-          throws XMLStreamException, EdmPrimitiveTypeException {
-    for (Object item : value) {
-      writer.writeStartElement(Constants.PREFIX_METADATA, Constants.ELEM_ELEMENT, namespaceMetadata);
-      value(writer, valueType, kind, item);
-      writer.writeEndElement();
-    }
-  }
-
-  private void value(final XMLStreamWriter writer,
-      final ValueType valueType, final EdmPrimitiveTypeKind kind, final Object value)
-          throws XMLStreamException, EdmPrimitiveTypeException {
-    if (value == null) {
-      writer.writeAttribute(Constants.PREFIX_METADATA, namespaceMetadata,
-          Constants.ATTR_NULL, Boolean.TRUE.toString());
-      return;
-    }
-    switch (valueType) {
-    case PRIMITIVE:
-      writer.writeCharacters(kind == null ? value.toString() :
-        EdmPrimitiveTypeFactory.getInstance(kind) // TODO: add facets
-        .valueToString(value, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null));
-      break;
-    case ENUM:
-      writer.writeCharacters(value.toString());
-      break;
-    case GEOSPATIAL:
-      geoSerializer.serialize(writer, (Geospatial) value);
-      break;
-    case COLLECTION_PRIMITIVE:
-    case COLLECTION_GEOSPATIAL:
-    case COLLECTION_ENUM:
-    case COLLECTION_COMPLEX:
-      collection(writer, valueType.getBaseType(), kind, (List<?>) value);
-      break;
-    case COMPLEX:
-      for (Property property : ((ComplexValue) value).getValue()) {
-        property(writer, property, false);
-      }
-      break;
-    case ENTITY:
-    case COLLECTION_ENTITY:
-      throw new ODataRuntimeException("Entities cannot appear in this payload");
-    }
-  }
-
-  public void property(final XMLStreamWriter writer, final Property property, final boolean standalone)
-      throws XMLStreamException, EdmPrimitiveTypeException {
-
-    if (standalone) {
-      writer.writeStartElement(Constants.PREFIX_METADATA, Constants.VALUE, namespaceData);
-      namespaces(writer);
-    } else {
-      writer.writeStartElement(Constants.PREFIX_DATASERVICES, property.getName(), namespaceData);
-    }
-
-    EdmTypeInfo typeInfo = null;
-    if (StringUtils.isNotBlank(property.getType())) {
-      typeInfo = new EdmTypeInfo.Builder().setTypeExpression(property.getType()).build();
-      if (!EdmPrimitiveTypeKind.String.getFullQualifiedName().toString().equals(typeInfo.internal())) {
-        writer.writeAttribute(Constants.PREFIX_METADATA, namespaceMetadata,
-            Constants.ATTR_TYPE, typeInfo.external());
-      }
-    }
-
-    value(writer, property.getValueType(), typeInfo == null ? null : typeInfo.getPrimitiveTypeKind(),
-        property.getValue());
-    if (!property.isNull() && property.isComplex() && !property.isCollection()) {
-      links(writer, property.asComplex().getAssociationLinks());
-      links(writer, property.asComplex().getNavigationLinks());
-    }
-
-    writer.writeEndElement();
-
-    for (Annotation annotation : property.getAnnotations()) {
-      annotation(writer, annotation, property.getName());
-    }
-  }
-
-  private void property(final XMLStreamWriter writer, final Property property)
-      throws XMLStreamException, EdmPrimitiveTypeException {
-    property(writer, property, true);
-  }
-
-  private void startDocument(final XMLStreamWriter writer, final String rootElement) throws XMLStreamException {
-    writer.writeStartDocument();
-    writer.setDefaultNamespace(Constants.NS_ATOM);
-
-    writer.writeStartElement(rootElement);
-
-    namespaces(writer);
-  }
-
-  private void property(final Writer outWriter, final Property property)
-      throws XMLStreamException, EdmPrimitiveTypeException {
-    final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
-
-    writer.writeStartDocument();
-
-    property(writer, property);
-
-    writer.writeEndDocument();
-    writer.flush();
-  }
-
-  private void links(final XMLStreamWriter writer, final List<Link> links)
-      throws XMLStreamException, EdmPrimitiveTypeException {
-    for (Link link : links) {
-      writer.writeStartElement(Constants.ATOM_ELEM_LINK);
-
-      if (StringUtils.isNotBlank(link.getRel())) {
-        writer.writeAttribute(Constants.ATTR_REL, link.getRel());
-      }
-      if (StringUtils.isNotBlank(link.getTitle())) {
-        writer.writeAttribute(Constants.ATTR_TITLE, link.getTitle());
-      }
-      if (StringUtils.isNotBlank(link.getHref())) {
-        writer.writeAttribute(Constants.ATTR_HREF, link.getHref());
-      }
-      if (StringUtils.isNotBlank(link.getType())) {
-        writer.writeAttribute(Constants.ATTR_TYPE, link.getType());
-      }
-
-      if (link.getInlineEntity() != null || link.getInlineEntitySet() != null) {
-        writer.writeStartElement(Constants.PREFIX_METADATA, Constants.ATOM_ELEM_INLINE, namespaceMetadata);
-
-        if (link.getInlineEntity() != null) {
-          writer.writeStartElement(Constants.ATOM_ELEM_ENTRY);
-          entity(writer, link.getInlineEntity());
-          writer.writeEndElement();
-        }
-        if (link.getInlineEntitySet() != null) {
-          writer.writeStartElement(Constants.ATOM_ELEM_FEED);
-          entitySet(writer, link.getInlineEntitySet());
-          writer.writeEndElement();
-        }
-
-        writer.writeEndElement();
-      }
-
-      for (Annotation annotation : link.getAnnotations()) {
-        annotation(writer, annotation, null);
-      }
-
-      writer.writeEndElement();
-    }
-  }
-
-  private void common(final XMLStreamWriter writer, final AbstractODataObject object) throws XMLStreamException {
-    if (StringUtils.isNotBlank(object.getTitle())) {
-      writer.writeStartElement(Constants.ATOM_ELEM_TITLE);
-      writer.writeAttribute(Constants.ATTR_TYPE, TYPE_TEXT);
-      writer.writeCharacters(object.getTitle());
-      writer.writeEndElement();
-    }
-  }
-
-  private void properties(final XMLStreamWriter writer, final List<Property> properties)
-      throws XMLStreamException, EdmPrimitiveTypeException {
-    for (Property property : properties) {
-      property(writer, property, false);
-    }
-  }
-
-  private void annotation(final XMLStreamWriter writer, final Annotation annotation, final String target)
-      throws XMLStreamException, EdmPrimitiveTypeException {
-
-    writer.writeStartElement(Constants.PREFIX_METADATA, Constants.ANNOTATION, namespaceMetadata);
-
-    writer.writeAttribute(Constants.ATOM_ATTR_TERM, annotation.getTerm());
-
-    if (target != null) {
-      writer.writeAttribute(Constants.ATTR_TARGET, target);
-    }
-
-    EdmTypeInfo typeInfo = null;
-    if (StringUtils.isNotBlank(annotation.getType())) {
-      typeInfo = new EdmTypeInfo.Builder().setTypeExpression(annotation.getType()).build();
-      if (!EdmPrimitiveTypeKind.String.getFullQualifiedName().toString().equals(typeInfo.internal())) {
-        writer.writeAttribute(Constants.PREFIX_METADATA, namespaceMetadata,
-            Constants.ATTR_TYPE, typeInfo.external());
-      }
-    }
-
-    value(writer, annotation.getValueType(), typeInfo == null ? null : typeInfo.getPrimitiveTypeKind(),
-        annotation.getValue());
-
-    writer.writeEndElement();
-  }
-
-  private void entity(final XMLStreamWriter writer, final Entity entity)
-      throws XMLStreamException, EdmPrimitiveTypeException {
-    if (entity.getBaseURI() != null) {
-      writer.writeAttribute(XMLConstants.XML_NS_URI, Constants.ATTR_XML_BASE, entity.getBaseURI().toASCIIString());
-    }
-
-    if (serverMode && StringUtils.isNotBlank(entity.getETag())) {
-      writer.writeAttribute(namespaceMetadata, Constants.ATOM_ATTR_ETAG, entity.getETag());
-    }
-
-    if (entity.getId() != null) {
-      writer.writeStartElement(Constants.ATOM_ELEM_ID);
-      writer.writeCharacters(entity.getId().toASCIIString());
-      writer.writeEndElement();
-    }
-
-    writer.writeStartElement(Constants.ATOM_ELEM_CATEGORY);
-    writer.writeAttribute(Constants.ATOM_ATTR_SCHEME, Constants.NS_SCHEME);
-    if (StringUtils.isNotBlank(entity.getType())) {
-      writer.writeAttribute(Constants.ATOM_ATTR_TERM,
-          new EdmTypeInfo.Builder().setTypeExpression(entity.getType()).build().external());
-    }
-    writer.writeEndElement();
-
-    common(writer, entity);
-
-    if (serverMode) {
-      if (entity.getEditLink() != null) {
-        links(writer, Collections.singletonList(entity.getEditLink()));
-      }
-
-      if (entity.getSelfLink() != null) {
-        links(writer, Collections.singletonList(entity.getSelfLink()));
-      }
-    }
-
-    links(writer, entity.getAssociationLinks());
-    links(writer, entity.getNavigationLinks());
-    links(writer, entity.getMediaEditLinks());
-
-    if (serverMode) {
-      for (Operation operation : entity.getOperations()) {
-        writer.writeStartElement(namespaceMetadata, Constants.ATOM_ELEM_ACTION);
-        writer.writeAttribute(Constants.ATTR_METADATA, operation.getMetadataAnchor());
-        writer.writeAttribute(Constants.ATTR_TITLE, operation.getTitle());
-        writer.writeAttribute(Constants.ATTR_TARGET, operation.getTarget().toASCIIString());
-        writer.writeEndElement();
-      }
-    }
-
-    writer.writeStartElement(Constants.ATOM_ELEM_CONTENT);
-    if (entity.isMediaEntity()) {
-      if (StringUtils.isNotBlank(entity.getMediaContentType())) {
-        writer.writeAttribute(Constants.ATTR_TYPE, entity.getMediaContentType());
-      }
-      if (entity.getMediaContentSource() != null) {
-        writer.writeAttribute(Constants.ATOM_ATTR_SRC, entity.getMediaContentSource().toASCIIString());
-      }
-      writer.writeEndElement();
-
-      writer.writeStartElement(namespaceMetadata, Constants.PROPERTIES);
-      properties(writer, entity.getProperties());
-    } else {
-      writer.writeAttribute(Constants.ATTR_TYPE, ContentType.APPLICATION_XML.toContentTypeString());
-      writer.writeStartElement(namespaceMetadata, Constants.PROPERTIES);
-      properties(writer, entity.getProperties());
-      writer.writeEndElement();
-    }
-    writer.writeEndElement();
-
-    for (Annotation annotation : entity.getAnnotations()) {
-      annotation(writer, annotation, null);
-    }
-  }
-
-  private void entityRef(final XMLStreamWriter writer, final Entity entity) throws XMLStreamException {
-    writer.writeStartElement(Constants.ATOM_ELEM_ENTRY_REF);
-    writer.writeNamespace(StringUtils.EMPTY, namespaceMetadata);
-    writer.writeAttribute(Constants.ATOM_ATTR_ID, entity.getId().toASCIIString());
-  }
-
-  private void entityRef(final XMLStreamWriter writer, final ResWrap<Entity> container) throws XMLStreamException {
-    writer.writeStartElement(Constants.ATOM_ELEM_ENTRY_REF);
-    writer.writeNamespace(StringUtils.EMPTY, namespaceMetadata);
-    addContextInfo(writer, container);
-    writer.writeAttribute(Constants.ATOM_ATTR_ID, container.getPayload().getId().toASCIIString());
-  }
-
-  private void entity(final Writer outWriter, final Entity entity)
-      throws XMLStreamException, EdmPrimitiveTypeException {
-    final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
-
-    if (entity.getType() == null && entity.getProperties().isEmpty()) {
-      writer.writeStartDocument();
-      writer.setDefaultNamespace(namespaceMetadata);
-
-      entityRef(writer, entity);
-    } else {
-      startDocument(writer, Constants.ATOM_ELEM_ENTRY);
-
-      entity(writer, entity);
-    }
-
-    writer.writeEndElement();
-    writer.writeEndDocument();
-    writer.flush();
-  }
-
-  private void entity(final Writer outWriter, final ResWrap<Entity> container)
-      throws XMLStreamException, EdmPrimitiveTypeException {
-    final Entity entity = container.getPayload();
-
-    final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
-
-    if (entity.getType() == null && entity.getProperties().isEmpty()) {
-      writer.writeStartDocument();
-      writer.setDefaultNamespace(namespaceMetadata);
-
-      entityRef(writer, container);
-    } else {
-      startDocument(writer, Constants.ATOM_ELEM_ENTRY);
-
-      addContextInfo(writer, container);
-
-      entity(writer, entity);
-    }
-
-    writer.writeEndElement();
-    writer.writeEndDocument();
-    writer.flush();
-  }
-
-  private void entitySet(final XMLStreamWriter writer, final EntityCollection entitySet)
-      throws XMLStreamException, EdmPrimitiveTypeException {
-    if (entitySet.getBaseURI() != null) {
-      writer.writeAttribute(XMLConstants.XML_NS_URI, Constants.ATTR_XML_BASE, entitySet.getBaseURI().toASCIIString());
-    }
-
-    if (entitySet.getCount() != null) {
-      writer.writeStartElement(namespaceMetadata, Constants.ATOM_ELEM_COUNT);
-      writer.writeCharacters(Integer.toString(entitySet.getCount()));
-      writer.writeEndElement();
-    }
-
-    if (entitySet.getId() != null) {
-      writer.writeStartElement(Constants.ATOM_ELEM_ID);
-      writer.writeCharacters(entitySet.getId().toASCIIString());
-      writer.writeEndElement();
-    }
-
-    common(writer, entitySet);
-
-    for (Entity entity : entitySet.getEntities()) {
-      if (entity.getType() == null && entity.getProperties().isEmpty()) {
-        entityRef(writer, entity);
-        writer.writeEndElement();
-      } else {
-        writer.writeStartElement(Constants.ATOM_ELEM_ENTRY);
-        entity(writer, entity);
-        writer.writeEndElement();
-      }
-    }
-
-    if (serverMode) {
-      if (entitySet.getNext() != null) {
-        final Link next = new Link();
-        next.setRel(Constants.NEXT_LINK_REL);
-        next.setHref(entitySet.getNext().toASCIIString());
-
-        links(writer, Collections.<Link> singletonList(next));
-      }
-      if (entitySet.getDeltaLink() != null) {
-        final Link next = new Link();
-        next.setRel(Constants.NS_DELTA_LINK_REL);
-        next.setHref(entitySet.getDeltaLink().toASCIIString());
-
-        links(writer, Collections.<Link> singletonList(next));
-      }
-    }
-  }
-
-  private void entitySet(final Writer outWriter, final EntityCollection entitySet)
-      throws XMLStreamException, EdmPrimitiveTypeException {
-    final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
-
-    startDocument(writer, Constants.ATOM_ELEM_FEED);
-
-    entitySet(writer, entitySet);
-
-    writer.writeEndElement();
-    writer.writeEndDocument();
-    writer.flush();
-  }
-
-  private void entitySet(final Writer outWriter, final ResWrap<EntityCollection> entitySet)
-      throws XMLStreamException, EdmPrimitiveTypeException {
-    final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
-
-    startDocument(writer, Constants.ATOM_ELEM_FEED);
-
-    addContextInfo(writer, entitySet);
-
-    entitySet(writer, entitySet.getPayload());
-
-    writer.writeEndElement();
-    writer.writeEndDocument();
-    writer.flush();
-  }
-
-  private void link(final Writer outWriter, final Link link) throws XMLStreamException {
-    final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
-
-    writer.writeStartDocument();
-
-    writer.writeStartElement(Constants.ELEM_LINKS);
-    writer.writeDefaultNamespace(namespaceData);
-
-    writer.writeStartElement(Constants.ELEM_URI);
-    writer.writeCharacters(link.getHref());
-    writer.writeEndElement();
-
-    writer.writeEndElement();
-
-    writer.writeEndDocument();
-    writer.flush();
-  }
-
-  @Override
-  public <T> void write(final Writer writer, final T obj) throws ODataSerializerException {
-    try {
-      if (obj instanceof EntityCollection) {
-        entitySet(writer, (EntityCollection) obj);
-      } else if (obj instanceof Entity) {
-        entity(writer, (Entity) obj);
-      } else if (obj instanceof Property) {
-        property(writer, (Property) obj);
-      } else if (obj instanceof Link) {
-        link(writer, (Link) obj);
-      }
-    } catch (final XMLStreamException e) {
-      throw new ODataSerializerException(e);
-    } catch (final EdmPrimitiveTypeException e) {
-      throw new ODataSerializerException(e);
-    }
-  }
-
-  private void reference(final Writer outWriter, final ResWrap<URI> container) throws XMLStreamException {
-    final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
-
-    writer.writeStartDocument();
-
-    writer.writeStartElement(Constants.ATTR_METADATA, Constants.ATTR_REF);
-    writer.writeNamespace(Constants.ATTR_METADATA, Constants.NS_METADATA);
-    writer.writeAttribute(Constants.ATTR_METADATA, Constants.CONTEXT, container.getContextURL().toASCIIString());
-    writer.writeAttribute(Constants.ATOM_ATTR_ID, container.getPayload().toASCIIString());
-    writer.writeEndElement();
-
-    writer.writeEndDocument();
-  }
-
-  @Override
-  @SuppressWarnings("unchecked")
-  public <T> void write(final Writer writer, final ResWrap<T> container) throws ODataSerializerException {
-    final T obj = container == null ? null : container.getPayload();
-
-    try {
-      if (obj instanceof EntityCollection) {
-        this.entitySet(writer, (ResWrap<EntityCollection>) container);
-      } else if (obj instanceof Entity) {
-        entity(writer, (ResWrap<Entity>) container);
-      } else if (obj instanceof Property) {
-        property(writer, (Property) obj);
-      } else if (obj instanceof Link) {
-        link(writer, (Link) obj);
-      } else if (obj instanceof URI) {
-        reference(writer, (ResWrap<URI>) container);
-      }
-    } catch (final XMLStreamException e) {
-      throw new ODataSerializerException(e);
-    } catch (final EdmPrimitiveTypeException e) {
-      throw new ODataSerializerException(e);
-    }
-  }
-
-  private <T> void addContextInfo(
-      final XMLStreamWriter writer, final ResWrap<T> container) throws XMLStreamException {
-
-    if (container.getContextURL() != null) {
-      final ContextURL contextURL = ContextURLParser.parse(container.getContextURL());
-      final URI base = contextURL.getServiceRoot();
-      if (container.getPayload() instanceof EntityCollection) {
-        ((EntityCollection) container.getPayload()).setBaseURI(base);
-      }
-      if (container.getPayload() instanceof Entity) {
-        ((Entity) container.getPayload()).setBaseURI(base);
-      }
-
-      writer.writeAttribute(namespaceMetadata, Constants.CONTEXT,
-          container.getContextURL().toASCIIString());
-    }
-
-    if (StringUtils.isNotBlank(container.getMetadataETag())) {
-      writer.writeAttribute(namespaceMetadata, Constants.ATOM_ATTR_METADATAETAG,
-          container.getMetadataETag());
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/ContextURLParser.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/ContextURLParser.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/ContextURLParser.java
deleted file mode 100644
index 460cd16..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/ContextURLParser.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.serialization;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.ContextURL;
-import org.apache.olingo.commons.api.data.ContextURL.Suffix;
-
-public class ContextURLParser {
-
-  public static ContextURL parse(final URI contextURL) {
-    if (contextURL == null) {
-      return null;
-    }
-
-    final ContextURL.Builder contextUrl = ContextURL.with();
-
-    String contextURLasString = contextURL.toASCIIString();
-
-    boolean isEntity = false;
-    if (contextURLasString.endsWith("/$entity") || contextURLasString.endsWith("/@Element")) {
-      isEntity = true;
-      contextUrl.suffix(Suffix.ENTITY);
-      contextURLasString = contextURLasString.replace("/$entity", StringUtils.EMPTY).
-          replace("/@Element", StringUtils.EMPTY);
-    } else if (contextURLasString.endsWith("/$ref")) {
-      contextUrl.suffix(Suffix.REFERENCE);
-      contextURLasString = contextURLasString.replace("/$ref", StringUtils.EMPTY);
-    } else if (contextURLasString.endsWith("/$delta")) {
-      contextUrl.suffix(Suffix.DELTA);
-      contextURLasString = contextURLasString.replace("/$delta", StringUtils.EMPTY);
-    } else if (contextURLasString.endsWith("/$deletedEntity")) {
-      contextUrl.suffix(Suffix.DELTA_DELETED_ENTITY);
-      contextURLasString = contextURLasString.replace("/$deletedEntity", StringUtils.EMPTY);
-    } else if (contextURLasString.endsWith("/$link")) {
-      contextUrl.suffix(Suffix.DELTA_LINK);
-      contextURLasString = contextURLasString.replace("/$link", StringUtils.EMPTY);
-    } else if (contextURLasString.endsWith("/$deletedLink")) {
-      contextUrl.suffix(Suffix.DELTA_DELETED_LINK);
-      contextURLasString = contextURLasString.replace("/$deletedLink", StringUtils.EMPTY);
-    }
-
-    contextUrl.serviceRoot(URI.create(StringUtils.substringBefore(contextURLasString, Constants.METADATA)));
-
-    final String rest = StringUtils.substringAfter(contextURLasString, Constants.METADATA + "#");
-
-    String firstToken;
-    String entitySetOrSingletonOrType;
-    if (rest.startsWith("Collection(")) {
-      firstToken = rest.substring(0, rest.indexOf(')') + 1);
-      entitySetOrSingletonOrType = firstToken;
-    } else {
-      final int openParIdx = rest.indexOf('(');
-      if (openParIdx == -1) {
-        firstToken = StringUtils.substringBeforeLast(rest, "/");
-
-        entitySetOrSingletonOrType = firstToken;
-      } else {
-        firstToken = isEntity ? rest : StringUtils.substringBeforeLast(rest, ")") + ")";
-
-        final List<String> parts = new ArrayList<String>();
-        for (String split : firstToken.split("\\)/")) {
-          parts.add(split.replaceAll("\\(.*", ""));
-        }
-        entitySetOrSingletonOrType = StringUtils.join(parts, '/');
-        final int commaIdx = firstToken.indexOf(',');
-        if (commaIdx != -1) {
-          contextUrl.selectList(firstToken.substring(openParIdx + 1, firstToken.length() - 1));
-        }
-      }
-    }
-    contextUrl.entitySetOrSingletonOrType(entitySetOrSingletonOrType);
-
-    final int slashIdx = entitySetOrSingletonOrType.lastIndexOf('/');
-    if (slashIdx != -1 && entitySetOrSingletonOrType.substring(slashIdx + 1).indexOf('.') != -1) {
-      contextUrl.entitySetOrSingletonOrType(entitySetOrSingletonOrType.substring(0, slashIdx));
-      contextUrl.derivedEntity(entitySetOrSingletonOrType.substring(slashIdx + 1));
-    }
-
-    if (!firstToken.equals(rest)) {
-      final String[] pathElems = StringUtils.substringAfter(rest, "/").split("/");
-      if (pathElems.length > 0 && pathElems[0].length() > 0) {
-        if (pathElems[0].indexOf('.') == -1) {
-          contextUrl.navOrPropertyPath(pathElems[0]);
-        } else {
-          contextUrl.derivedEntity(pathElems[0]);
-        }
-
-        if (pathElems.length > 1) {
-          contextUrl.navOrPropertyPath(pathElems[1]);
-        }
-      }
-    }
-
-    return contextUrl.build();
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeltaDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeltaDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeltaDeserializer.java
deleted file mode 100644
index 89f327f..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeltaDeserializer.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.serialization;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.ContextURL;
-import org.apache.olingo.commons.api.data.DeletedEntity;
-import org.apache.olingo.commons.api.data.Delta;
-import org.apache.olingo.commons.api.data.DeltaLink;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
-
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-public class JsonDeltaDeserializer extends JsonDeserializer {
-
-  public JsonDeltaDeserializer(final boolean serverMode) {
-    super(serverMode);
-  }
-
-  protected ResWrap<Delta> doDeserialize(final JsonParser parser) throws IOException {
-
-    final ObjectNode tree = parser.getCodec().readTree(parser);
-
-    final Delta delta = new Delta();
-
-    final URI contextURL = tree.hasNonNull(Constants.JSON_CONTEXT) ?
-        URI.create(tree.get(Constants.JSON_CONTEXT).textValue()) : null;
-    if (contextURL != null) {
-      delta.setBaseURI(URI.create(StringUtils.substringBefore(contextURL.toASCIIString(), Constants.METADATA)));
-    }
-
-    if (tree.hasNonNull(Constants.JSON_COUNT)) {
-      delta.setCount(tree.get(Constants.JSON_COUNT).asInt());
-    }
-    if (tree.hasNonNull(Constants.JSON_NEXT_LINK)) {
-      delta.setNext(URI.create(tree.get(Constants.JSON_NEXT_LINK).textValue()));
-    }
-    if (tree.hasNonNull(Constants.JSON_DELTA_LINK)) {
-      delta.setDeltaLink(URI.create(tree.get(Constants.JSON_DELTA_LINK).textValue()));
-    }
-
-    if (tree.hasNonNull(Constants.VALUE)) {
-      JsonEntityDeserializer entityDeserializer = new JsonEntityDeserializer(serverMode);
-      for (JsonNode jsonNode : tree.get(Constants.VALUE)) {
-        final ObjectNode item = (ObjectNode) jsonNode;
-        final ContextURL itemContextURL = item.hasNonNull(Constants.JSON_CONTEXT) ?
-            ContextURLParser.parse(URI.create(item.get(Constants.JSON_CONTEXT).textValue())) : null;
-        item.remove(Constants.JSON_CONTEXT);
-
-        if (itemContextURL == null || itemContextURL.isEntity()) {
-          delta.getEntities().add(
-              entityDeserializer.doDeserialize(item.traverse(parser.getCodec())).getPayload());
-        } else if (itemContextURL.isDeltaDeletedEntity()) {
-          delta.getDeletedEntities().add(parser.getCodec().treeToValue(item, DeletedEntity.class));
-        } else if (itemContextURL.isDeltaLink()) {
-          delta.getAddedLinks().add(parser.getCodec().treeToValue(item, DeltaLink.class));
-        } else if (itemContextURL.isDeltaDeletedLink()) {
-          delta.getDeletedLinks().add(parser.getCodec().treeToValue(item, DeltaLink.class));
-        }
-      }
-    }
-
-    return new ResWrap<Delta>(contextURL, null, delta);
-  }
-
-  public ResWrap<Delta> toDelta(final InputStream input) throws ODataDeserializerException {
-    try {
-      JsonParser parser = new JsonFactory(new ObjectMapper()).createParser(input);
-      return doDeserialize(parser);
-    } catch (final IOException e) {
-      throw new ODataDeserializerException(e);
-    }
-  }
-}


[34/39] olingo-odata4 git commit: [OLINGO-694] Exclude samples from cobertura coverage

Posted by ch...@apache.org.
[OLINGO-694] Exclude samples from cobertura coverage


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

Branch: refs/heads/IEE754Compatible
Commit: 01425faf1c5380cb16e546c8c56e9bd01301661d
Parents: 4a002aa
Author: Michael Bolz <mi...@sap.com>
Authored: Mon Jun 22 14:11:26 2015 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Mon Jun 22 14:11:29 2015 +0200

----------------------------------------------------------------------
 fit/pom.xml | 1 -
 pom.xml     | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/01425faf/fit/pom.xml
----------------------------------------------------------------------
diff --git a/fit/pom.xml b/fit/pom.xml
index 80c8daa..484ba0d 100644
--- a/fit/pom.xml
+++ b/fit/pom.xml
@@ -191,7 +191,6 @@
         <configuration>
           <instrumentation>
             <excludes>
-              <exclude>org/apache/olingo/**/sample/**/*.class</exclude>
               <exclude>org/apache/olingo/**/tecsvc/**/*.class</exclude>
               <exclude>org/apache/olingo/**/fit/**/*.class</exclude>
               <exclude>org/apache/olingo/**/testutil/**/*.class</exclude>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/01425faf/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 144f56a..8176692 100644
--- a/pom.xml
+++ b/pom.xml
@@ -530,6 +530,7 @@
         <configuration>
           <instrumentation>
             <excludes>
+              <exclude>org/apache/olingo/**/sample/**/*.class</exclude>
               <exclude>org/apache/olingo/**/tecsvc/**/*.class</exclude>
               <exclude>org/apache/olingo/**/fit/**/*.class</exclude>
               <exclude>org/apache/olingo/**/testutil/**/*.class</exclude>


[36/39] olingo-odata4 git commit: [OLINGO-698] fix for navigation from function in technical service

Posted by ch...@apache.org.
[OLINGO-698] fix for navigation from function in technical service

Signed-off-by: Christian Amend <ch...@sap.com>


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

Branch: refs/heads/IEE754Compatible
Commit: a3fbf39f535d47d48d4aa60e3a4f9d305b8f837f
Parents: bfb5c93
Author: Klaus Straubinger <kl...@sap.com>
Authored: Fri Jun 19 16:43:21 2015 +0200
Committer: Christian Amend <ch...@sap.com>
Committed: Tue Jun 23 10:13:47 2015 +0200

----------------------------------------------------------------------
 .../server/tecsvc/processor/TechnicalEntityProcessor.java    | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a3fbf39f/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
index ccf8189..807c815 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
@@ -40,8 +40,8 @@ import org.apache.olingo.server.api.ODataResponse;
 import org.apache.olingo.server.api.ServiceMetadata;
 import org.apache.olingo.server.api.deserializer.DeserializerResult;
 import org.apache.olingo.server.api.deserializer.ODataDeserializer;
-import org.apache.olingo.server.api.prefer.PreferencesApplied;
 import org.apache.olingo.server.api.prefer.Preferences.Return;
+import org.apache.olingo.server.api.prefer.PreferencesApplied;
 import org.apache.olingo.server.api.processor.CountEntityCollectionProcessor;
 import org.apache.olingo.server.api.processor.EntityCollectionProcessor;
 import org.apache.olingo.server.api.processor.EntityProcessor;
@@ -53,8 +53,8 @@ import org.apache.olingo.server.api.serializer.EntitySerializerOptions;
 import org.apache.olingo.server.api.serializer.SerializerResult;
 import org.apache.olingo.server.api.uri.UriInfo;
 import org.apache.olingo.server.api.uri.UriResourceEntitySet;
-import org.apache.olingo.server.api.uri.UriResourceFunction;
 import org.apache.olingo.server.api.uri.UriResourceNavigation;
+import org.apache.olingo.server.api.uri.UriResourcePartTyped;
 import org.apache.olingo.server.api.uri.queryoption.CountOption;
 import org.apache.olingo.server.api.uri.queryoption.ExpandOption;
 import org.apache.olingo.server.api.uri.queryoption.IdOption;
@@ -382,7 +382,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
       throws ODataApplicationException, ODataLibraryException {
     final EdmEntitySet edmEntitySet = getEdmEntitySet(uriInfo);
     final EdmEntityType edmEntityType = edmEntitySet == null ?
-        (EdmEntityType) ((UriResourceFunction) uriInfo.getUriResourceParts()
+        (EdmEntityType) ((UriResourcePartTyped) uriInfo.getUriResourceParts()
             .get(uriInfo.getUriResourceParts().size() - 1)).getType() :
         edmEntitySet.getEntityType();
 
@@ -421,7 +421,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
       throws ODataApplicationException, ODataLibraryException {
     final EdmEntitySet edmEntitySet = getEdmEntitySet(uriInfo.asUriInfoResource());
     final EdmEntityType edmEntityType = edmEntitySet == null ?
-        (EdmEntityType) ((UriResourceFunction) uriInfo.getUriResourceParts()
+        (EdmEntityType) ((UriResourcePartTyped) uriInfo.getUriResourceParts()
             .get(uriInfo.getUriResourceParts().size() - 1)).getType() :
         edmEntitySet.getEntityType();
 


[09/39] olingo-odata4 git commit: [OLINGO-699] Moved serializer code to client module

Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonSerializer.java
deleted file mode 100755
index 92ce269..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonSerializer.java
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.serialization;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.Annotatable;
-import org.apache.olingo.commons.api.data.Annotation;
-import org.apache.olingo.commons.api.data.ComplexValue;
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntityCollection;
-import org.apache.olingo.commons.api.data.Link;
-import org.apache.olingo.commons.api.data.Linked;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.data.Valuable;
-import org.apache.olingo.commons.api.data.ValueType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.geo.Geospatial;
-import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.serialization.ODataSerializer;
-import org.apache.olingo.commons.api.serialization.ODataSerializerException;
-import org.apache.olingo.commons.core.edm.EdmTypeInfo;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
-
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonGenerator;
-
-public class JsonSerializer implements ODataSerializer {
-
-  private static final EdmPrimitiveTypeKind[] NUMBER_TYPES = {
-    EdmPrimitiveTypeKind.Byte, EdmPrimitiveTypeKind.SByte,
-    EdmPrimitiveTypeKind.Single, EdmPrimitiveTypeKind.Double,
-    EdmPrimitiveTypeKind.Int16, EdmPrimitiveTypeKind.Int32, EdmPrimitiveTypeKind.Int64,
-    EdmPrimitiveTypeKind.Decimal
-  };
-
-  private final JsonGeoValueSerializer geoSerializer = new JsonGeoValueSerializer();
-
-  protected boolean serverMode;
-
-  protected ODataFormat format;
-
-  public JsonSerializer(final boolean serverMode) {
-    this(serverMode, ODataFormat.JSON_FULL_METADATA);
-  }
-
-  public JsonSerializer(final boolean serverMode, final ODataFormat format) {
-    this.serverMode = serverMode;
-    this.format = format;
-  }
-
-  @Override
-  public <T> void write(final Writer writer, final T obj) throws ODataSerializerException {
-    try {
-      final JsonGenerator json = new JsonFactory().createGenerator(writer);
-      if (obj instanceof EntityCollection) {
-        new JsonEntitySetSerializer(serverMode).doSerialize((EntityCollection) obj, json);
-      } else if (obj instanceof Entity) {
-        new JsonEntitySerializer(serverMode, format).doSerialize((Entity) obj, json);
-      } else if (obj instanceof Property) {
-        new JsonPropertySerializer(serverMode).doSerialize((Property) obj, json);
-      } else if (obj instanceof Link) {
-        link((Link) obj, json);
-      }
-      json.flush();
-    } catch (final IOException e) {
-      throw new ODataSerializerException(e);
-    } catch (final EdmPrimitiveTypeException e) {
-      throw new ODataSerializerException(e);
-    }
-  }
-
-  private void reference(final ResWrap<URI> container, final JsonGenerator json) throws IOException {
-    json.writeStartObject();
-
-    json.writeStringField(Constants.JSON_CONTEXT, container.getContextURL().toASCIIString());
-    json.writeStringField(Constants.JSON_ID, container.getPayload().toASCIIString());
-
-    json.writeEndObject();
-  }
-
-  @SuppressWarnings("unchecked")
-  @Override
-  public <T> void write(final Writer writer, final ResWrap<T> container) throws ODataSerializerException {
-    final T obj = container == null ? null : container.getPayload();
-    try {
-      final JsonGenerator json = new JsonFactory().createGenerator(writer);
-      if (obj instanceof EntityCollection) {
-        new JsonEntitySetSerializer(serverMode).doContainerSerialize((ResWrap<EntityCollection>) container, json);
-      } else if (obj instanceof Entity) {
-        new JsonEntitySerializer(serverMode).doContainerSerialize((ResWrap<Entity>) container, json);
-      } else if (obj instanceof Property) {
-        new JsonPropertySerializer(serverMode).doContainerSerialize((ResWrap<Property>) container, json);
-      } else if (obj instanceof Link) {
-        link((Link) obj, json);
-      } else if (obj instanceof URI) {
-        reference((ResWrap<URI>) container, json);
-      }
-      json.flush();
-    } catch (final IOException e) {
-      throw new ODataSerializerException(e);
-    } catch (final EdmPrimitiveTypeException e) {
-      throw new ODataSerializerException(e);
-    }
-  }
-
-  protected void link(final Link link, final JsonGenerator jgen) throws IOException {
-    jgen.writeStartObject();
-    jgen.writeStringField(Constants.JSON_URL, link.getHref());
-    jgen.writeEndObject();
-  }
-
-  protected void links(final Linked linked, final JsonGenerator jgen)
-      throws IOException, EdmPrimitiveTypeException {
-
-    if (serverMode) {
-      serverLinks(linked, jgen);
-    } else {
-      clientLinks(linked, jgen);
-    }
-  }
-
-  protected void clientLinks(final Linked linked, final JsonGenerator jgen)
-      throws IOException, EdmPrimitiveTypeException {
-
-    final Map<String, List<String>> entitySetLinks = new HashMap<String, List<String>>();
-    for (Link link : linked.getNavigationLinks()) {
-      for (Annotation annotation : link.getAnnotations()) {
-        valuable(jgen, annotation, link.getTitle() + "@" + annotation.getTerm());
-      }
-
-      if (isEntitySetNavigation(link)) {
-        final List<String> uris;
-        if (entitySetLinks.containsKey(link.getTitle())) {
-          uris = entitySetLinks.get(link.getTitle());
-        } else {
-          uris = new ArrayList<String>();
-          entitySetLinks.put(link.getTitle(), uris);
-        }
-        if (StringUtils.isNotBlank(link.getHref())) {
-          uris.add(link.getHref());
-        }
-      } else {
-        if (StringUtils.isNotBlank(link.getHref())) {
-          jgen.writeStringField(link.getTitle() + Constants.JSON_BIND_LINK_SUFFIX, link.getHref());
-        }
-      }
-
-      if (link.getInlineEntity() != null) {
-        jgen.writeFieldName(link.getTitle());
-        new JsonEntitySerializer(serverMode).doSerialize(link.getInlineEntity(), jgen);
-      } else if (link.getInlineEntitySet() != null) {
-        jgen.writeArrayFieldStart(link.getTitle());
-        final JsonEntitySerializer entitySerializer = new JsonEntitySerializer(serverMode);
-        for (Entity subEntry : link.getInlineEntitySet().getEntities()) {
-          entitySerializer.doSerialize(subEntry, jgen);
-        }
-        jgen.writeEndArray();
-      }
-    }
-    for (Map.Entry<String, List<String>> entitySetLink : entitySetLinks.entrySet()) {
-      if (!entitySetLink.getValue().isEmpty()) {
-        jgen.writeArrayFieldStart(entitySetLink.getKey() + Constants.JSON_BIND_LINK_SUFFIX);
-        for (String uri : entitySetLink.getValue()) {
-          jgen.writeString(uri);
-        }
-        jgen.writeEndArray();
-      }
-    }
-  }
-
-  private boolean isEntitySetNavigation(final Link link) {
-    return Constants.ENTITY_SET_NAVIGATION_LINK_TYPE.equals(link.getType());
-  }
-
-  protected void serverLinks(final Linked linked, final JsonGenerator jgen)
-      throws IOException, EdmPrimitiveTypeException {
-    if (linked instanceof Entity) {
-      for (Link link : ((Entity) linked).getMediaEditLinks()) {
-        if (StringUtils.isNotBlank(link.getHref())) {
-          jgen.writeStringField(
-              link.getTitle() + StringUtils.prependIfMissing(Constants.JSON_MEDIA_EDIT_LINK, "@"),
-              link.getHref());
-        }
-      }
-    }
-
-    for (Link link : linked.getAssociationLinks()) {
-      if (StringUtils.isNotBlank(link.getHref())) {
-        jgen.writeStringField(
-            link.getTitle() + Constants.JSON_ASSOCIATION_LINK,
-            link.getHref());
-      }
-    }
-
-    for (Link link : linked.getNavigationLinks()) {
-      for (Annotation annotation : link.getAnnotations()) {
-        valuable(jgen, annotation, link.getTitle() + "@" + annotation.getTerm());
-      }
-
-      if (StringUtils.isNotBlank(link.getHref())) {
-        jgen.writeStringField(
-            link.getTitle() + Constants.JSON_NAVIGATION_LINK,
-            link.getHref());
-      }
-
-      if (link.getInlineEntity() != null) {
-        jgen.writeFieldName(link.getTitle());
-        new JsonEntitySerializer(serverMode).doSerialize(link.getInlineEntity(), jgen);
-      } else if (link.getInlineEntitySet() != null) {
-        jgen.writeArrayFieldStart(link.getTitle());
-        JsonEntitySerializer entitySerializer = new JsonEntitySerializer(serverMode);
-        for (Entity subEntry : link.getInlineEntitySet().getEntities()) {
-          entitySerializer.doSerialize(subEntry, jgen);
-        }
-        jgen.writeEndArray();
-      }
-    }
-  }
-
-  private void collection(final JsonGenerator jgen, final EdmTypeInfo typeInfo,
-      final ValueType valueType, final List<?> value)
-          throws IOException, EdmPrimitiveTypeException {
-
-    jgen.writeStartArray();
-
-    for (Object item : value) {
-      final EdmTypeInfo itemTypeInfo = typeInfo == null
-          ? null
-              : new EdmTypeInfo.Builder().setTypeExpression(typeInfo.getFullQualifiedName().toString()).build();
-      switch (valueType) {
-      case COLLECTION_PRIMITIVE:
-        primitiveValue(jgen, itemTypeInfo, item);
-        break;
-
-      case COLLECTION_GEOSPATIAL:
-        jgen.writeStartObject();
-        geoSerializer.serialize(jgen, (Geospatial) item);
-        jgen.writeEndObject();
-        break;
-
-      case COLLECTION_ENUM:
-        jgen.writeString(item.toString());
-        break;
-
-      case COLLECTION_COMPLEX:
-        final ComplexValue complexItem2 = (ComplexValue) item;
-        complexValue(jgen, itemTypeInfo, complexItem2.getValue(), complexItem2);
-        break;
-
-      default:
-      }
-    }
-
-    jgen.writeEndArray();
-  }
-
-  protected void primitiveValue(final JsonGenerator jgen, final EdmTypeInfo typeInfo, final Object value)
-      throws IOException, EdmPrimitiveTypeException {
-
-    final EdmPrimitiveTypeKind kind = typeInfo == null ? null : typeInfo.getPrimitiveTypeKind();
-    final boolean isNumber = kind == null ? value instanceof Number : ArrayUtils.contains(NUMBER_TYPES, kind);
-    final boolean isBoolean = kind == null ? value instanceof Boolean : kind == EdmPrimitiveTypeKind.Boolean;
-
-    if (value == null) {
-      jgen.writeNull();
-    } else if (isBoolean) {
-      jgen.writeBoolean((Boolean) value);
-    } else {
-      final String serialized = kind == null
-          ? value.toString()
-              // TODO: add facets
-              : EdmPrimitiveTypeFactory.getInstance(kind).
-              valueToString(value, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null);
-          if (isNumber) {
-            jgen.writeNumber(serialized);
-          } else {
-            jgen.writeString(serialized);
-          }
-    }
-  }
-
-  private void complexValue(final JsonGenerator jgen, final EdmTypeInfo typeInfo,
-      final List<Property> value, final Linked linked)
-          throws IOException, EdmPrimitiveTypeException {
-    jgen.writeStartObject();
-
-    if (typeInfo != null && format != ODataFormat.JSON_NO_METADATA) {
-      jgen.writeStringField(Constants.JSON_TYPE, typeInfo.external());
-    }
-
-    for (Property property : value) {
-      valuable(jgen, property, property.getName());
-    }
-    if (linked != null) {
-      links(linked, jgen);
-    }
-
-    jgen.writeEndObject();
-  }
-
-  private void value(final JsonGenerator jgen, final String type, final Valuable value)
-      throws IOException, EdmPrimitiveTypeException {
-    final EdmTypeInfo typeInfo = type == null ? null : new EdmTypeInfo.Builder().setTypeExpression(type).build();
-
-    if (value.isNull()) {
-      jgen.writeNull();
-    } else if (value.isCollection()) {
-      collection(jgen, typeInfo, value.getValueType(), value.asCollection());
-    } else if (value.isPrimitive()) {
-      primitiveValue(jgen, typeInfo, value.asPrimitive());
-    } else if (value.isEnum()) {
-      jgen.writeString(value.asEnum().toString());
-    } else if (value.isGeospatial()) {
-      jgen.writeStartObject();
-      geoSerializer.serialize(jgen, value.asGeospatial());
-      jgen.writeEndObject();
-    } else if (value.isComplex()) {
-      complexValue(jgen, typeInfo, value.asComplex().getValue(), value.asComplex());
-    }
-  }
-
-  protected void valuable(final JsonGenerator jgen, final Valuable valuable, final String name)
-      throws IOException, EdmPrimitiveTypeException {
-
-    if (!Constants.VALUE.equals(name) && !(valuable instanceof Annotation)
-        && !(valuable.isComplex() && !valuable.isCollection())) {
-
-      String type = valuable.getType();
-      if ((!valuable.isCollection() &&
-          StringUtils.isBlank(type) &&
-          valuable.isPrimitive()) || valuable.isNull()) {
-        type = EdmPrimitiveTypeKind.String.getFullQualifiedName().toString();
-      }
-      if (StringUtils.isNotBlank(type) && format != ODataFormat.JSON_NO_METADATA) {
-        jgen.writeFieldName(
-            name + StringUtils.prependIfMissing(Constants.JSON_TYPE, "@"));
-        jgen.writeString(new EdmTypeInfo.Builder().setTypeExpression(type).build().external());
-      }
-    }
-
-    for (Annotation annotation : ((Annotatable) valuable).getAnnotations()) {
-      valuable(jgen, annotation, name + "@" + annotation.getTerm());
-    }
-
-    jgen.writeFieldName(name);
-    value(jgen, valuable.getType(), valuable);
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/commons-core/src/test/java/org/apache/olingo/commons/core/serialization/AtomDeserializerTest.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/serialization/AtomDeserializerTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/serialization/AtomDeserializerTest.java
deleted file mode 100644
index c1226b2..0000000
--- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/serialization/AtomDeserializerTest.java
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.serialization;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntityCollection;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.junit.Test;
-
-public class AtomDeserializerTest {
-
-  @Test
-  public void emptyInlineEntityOlingo540() throws Exception {
-    final String content = "" +
-        "<entry xmlns=\"http://www.w3.org/2005/Atom\" "
-        + "xmlns:data=\"http://docs.oasis-open.org/odata/ns/data\" "
-        + "xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\" "
-        + "xmlns:georss=\"http://www.georss.org/georss\" xmlns:gml=\"http://www.opengis.net/gml\" "
-        + "xml:base=\"http://services.odata.org/V3/OData/OData.svc/\">\r\n" +
-        "    <id>http://services.odata.org/V3/OData/OData.svc/Products(3)</id>\r\n" +
-        "    <category term=\"ODataDemo.Product\" "
-        + "scheme=\"http://docs.oasis-open.org/odata/ns/scheme\" />\r\n" +
-        "    \r\n" +
-        "    <link rel=\"edit\" title=\"Product\" href=\"Products\" />\r\n" +
-        "    <link rel=\"http://docs.oasis-open.org/odata/ns/related/Categories\" "
-        + "type=\"application/atom+xml;type=feed\" title=\"Categories\" href=\"Products(3)/Categories\" />\r\n" +
-        "    <link rel=\"http://docs.oasis-open.org/odata/ns/related/Supplier\" "
-        + "type=\"application/atom+xml;type=entry\" title=\"Supplier\" href=\"Products(3)/Supplier\">\r\n" +
-        "    <metadata:inline>\r\n" +
-        "    </metadata:inline>\r\n" +
-        "    </link>\r\n" +
-        "    <link rel=\"http://docs.oasis-open.org/odata/ns/related/ProductDetail\""
-        + " type=\"application/atom+xml;type=entry\" title=\"ProductDetail\" "
-        + "href=\"Products(3)/ProductDetail\" />\r\n" +
-        "    <title type=\"text\">Havina Cola</title>\r\n" +
-        "    <summary type=\"text\">The Original Key Lime Cola</summary>\r\n" +
-        "    <updated>2015-01-26T08:57:02Z</updated>\r\n" +
-        "    <author>\r\n" +
-        "        <name />\r\n" +
-        "    </author>\r\n" +
-        "    <link rel=\"http://docs.oasis-open.org/odata/ns/relatedlinks/Categories\" "
-        + "type=\"application/xml\" title=\"Categories\" href=\"Products(3)/$links/Categories\" />\r\n" +
-        "    <link rel=\"http://docs.oasis-open.org/odata/ns/relatedlinks/Supplier\" "
-        + "type=\"application/xml\" title=\"Supplier\" href=\"Products(3)/$links/Supplier\" />\r\n" +
-        "    <link rel=\"http://docs.oasis-open.org/odata/ns/relatedlinks/ProductDetail\""
-        + " type=\"application/xml\" title=\"ProductDetail\" href=\"Products(3)/$links/ProductDetail\" />\r\n" +
-        "    <content type=\"application/xml\">\r\n" +
-        "        <metadata:properties>\r\n" +
-        "            <data:ID metadata:type=\"Edm.Int32\">3</data:ID>\r\n" +
-        "            <data:ReleaseDate metadata:type=\"Edm.DateTime\">2005-10-01T00:00:00</data:ReleaseDate>\r\n" +
-        "  <data:DiscontinuedDate metadata:type=\"Edm.DateTime\">2006-10-01T00:00:00</data:DiscontinuedDate>\r\n" +
-        "            <data:Rating metadata:type=\"Edm.Int16\">3</data:Rating>\r\n" +
-        "            <data:Price metadata:type=\"Edm.Double\">19.9</data:Price>\r\n" +
-        "        </metadata:properties>\r\n" +
-        "    </content>\r\n" +
-        " </entry>";
-
-    final AtomDeserializer deserializer = new AtomDeserializer();
-    final InputStream in = new ByteArrayInputStream(content.getBytes("UTF-8"));
-    final ResWrap<Entity> entity = deserializer.toEntity(in);
-
-    assertNotNull(entity);
-    assertNull(entity.getPayload().getNavigationLink("Supplier").getInlineEntitySet());
-  }
-
-  @Test
-  public void filledInlineEntity() throws Exception {
-    final String content = "" +
-        "<entry xmlns=\"http://www.w3.org/2005/Atom\" "
-        + "xmlns:data=\"http://docs.oasis-open.org/odata/ns/data\" "
-        + "xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\" "
-        + "xmlns:georss=\"http://www.georss.org/georss\" "
-        + "xmlns:gml=\"http://www.opengis.net/gml\" "
-        + "xml:base=\"http://services.odata.org/V4/OData/OData.svc/\">\r\n" +
-        "    <id>http://services.odata.org/V4/OData/OData.svc/Products(3)</id>\r\n" +
-        "    <category term=\"#ODataDemo.Product\" "
-        + "scheme=\"http://docs.oasis-open.org/odata/ns/scheme\" />\r\n" +
-        "    \r\n" +
-        "    <link rel=\"edit\" title=\"Product\" href=\"Products\" />\r\n" +
-        "    <link rel=\"http://docs.oasis-open.org/odata/ns/related/Categories\" "
-        + "type=\"application/atom+xml;type=feed\" title=\"Categories\" href=\"Products(3)/Categories\" />\r\n" +
-        "    <link rel=\"http://docs.oasis-open.org/odata/ns/related/Supplier\" "
-        + "type=\"application/atom+xml;type=entry\" title=\"Supplier\" href=\"Products(3)/Supplier\">\r\n" +
-        "    <metadata:inline>\r\n" +
-        "       <entry>\r\n" +
-        "            <id>http://services.odata.org/V4/OData/OData.svc/Suppliers(0)</id>\r\n" +
-        "            <category term=\"ODataDemo.Supplier\" "
-        + "scheme=\"http://docs.oasis-open.org/odata/ns/scheme\" />\r\n" +
-        "            <link rel=\"edit\" title=\"Supplier\" href=\"Suppliers(0)\" />\r\n" +
-        "            <link rel=\"http://docs.oasis-open.org/odata/ns/related/Products\" "
-        + "type=\"application/atom+xml;type=feed\" title=\"Products\" href=\"Suppliers(0)/Products\" />\r\n" +
-        "            <title type=\"text\">Exotic Liquids</title>\r\n" +
-        "            <updated>2015-01-26T08:57:02Z</updated>\r\n" +
-        "            <author>\r\n" +
-        "                <name />\r\n" +
-        "            </author>\r\n" +
-        "            <link rel=\"http://docs.oasis-open.org/odata/ns/relatedlinks/Products\" "
-        + "type=\"application/xml\" title=\"Products\" href=\"Suppliers(0)/$links/Products\" />\r\n" +
-        "            <content type=\"application/xml\">\r\n" +
-        "                 <metadata:properties>\r\n" +
-        "                    <data:ID metadata:type=\"Edm.Int32\">0</data:ID>\r\n" +
-        "                    <data:Name>Exotic Liquids</data:Name>\r\n" +
-        "                    <data:Address metadata:type=\"ODataDemo.Address\">\r\n" +
-        "                    <data:Street>NE 228th</data:Street>\r\n" +
-        "                    <data:City>Sammamish</data:City>\r\n" +
-        "                    <data:State>WA</data:State>\r\n" +
-        "                    <data:ZipCode>98074</data:ZipCode>\r\n" +
-        "                    <data:Country>USA</data:Country>\r\n" +
-        "                     </data:Address>\r\n" +
-        "                    <data:Location metadata:type=\"Edm.GeographyPoint\">\r\n" +
-        "                    <gml:Point gml:srsName=\"http://www.opengis.net/def/crs/EPSG/0/4326\">\r\n" +
-        "                    <gml:pos>47.6316604614258 -122.03547668457</gml:pos>\r\n" +
-        "                    </gml:Point>\r\n" +
-        "                    </data:Location>\r\n" +
-        "                    <data:Concurrency metadata:type=\"Edm.Int32\">0</data:Concurrency>\r\n" +
-        "                 </metadata:properties>\r\n" +
-        "            </content>\r\n" +
-        "         </entry>" +
-        "    </metadata:inline>\r\n" +
-        "    </link>\r\n" +
-        "    <link rel=\"http://docs.oasis-open.org/odata/ns/related/ProductDetail\" "
-        + "type=\"application/atom+xml;type=entry\" "
-        + "title=\"ProductDetail\" href=\"Products(3)/ProductDetail\" />\r\n" +
-        "    <title type=\"text\">Havina Cola</title>\r\n" +
-        "    <summary type=\"text\">The Original Key Lime Cola</summary>\r\n" +
-        "    <updated>2015-01-26T08:57:02Z</updated>\r\n" +
-        "    <author>\r\n" +
-        "        <name />\r\n" +
-        "    </author>\r\n" +
-        "    <link rel=\"http://docs.oasis-open.org/odata/ns/relatedlinks/Categories\" "
-        + "type=\"application/xml\" title=\"Categories\" href=\"Products(3)/$links/Categories\" />\r\n" +
-        "    <link rel=\"http://docs.oasis-open.org/odata/ns/relatedlinks/Supplier\" "
-        + "type=\"application/xml\" title=\"Supplier\" href=\"Products(3)/$links/Supplier\" />\r\n" +
-        "    <link rel=\"http://docs.oasis-open.org/odata/ns/relatedlinks/ProductDetail\" "
-        + "type=\"application/xml\" title=\"ProductDetail\" href=\"Products(3)/$links/ProductDetail\" />\r\n" +
-        "    <content type=\"application/xml\">\r\n" +
-        "        <metadata:properties>\r\n" +
-        "            <data:ID metadata:type=\"Edm.Int32\">3</data:ID>\r\n" +
-        "            <data:ReleaseDate metadata:type=\"Edm.DateTime\">2005-10-01T00:00:00</data:ReleaseDate>\r\n" +
-        "  <data:DiscontinuedDate metadata:type=\"Edm.DateTime\">2006-10-01T00:00:00</data:DiscontinuedDate>\r\n" +
-        "            <data:Rating metadata:type=\"Edm.Int16\">3</data:Rating>\r\n" +
-        "            <data:Price metadata:type=\"Edm.Double\">19.9</data:Price>\r\n" +
-        "        </metadata:properties>\r\n" +
-        "    </content>\r\n" +
-        " </entry>";
-    final AtomDeserializer deserializer = new AtomDeserializer();
-    final InputStream in = new ByteArrayInputStream(content.getBytes("UTF-8"));
-    final ResWrap<Entity> entity = deserializer.toEntity(in);
-
-    assertNotNull(entity);
-    final Entity inlineEntity = entity.getPayload().getNavigationLink("Supplier").getInlineEntity();
-    assertNotNull(inlineEntity);
-
-    assertEquals(new Integer(0), inlineEntity.getProperty("ID").getValue());
-    assertEquals("Exotic Liquids", inlineEntity.getProperty("Name").getValue());
-  }
-
-  @Test
-  public void emptyInlineEntityCollection() throws Exception {
-    final String content = "" +
-        "<entry xmlns=\"http://www.w3.org/2005/Atom\" "
-        + "xmlns:data=\"http://docs.oasis-open.org/odata/ns/data\" "
-        + "xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\" "
-        + "xmlns:georss=\"http://www.georss.org/georss\" xmlns:gml=\"http://www.opengis.net/gml\" "
-        + "xml:base=\"http://services.odata.org/V3/OData/OData.svc/\">\r\n" +
-        "    <id>http://services.odata.org/V3/OData/OData.svc/Products(3)</id>\r\n" +
-        "    <category term=\"ODataDemo.Product\" "
-        + "scheme=\"http://docs.oasis-open.org/odata/ns/scheme\" />\r\n" +
-        "    \r\n" +
-        "    <link rel=\"edit\" title=\"Product\" href=\"Products(3)\" />\r\n" +
-        "    <link rel=\"http://docs.oasis-open.org/odata/ns/related/Categories\" "
-        + "type=\"application/atom+xml;type=feed\" title=\"Categories\" href=\"Products(3)/Categories\" />\r\n" +
-        "    <link rel=\"http://docs.oasis-open.org/odata/ns/related/Supplier\" "
-        + "type=\"application/atom+xml;type=feed\" title=\"Supplier\" href=\"Products(3)/Supplier\">\r\n" +
-        "    <metadata:inline>\r\n" +
-        "        <feed>\r\n" +
-        "         </feed>\r\n" +
-        "    </metadata:inline>\r\n" +
-        "    </link>\r\n" +
-        "    <link rel=\"http://docs.oasis-open.org/odata/ns/related/ProductDetail\" "
-        + "type=\"application/atom+xml;type=entry\" "
-        + "title=\"ProductDetail\" href=\"Products(3)/ProductDetail\" />\r\n" +
-        "    <title type=\"text\">Havina Cola</title>\r\n" +
-        "    <summary type=\"text\">The Original Key Lime Cola</summary>\r\n" +
-        "    <updated>2015-01-26T08:57:02Z</updated>\r\n" +
-        "    <author>\r\n" +
-        "        <name />\r\n" +
-        "    </author>\r\n" +
-        "    <link rel=\"http://docs.oasis-open.org/odata/ns/relatedlinks/Categories\" "
-        + "type=\"application/xml\" title=\"Categories\" href=\"Products(3)/$links/Categories\" />\r\n" +
-        "    <link rel=\"http://docs.oasis-open.org/odata/ns/relatedlinks/Supplier\" "
-        + "type=\"application/xml\" title=\"Supplier\" href=\"Products(3)/$links/Supplier\" />\r\n" +
-        "    <link rel=\"http://docs.oasis-open.org/odata/ns/relatedlinks/ProductDetail\" "
-        + "type=\"application/xml\" title=\"ProductDetail\" href=\"Products(3)/$links/ProductDetail\" />\r\n" +
-        "    <content type=\"application/xml\">\r\n" +
-        "        <metadata:properties>\r\n" +
-        "            <data:ID metadata:type=\"Edm.Int32\">3</data:ID>\r\n" +
-        "            <data:ReleaseDate metadata:type=\"Edm.DateTime\">2005-10-01T00:00:00</data:ReleaseDate>\r\n" +
-        "  <data:DiscontinuedDate metadata:type=\"Edm.DateTime\">2006-10-01T00:00:00</data:DiscontinuedDate>\r\n" +
-        "            <data:Rating metadata:type=\"Edm.Int16\">3</data:Rating>\r\n" +
-        "            <data:Price metadata:type=\"Edm.Double\">19.9</data:Price>\r\n" +
-        "        </metadata:properties>\r\n" +
-        "    </content>\r\n" +
-        " </entry>";
-    final AtomDeserializer deserializer = new AtomDeserializer();
-    final InputStream in = new ByteArrayInputStream(content.getBytes("UTF-8"));
-    final ResWrap<Entity> entity = deserializer.toEntity(in);
-
-    assertNotNull(entity);
-    final EntityCollection inlineEntitySet = entity.getPayload().getNavigationLink("Supplier").getInlineEntitySet();
-    assertNotNull(inlineEntitySet);
-    assertEquals(0, inlineEntitySet.getEntities().size());
-  }
-
-  @Test
-  public void filledInlineEntityCollection() throws Exception {
-    final String content = "" +
-        "<entry xmlns=\"http://www.w3.org/2005/Atom\" "
-        + "xmlns:data=\"http://docs.oasis-open.org/odata/ns/data\" "
-        + "xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\" "
-        + "xmlns:georss=\"http://www.georss.org/georss\" xmlns:gml=\"http://www.opengis.net/gml\" "
-        + "xml:base=\"http://services.odata.org/V3/OData/OData.svc/\">\r\n" +
-        "    <id>http://services.odata.org/V3/OData/OData.svc/Products(3)</id>\r\n" +
-        "    <category term=\"ODataDemo.Product\" "
-        + "scheme=\"http://docs.oasis-open.org/odata/ns/scheme\" />\r\n" +
-        "    \r\n" +
-        "    <link rel=\"edit\" title=\"Product\" href=\"Products(3)\" />\r\n" +
-        "    <link rel=\"http://docs.oasis-open.org/odata/ns/related/Categories\" "
-        + "type=\"application/atom+xml;type=feed\" title=\"Categories\" href=\"Products(3)/Categories\" />\r\n" +
-        "    <link rel=\"http://docs.oasis-open.org/odata/ns/related/Supplier\" "
-        + "type=\"application/atom+xml;type=feed\" title=\"Supplier\" href=\"Products(3)/Supplier\">\r\n" +
-        "    <metadata:inline>\r\n" +
-        "        <feed>\r\n" +
-        "        <entry>\r\n" +
-        "            <id>http://services.odata.org/V3/OData/OData.svc/Suppliers(0)</id>\r\n" +
-        "            <category term=\"ODataDemo.Supplier\" "
-        + "scheme=\"http://docs.oasis-open.org/odata/ns/scheme\" />\r\n" +
-        "            <link rel=\"edit\" title=\"Supplier\" href=\"Suppliers(0)\" />\r\n" +
-        "            <link rel=\"http://docs.oasis-open.org/odata/ns/related/Products\" "
-        + "type=\"application/atom+xml;type=feed\" title=\"Products\" href=\"Suppliers(0)/Products\" />\r\n" +
-        "            <title type=\"text\">Exotic Liquids</title>\r\n" +
-        "            <updated>2015-01-26T08:57:02Z</updated>\r\n" +
-        "            <author>\r\n" +
-        "                <name />\r\n" +
-        "            </author>\r\n" +
-        "            <link rel=\"http://docs.oasis-open.org/odata/ns/relatedlinks/Products\" "
-        + "type=\"application/xml\" title=\"Products\" href=\"Suppliers(0)/$links/Products\" />\r\n" +
-        "            <content type=\"application/xml\">\r\n" +
-        "                 <metadata:properties>\r\n" +
-        "                    <data:ID metadata:type=\"Edm.Int32\">0</data:ID>\r\n" +
-        "                    <data:Name>Exotic Liquids</data:Name>\r\n" +
-        "                    <data:Address metadata:type=\"ODataDemo.Address\">\r\n" +
-        "                    <data:Street>NE 228th</data:Street>\r\n" +
-        "                    <data:City>Sammamish</data:City>\r\n" +
-        "                    <data:State>WA</data:State>\r\n" +
-        "                    <data:ZipCode>98074</data:ZipCode>\r\n" +
-        "                    <data:Country>USA</data:Country>\r\n" +
-        "                     </data:Address>\r\n" +
-        "                    <data:Location metadata:type=\"Edm.GeographyPoint\">\r\n" +
-        "                    <gml:Point gml:srsName=\"http://www.opengis.net/def/crs/EPSG/0/4326\">\r\n" +
-        "                    <gml:pos>47.6316604614258 -122.03547668457</gml:pos>\r\n" +
-        "                    </gml:Point>\r\n" +
-        "                    </data:Location>\r\n" +
-        "                    <data:Concurrency metadata:type=\"Edm.Int32\">0</data:Concurrency>\r\n" +
-        "                 </metadata:properties>\r\n" +
-        "            </content>\r\n" +
-        "         </entry>\r\n" +
-        "         </feed>\r\n" +
-        "    </metadata:inline>\r\n" +
-        "    </link>\r\n" +
-        "    <link rel=\"http://docs.oasis-open.org/odata/ns/related/ProductDetail\" "
-        + "type=\"application/atom+xml;type=entry\" "
-        + "title=\"ProductDetail\" href=\"Products(3)/ProductDetail\" />\r\n" +
-        "    <title type=\"text\">Havina Cola</title>\r\n" +
-        "    <summary type=\"text\">The Original Key Lime Cola</summary>\r\n" +
-        "    <updated>2015-01-26T08:57:02Z</updated>\r\n" +
-        "    <author>\r\n" +
-        "        <name />\r\n" +
-        "    </author>\r\n" +
-        "    <link rel=\"http://docs.oasis-open.org/odata/ns/relatedlinks/Categories\" "
-        + "type=\"application/xml\" title=\"Categories\" href=\"Products(3)/$links/Categories\" />\r\n" +
-        "    <link rel=\"http://docs.oasis-open.org/odata/ns/relatedlinks/Supplier\" "
-        + "type=\"application/xml\" title=\"Supplier\" href=\"Products(3)/$links/Supplier\" />\r\n" +
-        "    <link rel=\"http://docs.oasis-open.org/odata/ns/relatedlinks/ProductDetail\" "
-        + "type=\"application/xml\" title=\"ProductDetail\" href=\"Products(3)/$links/ProductDetail\" />\r\n" +
-        "    <content type=\"application/xml\">\r\n" +
-        "        <metadata:properties>\r\n" +
-        "            <data:ID metadata:type=\"Edm.Int32\">3</data:ID>\r\n" +
-        "            <data:ReleaseDate metadata:type=\"Edm.DateTime\">2005-10-01T00:00:00</data:ReleaseDate>\r\n" +
-        "  <data:DiscontinuedDate metadata:type=\"Edm.DateTime\">2006-10-01T00:00:00</data:DiscontinuedDate>\r\n" +
-        "            <data:Rating metadata:type=\"Edm.Int16\">3</data:Rating>\r\n" +
-        "            <data:Price metadata:type=\"Edm.Double\">19.9</data:Price>\r\n" +
-        "        </metadata:properties>\r\n" +
-        "    </content>\r\n" +
-        " </entry>";
-    final AtomDeserializer deserializer = new AtomDeserializer();
-    final InputStream in = new ByteArrayInputStream(content.getBytes("UTF-8"));
-    final ResWrap<Entity> entity = deserializer.toEntity(in);
-
-    assertNotNull(entity);
-    final EntityCollection inlineEntitySet = entity.getPayload().getNavigationLink("Supplier").getInlineEntitySet();
-    assertNotNull(inlineEntitySet);
-    assertEquals(1, inlineEntitySet.getEntities().size());
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/20351253/lib/commons-core/src/test/java/org/apache/olingo/commons/core/serialization/ContextURLParserTest.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/serialization/ContextURLParserTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/serialization/ContextURLParserTest.java
deleted file mode 100644
index 7c401e1..0000000
--- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/serialization/ContextURLParserTest.java
+++ /dev/null
@@ -1,255 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.serialization;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.net.URI;
-
-import org.apache.olingo.commons.api.data.ContextURL;
-import org.junit.Test;
-
-public class ContextURLParserTest {
-
-  @Test
-  public void collectionOfEntities() {
-    ContextURL contextURL = ContextURLParser.parse(URI.create("http://host/service/$metadata#Customers"));
-
-    assertEquals(URI.create("http://host/service/"), contextURL.getServiceRoot());
-    assertEquals("Customers", contextURL.getEntitySetOrSingletonOrType());
-    assertNull(contextURL.getDerivedEntity());
-    assertNull(contextURL.getSelectList());
-    assertNull(contextURL.getNavOrPropertyPath());
-    assertFalse(contextURL.isEntity());
-
-    contextURL = ContextURLParser.parse(URI.create("http://host/service/$metadata#Orders(4711)/Items"));
-
-    assertEquals("Orders", contextURL.getEntitySetOrSingletonOrType());
-    assertNull(contextURL.getDerivedEntity());
-    assertNull(contextURL.getSelectList());
-    assertEquals("Items", contextURL.getNavOrPropertyPath());
-    assertFalse(contextURL.isEntity());
-
-    contextURL = ContextURLParser.parse(URI.create("http://host/service/$metadata#Me/Folders('Inbox')/Messages"));
-
-    assertEquals("Me/Folders", contextURL.getEntitySetOrSingletonOrType());
-    assertEquals("Messages", contextURL.getNavOrPropertyPath());
-  }
-
-  @Test
-  public void entity() {
-    ContextURL contextURL = ContextURLParser.parse(URI.create("http://host/service/$metadata#Customers/$entity"));
-
-    assertEquals("Customers", contextURL.getEntitySetOrSingletonOrType());
-    assertNull(contextURL.getDerivedEntity());
-    assertNull(contextURL.getSelectList());
-    assertNull(contextURL.getNavOrPropertyPath());
-    assertTrue(contextURL.isEntity());
-
-    contextURL = ContextURLParser.parse(URI.create("http://host/service/$metadata#Orders(4711)/Items/$entity"));
-
-    assertEquals("Orders/Items", contextURL.getEntitySetOrSingletonOrType());
-    assertNull(contextURL.getDerivedEntity());
-    assertNull(contextURL.getSelectList());
-    assertNull(contextURL.getNavOrPropertyPath());
-    assertTrue(contextURL.isEntity());
-
-    contextURL = ContextURLParser.parse(
-        URI.create("http://host/service/$metadata#Users('user')/Messages('message')/Attachments/$entity"));
-
-    assertEquals("Users/Messages/Attachments", contextURL.getEntitySetOrSingletonOrType());
-    assertNull(contextURL.getDerivedEntity());
-    assertNull(contextURL.getSelectList());
-    assertNull(contextURL.getNavOrPropertyPath());
-    assertTrue(contextURL.isEntity());
-
-    // v3
-    contextURL = ContextURLParser.parse(URI.create("http://host/service/$metadata#Products/@Element"));
-
-    assertEquals("Products", contextURL.getEntitySetOrSingletonOrType());
-    assertNull(contextURL.getDerivedEntity());
-    assertNull(contextURL.getSelectList());
-    assertNull(contextURL.getNavOrPropertyPath());
-    assertTrue(contextURL.isEntity());
-  }
-
-  @Test
-  public void singleton() {
-    ContextURL contextURL = ContextURLParser.parse(URI.create("http://host/service/$metadata#Contoso"));
-
-    assertEquals("Contoso", contextURL.getEntitySetOrSingletonOrType());
-    assertNull(contextURL.getDerivedEntity());
-    assertNull(contextURL.getSelectList());
-    assertNull(contextURL.getNavOrPropertyPath());
-    assertFalse(contextURL.isEntity());
-  }
-
-  @Test
-  public void collectionOfDerivedEntities() {
-    final ContextURL contextURL = ContextURLParser.parse(
-        URI.create("http://host/service/$metadata#Customers/Model.VipCustomer"));
-
-    assertEquals("Customers", contextURL.getEntitySetOrSingletonOrType());
-    assertEquals("Model.VipCustomer", contextURL.getDerivedEntity());
-    assertNull(contextURL.getSelectList());
-    assertNull(contextURL.getNavOrPropertyPath());
-    assertFalse(contextURL.isEntity());
-  }
-
-  @Test
-  public void derivedEntity() {
-    final ContextURL contextURL = ContextURLParser.parse(
-        URI.create("http://host/service/$metadata#Customers/Model.VipCustomer/$entity"));
-
-    assertEquals("Customers", contextURL.getEntitySetOrSingletonOrType());
-    assertEquals("Model.VipCustomer", contextURL.getDerivedEntity());
-    assertNull(contextURL.getSelectList());
-    assertNull(contextURL.getNavOrPropertyPath());
-    assertTrue(contextURL.isEntity());
-  }
-
-  @Test
-  public void collectionOfProjectedEntities() {
-    final ContextURL contextURL = ContextURLParser.parse(
-        URI.create("http://host/service/$metadata#Customers(Address,Orders)"));
-
-    assertEquals("Customers", contextURL.getEntitySetOrSingletonOrType());
-    assertNull(contextURL.getDerivedEntity());
-    assertEquals("Address,Orders", contextURL.getSelectList());
-    assertNull(contextURL.getNavOrPropertyPath());
-    assertFalse(contextURL.isEntity());
-  }
-
-  @Test
-  public void projectedEntity() {
-    ContextURL contextURL = ContextURLParser.parse(
-        URI.create("http://host/service/$metadata#Customers(Name,Rating)/$entity"));
-
-    assertEquals("Customers", contextURL.getEntitySetOrSingletonOrType());
-    assertNull(contextURL.getDerivedEntity());
-    assertEquals("Name,Rating", contextURL.getSelectList());
-    assertNull(contextURL.getNavOrPropertyPath());
-    assertTrue(contextURL.isEntity());
-
-    contextURL = ContextURLParser.parse(
-        URI.create("http://host/service/$metadata#Customers(Name,Address/Country)"));
-
-    assertEquals("Customers", contextURL.getEntitySetOrSingletonOrType());
-    assertNull(contextURL.getDerivedEntity());
-    assertEquals("Name,Address/Country", contextURL.getSelectList());
-    assertNull(contextURL.getNavOrPropertyPath());
-    assertFalse(contextURL.isEntity());
-  }
-
-  @Test
-  public void collectionOfProjectedExpandedEntities() {
-    final ContextURL contextURL = ContextURLParser.parse(
-        URI.create("http://host/service/$metadata#Employees/"
-            + "Sales.Manager(DirectReports,DirectReports+(FirstName,LastName))"));
-
-    assertEquals("Employees", contextURL.getEntitySetOrSingletonOrType());
-    assertEquals("Sales.Manager", contextURL.getDerivedEntity());
-    assertEquals("DirectReports,DirectReports+(FirstName,LastName)", contextURL.getSelectList());
-    assertNull(contextURL.getNavOrPropertyPath());
-    assertFalse(contextURL.isEntity());
-  }
-
-  @Test
-  public void propertyValue() {
-    final ContextURL contextURL = ContextURLParser.parse(
-        URI.create("http://host/service/$metadata#Customers(1)/Addresses"));
-
-    assertEquals("Customers", contextURL.getEntitySetOrSingletonOrType());
-    assertNull(contextURL.getDerivedEntity());
-    assertNull(contextURL.getSelectList());
-    assertEquals("Addresses", contextURL.getNavOrPropertyPath());
-    assertFalse(contextURL.isEntity());
-  }
-
-  @Test
-  public void CollectionOfComplexOrPrimitiveTypes() {
-    final ContextURL contextURL = ContextURLParser.parse(
-        URI.create("http://host/service/$metadata#Collection(Edm.String)"));
-
-    assertEquals("Collection(Edm.String)", contextURL.getEntitySetOrSingletonOrType());
-    assertNull(contextURL.getDerivedEntity());
-    assertNull(contextURL.getSelectList());
-    assertNull(contextURL.getNavOrPropertyPath());
-    assertFalse(contextURL.isEntity());
-  }
-
-  @Test
-  public void complexOrPrimitiveType() {
-    ContextURL contextURL = ContextURLParser.parse(URI.create("http://host/service/$metadata#Edm.String"));
-
-    assertEquals("Edm.String", contextURL.getEntitySetOrSingletonOrType());
-    assertNull(contextURL.getDerivedEntity());
-    assertNull(contextURL.getSelectList());
-    assertNull(contextURL.getNavOrPropertyPath());
-    assertFalse(contextURL.isEntity());
-
-    contextURL = ContextURLParser.parse(URI.create("http://host/service/$metadata#ODataDemo.Address"));
-
-    assertEquals("ODataDemo.Address", contextURL.getEntitySetOrSingletonOrType());
-    assertNull(contextURL.getDerivedEntity());
-    assertNull(contextURL.getSelectList());
-    assertNull(contextURL.getNavOrPropertyPath());
-    assertFalse(contextURL.isEntity());
-  }
-
-  @Test
-  public void reference() {
-    ContextURL contextURL = ContextURLParser.parse(URI.create("http://host/service/$metadata#Customers/$ref"));
-    assertTrue(contextURL.isReference());
-    assertNull(contextURL.getSelectList());
-    assertNull(contextURL.getNavOrPropertyPath());
-    assertFalse(contextURL.isEntity());
-    assertFalse(contextURL.isDelta());
-  }
-
-  @Test
-  public void delta() {
-    ContextURL contextURL = ContextURLParser.parse(URI.create("http://host/service/$metadata#Customers/$delta"));
-    assertTrue(contextURL.isDelta());
-    assertNull(contextURL.getSelectList());
-    assertNull(contextURL.getNavOrPropertyPath());
-    assertFalse(contextURL.isEntity());
-
-    contextURL = ContextURLParser.parse(URI.create("http://host/service/$metadata#Customers/$deletedLink"));
-    assertTrue(contextURL.isDeltaDeletedLink());
-    assertNull(contextURL.getSelectList());
-    assertNull(contextURL.getNavOrPropertyPath());
-    assertFalse(contextURL.isEntity());
-
-    contextURL = ContextURLParser.parse(URI.create("http://host/service/$metadata#Customers/$link"));
-    assertTrue(contextURL.isDeltaLink());
-    assertNull(contextURL.getSelectList());
-    assertNull(contextURL.getNavOrPropertyPath());
-    assertFalse(contextURL.isEntity());
-
-    contextURL = ContextURLParser.parse(URI.create("http://host/service/$metadata#Customers/$deletedEntity"));
-    assertTrue(contextURL.isDeltaDeletedEntity());
-    assertNull(contextURL.getSelectList());
-    assertNull(contextURL.getNavOrPropertyPath());
-    assertFalse(contextURL.isEntity());
-  }
-}


[32/39] olingo-odata4 git commit: [OLINGO-695] Merge remote-tracking branch 'origin/master' into OLINGO-695_OSGi-Support

Posted by ch...@apache.org.
[OLINGO-695] Merge remote-tracking branch 'origin/master' into OLINGO-695_OSGi-Support


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

Branch: refs/heads/IEE754Compatible
Commit: 85cd9072e4ae6f0ea16c30e73c51c253c409ac04
Parents: 74fddd1 fd513e2
Author: Michael Bolz <mi...@sap.com>
Authored: Fri Jun 19 18:17:53 2015 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Fri Jun 19 18:18:32 2015 +0200

----------------------------------------------------------------------
 .../fit/tecsvc/client/ActionImportITCase.java   |   2 +-
 .../olingo/fit/tecsvc/client/BasicITCase.java   |   6 +-
 .../tecsvc/client/PrimitiveComplexITCase.java   |   2 +-
 .../tecsvc/client/SystemQueryOptionITCase.java  |   2 +-
 .../communication/header/ODataPreferences.java  |  33 ++-
 .../commons/api/ODataPreferenceNames.java       |  46 +++++
 .../olingo/server/api/prefer/Preferences.java   |   5 +-
 .../server/api/prefer/PreferencesApplied.java   |  49 +++--
 .../api/prefer/PreferencesAppliedTest.java      |  18 +-
 .../server/core/prefer/PreferencesImpl.java     |  35 ++--
 .../server/core/uri/UriResourceActionImpl.java  |  13 +-
 .../server/core/uri/UriResourceTypedImpl.java   |   8 +-
 .../uri/queryoption/expression/MemberImpl.java  |   5 +
 .../processor/TechnicalActionProcessor.java     |  12 +-
 .../processor/TechnicalBatchProcessor.java      |   2 +-
 .../processor/TechnicalEntityProcessor.java     |   8 +-
 .../TechnicalPrimitiveComplexProcessor.java     |   2 +-
 .../olingo/server/core/ODataHandlerTest.java    |  62 ++----
 .../server/core/PreconditionsValidatorTest.java | 205 ++++++++-----------
 .../core/uri/antlr/TestFullResourcePath.java    |  12 ++
 .../core/uri/antlr/TestUriParserImpl.java       |   2 +-
 .../queryoption/expression/ExpressionTest.java  |  20 +-
 22 files changed, 271 insertions(+), 278 deletions(-)
----------------------------------------------------------------------



[19/39] olingo-odata4 git commit: [OLINGO-698] technical service supports preferences, part 2

Posted by ch...@apache.org.
[OLINGO-698] technical service supports preferences, part 2

Signed-off-by: Christian Amend <ch...@sap.com>


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

Branch: refs/heads/IEE754Compatible
Commit: afda326d7538ddb970fd4237321d1c420b8ac31b
Parents: 0938f11
Author: Klaus Straubinger <kl...@sap.com>
Authored: Wed Jun 17 09:59:23 2015 +0200
Committer: Christian Amend <ch...@sap.com>
Committed: Wed Jun 17 10:05:18 2015 +0200

----------------------------------------------------------------------
 .../fit/tecsvc/client/BatchClientITCase.java    |  64 ++++-----
 .../deserializer/batch/ODataResponsePart.java   |  29 ++--
 .../core/batchhandler/BatchPartHandler.java     |  14 +-
 .../apache/olingo/server/tecsvc/Encoder.java    | 132 -------------------
 .../processor/TechnicalBatchProcessor.java      |  26 ++--
 .../options/ServerSidePagingHandler.java        |  12 +-
 6 files changed, 64 insertions(+), 213 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/afda326d/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java
index 72a4ef3..e56165d 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java
@@ -60,7 +60,6 @@ import org.junit.Before;
 import org.junit.Test;
 
 public class BatchClientITCase extends AbstractTestITCase {
-  private final static String ACCEPT = ContentType.APPLICATION_OCTET_STREAM.toContentTypeString();
   private static final String SERVICE_URI = TecSvcConst.BASE_URI;
   private static final String SERVICE_NAMESPACE = "olingo.odata.test1";
   private static final String ES_NOT_AVAILABLE_NAME = "ESNotAvailable";
@@ -70,6 +69,7 @@ public class BatchClientITCase extends AbstractTestITCase {
 
   @Before
   public void setup() {
+    client.getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
     client.getConfiguration().setContinueOnError(false);
   }
 
@@ -98,7 +98,6 @@ public class BatchClientITCase extends AbstractTestITCase {
     entity.getProperties().add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder()
         .buildString("1")));
     final ODataBatchRequest batchRequest = client.getBatchRequestFactory().getBatchRequest(SERVICE_URI);
-    batchRequest.setAccept(ACCEPT);
     final BatchManager payloadManager = batchRequest.payloadManager();
     final ODataChangeset changeset = payloadManager.addChangeset();
     final URI targetURI = client.newURIBuilder(SERVICE_URI)
@@ -130,12 +129,11 @@ public class BatchClientITCase extends AbstractTestITCase {
   public void emptyBatchRequest() {
     // create your request
     final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(SERVICE_URI);
-    request.setAccept(ACCEPT);
 
     final BatchManager payload = request.payloadManager();
     final ODataBatchResponse response = payload.getResponse();
 
-    assertEquals(202, response.getStatusCode());
+    assertEquals(HttpStatusCode.ACCEPTED.getStatusCode(), response.getStatusCode());
     assertEquals("Accepted", response.getStatusMessage());
 
     final Iterator<ODataBatchResponseItem> iter = response.getBody();
@@ -145,7 +143,6 @@ public class BatchClientITCase extends AbstractTestITCase {
   @Test
   public void getBatchRequestWithRelativeUris() throws URISyntaxException {
     final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(SERVICE_URI);
-    request.setAccept(ACCEPT);
 
     final BatchManager payload = request.payloadManager();
 
@@ -155,7 +152,7 @@ public class BatchClientITCase extends AbstractTestITCase {
     // Fetch result
     final ODataBatchResponse response = payload.getResponse();
 
-    assertEquals(202, response.getStatusCode());
+    assertEquals(HttpStatusCode.ACCEPTED.getStatusCode(), response.getStatusCode());
     assertEquals("Accepted", response.getStatusMessage());
 
     final Iterator<ODataBatchResponseItem> iter = response.getBody();
@@ -177,7 +174,6 @@ public class BatchClientITCase extends AbstractTestITCase {
   @Test
   public void getBatchRequest() throws URISyntaxException {
     final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(SERVICE_URI);
-    request.setAccept(ACCEPT);
 
     final BatchManager payload = request.payloadManager();
 
@@ -187,7 +183,7 @@ public class BatchClientITCase extends AbstractTestITCase {
     // Fetch result
     final ODataBatchResponse response = payload.getResponse();
 
-    assertEquals(202, response.getStatusCode());
+    assertEquals(HttpStatusCode.ACCEPTED.getStatusCode(), response.getStatusCode());
     assertEquals("Accepted", response.getStatusMessage());
 
     final Iterator<ODataBatchResponseItem> iter = response.getBody();
@@ -209,7 +205,6 @@ public class BatchClientITCase extends AbstractTestITCase {
   @Test
   public void testErrorWithoutContinueOnErrorPreferHeader() throws URISyntaxException {
     final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(SERVICE_URI);
-    request.setAccept(ACCEPT);
 
     final BatchManager payload = request.payloadManager();
 
@@ -219,7 +214,7 @@ public class BatchClientITCase extends AbstractTestITCase {
 
     // Fetch result
     final ODataBatchResponse response = payload.getResponse();
-    assertEquals(202, response.getStatusCode());
+    assertEquals(HttpStatusCode.ACCEPTED.getStatusCode(), response.getStatusCode());
 
     final Iterator<ODataBatchResponseItem> iter = response.getBody();
 
@@ -253,7 +248,6 @@ public class BatchClientITCase extends AbstractTestITCase {
   @Test
   public void testInvalidAbsoluteUri() throws URISyntaxException {
     final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(SERVICE_URI);
-    request.setAccept(ACCEPT);
 
     final BatchManager payload = request.payloadManager();
     final URI uri = new URI(SERVICE_URI + "/../ESAllPrim(32767)");
@@ -263,7 +257,7 @@ public class BatchClientITCase extends AbstractTestITCase {
 
     // Fetch result
     final ODataBatchResponse response = payload.getResponse();
-    assertEquals(202, response.getStatusCode());
+    assertEquals(HttpStatusCode.ACCEPTED.getStatusCode(), response.getStatusCode());
 
     final Iterator<ODataBatchResponseItem> bodyIterator = response.getBody();
     assertTrue(bodyIterator.hasNext());
@@ -272,13 +266,12 @@ public class BatchClientITCase extends AbstractTestITCase {
     assertFalse(item.isChangeset());
 
     final ODataResponse oDataResponse = item.next();
-    assertEquals(400, oDataResponse.getStatusCode());
+    assertEquals(HttpStatusCode.BAD_REQUEST.getStatusCode(), oDataResponse.getStatusCode());
   }
 
   @Test(expected = HttpClientException.class)
   public void testInvalidHost() throws URISyntaxException {
     final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(SERVICE_URI);
-    request.setAccept(ACCEPT);
 
     final BatchManager payload = request.payloadManager();
     final URI uri = new URI("http://otherhost/odata/ESAllPrim(32767)");
@@ -293,7 +286,6 @@ public class BatchClientITCase extends AbstractTestITCase {
   @Test(expected = HttpClientException.class)
   public void testInvalidAbsoluteRequest() throws URISyntaxException {
     final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(SERVICE_URI);
-    request.setAccept(ACCEPT);
 
     final BatchManager payload = request.payloadManager();
     final URI uri = new URI("/ESAllPrim(32767)");
@@ -306,10 +298,9 @@ public class BatchClientITCase extends AbstractTestITCase {
   }
 
   @Test
-  public void testErrorWithContinueOnErrorPreferHeader() throws URISyntaxException {
+  public void errorWithContinueOnErrorPreferHeader() throws Exception {
     client.getConfiguration().setContinueOnError(true);
     final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(SERVICE_URI);
-    request.setAccept(ACCEPT);
 
     final BatchManager payload = request.payloadManager();
 
@@ -319,7 +310,8 @@ public class BatchClientITCase extends AbstractTestITCase {
 
     // Fetch result
     final ODataBatchResponse response = payload.getResponse();
-    assertEquals(202, response.getStatusCode());
+    assertEquals(HttpStatusCode.ACCEPTED.getStatusCode(), response.getStatusCode());
+    assertEquals("odata.continue-on-error", response.getHeader(HttpHeader.PREFERENCE_APPLIED).iterator().next());
 
     final Iterator<ODataBatchResponseItem> bodyIterator = response.getBody();
 
@@ -331,10 +323,10 @@ public class BatchClientITCase extends AbstractTestITCase {
     ODataResponse oDataResonse = item.next();
     assertNotNull(oDataResonse);
     assertEquals(HttpStatusCode.OK.getStatusCode(), oDataResonse.getStatusCode());
-    assertEquals(1, oDataResonse.getHeader("OData-Version").size());
-    assertEquals("4.0", oDataResonse.getHeader("OData-Version").toArray()[0]);
-    assertEquals(1, oDataResonse.getHeader("Content-Length").size());
-    assertEquals("605", oDataResonse.getHeader("Content-Length").toArray()[0]);
+    assertEquals(1, oDataResonse.getHeader(HttpHeader.ODATA_VERSION).size());
+    assertEquals("4.0", oDataResonse.getHeader(HttpHeader.ODATA_VERSION).toArray()[0]);
+    assertEquals(1, oDataResonse.getHeader(HttpHeader.CONTENT_LENGTH).size());
+    assertEquals("605", oDataResonse.getHeader(HttpHeader.CONTENT_LENGTH).toArray()[0]);
     assertEquals("application/json;odata.metadata=minimal", oDataResonse.getContentType());
 
     // Check second get request
@@ -354,20 +346,18 @@ public class BatchClientITCase extends AbstractTestITCase {
     oDataResonse = item.next();
     assertNotNull(oDataResonse);
     assertEquals(HttpStatusCode.OK.getStatusCode(), oDataResonse.getStatusCode());
-    assertEquals(1, oDataResonse.getHeader("OData-Version").size());
-    assertEquals("4.0", oDataResonse.getHeader("OData-Version").toArray()[0]);
-    assertEquals(1, oDataResonse.getHeader("Content-Length").size());
-    assertEquals("513", oDataResonse.getHeader("Content-Length").toArray()[0]);
+    assertEquals(1, oDataResonse.getHeader(HttpHeader.ODATA_VERSION).size());
+    assertEquals("4.0", oDataResonse.getHeader(HttpHeader.ODATA_VERSION).toArray()[0]);
+    assertEquals(1, oDataResonse.getHeader(HttpHeader.CONTENT_LENGTH).size());
+    assertEquals("513", oDataResonse.getHeader(HttpHeader.CONTENT_LENGTH).toArray()[0]);
     assertEquals("application/json;odata.metadata=minimal", oDataResonse.getContentType());
   }
 
   @Test
-  @SuppressWarnings("unchecked")
   public void changesetWithReferences() throws EdmPrimitiveTypeException, URISyntaxException {
     // create your request
     final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(SERVICE_URI);
     final ClientObjectFactory of = client.getObjectFactory();
-    request.setAccept(ACCEPT);
     final BatchManager streamManager = request.payloadManager();
 
     final ODataChangeset changeset = streamManager.addChangeset();
@@ -421,7 +411,7 @@ public class BatchClientITCase extends AbstractTestITCase {
     ODataResponse res = chgitem.next();
     assertEquals(HttpStatusCode.CREATED.getStatusCode(), res.getStatusCode());
     assertTrue(res instanceof ODataEntityCreateResponse);
-    final ODataEntityCreateResponse<ClientEntity> createResponse = ((ODataEntityCreateResponse<ClientEntity>) res);
+    final ODataEntityCreateResponse<?> createResponse = ((ODataEntityCreateResponse<?>) res);
 
     res = chgitem.next();
     assertEquals(HttpStatusCode.OK.getStatusCode(), res.getStatusCode());
@@ -442,11 +432,9 @@ public class BatchClientITCase extends AbstractTestITCase {
   }
 
   @Test
-  @SuppressWarnings("unchecked")
   public void changesetBatchRequest() throws URISyntaxException {
     final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(SERVICE_URI);
     final ClientObjectFactory of = client.getObjectFactory();
-    request.setAccept(ACCEPT);
 
     final BatchManager payload = request.payloadManager();
     // -----------------------------
@@ -530,7 +518,7 @@ public class BatchClientITCase extends AbstractTestITCase {
     // - Fetch result
     // -----------------------------
     final ODataBatchResponse response = payload.getResponse();
-    assertEquals(202, response.getStatusCode());
+    assertEquals(HttpStatusCode.ACCEPTED.getStatusCode(), response.getStatusCode());
     final Iterator<ODataBatchResponseItem> bodyIterator = response.getBody();
 
     // Check first get request
@@ -540,7 +528,9 @@ public class BatchClientITCase extends AbstractTestITCase {
     assertTrue(item.hasNext());
     final ODataResponse response0 = item.next();
     assertTrue(response0 instanceof ODataRetrieveResponse);
-    assertEquals(34, ((ODataRetrieveResponse<ClientEntity>) response0).getBody()
+    @SuppressWarnings("unchecked")
+    ODataRetrieveResponse<ClientEntity> retrieveResponse = (ODataRetrieveResponse<ClientEntity>) response0;
+    assertEquals(34, retrieveResponse.getBody()
         .getProperty("PropertyDecimal")
         .getPrimitiveValue()
         .toValue());
@@ -555,7 +545,7 @@ public class BatchClientITCase extends AbstractTestITCase {
     final ODataResponse response1 = item.next();
     assertEquals(HttpStatusCode.CREATED.getStatusCode(), response1.getStatusCode());
     assertTrue(response1 instanceof ODataEntityCreateResponse);
-    assertEquals(3.1415, ((ODataEntityCreateResponse<ClientEntity>) response1).getBody().getProperty("PropertyDouble")
+    assertEquals(3.1415, ((ODataEntityCreateResponse<?>) response1).getBody().getProperty("PropertyDouble")
         .getPrimitiveValue()
         .toValue());
     // Update
@@ -569,7 +559,7 @@ public class BatchClientITCase extends AbstractTestITCase {
     final ODataResponse response3 = item.next();
     assertEquals(HttpStatusCode.CREATED.getStatusCode(), response3.getStatusCode());
     assertTrue(response3 instanceof ODataEntityUpdateResponse);
-    assertEquals(3.1415, ((ODataEntityUpdateResponse<ClientEntity>) response3).getBody().getProperty("PropertyDouble")
+    assertEquals(3.1415, ((ODataEntityUpdateResponse<?>) response3).getBody().getProperty("PropertyDouble")
         .getPrimitiveValue()
         .toValue());
 
@@ -580,7 +570,9 @@ public class BatchClientITCase extends AbstractTestITCase {
     assertTrue(item.hasNext());
     final ODataResponse response4 = item.next();
     assertTrue(response4 instanceof ODataRetrieveResponse);
-    assertEquals(3.1415, ((ODataRetrieveResponse<ClientEntity>) response4).getBody()
+    @SuppressWarnings("unchecked")
+    final ODataRetrieveResponse<ClientEntity> retrieveResponse2 = (ODataRetrieveResponse<ClientEntity>) response4;
+    assertEquals(3.1415, retrieveResponse2.getBody()
         .getProperty("PropertyDouble")
         .getPrimitiveValue()
         .toValue());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/afda326d/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/batch/ODataResponsePart.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/batch/ODataResponsePart.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/batch/ODataResponsePart.java
index 56c0084..8b0bd52 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/batch/ODataResponsePart.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/batch/ODataResponsePart.java
@@ -24,23 +24,23 @@ import java.util.List;
 import org.apache.olingo.server.api.ODataResponse;
 
 /**
- * An ODataResponsePart represents a collections of ODataResponses.
+ * An ODataResponsePart represents a collection of ODataResponses.
  * A list of ODataResponseParts can be combined by the BatchSerializer to a single
  * OData batch response.
  */
 public class ODataResponsePart {
-  private List<ODataResponse> responses;
-  private boolean isChangeSet;
+  private final List<ODataResponse> responses;
+  private final boolean isChangeSet;
 
   /**
    * Creates a new ODataResponsePart.
    *
-   * An ODataResponsePart represents a collections of ODataResponses.
+   * An ODataResponsePart represents a collection of ODataResponses.
    * A list of ODataResponseParts can be combined by the BatchSerializer to a single
    * OData batch response.
    * 
    * @param responses A list of {@link ODataResponse}
-   * @param isChangeSet True this ODataResponsePart represents a change set, otherwise false
+   * @param isChangeSet whether this ODataResponsePart represents a change set
    */
   public ODataResponsePart(final List<ODataResponse> responses, final boolean isChangeSet) {
     this.responses = responses;
@@ -50,12 +50,12 @@ public class ODataResponsePart {
   /**
    * Creates a new ODataResponsePart.
    *
-   * An ODataResponsePart represents a collections of ODataResponses.
+   * An ODataResponsePart represents a collection of ODataResponses.
    * A list of ODataResponseParts can be combined by the BatchSerializer to a single
    * OData batch response.
    * 
    * @param response A single {@link ODataResponse}
-   * @param isChangeSet True this ODataResponsePart represents a change set, otherwise false
+   * @param isChangeSet whether this ODataResponsePart represents a change set
    */
   public ODataResponsePart(final ODataResponse response, final boolean isChangeSet) {
     responses = Arrays.asList(response);
@@ -63,21 +63,18 @@ public class ODataResponsePart {
   }
 
   /**
-   * Returns true if the current instance represents a change set.
-   *
-   * @return true or false
+   * Returns a collection of ODataResponses.
+   * Each collection contains at least one {@link ODataResponse}.
+   * If this instance represents a change set, there may be many ODataResponses.
+   * @return a list of {@link ODataResponse}
    */
   public List<ODataResponse> getResponses() {
     return responses;
   }
 
   /**
-   * Returns a collection of ODataResponses.
-   * Each collections contains at least one {@link ODataResponse}.
-   *
-   * If this instance represents a change set, there are may many ODataResponses
-   * 
-   * @return a list of {@link ODataResponse}
+   * Returns true if the current instance represents a change set.
+   * @return true or false
    */
   public boolean isChangeSet() {
     return isChangeSet;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/afda326d/lib/server-core/src/main/java/org/apache/olingo/server/core/batchhandler/BatchPartHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/batchhandler/BatchPartHandler.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/batchhandler/BatchPartHandler.java
index c3cf73a..de1dcb1 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/batchhandler/BatchPartHandler.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/batchhandler/BatchPartHandler.java
@@ -34,14 +34,14 @@ import org.apache.olingo.server.core.deserializer.batch.BatchParserCommon;
 public class BatchPartHandler {
   private final ODataHandler oDataHandler;
   private final BatchProcessor batchProcessor;
-  private final BatchFacade batchFascade;
+  private final BatchFacade batchFacade;
   private final BatchReferenceRewriter rewriter;
 
   public BatchPartHandler(final ODataHandler oDataHandler, final BatchProcessor processor,
-      final BatchFacade batchFascade) {
+      final BatchFacade batchFacade) {
     this.oDataHandler = oDataHandler;
     batchProcessor = processor;
-    this.batchFascade = batchFascade;
+    this.batchFacade = batchFacade;
     rewriter = new BatchReferenceRewriter();
   }
 
@@ -49,8 +49,8 @@ public class BatchPartHandler {
     return handle(request, true);
   }
 
-  public ODataResponsePart handleBatchRequest(final BatchRequestPart request) throws ODataApplicationException,
-      ODataLibraryException {
+  public ODataResponsePart handleBatchRequest(final BatchRequestPart request)
+      throws ODataApplicationException, ODataLibraryException {
     if (request.isChangeSet()) {
       return handleChangeSet(request);
     } else {
@@ -62,7 +62,7 @@ public class BatchPartHandler {
 
   public ODataResponse handle(final ODataRequest request, final boolean isChangeSet)
       throws BatchDeserializerException {
-    final ODataResponse response;
+    ODataResponse response;
 
     if (isChangeSet) {
       rewriter.replaceReference(request);
@@ -85,7 +85,7 @@ public class BatchPartHandler {
 
   private ODataResponsePart handleChangeSet(final BatchRequestPart request) throws ODataApplicationException,
       ODataLibraryException {
-    return batchProcessor.processChangeSet(batchFascade, request.getRequests());
+    return batchProcessor.processChangeSet(batchFacade, request.getRequests());
   }
 
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/afda326d/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/Encoder.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/Encoder.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/Encoder.java
deleted file mode 100644
index 33956b5..0000000
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/Encoder.java
+++ /dev/null
@@ -1,132 +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.server.tecsvc;
-
-import java.io.UnsupportedEncodingException;
-
-/**
- * Encodes a Java String (in its internal UTF-16 encoding) into its
- * percent-encoded UTF-8 representation according to
- * <a href="http://www.ietf.org/rfc/rfc3986.txt">RFC 3986</a>
- * (with consideration of its predecessor RFC 2396).
- *
- */
-public class Encoder {
-
-  // TODO: Should we really copy this class?
-
-  /**
-   * Encodes a Java String (in its internal UTF-16 encoding) into its
-   * percent-encoded UTF-8 representation according to
-   * <a href="http://www.ietf.org/rfc/rfc3986.txt">RFC 3986</a>,
-   * suitable for parts of an OData path segment.
-   * @param value the Java String
-   * @return the encoded String
-   */
-  public static String encode(final String value) {
-    return encoder.encodeInternal(value);
-  }
-
-  // OData has special handling for "'", so we allow that to remain unencoded.
-  // Other sub-delims not used neither by JAX-RS nor by OData could be added
-  // if the encoding is considered to be too aggressive.
-  // RFC 3986 would also allow the gen-delims ":" and "@" to appear literally
-  // in path-segment parts.
-  private static final String ODATA_UNENCODED = "'";
-
-  // Character classes from RFC 3986
-  private final static String UNRESERVED = "-._~"; // + ALPHA + DIGIT
-  // RFC 3986 says: "For consistency, URI producers and normalizers should
-  // use uppercase hexadecimal digits for all percent-encodings."
-  private final static String[] hex = { "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07", "%08", "%09", "%0A",
-      "%0B", "%0C", "%0D", "%0E", "%0F", "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17", "%18", "%19", "%1A",
-      "%1B", "%1C", "%1D", "%1E", "%1F", "%20", "%21", "%22", "%23", "%24", "%25", "%26", "%27", "%28", "%29", "%2A",
-      "%2B", "%2C", "%2D", "%2E", "%2F", "%30", "%31", "%32", "%33", "%34", "%35", "%36", "%37", "%38", "%39", "%3A",
-      "%3B", "%3C", "%3D", "%3E", "%3F", "%40", "%41", "%42", "%43", "%44", "%45", "%46", "%47", "%48", "%49", "%4A",
-      "%4B", "%4C", "%4D", "%4E", "%4F", "%50", "%51", "%52", "%53", "%54", "%55", "%56", "%57", "%58", "%59", "%5A",
-      "%5B", "%5C", "%5D", "%5E", "%5F", "%60", "%61", "%62", "%63", "%64", "%65", "%66", "%67", "%68", "%69", "%6A",
-      "%6B", "%6C", "%6D", "%6E", "%6F", "%70", "%71", "%72", "%73", "%74", "%75", "%76", "%77", "%78", "%79", "%7A",
-      "%7B", "%7C", "%7D", "%7E", "%7F", "%80", "%81", "%82", "%83", "%84", "%85", "%86", "%87", "%88",
-      "%89", "%8A", "%8B", "%8C", "%8D", "%8E", "%8F", "%90", "%91", "%92", "%93", "%94", "%95", "%96", "%97", "%98",
-      "%99", "%9A", "%9B", "%9C", "%9D", "%9E", "%9F", "%A0", "%A1", "%A2", "%A3", "%A4", "%A5", "%A6", "%A7", "%A8",
-      "%A9", "%AA", "%AB", "%AC", "%AD", "%AE", "%AF", "%B0", "%B1", "%B2", "%B3", "%B4", "%B5", "%B6", "%B7", "%B8",
-      "%B9", "%BA", "%BB", "%BC", "%BD", "%BE", "%BF", "%C0", "%C1", "%C2", "%C3", "%C4", "%C5", "%C6", "%C7", "%C8",
-      "%C9", "%CA", "%CB", "%CC", "%CD", "%CE", "%CF", "%D0", "%D1", "%D2", "%D3", "%D4", "%D5", "%D6", "%D7", "%D8",
-      "%D9", "%DA", "%DB", "%DC", "%DD", "%DE", "%DF", "%E0", "%E1", "%E2", "%E3", "%E4", "%E5", "%E6", "%E7", "%E8",
-      "%E9", "%EA", "%EB", "%EC", "%ED", "%EE", "%EF", "%F0", "%F1", "%F2", "%F3", "%F4", "%F5", "%F6", "%F7", "%F8",
-      "%F9", "%FA", "%FB", "%FC", "%FD", "%FE", "%FF" };
-
-  private static final Encoder encoder = new Encoder(ODATA_UNENCODED);
-
-  /** characters to remain unencoded in addition to {@link #UNRESERVED} */
-  private final String unencoded;
-
-  private Encoder(final String unencoded) {
-    this.unencoded = unencoded == null ? "" : unencoded;
-  }
-
-  /**
-   * <p>Returns the percent-encoded UTF-8 representation of a String.</p>
-   * <p>In order to avoid producing percent-encoded CESU-8 (as described in
-   * the Unicode Consortium's <a href="http://www.unicode.org/reports/tr26/">
-   * Technical Report #26</a>), this is done in two steps:
-   * <ol>
-   * <li>Re-encode the characters from their Java-internal UTF-16 representations
-   * into their UTF-8 representations.</li>
-   * <li>Percent-encode each of the bytes in the UTF-8 representation.
-   * This is possible on byte level because all characters that do not have
-   * a <code>%xx</code> representation are represented in one byte in UTF-8.</li>
-   * </ol></p>
-   * @param input input String
-   * @return encoded representation
-   */
-  private String encodeInternal(final String input) {
-    StringBuilder resultStr = new StringBuilder();
-
-    try {
-      for (byte utf8Byte : input.getBytes("UTF-8")) {
-        final char character = (char) utf8Byte;
-        if (isUnreserved(character)) {
-          resultStr.append(character);
-        } else if (isUnencoded(character)) {
-          resultStr.append(character);
-        } else if (utf8Byte >= 0) {
-          resultStr.append(hex[utf8Byte]);
-        } else {
-          // case UTF-8 continuation byte
-          resultStr.append(hex[256 + utf8Byte]); // index adjusted for the usage of signed bytes
-        }
-      }
-    } catch (final UnsupportedEncodingException e) { // should never happen; UTF-8 is always there
-      return null;
-    }
-    return resultStr.toString();
-  }
-
-  private static boolean isUnreserved(final char character) {
-    return 'A' <= character && character <= 'Z' // case A..Z
-        || 'a' <= character && character <= 'z' // case a..z
-        || '0' <= character && character <= '9' // case 0..9
-        || UNRESERVED.indexOf(character) >= 0;
-  }
-
-  private boolean isUnencoded(final char character) {
-    return unencoded.indexOf(character) >= 0;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/afda326d/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalBatchProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalBatchProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalBatchProcessor.java
index b96ab82..fbdeb90 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalBatchProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalBatchProcessor.java
@@ -34,11 +34,11 @@ import org.apache.olingo.server.api.batch.BatchFacade;
 import org.apache.olingo.server.api.deserializer.batch.BatchOptions;
 import org.apache.olingo.server.api.deserializer.batch.BatchRequestPart;
 import org.apache.olingo.server.api.deserializer.batch.ODataResponsePart;
+import org.apache.olingo.server.api.prefer.PreferencesApplied;
 import org.apache.olingo.server.api.processor.BatchProcessor;
 import org.apache.olingo.server.tecsvc.data.DataProvider;
 
 public class TechnicalBatchProcessor extends TechnicalProcessor implements BatchProcessor {
-  private static final String PREFERENCE_CONTINUE_ON_ERROR = "odata.continue-on-error";
 
   public TechnicalBatchProcessor(final DataProvider dataProvider) {
     super(dataProvider);
@@ -47,7 +47,8 @@ public class TechnicalBatchProcessor extends TechnicalProcessor implements Batch
   @Override
   public void processBatch(final BatchFacade facade, final ODataRequest request, final ODataResponse response)
       throws ODataApplicationException, ODataLibraryException {
-    boolean continueOnError = isContinueOnError(request);
+    final boolean continueOnError =
+        odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).hasContinueOnError();
 
     final String boundary = facade.extractBoundaryFromContentType(request.getHeader(HttpHeader.CONTENT_TYPE));
     final BatchOptions options = BatchOptions.with()
@@ -59,15 +60,15 @@ public class TechnicalBatchProcessor extends TechnicalProcessor implements Batch
 
     for (BatchRequestPart part : parts) {
       final ODataResponsePart responsePart = facade.handleBatchRequest(part);
-      responseParts.add(responsePart); // Also add failed responses
+      responseParts.add(responsePart); // Also add failed responses.
       final int statusCode = responsePart.getResponses().get(0).getStatusCode();
 
       if ((statusCode >= 400 && statusCode <= 600) && !continueOnError) {
 
-        // Perform some additions actions
+        // Perform some additional actions.
         // ...
 
-        break; // Stop processing, but serialize all recent requests
+        break; // Stop processing, but serialize responses to all recent requests.
       }
     }
 
@@ -77,19 +78,10 @@ public class TechnicalBatchProcessor extends TechnicalProcessor implements Batch
     response.setHeader(HttpHeader.CONTENT_TYPE, ContentType.MULTIPART_MIXED + ";boundary=" + responseBoundary);
     response.setContent(responseContent);
     response.setStatusCode(HttpStatusCode.ACCEPTED.getStatusCode());
-  }
-
-  private boolean isContinueOnError(final ODataRequest request) {
-    final List<String> preferValues = request.getHeaders(HttpHeader.PREFER);
-
-    if (preferValues != null) {
-      for (final String preference : preferValues) {
-        if (PREFERENCE_CONTINUE_ON_ERROR.equals(preference)) {
-          return true;
-        }
-      }
+    if (continueOnError) {
+      response.setHeader(HttpHeader.PREFERENCE_APPLIED,
+          PreferencesApplied.with().continueOnError().build().toString());
     }
-    return false;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/afda326d/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/ServerSidePagingHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/ServerSidePagingHandler.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/ServerSidePagingHandler.java
index 71496fd..ad8b7dd 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/ServerSidePagingHandler.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/ServerSidePagingHandler.java
@@ -28,7 +28,6 @@ import org.apache.olingo.commons.api.http.HttpStatusCode;
 import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.api.uri.queryoption.SkipTokenOption;
 import org.apache.olingo.server.api.uri.queryoption.SystemQueryOptionKind;
-import org.apache.olingo.server.tecsvc.Encoder;
 
 public class ServerSidePagingHandler {
   private static final int MAX_PAGE_SIZE = 10;
@@ -45,7 +44,7 @@ public class ServerSidePagingHandler {
    * @param rawRequestUri     the request URI (used to construct the next link)
    * @param preferredPageSize the client's preference for page size
    * @return the chosen page size (or <code>null</code> if no paging has been done);
-   *        could be used in the Preference-Applied HTTP header
+   *         could be used in the Preference-Applied HTTP header
    * @throws ODataApplicationException
    */
   public static Integer applyServerSidePaging(final SkipTokenOption skipTokenOption, EntityCollection entityCollection,
@@ -74,7 +73,7 @@ public class ServerSidePagingHandler {
     return null;
   }
 
-  private static URI createNextLink(final String rawRequestUri, final Integer page, final int pageSize)
+  private static URI createNextLink(final String rawRequestUri, final int page, final int pageSize)
       throws ODataApplicationException {
     // Remove a maybe existing skiptoken, making sure that the query part is not empty.
     String nextlink = rawRequestUri.contains("?") ?
@@ -85,9 +84,12 @@ public class ServerSidePagingHandler {
     nextlink += nextlink.contains("?") ? '&' : '?';
 
     // Append the new skiptoken.
+    nextlink += SystemQueryOptionKind.SKIPTOKEN.toString().replace("$", "%24")  // poor man's percent encoding
+        + '='
+        + page + "%2A" + pageSize;  // "%2A" is a percent-encoded asterisk
+
     try {
-      return new URI(nextlink + Encoder.encode(SystemQueryOptionKind.SKIPTOKEN.toString()) + '='
-          + Encoder.encode(page.toString() + '*' + pageSize));
+      return new URI(nextlink);
     } catch (final URISyntaxException e) {
       throw new ODataApplicationException("Exception while constructing next link",
           HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), Locale.ROOT, e);


[08/39] olingo-odata4 git commit: [OLINGO-693] Removed Serializable interface from csdNamed

Posted by ch...@apache.org.
[OLINGO-693] Removed Serializable interface from csdNamed


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

Branch: refs/heads/IEE754Compatible
Commit: a6d20f627b006bfe8007780ab407212a9775af52
Parents: 3b506ea
Author: Christian Amend <ch...@sap.com>
Authored: Mon Jun 15 10:23:10 2015 +0200
Committer: Christian Amend <ch...@sap.com>
Committed: Mon Jun 15 10:23:10 2015 +0200

----------------------------------------------------------------------
 .../org/apache/olingo/commons/api/edm/provider/CsdlNamed.java     | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a6d20f62/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/CsdlNamed.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/CsdlNamed.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/CsdlNamed.java
index 4529014..f82edc2 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/CsdlNamed.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/CsdlNamed.java
@@ -18,9 +18,8 @@
  */
 package org.apache.olingo.commons.api.edm.provider;
 
-import java.io.Serializable;
 
-public interface CsdlNamed extends Serializable {
+public interface CsdlNamed {
 
   String getName();
 }


[24/39] olingo-odata4 git commit: [OLINGO-694] Added read property and write tutorial (part 2 and 3)

Posted by ch...@apache.org.
[OLINGO-694] Added read property and write tutorial (part 2 and 3)


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

Branch: refs/heads/IEE754Compatible
Commit: f24c3874e0686c6fd2d110f42778f8bff8535900
Parents: bff2ecf
Author: Michael Bolz <mi...@sap.com>
Authored: Thu Jun 18 12:15:03 2015 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Thu Jun 18 12:16:07 2015 +0200

----------------------------------------------------------------------
 samples/tutorials/p1_read/pom.xml               |   6 +-
 samples/tutorials/p2_readep/pom.xml             |  75 +++++
 .../myservice/mynamespace/data/Storage.java     | 107 ++++++++
 .../mynamespace/service/DemoEdmProvider.java    | 135 +++++++++
 .../service/DemoEntityCollectionProcessor.java  |  72 +++++
 .../service/DemoEntityProcessor.java            | 108 ++++++++
 .../service/DemoPrimitiveProcessor.java         | 129 +++++++++
 .../java/myservice/mynamespace/util/Util.java   | 120 ++++++++
 .../myservice/mynamespace/web/DemoServlet.java  |  76 ++++++
 .../p2_readep/src/main/webapp/WEB-INF/web.xml   |  40 +++
 .../p2_readep/src/main/webapp/index.jsp         |  26 ++
 samples/tutorials/p3_write/pom.xml              |  75 +++++
 .../myservice/mynamespace/data/Storage.java     | 272 +++++++++++++++++++
 .../mynamespace/service/DemoEdmProvider.java    | 155 +++++++++++
 .../service/DemoEntityCollectionProcessor.java  |  93 +++++++
 .../service/DemoEntityProcessor.java            | 189 +++++++++++++
 .../service/DemoPrimitiveProcessor.java         | 143 ++++++++++
 .../java/myservice/mynamespace/util/Util.java   | 122 +++++++++
 .../myservice/mynamespace/web/DemoServlet.java  |  73 +++++
 .../p3_write/src/main/webapp/WEB-INF/web.xml    |  40 +++
 .../p3_write/src/main/webapp/index.jsp          |  26 ++
 samples/tutorials/pom.xml                       |   2 +
 22 files changed, 2081 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f24c3874/samples/tutorials/p1_read/pom.xml
----------------------------------------------------------------------
diff --git a/samples/tutorials/p1_read/pom.xml b/samples/tutorials/p1_read/pom.xml
index c815f8d..bcae4ef 100755
--- a/samples/tutorials/p1_read/pom.xml
+++ b/samples/tutorials/p1_read/pom.xml
@@ -22,12 +22,12 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 	<modelVersion>4.0.0</modelVersion>
-	<groupId>myservice.mynamespace</groupId>
-	<artifactId>DemoService</artifactId>
+  <groupId>my.group.id</groupId>
+	<artifactId>DemoService-Read</artifactId>
 	<packaging>war</packaging>
 	<version>0.0.1</version>
 
-	<name>DemoService Maven Webapp</name>
+	<name>${project.artifactId}-Webapp</name>
 
 	<properties>
 		<javax.version>2.5</javax.version>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f24c3874/samples/tutorials/p2_readep/pom.xml
----------------------------------------------------------------------
diff --git a/samples/tutorials/p2_readep/pom.xml b/samples/tutorials/p2_readep/pom.xml
new file mode 100755
index 0000000..abe0601
--- /dev/null
+++ b/samples/tutorials/p2_readep/pom.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>my.group.id</groupId>
+	<artifactId>DemoService-ReadEp</artifactId>
+	<packaging>war</packaging>
+	<version>0.0.1</version>
+
+	<name>${project.artifactId}-Webapp</name>
+
+	<properties>
+		<javax.version>2.5</javax.version>
+		<odata.version>4.0.0-beta-03</odata.version>
+		<slf4j.version>1.7.7</slf4j.version>
+	</properties>
+
+	<dependencies>
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>servlet-api</artifactId>
+			<version>${javax.version}</version>
+			<scope>provided</scope>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.olingo</groupId>
+			<artifactId>odata-server-api</artifactId>
+			<version>${odata.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.olingo</groupId>
+			<artifactId>odata-server-core</artifactId>
+			<version>${odata.version}</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.olingo</groupId>
+			<artifactId>odata-commons-api</artifactId>
+			<version>${odata.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.olingo</groupId>
+			<artifactId>odata-commons-core</artifactId>
+			<version>${odata.version}</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-simple</artifactId>
+			<version>${slf4j.version}</version>
+			<scope>runtime</scope>
+		</dependency>
+	</dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f24c3874/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/data/Storage.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/data/Storage.java b/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/data/Storage.java
new file mode 100755
index 0000000..be985f5
--- /dev/null
+++ b/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/data/Storage.java
@@ -0,0 +1,107 @@
+package myservice.mynamespace.data;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+import myservice.mynamespace.service.DemoEdmProvider;
+import myservice.mynamespace.util.Util;
+
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntityCollection;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ValueType;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
+import org.apache.olingo.commons.api.http.HttpStatusCode;
+import org.apache.olingo.server.api.ODataApplicationException;
+import org.apache.olingo.server.api.uri.UriParameter;
+
+public class Storage {
+
+	private List<Entity> productList;
+
+	public Storage() {
+		productList = new ArrayList<Entity>();
+		initSampleData();
+	}
+
+	/* PUBLIC FACADE */
+
+	public EntityCollection readEntitySetData(EdmEntitySet edmEntitySet)throws ODataApplicationException{
+
+		// actually, this is only required if we have more than one Entity Sets
+		if(edmEntitySet.getName().equals(DemoEdmProvider.ES_PRODUCTS_NAME)){
+			return getProducts();
+		}
+
+		return null;
+	}
+
+	public Entity readEntityData(EdmEntitySet edmEntitySet, List<UriParameter> keyParams) throws ODataApplicationException{
+
+		EdmEntityType edmEntityType = edmEntitySet.getEntityType();
+
+		// actually, this is only required if we have more than one Entity Type
+		if(edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)){
+			return getProduct(edmEntityType, keyParams);
+		}
+
+		return null;
+	}
+
+
+
+	/*  INTERNAL */
+
+	private EntityCollection getProducts(){
+		EntityCollection retEntitySet = new EntityCollection();
+
+		for(Entity productEntity : this.productList){
+			   retEntitySet.getEntities().add(productEntity);
+		}
+
+		return retEntitySet;
+	}
+
+
+	private Entity getProduct(EdmEntityType edmEntityType, List<UriParameter> keyParams) throws ODataApplicationException{
+
+		// the list of entities at runtime
+		EntityCollection entitySet = getProducts();
+		
+		/*  generic approach  to find the requested entity */
+		Entity requestedEntity = Util.findEntity(edmEntityType, entitySet, keyParams);
+		
+		if(requestedEntity == null){
+			// this variable is null if our data doesn't contain an entity for the requested key
+			// Throw suitable exception
+			throw new ODataApplicationException("Entity for requested key doesn't exist",
+          HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
+		}
+
+		return requestedEntity;
+	}
+
+	/* HELPER */
+
+	private void initSampleData(){
+
+		// add some sample product entities
+		productList.add(new Entity()
+			.addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 1))
+			.addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "Notebook Basic 15"))
+			.addProperty(new Property(null, "Description", ValueType.PRIMITIVE, "Notebook Basic, 1.7GHz - 15 XGA - 1024MB DDR2 SDRAM - 40GB")));
+
+		productList.add(new Entity()
+			.addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 2))
+			.addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "1UMTS PDA"))
+			.addProperty(new Property(null, "Description", ValueType.PRIMITIVE, "Ultrafast 3G UMTS/HSDPA Pocket PC, supports GSM network")));
+
+		productList.add(new Entity()
+			.addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 3))
+			.addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "Ergo Screen"))
+			.addProperty(new Property(null, "Description", ValueType.PRIMITIVE, "19 Optimum Resolution 1024 x 768 @ 85Hz, resolution 1280 x 960")));
+
+	}
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f24c3874/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoEdmProvider.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoEdmProvider.java b/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoEdmProvider.java
new file mode 100755
index 0000000..0b091ff
--- /dev/null
+++ b/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoEdmProvider.java
@@ -0,0 +1,135 @@
+package myservice.mynamespace.service;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.olingo.commons.api.ODataException;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.provider.CsdlAbstractEdmProvider;
+import org.apache.olingo.commons.api.edm.provider.CsdlEntityContainer;
+import org.apache.olingo.commons.api.edm.provider.CsdlEntityContainerInfo;
+import org.apache.olingo.commons.api.edm.provider.CsdlEntitySet;
+import org.apache.olingo.commons.api.edm.provider.CsdlEntityType;
+import org.apache.olingo.commons.api.edm.provider.CsdlProperty;
+import org.apache.olingo.commons.api.edm.provider.CsdlPropertyRef;
+import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
+
+public class DemoEdmProvider extends CsdlAbstractEdmProvider {
+
+  // Service Namespace
+  public static final String NAMESPACE = "OData.Demo";
+
+  // EDM Container
+  public static final String CONTAINER_NAME = "Container";
+  public static final FullQualifiedName CONTAINER = new FullQualifiedName(NAMESPACE, CONTAINER_NAME);
+
+  // Entity Types Names
+  public static final String ET_PRODUCT_NAME = "Product";
+  public static final FullQualifiedName ET_PRODUCT_FQN = new FullQualifiedName(NAMESPACE, ET_PRODUCT_NAME);
+
+  // Entity Set Names
+  public static final String ES_PRODUCTS_NAME = "Products";
+
+
+  @Override
+  public CsdlEntityType getEntityType(FullQualifiedName entityTypeName)
+      throws ODataException {
+    // this method is called for one of the EntityTypes that are configured in the Schema
+    if(ET_PRODUCT_FQN.equals(entityTypeName)){
+
+      //create EntityType properties
+      CsdlProperty id = new CsdlProperty().setName("ID").setType(EdmPrimitiveTypeKind.Int32.getFullQualifiedName());
+      CsdlProperty name = new CsdlProperty().setName("Name").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
+      CsdlProperty  description = new CsdlProperty().setName("Description").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
+
+      // create PropertyRef for Key element
+      CsdlPropertyRef propertyRef = new CsdlPropertyRef();
+      propertyRef.setName("ID");
+
+      // configure EntityType
+      CsdlEntityType entityType = new CsdlEntityType();
+      entityType.setName(ET_PRODUCT_NAME);
+      entityType.setProperties(Arrays.asList(id, name, description));
+      entityType.setKey(Collections.singletonList(propertyRef));
+
+      return entityType;
+    }
+
+    return null;
+
+  }
+
+  @Override
+  public CsdlEntitySet getEntitySet(FullQualifiedName entityContainer,
+      String entitySetName) throws ODataException {
+    if(entityContainer.equals(CONTAINER)){
+      if(entitySetName.equals(ES_PRODUCTS_NAME)){
+        CsdlEntitySet entitySet = new CsdlEntitySet();
+        entitySet.setName(ES_PRODUCTS_NAME);
+        entitySet.setType(ET_PRODUCT_FQN);
+
+        return entitySet;
+      }
+    }
+
+    return null;
+
+  }
+
+  @Override
+  public CsdlEntityContainerInfo getEntityContainerInfo(
+      FullQualifiedName entityContainerName) throws ODataException {
+    // This method is invoked when displaying the service document at e.g. http://localhost:8080/DemoService/DemoService.svc
+    if(entityContainerName == null || entityContainerName.equals(CONTAINER)){
+      CsdlEntityContainerInfo entityContainerInfo = new CsdlEntityContainerInfo();
+      entityContainerInfo.setContainerName(CONTAINER);
+      return entityContainerInfo;
+    }
+
+    return null;
+
+  }
+
+  @Override
+  public List<CsdlSchema> getSchemas() throws ODataException {
+    // create Schema
+    CsdlSchema schema = new CsdlSchema();
+    schema.setNamespace(NAMESPACE);
+
+    // add EntityTypes
+    List<CsdlEntityType> entityTypes = new ArrayList<CsdlEntityType>();
+    entityTypes.add(getEntityType(ET_PRODUCT_FQN));
+    schema.setEntityTypes(entityTypes);
+
+    // add EntityContainer
+    schema.setEntityContainer(getEntityContainer());
+
+    // finally
+    List<CsdlSchema> schemas = new ArrayList<CsdlSchema>();
+    schemas.add(schema);
+
+    return schemas;
+
+  }
+
+  @Override
+  public CsdlEntityContainer getEntityContainer() throws ODataException {
+    // create EntitySets
+    List<CsdlEntitySet> entitySets = new ArrayList<CsdlEntitySet>();
+    entitySets.add(getEntitySet(CONTAINER, ES_PRODUCTS_NAME));
+
+    // create EntityContainer
+    CsdlEntityContainer entityContainer = new CsdlEntityContainer();
+    entityContainer.setName(CONTAINER_NAME);
+    entityContainer.setEntitySets(entitySets);
+
+    return entityContainer;
+
+  }
+
+
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f24c3874/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoEntityCollectionProcessor.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoEntityCollectionProcessor.java b/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoEntityCollectionProcessor.java
new file mode 100755
index 0000000..0835a41
--- /dev/null
+++ b/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoEntityCollectionProcessor.java
@@ -0,0 +1,72 @@
+package myservice.mynamespace.service;
+
+import java.io.InputStream;
+import java.util.List;
+
+import myservice.mynamespace.data.Storage;
+
+import org.apache.olingo.commons.api.data.ContextURL;
+import org.apache.olingo.commons.api.data.EntityCollection;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.http.HttpHeader;
+import org.apache.olingo.commons.api.http.HttpStatusCode;
+import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.ODataApplicationException;
+import org.apache.olingo.server.api.ODataRequest;
+import org.apache.olingo.server.api.ODataResponse;
+import org.apache.olingo.server.api.ServiceMetadata;
+import org.apache.olingo.server.api.processor.EntityCollectionProcessor;
+import org.apache.olingo.server.api.serializer.EntityCollectionSerializerOptions;
+import org.apache.olingo.server.api.serializer.ODataSerializer;
+import org.apache.olingo.server.api.serializer.SerializerException;
+import org.apache.olingo.server.api.serializer.SerializerResult;
+import org.apache.olingo.server.api.uri.UriInfo;
+import org.apache.olingo.server.api.uri.UriResource;
+import org.apache.olingo.server.api.uri.UriResourceEntitySet;
+
+public class DemoEntityCollectionProcessor implements EntityCollectionProcessor {
+
+	private OData odata;
+	private ServiceMetadata serviceMetadata;
+	private Storage storage;
+
+	public DemoEntityCollectionProcessor(Storage storage) {
+		this.storage = storage;
+	}
+
+	public void init(OData odata, ServiceMetadata serviceMetadata) {
+		this.odata = odata;
+		this.serviceMetadata = serviceMetadata;
+	}
+
+	public void readEntityCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType responseFormat) throws ODataApplicationException, SerializerException {
+
+		// 1st retrieve the requested EntitySet from the uriInfo (representation of the parsed URI)
+		List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
+		UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0); // in our example, the first segment is the EntitySet
+		EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();
+
+		// 2nd: fetch the data from backend for this requested EntitySetName and deliver as EntitySet
+		EntityCollection entityCollection = storage.readEntitySetData(edmEntitySet);
+
+		// 3rd: create a serializer based on the requested format (json)
+		ODataFormat format = ODataFormat.fromContentType(responseFormat);
+		ODataSerializer serializer = odata.createSerializer(format);
+
+		// and serialize the content: transform from the EntitySet object to InputStream
+		EdmEntityType edmEntityType = edmEntitySet.getEntityType();
+		ContextURL contextUrl = ContextURL.with().entitySet(edmEntitySet).build();
+
+		EntityCollectionSerializerOptions opts = EntityCollectionSerializerOptions.with().contextURL(contextUrl).build();
+		SerializerResult serializerResult = serializer.entityCollection(serviceMetadata, edmEntityType, entityCollection, opts);
+		InputStream serializedContent = serializerResult.getContent();
+
+		// 4th: configure the response object: set the body, headers and status code
+		response.setContent(serializedContent);
+		response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+		response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+	}
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f24c3874/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoEntityProcessor.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoEntityProcessor.java b/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoEntityProcessor.java
new file mode 100755
index 0000000..dc633b1
--- /dev/null
+++ b/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoEntityProcessor.java
@@ -0,0 +1,108 @@
+package myservice.mynamespace.service;
+
+import java.io.InputStream;
+import java.util.List;
+import java.util.Locale;
+
+import myservice.mynamespace.data.Storage;
+
+import org.apache.olingo.commons.api.data.ContextURL;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.http.HttpHeader;
+import org.apache.olingo.commons.api.http.HttpStatusCode;
+import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.ODataApplicationException;
+import org.apache.olingo.server.api.ODataRequest;
+import org.apache.olingo.server.api.ODataResponse;
+import org.apache.olingo.server.api.ServiceMetadata;
+import org.apache.olingo.server.api.deserializer.DeserializerException;
+import org.apache.olingo.server.api.processor.EntityProcessor;
+import org.apache.olingo.server.api.serializer.EntitySerializerOptions;
+import org.apache.olingo.server.api.serializer.ODataSerializer;
+import org.apache.olingo.server.api.serializer.SerializerException;
+import org.apache.olingo.server.api.serializer.SerializerResult;
+import org.apache.olingo.server.api.uri.UriInfo;
+import org.apache.olingo.server.api.uri.UriParameter;
+import org.apache.olingo.server.api.uri.UriResource;
+import org.apache.olingo.server.api.uri.UriResourceEntitySet;
+
+public class DemoEntityProcessor implements EntityProcessor {
+
+
+	private OData odata;
+	private ServiceMetadata serviceMetadata;
+	private Storage storage;
+
+
+
+	public DemoEntityProcessor(Storage storage) {
+		this.storage = storage;
+	}
+
+
+	public void init(OData odata, ServiceMetadata serviceMetadata) {
+		this.odata = odata;
+		this.serviceMetadata = serviceMetadata;
+	}
+
+
+	public void readEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType responseFormat)
+							throws ODataApplicationException, SerializerException {
+
+		// 1. retrieve the Entity Type
+		List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
+		// Note: only in our example we can assume that the first segment is the EntitySet
+		UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0);
+		EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();
+
+		// 2. retrieve the data from backend
+		List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
+		Entity entity = storage.readEntityData(edmEntitySet, keyPredicates);
+
+		// 3. serialize
+		EdmEntityType entityType = edmEntitySet.getEntityType();
+
+		ContextURL contextUrl = ContextURL.with().entitySet(edmEntitySet).suffix(ContextURL.Suffix.ENTITY).build();
+	 	// expand and select currently not supported
+		EntitySerializerOptions options = EntitySerializerOptions.with().contextURL(contextUrl).build();
+
+		ODataFormat oDataFormat = ODataFormat.fromContentType(responseFormat);
+		ODataSerializer serializer = this.odata.createSerializer(oDataFormat);
+		SerializerResult serializerResult = serializer.entity(serviceMetadata, entityType, entity, options);
+		InputStream entityStream = serializerResult.getContent();
+
+		//4. configure the response object
+		response.setContent(entityStream);
+		response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+		response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+	}
+
+
+
+
+	/*
+	 * These processor methods are not handled in this tutorial
+	 * */
+
+
+	public void createEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType requestFormat, ContentType responseFormat)
+				throws ODataApplicationException, DeserializerException, SerializerException {
+		throw new ODataApplicationException("Not supported.", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
+	}
+
+
+	public void updateEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType requestFormat, ContentType responseFormat)
+							throws ODataApplicationException, DeserializerException, SerializerException {
+		throw new ODataApplicationException("Not supported.", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
+	}
+
+
+	public void deleteEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo) throws ODataApplicationException {
+		throw new ODataApplicationException("Not supported.", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f24c3874/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoPrimitiveProcessor.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoPrimitiveProcessor.java b/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoPrimitiveProcessor.java
new file mode 100755
index 0000000..7c5b315
--- /dev/null
+++ b/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoPrimitiveProcessor.java
@@ -0,0 +1,129 @@
+package myservice.mynamespace.service;
+
+import java.io.InputStream;
+import java.util.List;
+import java.util.Locale;
+
+import myservice.mynamespace.data.Storage;
+
+import org.apache.olingo.commons.api.data.ContextURL;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
+import org.apache.olingo.commons.api.edm.EdmProperty;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.http.HttpHeader;
+import org.apache.olingo.commons.api.http.HttpStatusCode;
+import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.ODataApplicationException;
+import org.apache.olingo.server.api.ODataRequest;
+import org.apache.olingo.server.api.ODataResponse;
+import org.apache.olingo.server.api.ServiceMetadata;
+import org.apache.olingo.server.api.deserializer.DeserializerException;
+import org.apache.olingo.server.api.processor.PrimitiveProcessor;
+import org.apache.olingo.server.api.serializer.ODataSerializer;
+import org.apache.olingo.server.api.serializer.PrimitiveSerializerOptions;
+import org.apache.olingo.server.api.serializer.SerializerException;
+import org.apache.olingo.server.api.serializer.SerializerResult;
+import org.apache.olingo.server.api.uri.UriInfo;
+import org.apache.olingo.server.api.uri.UriParameter;
+import org.apache.olingo.server.api.uri.UriResource;
+import org.apache.olingo.server.api.uri.UriResourceEntitySet;
+import org.apache.olingo.server.api.uri.UriResourceProperty;
+
+public class DemoPrimitiveProcessor implements PrimitiveProcessor {
+
+	private OData odata;
+	private Storage storage;
+
+	public DemoPrimitiveProcessor(Storage storage) {
+		this.storage = storage;
+	}
+
+	public void init(OData odata, ServiceMetadata serviceMetadata) {
+		this.odata = odata;
+
+	}
+
+	/*
+	 * In our example, the URL would be: http://localhost:8080/DemoService/DemoService.svc/Products(1)/Name
+	 * and the response:
+	 * {
+	 *	  @odata.context: "$metadata#Products/Name",
+	 *	  value: "Notebook Basic 15"
+	 * }
+	 * */
+	public void readPrimitive(ODataRequest request, ODataResponse response,
+								UriInfo uriInfo, ContentType responseFormat)
+								throws ODataApplicationException, SerializerException {
+
+		// 1. Retrieve info from URI
+		// 1.1. retrieve the info about the requested entity set
+		List<UriResource> resourceParts = uriInfo.getUriResourceParts();
+		// Note: only in our example we can rely that the first segment is the EntitySet
+		UriResourceEntitySet uriEntityset = (UriResourceEntitySet) resourceParts.get(0);
+		EdmEntitySet edmEntitySet = uriEntityset.getEntitySet();
+		// the key for the entity
+		List<UriParameter> keyPredicates = uriEntityset.getKeyPredicates();
+
+		// 1.2. retrieve the requested (Edm) property
+		UriResourceProperty uriProperty = (UriResourceProperty)resourceParts.get(resourceParts.size() -1); // the last segment is the Property
+		EdmProperty edmProperty = uriProperty.getProperty();
+		String edmPropertyName = edmProperty.getName();
+		// in our example, we know we have only primitive types in our model
+		EdmPrimitiveType edmPropertyType = (EdmPrimitiveType) edmProperty.getType();
+
+
+		// 2. retrieve data from backend
+		// 2.1. retrieve the entity data, for which the property has to be read
+		Entity entity = storage.readEntityData(edmEntitySet, keyPredicates);
+		if (entity == null) { // Bad request
+			throw new ODataApplicationException("Entity not found", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
+		}
+
+		// 2.2. retrieve the property data from the entity
+		Property property = entity.getProperty(edmPropertyName);
+		if (property == null) {
+			throw new ODataApplicationException("Property not found", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
+		}
+
+		// 3. serialize
+		Object value = property.getValue();
+		if (value != null) {
+			// 3.1. configure the serializer
+			ODataFormat format = ODataFormat.fromContentType(responseFormat);
+			ODataSerializer serializer = odata.createSerializer(format);
+
+			ContextURL contextUrl = ContextURL.with().entitySet(edmEntitySet).navOrPropertyPath(edmPropertyName).build();
+			PrimitiveSerializerOptions options = PrimitiveSerializerOptions.with().contextURL(contextUrl).build();
+			// 3.2. serialize
+			SerializerResult serializerResult = serializer.primitive(edmPropertyType, property, options);
+			InputStream propertyStream = serializerResult.getContent();
+
+			//4. configure the response object
+			response.setContent(propertyStream);
+			response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+			response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+		} else {
+			// in case there's no value for the property, we can skip the serialization
+			response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
+		}
+	}
+
+
+
+	/*
+	 * These processor methods are not handled in this tutorial
+	 * */
+
+	public void updatePrimitive(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType requestFormat, ContentType responseFormat)
+								throws ODataApplicationException, DeserializerException, SerializerException {
+		throw new ODataApplicationException("Not supported.", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
+	}
+
+	public void deletePrimitive(ODataRequest request, ODataResponse response, UriInfo uriInfo) throws ODataApplicationException {
+		throw new ODataApplicationException("Not supported.", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
+	}
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f24c3874/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/util/Util.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/util/Util.java b/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/util/Util.java
new file mode 100755
index 0000000..16c7745
--- /dev/null
+++ b/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/util/Util.java
@@ -0,0 +1,120 @@
+/*
+ * 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 myservice.mynamespace.util;
+
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntityCollection;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.edm.EdmProperty;
+import org.apache.olingo.commons.api.edm.EdmType;
+import org.apache.olingo.commons.api.http.HttpStatusCode;
+import org.apache.olingo.server.api.ODataApplicationException;
+import org.apache.olingo.server.api.uri.UriInfoResource;
+import org.apache.olingo.server.api.uri.UriParameter;
+import org.apache.olingo.server.api.uri.UriResource;
+import org.apache.olingo.server.api.uri.UriResourceEntitySet;
+
+public class Util {
+
+	public static EdmEntitySet getEdmEntitySet(UriInfoResource uriInfo) throws ODataApplicationException {
+		List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
+		 // To get the entity set we have to interpret all URI segments
+		if (!(resourcePaths.get(0) instanceof UriResourceEntitySet)) {
+			// Here we should interpret the whole URI but in this example we do not support navigation so we throw an exception
+			throw new ODataApplicationException("Invalid resource type for first segment.", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(),Locale.ENGLISH);
+		}
+		
+		UriResourceEntitySet uriResource = (UriResourceEntitySet) resourcePaths.get(0);
+		
+		return uriResource.getEntitySet();
+	}
+
+	
+	public static Entity findEntity(EdmEntityType edmEntityType, EntityCollection entitySet, List<UriParameter> keyParams) throws ODataApplicationException {
+		
+		List<Entity> entityList = entitySet.getEntities();
+		
+		// loop over all entities in order to find that one that matches all keys in request e.g. contacts(ContactID=1, CompanyID=1) 
+		for(Entity entity : entityList){
+			boolean foundEntity = entityMatchesAllKeys(edmEntityType, entity, keyParams);
+			if(foundEntity) {
+				return entity;
+			}
+		}
+		
+		return null;
+	}
+	
+	
+  public static boolean
+      entityMatchesAllKeys(EdmEntityType edmEntityType, Entity rt_entity, List<UriParameter> keyParams)
+          throws ODataApplicationException {
+
+    // loop over all keys
+    for (final UriParameter key : keyParams) {
+      // key
+      String keyName = key.getName();
+      String keyText = key.getText();
+
+      // Edm: we need this info for the comparison below
+      EdmProperty edmKeyProperty = (EdmProperty) edmEntityType.getProperty(keyName);
+      Boolean isNullable = edmKeyProperty.isNullable();
+      Integer maxLength = edmKeyProperty.getMaxLength();
+      Integer precision = edmKeyProperty.getPrecision();
+      Boolean isUnicode = edmKeyProperty.isUnicode();
+      Integer scale = edmKeyProperty.getScale();
+      // get the EdmType in order to compare
+      EdmType edmType = edmKeyProperty.getType();
+      // if(EdmType instanceof EdmPrimitiveType) // do we need this?
+      EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) edmType;
+
+      // Runtime data: the value of the current entity
+      // don't need to check for null, this is done in olingo library
+      Object valueObject = rt_entity.getProperty(keyName).getValue();
+
+      // now need to compare the valueObject with the keyText String
+      // this is done using type.valueToString
+      String valueAsString = null;
+      try {
+        valueAsString = edmPrimitiveType.valueToString(valueObject, isNullable, maxLength, precision, scale, isUnicode);
+      } catch (EdmPrimitiveTypeException e) {
+        throw new ODataApplicationException("Failed to retrieve String value",
+						HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), Locale.ENGLISH, e);
+      }
+
+      if (valueAsString == null) {
+        return false;
+      }
+
+      boolean matches = valueAsString.equals(keyText);
+      if (!matches) {
+        // if any of the key properties is not found in the entity, we don't need to search further
+        return false;
+      }
+    }
+
+    return true;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f24c3874/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/web/DemoServlet.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/web/DemoServlet.java b/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/web/DemoServlet.java
new file mode 100755
index 0000000..fe5cdbb
--- /dev/null
+++ b/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/web/DemoServlet.java
@@ -0,0 +1,76 @@
+/*
+ * 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 myservice.mynamespace.web;
+
+import java.io.IOException;
+import java.lang.Override;import java.lang.RuntimeException;import java.util.ArrayList;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import myservice.mynamespace.data.Storage;
+import myservice.mynamespace.service.DemoEdmProvider;
+import myservice.mynamespace.service.DemoEntityCollectionProcessor;
+import myservice.mynamespace.service.DemoEntityProcessor;
+import myservice.mynamespace.service.DemoPrimitiveProcessor;
+
+import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.ODataHttpHandler;
+import org.apache.olingo.server.api.ServiceMetadata;
+import org.apache.olingo.server.api.edmx.EdmxReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DemoServlet extends HttpServlet {
+
+  private static final long serialVersionUID = 1L;
+  private static final Logger LOG = LoggerFactory.getLogger(DemoServlet.class);
+
+
+  @Override
+  protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+    try {
+      HttpSession session = req.getSession(true);
+      Storage storage = (Storage) session.getAttribute(Storage.class.getName());
+      if (storage == null) {
+        storage = new Storage();
+        session.setAttribute(Storage.class.getName(), storage);
+      }
+
+      // create odata handler and configure it with EdmProvider and Processor
+      OData odata = OData.newInstance();
+      ServiceMetadata edm = odata.createServiceMetadata(new DemoEdmProvider(), new ArrayList<EdmxReference>());
+      ODataHttpHandler handler = odata.createHandler(edm);
+      handler.register(new DemoEntityCollectionProcessor(storage));
+      handler.register(new DemoEntityProcessor(storage));
+      handler.register(new DemoPrimitiveProcessor(storage));
+
+      // let the handler do the work
+      handler.process(req, resp);
+    } catch (RuntimeException e) {
+      LOG.error("Server Error occurred in ExampleServlet", e);
+      throw new ServletException(e);
+    }
+
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f24c3874/samples/tutorials/p2_readep/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/samples/tutorials/p2_readep/src/main/webapp/WEB-INF/web.xml b/samples/tutorials/p2_readep/src/main/webapp/WEB-INF/web.xml
new file mode 100755
index 0000000..21de52a
--- /dev/null
+++ b/samples/tutorials/p2_readep/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+         or more contributor license agreements.  See the NOTICE file
+         distributed with this work for additional information
+         regarding copyright ownership.  The ASF licenses this file
+         to you under the Apache License, Version 2.0 (the
+         "License"); you may not use this file except in compliance
+         with the License.  You may obtain a copy of the License at
+
+           http://www.apache.org/licenses/LICENSE-2.0
+
+         Unless required by applicable law or agreed to in writing,
+         software distributed under the License is distributed on an
+         "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+         KIND, either express or implied.  See the License for the
+         specific language governing permissions and limitations
+         under the License.
+-->
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+				 id="WebApp_ID" version="2.5">
+
+	<!-- Register the HttpServlet implementation -->
+	<servlet>
+	  <servlet-name>DemoServlet</servlet-name>
+	  <servlet-class>myservice.mynamespace.web.DemoServlet</servlet-class>
+	  <load-on-startup>1</load-on-startup>
+	</servlet>
+	
+	<!-- 
+		Our OData service can be invoked at 
+		http://localhost:8080/DemoService/DemoService.svc
+	-->
+	<servlet-mapping>
+	  <servlet-name>DemoServlet</servlet-name>
+	  <url-pattern>/DemoService.svc/*</url-pattern>
+	</servlet-mapping>
+</web-app>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f24c3874/samples/tutorials/p2_readep/src/main/webapp/index.jsp
----------------------------------------------------------------------
diff --git a/samples/tutorials/p2_readep/src/main/webapp/index.jsp b/samples/tutorials/p2_readep/src/main/webapp/index.jsp
new file mode 100755
index 0000000..7ffb4ba
--- /dev/null
+++ b/samples/tutorials/p2_readep/src/main/webapp/index.jsp
@@ -0,0 +1,26 @@
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+
+-->
+<html>
+<body>
+<h2>Hello World!</h2>
+<a href="DemoService.svc/">OData Olingo V4 Demo Service</a>
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f24c3874/samples/tutorials/p3_write/pom.xml
----------------------------------------------------------------------
diff --git a/samples/tutorials/p3_write/pom.xml b/samples/tutorials/p3_write/pom.xml
new file mode 100755
index 0000000..4511a6f
--- /dev/null
+++ b/samples/tutorials/p3_write/pom.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>my.group.id</groupId>
+	<artifactId>DemoService-Write</artifactId>
+	<packaging>war</packaging>
+	<version>0.0.1</version>
+
+	<name>${project.artifactId}-Webapp</name>
+
+	<properties>
+		<javax.version>2.5</javax.version>
+		<odata.version>4.0.0-beta-03</odata.version>
+		<slf4j.version>1.7.7</slf4j.version>
+	</properties>
+
+	<dependencies>
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>servlet-api</artifactId>
+			<version>${javax.version}</version>
+			<scope>provided</scope>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.olingo</groupId>
+			<artifactId>odata-server-api</artifactId>
+			<version>${odata.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.olingo</groupId>
+			<artifactId>odata-server-core</artifactId>
+			<version>${odata.version}</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.olingo</groupId>
+			<artifactId>odata-commons-api</artifactId>
+			<version>${odata.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.olingo</groupId>
+			<artifactId>odata-commons-core</artifactId>
+			<version>${odata.version}</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-simple</artifactId>
+			<version>${slf4j.version}</version>
+			<scope>runtime</scope>
+		</dependency>
+	</dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f24c3874/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/data/Storage.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/data/Storage.java b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/data/Storage.java
new file mode 100755
index 0000000..3af3260
--- /dev/null
+++ b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/data/Storage.java
@@ -0,0 +1,272 @@
+/*
+ * 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 myservice.mynamespace.data;
+
+import myservice.mynamespace.service.DemoEdmProvider;
+import myservice.mynamespace.util.Util;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntityCollection;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ValueType;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
+import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef;
+import org.apache.olingo.commons.api.http.HttpMethod;
+import org.apache.olingo.commons.api.http.HttpStatusCode;
+import org.apache.olingo.server.api.ODataApplicationException;
+import org.apache.olingo.server.api.uri.UriParameter;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+public class Storage {
+
+	
+	private List<Entity> productList;
+	
+	
+	public Storage() {
+		
+		productList = new ArrayList<Entity>();
+		initSampleData();
+	}
+
+	
+	
+	/* PUBLIC FACADE */
+	
+	
+	public EntityCollection readEntitySetData(EdmEntitySet edmEntitySet)throws ODataApplicationException{
+		
+		// actually, this is only required if we have more than one Entity Sets
+		if(edmEntitySet.getName().equals(DemoEdmProvider.ES_PRODUCTS_NAME)){
+			return getProducts();
+		}
+		
+		return null;
+	}
+	
+	
+	public Entity readEntityData(EdmEntitySet edmEntitySet, List<UriParameter> keyParams) throws ODataApplicationException{
+		
+		EdmEntityType edmEntityType = edmEntitySet.getEntityType();
+		
+		// actually, this is only required if we have more than one Entity Type
+		if(edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)){
+			return getProduct(edmEntityType, keyParams);
+		}
+		
+		return null;
+	}
+
+	
+	public Entity createEntityData(EdmEntitySet edmEntitySet, Entity entityToCreate) {
+		
+		EdmEntityType edmEntityType = edmEntitySet.getEntityType();
+		
+		// actually, this is only required if we have more than one Entity Type
+		if(edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)){
+			return createProduct(edmEntityType, entityToCreate);
+		}
+		
+		return null;
+	}
+
+
+	/**
+	 * This method is invoked for PATCH or PUT requests
+	 * */
+	public void updateEntityData(EdmEntitySet edmEntitySet, List<UriParameter> keyParams, Entity updateEntity, HttpMethod httpMethod) throws ODataApplicationException{
+		
+		EdmEntityType edmEntityType = edmEntitySet.getEntityType();
+
+		// actually, this is only required if we have more than one Entity Type
+		if(edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)){
+			updateProduct(edmEntityType, keyParams, updateEntity, httpMethod);
+		}
+	}
+	
+
+	public void deleteEntityData(EdmEntitySet edmEntitySet, List<UriParameter> keyParams) throws ODataApplicationException{
+		
+		EdmEntityType edmEntityType = edmEntitySet.getEntityType();
+		
+		// actually, this is only required if we have more than one Entity Type
+		if(edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)){
+			deleteProduct(edmEntityType, keyParams);
+		}
+	}
+
+	
+	
+	/*  INTERNAL */
+	
+	private EntityCollection getProducts(){
+		EntityCollection retEntitySet = new EntityCollection();
+		
+		for(Entity productEntity : this.productList){
+			   retEntitySet.getEntities().add(productEntity);
+		}
+		
+		return retEntitySet;
+	}
+	
+	
+	private Entity getProduct(EdmEntityType edmEntityType, List<UriParameter> keyParams) throws ODataApplicationException{ 
+		
+		// the list of entities at runtime
+		EntityCollection entitySet = getProducts();
+		
+		/*  generic approach  to find the requested entity */
+		Entity requestedEntity = Util.findEntity(edmEntityType, entitySet, keyParams);
+		
+	
+		if(requestedEntity == null){
+			// this variable is null if our data doesn't contain an entity for the requested key
+			// Throw suitable exception
+			throw new ODataApplicationException("Entity for requested key doesn't exist",
+          HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
+		}
+		
+		return requestedEntity;
+	}
+		
+	
+	private Entity createProduct(EdmEntityType edmEntityType, Entity entity) {
+		
+		// the ID of the newly created product entity is generated automatically
+		int newId = 1;
+		while (productIdExists(newId)){
+			newId++;
+		}
+		
+		Property idProperty = entity.getProperty("ID");
+		if(idProperty != null){
+			idProperty.setValue(ValueType.PRIMITIVE, new Integer(newId));
+		}else{
+			// as of OData v4 spec, the key property can be omitted from the POST request body
+			entity.getProperties().add(new Property(null, "ID", ValueType.PRIMITIVE, newId));
+		}
+		
+		this.productList.add(entity);
+
+		return entity;
+		
+	}
+
+
+	private boolean productIdExists(int id){
+		
+		for(Entity entity : this.productList){
+			Integer existingID = (Integer) entity.getProperty("ID").getValue();
+			if(existingID.intValue() == id){
+				return true;
+			}
+		}
+		
+		return false;
+	}
+	
+	
+	private void updateProduct(EdmEntityType edmEntityType, List<UriParameter> keyParams, Entity entity, HttpMethod httpMethod) throws ODataApplicationException{
+		
+		Entity productEntity = getProduct(edmEntityType, keyParams);
+		if(productEntity == null){
+			throw new ODataApplicationException("Entity not found", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
+		}
+		
+		// loop over all properties and replace the values with the values of the given payload
+		// Note: ignoring ComplexType, as we don't have it in our odata model
+		List<Property> existingProperties = productEntity.getProperties();
+		for(Property existingProp : existingProperties){
+			String propName = existingProp.getName();
+			
+			// ignore the key properties, they aren't updateable
+			if(isKey(edmEntityType, propName)){
+				continue;
+			}
+			
+			Property updateProperty = entity.getProperty(propName); 
+			// the request payload might not consider ALL properties, so it can be null
+			if(updateProperty == null){
+				// if a property has NOT been added to the request payload
+				// depending on the HttpMethod, our behavior is different
+				if(httpMethod.equals(HttpMethod.PATCH)){
+					// as of the OData spec, in case of PATCH, the existing property is not touched
+					continue; // do nothing
+				}else if(httpMethod.equals(HttpMethod.PUT)){
+					// as of the OData spec, in case of PUT, the existing property is set to null (or to default value)
+					existingProp.setValue(existingProp.getValueType(), null);
+					continue;
+				}
+			}
+			
+			// change the value of the properties 
+			existingProp.setValue(existingProp.getValueType(), updateProperty.getValue());
+		}
+	}
+
+	private void deleteProduct(EdmEntityType edmEntityType, List<UriParameter> keyParams) throws ODataApplicationException{ 
+		
+		Entity productEntity = getProduct(edmEntityType, keyParams);
+		if(productEntity == null){
+			throw new ODataApplicationException("Entity not found", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
+		}
+		
+		this.productList.remove(productEntity);
+	}
+	
+	
+	
+	/* HELPER */
+	
+	
+	private boolean isKey(EdmEntityType edmEntityType, String propertyName){
+		List<EdmKeyPropertyRef> keyPropertyRefs = edmEntityType.getKeyPropertyRefs();
+		for(EdmKeyPropertyRef propRef : keyPropertyRefs){
+			String keyPropertyName = propRef.getName();
+			if(keyPropertyName.equals(propertyName)){
+				return true;
+			}
+		}
+		return false;
+	}
+
+	
+	private void initSampleData(){
+
+		// add some sample product entities
+		productList.add(new Entity()
+			.addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 1))
+			.addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "Notebook Basic 15"))
+			.addProperty(new Property(null, "Description", ValueType.PRIMITIVE, "Notebook Basic, 1.7GHz - 15 XGA - 1024MB DDR2 SDRAM - 40GB")));
+
+		productList.add(new Entity()
+			.addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 2))
+			.addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "1UMTS PDA"))
+			.addProperty(new Property(null, "Description", ValueType.PRIMITIVE, "Ultrafast 3G UMTS/HSDPA Pocket PC, supports GSM network")));
+
+		productList.add(new Entity()
+			.addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 3))
+			.addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "Ergo Screen"))
+			.addProperty(new Property(null, "Description", ValueType.PRIMITIVE, "19 Optimum Resolution 1024 x 768 @ 85Hz, resolution 1280 x 960")));
+
+	}
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f24c3874/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoEdmProvider.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoEdmProvider.java b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoEdmProvider.java
new file mode 100755
index 0000000..6a64b31
--- /dev/null
+++ b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoEdmProvider.java
@@ -0,0 +1,155 @@
+/*
+ * 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 myservice.mynamespace.service;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.olingo.commons.api.ODataException;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.provider.CsdlAbstractEdmProvider;
+import org.apache.olingo.commons.api.edm.provider.CsdlEntityContainer;
+import org.apache.olingo.commons.api.edm.provider.CsdlEntityContainerInfo;
+import org.apache.olingo.commons.api.edm.provider.CsdlEntitySet;
+import org.apache.olingo.commons.api.edm.provider.CsdlEntityType;
+import org.apache.olingo.commons.api.edm.provider.CsdlProperty;
+import org.apache.olingo.commons.api.edm.provider.CsdlPropertyRef;
+import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
+
+/*
+ * this class is supposed to declare the metadata of the OData service
+ * it is invoked by the Olingo framework e.g. when the metadata document of the service is invoked
+ * e.g. http://localhost:8080/ExampleService1/ExampleService1.svc/$metadata
+ */
+public class DemoEdmProvider extends CsdlAbstractEdmProvider {
+
+
+  // Service Namespace
+  public static final String NAMESPACE = "OData.Demo";
+
+  // EDM Container
+  public static final String CONTAINER_NAME = "Container";
+  public static final FullQualifiedName CONTAINER = new FullQualifiedName(NAMESPACE, CONTAINER_NAME);
+
+  // Entity Types Names
+  public static final String ET_PRODUCT_NAME = "Product";
+  public static final FullQualifiedName ET_PRODUCT_FQN = new FullQualifiedName(NAMESPACE, ET_PRODUCT_NAME);
+
+  // Entity Set Names
+  public static final String ES_PRODUCTS_NAME = "Products";
+
+
+  @Override
+  public List<CsdlSchema> getSchemas() throws ODataException {
+
+    // create Schema
+    CsdlSchema schema = new CsdlSchema();
+    schema.setNamespace(NAMESPACE);
+
+    // add EntityTypes
+    List<CsdlEntityType> entityTypes = new ArrayList<CsdlEntityType>();
+    entityTypes.add(getEntityType(ET_PRODUCT_FQN));
+    schema.setEntityTypes(entityTypes);
+
+    // add EntityContainer
+    schema.setEntityContainer(getEntityContainer());
+
+    // finally
+    List<CsdlSchema> schemas = new ArrayList<CsdlSchema>();
+    schemas.add(schema);
+
+    return schemas;
+  }
+
+
+  @Override
+  public CsdlEntityType getEntityType(FullQualifiedName entityTypeName) throws ODataException {
+    // this method is called for one of the EntityTypes that are configured in the Schema
+    if(entityTypeName.equals(ET_PRODUCT_FQN)){
+
+      //create EntityType properties
+      CsdlProperty id = new CsdlProperty().setName("ID").setType(EdmPrimitiveTypeKind.Int32.getFullQualifiedName());
+      CsdlProperty name = new CsdlProperty().setName("Name").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
+      CsdlProperty  description = new CsdlProperty().setName("Description").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
+
+      // create CsdlPropertyRef for Key element
+      CsdlPropertyRef propertyRef = new CsdlPropertyRef();
+      propertyRef.setName("ID");
+
+      // configure EntityType
+      CsdlEntityType entityType = new CsdlEntityType();
+      entityType.setName(ET_PRODUCT_NAME);
+      entityType.setProperties(Arrays.asList(id, name, description));
+      entityType.setKey(Collections.singletonList(propertyRef));
+
+      return entityType;
+    }
+
+    return null;
+
+  }
+
+  @Override
+  public CsdlEntitySet getEntitySet(FullQualifiedName entityContainer, String entitySetName) throws ODataException {
+
+    if(entityContainer.equals(CONTAINER)){
+      if(entitySetName.equals(ES_PRODUCTS_NAME)){
+        CsdlEntitySet entitySet = new CsdlEntitySet();
+        entitySet.setName(ES_PRODUCTS_NAME);
+        entitySet.setType(ET_PRODUCT_FQN);
+
+        return entitySet;
+      }
+    }
+
+    return null;
+
+  }
+
+
+  public CsdlEntityContainer getEntityContainer() throws ODataException {
+    // create EntitySets
+    List<CsdlEntitySet> entitySets = new ArrayList<CsdlEntitySet>();
+    entitySets.add(getEntitySet(CONTAINER, ES_PRODUCTS_NAME));
+
+    // create EntityContainer
+    CsdlEntityContainer entityContainer = new CsdlEntityContainer();
+    entityContainer.setName(CONTAINER_NAME);
+    entityContainer.setEntitySets(entitySets);
+
+    return entityContainer;
+
+  }
+
+  @Override
+  public CsdlEntityContainerInfo getEntityContainerInfo(FullQualifiedName entityContainerName) throws ODataException {
+
+    // This method is invoked when displaying the service document at
+    // e.g. http://localhost:8080/DemoService/DemoService.svc
+    if (entityContainerName == null || entityContainerName.equals(CONTAINER)) {
+      CsdlEntityContainerInfo entityContainerInfo = new CsdlEntityContainerInfo();
+      entityContainerInfo.setContainerName(CONTAINER);
+      return entityContainerInfo;
+    }
+    return null;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f24c3874/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoEntityCollectionProcessor.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoEntityCollectionProcessor.java b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoEntityCollectionProcessor.java
new file mode 100755
index 0000000..53470cb
--- /dev/null
+++ b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoEntityCollectionProcessor.java
@@ -0,0 +1,93 @@
+/*
+ * 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 myservice.mynamespace.service;
+
+import java.util.List;
+
+import myservice.mynamespace.data.Storage;
+
+import org.apache.olingo.commons.api.data.ContextURL;
+import org.apache.olingo.commons.api.data.EntityCollection;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.http.HttpHeader;
+import org.apache.olingo.commons.api.http.HttpStatusCode;
+import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.ODataApplicationException;
+import org.apache.olingo.server.api.ODataRequest;
+import org.apache.olingo.server.api.ODataResponse;
+import org.apache.olingo.server.api.ServiceMetadata;
+import org.apache.olingo.server.api.processor.EntityCollectionProcessor;
+import org.apache.olingo.server.api.serializer.EntityCollectionSerializerOptions;
+import org.apache.olingo.server.api.serializer.ODataSerializer;
+import org.apache.olingo.server.api.serializer.SerializerException;
+import org.apache.olingo.server.api.serializer.SerializerResult;
+import org.apache.olingo.server.api.uri.UriInfo;
+import org.apache.olingo.server.api.uri.UriResource;
+import org.apache.olingo.server.api.uri.UriResourceEntitySet;
+
+public class DemoEntityCollectionProcessor implements EntityCollectionProcessor {
+
+  private OData odata;
+  private Storage storage;
+  private ServiceMetadata serviceMetadata;
+
+
+  public DemoEntityCollectionProcessor(Storage storage) {
+    this.storage = storage;
+  }
+
+
+  public void init(OData odata, ServiceMetadata serviceMetadata) {
+    this.odata = odata;
+    this.serviceMetadata = serviceMetadata;
+  }
+
+  public void readEntityCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo,
+      ContentType responseFormat) throws ODataApplicationException, SerializerException {
+
+    // 1st retrieve the requested EntitySet from the uriInfo (representation of the parsed URI)
+    List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
+    // in our example, the first segment is the EntitySet
+    UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0);
+    EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();
+
+    // 2nd: fetch the data from backend for this requested EntitySetName
+    // it has to be delivered as EntitySet object
+    EntityCollection entitySet = storage.readEntitySetData(edmEntitySet);
+
+    // 3rd: create a serializer based on the requested format (json)
+    ODataFormat format = ODataFormat.fromContentType(responseFormat);
+    ODataSerializer serializer = odata.createSerializer(format);
+
+    // and serialize the content: transform from the EntitySet object to InputStream
+    EdmEntityType edmEntityType = edmEntitySet.getEntityType();
+    ContextURL contextUrl = ContextURL.with().entitySet(edmEntitySet).build();
+
+    EntityCollectionSerializerOptions opts = EntityCollectionSerializerOptions.with().contextURL(contextUrl).build();
+    SerializerResult serializedContent = serializer.entityCollection(serviceMetadata, edmEntityType, entitySet, opts);
+
+    // Finally: configure the response object: set the body, headers and status code
+    response.setContent(serializedContent.getContent());
+    response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+    response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f24c3874/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoEntityProcessor.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoEntityProcessor.java b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoEntityProcessor.java
new file mode 100755
index 0000000..10d5023
--- /dev/null
+++ b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoEntityProcessor.java
@@ -0,0 +1,189 @@
+/*
+ * 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 myservice.mynamespace.service;
+
+import java.io.InputStream;
+import java.util.List;
+
+import myservice.mynamespace.data.Storage;
+import myservice.mynamespace.util.Util;
+
+import org.apache.olingo.commons.api.data.ContextURL;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.http.HttpHeader;
+import org.apache.olingo.commons.api.http.HttpMethod;
+import org.apache.olingo.commons.api.http.HttpStatusCode;
+import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.ODataApplicationException;
+import org.apache.olingo.server.api.ODataRequest;
+import org.apache.olingo.server.api.ODataResponse;
+import org.apache.olingo.server.api.ServiceMetadata;
+import org.apache.olingo.server.api.deserializer.DeserializerException;
+import org.apache.olingo.server.api.deserializer.DeserializerResult;
+import org.apache.olingo.server.api.deserializer.ODataDeserializer;
+import org.apache.olingo.server.api.processor.EntityProcessor;
+import org.apache.olingo.server.api.serializer.EntitySerializerOptions;
+import org.apache.olingo.server.api.serializer.ODataSerializer;
+import org.apache.olingo.server.api.serializer.SerializerException;
+import org.apache.olingo.server.api.serializer.SerializerResult;
+import org.apache.olingo.server.api.uri.UriInfo;
+import org.apache.olingo.server.api.uri.UriParameter;
+import org.apache.olingo.server.api.uri.UriResource;
+import org.apache.olingo.server.api.uri.UriResourceEntitySet;
+
+public class DemoEntityProcessor implements EntityProcessor {
+
+	private OData odata;
+	private Storage storage;
+	private ServiceMetadata serviceMetadata;
+	
+	
+	public DemoEntityProcessor(Storage storage) {
+		this.storage = storage;
+	}
+
+	
+	public void init(OData odata, ServiceMetadata serviceMetadata) {
+		this.odata = odata;
+		this.serviceMetadata = serviceMetadata;
+	}
+
+	
+	public void readEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType responseFormat)
+      throws ODataApplicationException, SerializerException {
+		
+		// 1. retrieve the Entity Type 
+		List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
+		// Note: only in our example we can assume that the first segment is the EntitySet
+		UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0); 
+		EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();
+		
+		// 2. retrieve the data from backend
+		List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
+		Entity entity = storage.readEntityData(edmEntitySet, keyPredicates);
+		
+		// 3. serialize
+		EdmEntityType entityType = edmEntitySet.getEntityType();
+		
+		ContextURL contextUrl = ContextURL.with().entitySet(edmEntitySet).suffix(ContextURL.Suffix.ENTITY).build();
+	 	// expand and select currently not supported
+		EntitySerializerOptions options = EntitySerializerOptions.with().contextURL(contextUrl).build();
+
+		ODataFormat oDataFormat = ODataFormat.fromContentType(responseFormat);		
+		ODataSerializer serializer = this.odata.createSerializer(oDataFormat);
+		SerializerResult result = serializer.entity(serviceMetadata, entityType, entity, options);
+		
+		//4. configure the response object
+		response.setContent(result.getContent());
+		response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+		response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+	}
+
+	/*
+	 * Example request:
+	 * 
+	 * POST URL: http://localhost:8080/DemoService/DemoService.svc/Products
+	 * Header: Content-Type: application/json; odata.metadata=minimal
+	 * Request body:
+	 	{
+			"ID":3,
+			"Name":"Ergo Screen",
+			"Description":"17 Optimum Resolution 1024 x 768 @ 85Hz, resolution 1280 x 960"
+		}
+	 * */
+	public void createEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType requestFormat, ContentType responseFormat) 
+				throws ODataApplicationException, DeserializerException, SerializerException {
+		
+		// 1. Retrieve the entity type from the URI 
+		EdmEntitySet edmEntitySet = Util.getEdmEntitySet(uriInfo);
+		EdmEntityType edmEntityType = edmEntitySet.getEntityType();
+
+		// 2. create the data in backend 
+		// 2.1. retrieve the payload from the POST request for the entity to create and deserialize it
+		InputStream requestInputStream = request.getBody();
+		ODataFormat requestODataFormat = ODataFormat.fromContentType(requestFormat);
+		ODataDeserializer deserializer = this.odata.createDeserializer(requestODataFormat);
+		DeserializerResult result = deserializer.entity(requestInputStream, edmEntityType);
+		Entity requestEntity = result.getEntity();
+		// 2.2 do the creation in backend, which returns the newly created entity
+		Entity createdEntity = storage.createEntityData(edmEntitySet, requestEntity);
+		
+		// 3. serialize the response (we have to return the created entity)
+		ContextURL contextUrl = ContextURL.with().entitySet(edmEntitySet).build(); 
+		EntitySerializerOptions options = EntitySerializerOptions.with().contextURL(contextUrl).build(); // expand and select currently not supported 
+		
+		ODataFormat oDataFormat = ODataFormat.fromContentType(responseFormat);		
+		ODataSerializer serializer = this.odata.createSerializer(oDataFormat);
+		SerializerResult serializedResponse = serializer.entity(serviceMetadata, edmEntityType, createdEntity, options);
+		
+		//4. configure the response object
+		response.setContent(serializedResponse.getContent());
+		response.setStatusCode(HttpStatusCode.CREATED.getStatusCode());
+		response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+	}
+
+	
+	public void updateEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType requestFormat, ContentType responseFormat) 
+							throws ODataApplicationException, DeserializerException, SerializerException {
+		
+		// 1. Retrieve the entity set which belongs to the requested entity 
+		List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
+		// Note: only in our example we can assume that the first segment is the EntitySet
+		UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0); 
+		EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();
+		EdmEntityType edmEntityType = edmEntitySet.getEntityType();
+
+		// 2. update the data in backend
+		// 2.1. retrieve the payload from the PUT request for the entity to be updated 
+		InputStream requestInputStream = request.getBody();
+		ODataFormat requestODataFormat = ODataFormat.fromContentType(requestFormat);
+		ODataDeserializer deserializer = this.odata.createDeserializer(requestODataFormat);
+		DeserializerResult result = deserializer.entity(requestInputStream, edmEntityType);
+		Entity requestEntity = result.getEntity();
+		// 2.2 do the modification in backend
+		List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
+		// Note that this updateEntity()-method is invoked for both PUT or PATCH operations
+		HttpMethod httpMethod = request.getMethod();
+		storage.updateEntityData(edmEntitySet, keyPredicates, requestEntity, httpMethod);
+		
+		//3. configure the response object
+		response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
+	}
+
+	
+	public void deleteEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo) throws ODataApplicationException {
+		
+		// 1. Retrieve the entity set which belongs to the requested entity 
+		List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
+		// Note: only in our example we can assume that the first segment is the EntitySet
+		UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0); 
+		EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();
+
+		// 2. delete the data in backend
+		List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
+		storage.deleteEntityData(edmEntitySet, keyPredicates);
+		
+		//3. configure the response object
+		response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
+	}
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f24c3874/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoPrimitiveProcessor.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoPrimitiveProcessor.java b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoPrimitiveProcessor.java
new file mode 100755
index 0000000..ec4ba3a
--- /dev/null
+++ b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoPrimitiveProcessor.java
@@ -0,0 +1,143 @@
+/*
+ * 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 myservice.mynamespace.service;
+
+import java.util.List;
+import java.util.Locale;
+
+import myservice.mynamespace.data.Storage;
+
+import org.apache.olingo.commons.api.data.ContextURL;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
+import org.apache.olingo.commons.api.edm.EdmProperty;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.http.HttpHeader;
+import org.apache.olingo.commons.api.http.HttpStatusCode;
+import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.ODataApplicationException;
+import org.apache.olingo.server.api.ODataRequest;
+import org.apache.olingo.server.api.ODataResponse;
+import org.apache.olingo.server.api.ServiceMetadata;
+import org.apache.olingo.server.api.deserializer.DeserializerException;
+import org.apache.olingo.server.api.processor.PrimitiveProcessor;
+import org.apache.olingo.server.api.serializer.ODataSerializer;
+import org.apache.olingo.server.api.serializer.PrimitiveSerializerOptions;
+import org.apache.olingo.server.api.serializer.SerializerException;
+import org.apache.olingo.server.api.serializer.SerializerResult;
+import org.apache.olingo.server.api.uri.UriInfo;
+import org.apache.olingo.server.api.uri.UriParameter;
+import org.apache.olingo.server.api.uri.UriResource;
+import org.apache.olingo.server.api.uri.UriResourceEntitySet;
+import org.apache.olingo.server.api.uri.UriResourceProperty;
+
+public class DemoPrimitiveProcessor implements PrimitiveProcessor {
+
+	private OData odata;
+	private Storage storage;
+
+	public DemoPrimitiveProcessor(Storage storage) {
+		this.storage = storage;
+	}
+
+	public void init(OData odata, ServiceMetadata serviceMetadata) {
+		this.odata = odata;
+	}
+	
+
+	/*
+	 * In our example, the URL would be: http://localhost:8080/DemoService/DemoService.svc/Products(1)/Name
+	 * and the response:
+	 * {
+	 *	  @odata.context: "$metadata#Products/Name",
+	 *	  value: "Notebook Basic 15"
+	 * }
+	 * */
+	public void readPrimitive(ODataRequest request, ODataResponse response, 
+								UriInfo uriInfo, ContentType responseFormat) 
+								throws ODataApplicationException, SerializerException {
+
+		// 1. Retrieve info from URI
+		// 1.1. retrieve the info about the requested entity set 
+		List<UriResource> resourceParts = uriInfo.getUriResourceParts();
+		// Note: only in our example we can rely that the first segment is the EntitySet
+		UriResourceEntitySet uriEntityset = (UriResourceEntitySet) resourceParts.get(0); 
+		EdmEntitySet edmEntitySet = uriEntityset.getEntitySet();
+		// the key for the entity
+		List<UriParameter> keyPredicates = uriEntityset.getKeyPredicates();
+		
+		// 1.2. retrieve the requested (Edm) property 
+		UriResourceProperty uriProperty = (UriResourceProperty)resourceParts.get(resourceParts.size() -1); // the last segment is the Property
+		EdmProperty edmProperty = uriProperty.getProperty();
+		String edmPropertyName = edmProperty.getName();
+		// in our example, we know we have only primitive types in our model
+		EdmPrimitiveType edmPropertyType = (EdmPrimitiveType) edmProperty.getType(); 
+		
+		
+		// 2. retrieve data from backend
+		// 2.1. retrieve the entity data, for which the property has to be read
+		Entity entity = storage.readEntityData(edmEntitySet, keyPredicates);
+		if (entity == null) { // Bad request
+			throw new ODataApplicationException("Entity not found", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
+		} 
+		
+		// 2.2. retrieve the property data from the entity
+		Property property = entity.getProperty(edmPropertyName);
+		if (property == null) {
+			throw new ODataApplicationException("Property not found", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
+		}		
+		
+		// 3. serialize
+		Object value = property.getValue();
+		if (value != null) {
+			// 3.1. configure the serializer
+			ODataFormat format = ODataFormat.fromContentType(responseFormat);
+			ODataSerializer serializer = odata.createSerializer(format);
+			
+			ContextURL contextUrl = ContextURL.with().entitySet(edmEntitySet).navOrPropertyPath(edmPropertyName).build();
+			PrimitiveSerializerOptions options = PrimitiveSerializerOptions.with().contextURL(contextUrl).build();
+			// 3.2. serialize
+			SerializerResult result = serializer.primitive(edmPropertyType, property, options);
+			
+			//4. configure the response object
+			response.setContent(result.getContent());
+			response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+			response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());		
+		}else{
+			// in case there's no value for the property, we can skip the serialization
+			response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
+		}
+	}
+
+	/*
+	 * These processor methods are not handled in this tutorial 
+	 *
+	 * */
+	public void updatePrimitive(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType requestFormat, ContentType responseFormat)
+								throws ODataApplicationException, DeserializerException, SerializerException {
+		throw new ODataApplicationException("Not supported.", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
+	}
+
+	public void deletePrimitive(ODataRequest request, ODataResponse response, UriInfo uriInfo) throws ODataApplicationException {
+		throw new ODataApplicationException("Not supported.", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
+	}
+}


[27/39] olingo-odata4 git commit: [OLINGO-694] Minor code clean up in tutorials

Posted by ch...@apache.org.
[OLINGO-694] Minor code clean up in tutorials


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

Branch: refs/heads/IEE754Compatible
Commit: 431938c1e6f513912fe0131ee4a220e20d9a474e
Parents: 93999d5
Author: Michael Bolz <mi...@sap.com>
Authored: Fri Jun 19 06:56:44 2015 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Fri Jun 19 06:56:44 2015 +0200

----------------------------------------------------------------------
 .../java/myservice/mynamespace/util/Util.java   |  63 +--
 .../myservice/mynamespace/data/Storage.java     | 455 +++++++++----------
 .../mynamespace/service/DemoEdmProvider.java    |  10 +-
 .../service/DemoEntityProcessor.java            |  13 +-
 .../service/DemoPrimitiveProcessor.java         |  13 +-
 .../java/myservice/mynamespace/util/Util.java   |   3 +-
 6 files changed, 269 insertions(+), 288 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/431938c1/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/util/Util.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/util/Util.java b/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/util/Util.java
index 16c7745..c21d352 100755
--- a/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/util/Util.java
+++ b/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/util/Util.java
@@ -6,9 +6,9 @@
  * 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
@@ -37,39 +37,25 @@ import org.apache.olingo.server.api.uri.UriResource;
 import org.apache.olingo.server.api.uri.UriResourceEntitySet;
 
 public class Util {
+  
+  public static Entity findEntity(EdmEntityType edmEntityType, EntityCollection entitySet,
+                                  List<UriParameter> keyParams) throws ODataApplicationException {
 
-	public static EdmEntitySet getEdmEntitySet(UriInfoResource uriInfo) throws ODataApplicationException {
-		List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
-		 // To get the entity set we have to interpret all URI segments
-		if (!(resourcePaths.get(0) instanceof UriResourceEntitySet)) {
-			// Here we should interpret the whole URI but in this example we do not support navigation so we throw an exception
-			throw new ODataApplicationException("Invalid resource type for first segment.", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(),Locale.ENGLISH);
-		}
-		
-		UriResourceEntitySet uriResource = (UriResourceEntitySet) resourcePaths.get(0);
-		
-		return uriResource.getEntitySet();
-	}
+    List<Entity> entityList = entitySet.getEntities();
 
-	
-	public static Entity findEntity(EdmEntityType edmEntityType, EntityCollection entitySet, List<UriParameter> keyParams) throws ODataApplicationException {
-		
-		List<Entity> entityList = entitySet.getEntities();
-		
-		// loop over all entities in order to find that one that matches all keys in request e.g. contacts(ContactID=1, CompanyID=1) 
-		for(Entity entity : entityList){
-			boolean foundEntity = entityMatchesAllKeys(edmEntityType, entity, keyParams);
-			if(foundEntity) {
-				return entity;
-			}
-		}
-		
-		return null;
-	}
-	
-	
-  public static boolean
-      entityMatchesAllKeys(EdmEntityType edmEntityType, Entity rt_entity, List<UriParameter> keyParams)
+    // loop over all entities in order to find that one that matches all keys in request
+    // e.g. contacts(ContactID=1, CompanyID=1)
+    for (Entity entity: entityList) {
+      boolean foundEntity = entityMatchesAllKeys(edmEntityType, entity, keyParams);
+      if (foundEntity) {
+        return entity;
+      }
+    }
+
+    return null;
+  }
+
+  public static boolean entityMatchesAllKeys(EdmEntityType edmEntityType, Entity entity, List<UriParameter> keyParams)
           throws ODataApplicationException {
 
     // loop over all keys
@@ -87,21 +73,20 @@ public class Util {
       Integer scale = edmKeyProperty.getScale();
       // get the EdmType in order to compare
       EdmType edmType = edmKeyProperty.getType();
-      // if(EdmType instanceof EdmPrimitiveType) // do we need this?
       EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) edmType;
 
       // Runtime data: the value of the current entity
       // don't need to check for null, this is done in olingo library
-      Object valueObject = rt_entity.getProperty(keyName).getValue();
+      Object valueObject = entity.getProperty(keyName).getValue();
 
       // now need to compare the valueObject with the keyText String
-      // this is done using type.valueToString
-      String valueAsString = null;
+      // this is done using the type.valueToString
+      String valueAsString;
       try {
         valueAsString = edmPrimitiveType.valueToString(valueObject, isNullable, maxLength, precision, scale, isUnicode);
       } catch (EdmPrimitiveTypeException e) {
-        throw new ODataApplicationException("Failed to retrieve String value",
-						HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), Locale.ENGLISH, e);
+        throw new ODataApplicationException("Failed to retrieve String value", HttpStatusCode.INTERNAL_SERVER_ERROR
+                .getStatusCode(), Locale.ENGLISH, e);
       }
 
       if (valueAsString == null) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/431938c1/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/data/Storage.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/data/Storage.java b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/data/Storage.java
index 3af3260..ad5dd71 100755
--- a/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/data/Storage.java
+++ b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/data/Storage.java
@@ -6,9 +6,9 @@
  * 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
@@ -38,235 +38,226 @@ import java.util.Locale;
 
 public class Storage {
 
-	
-	private List<Entity> productList;
-	
-	
-	public Storage() {
-		
-		productList = new ArrayList<Entity>();
-		initSampleData();
-	}
-
-	
-	
-	/* PUBLIC FACADE */
-	
-	
-	public EntityCollection readEntitySetData(EdmEntitySet edmEntitySet)throws ODataApplicationException{
-		
-		// actually, this is only required if we have more than one Entity Sets
-		if(edmEntitySet.getName().equals(DemoEdmProvider.ES_PRODUCTS_NAME)){
-			return getProducts();
-		}
-		
-		return null;
-	}
-	
-	
-	public Entity readEntityData(EdmEntitySet edmEntitySet, List<UriParameter> keyParams) throws ODataApplicationException{
-		
-		EdmEntityType edmEntityType = edmEntitySet.getEntityType();
-		
-		// actually, this is only required if we have more than one Entity Type
-		if(edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)){
-			return getProduct(edmEntityType, keyParams);
-		}
-		
-		return null;
-	}
-
-	
-	public Entity createEntityData(EdmEntitySet edmEntitySet, Entity entityToCreate) {
-		
-		EdmEntityType edmEntityType = edmEntitySet.getEntityType();
-		
-		// actually, this is only required if we have more than one Entity Type
-		if(edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)){
-			return createProduct(edmEntityType, entityToCreate);
-		}
-		
-		return null;
-	}
-
-
-	/**
-	 * This method is invoked for PATCH or PUT requests
-	 * */
-	public void updateEntityData(EdmEntitySet edmEntitySet, List<UriParameter> keyParams, Entity updateEntity, HttpMethod httpMethod) throws ODataApplicationException{
-		
-		EdmEntityType edmEntityType = edmEntitySet.getEntityType();
-
-		// actually, this is only required if we have more than one Entity Type
-		if(edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)){
-			updateProduct(edmEntityType, keyParams, updateEntity, httpMethod);
-		}
-	}
-	
-
-	public void deleteEntityData(EdmEntitySet edmEntitySet, List<UriParameter> keyParams) throws ODataApplicationException{
-		
-		EdmEntityType edmEntityType = edmEntitySet.getEntityType();
-		
-		// actually, this is only required if we have more than one Entity Type
-		if(edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)){
-			deleteProduct(edmEntityType, keyParams);
-		}
-	}
-
-	
-	
-	/*  INTERNAL */
-	
-	private EntityCollection getProducts(){
-		EntityCollection retEntitySet = new EntityCollection();
-		
-		for(Entity productEntity : this.productList){
-			   retEntitySet.getEntities().add(productEntity);
-		}
-		
-		return retEntitySet;
-	}
-	
-	
-	private Entity getProduct(EdmEntityType edmEntityType, List<UriParameter> keyParams) throws ODataApplicationException{ 
-		
-		// the list of entities at runtime
-		EntityCollection entitySet = getProducts();
-		
-		/*  generic approach  to find the requested entity */
-		Entity requestedEntity = Util.findEntity(edmEntityType, entitySet, keyParams);
-		
-	
-		if(requestedEntity == null){
-			// this variable is null if our data doesn't contain an entity for the requested key
-			// Throw suitable exception
-			throw new ODataApplicationException("Entity for requested key doesn't exist",
+  private List<Entity> productList;
+
+  public Storage() {
+    productList = new ArrayList<Entity>();
+    initSampleData();
+  }
+
+  /* PUBLIC FACADE */
+
+  public EntityCollection readEntitySetData(EdmEntitySet edmEntitySet) throws ODataApplicationException {
+
+    // actually, this is only required if we have more than one Entity Sets
+    if (edmEntitySet.getName().equals(DemoEdmProvider.ES_PRODUCTS_NAME)) {
+      return getProducts();
+    }
+
+    return null;
+  }
+
+  public Entity readEntityData(EdmEntitySet edmEntitySet, List<UriParameter> keyParams)
+      throws ODataApplicationException {
+
+    EdmEntityType edmEntityType = edmEntitySet.getEntityType();
+
+    // actually, this is only required if we have more than one Entity Type
+    if (edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)) {
+      return getProduct(edmEntityType, keyParams);
+    }
+
+    return null;
+  }
+
+  public Entity createEntityData(EdmEntitySet edmEntitySet, Entity entityToCreate) {
+
+    EdmEntityType edmEntityType = edmEntitySet.getEntityType();
+
+    // actually, this is only required if we have more than one Entity Type
+    if (edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)) {
+      return createProduct(edmEntityType, entityToCreate);
+    }
+
+    return null;
+  }
+
+  /**
+   * This method is invoked for PATCH or PUT requests
+   * */
+  public void updateEntityData(EdmEntitySet edmEntitySet, List<UriParameter> keyParams, Entity updateEntity,
+      HttpMethod httpMethod) throws ODataApplicationException {
+
+    EdmEntityType edmEntityType = edmEntitySet.getEntityType();
+
+    // actually, this is only required if we have more than one Entity Type
+    if (edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)) {
+      updateProduct(edmEntityType, keyParams, updateEntity, httpMethod);
+    }
+  }
+
+  public void deleteEntityData(EdmEntitySet edmEntitySet, List<UriParameter> keyParams)
+      throws ODataApplicationException {
+
+    EdmEntityType edmEntityType = edmEntitySet.getEntityType();
+
+    // actually, this is only required if we have more than one Entity Type
+    if (edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)) {
+      deleteProduct(edmEntityType, keyParams);
+    }
+  }
+
+  /* INTERNAL */
+
+  private EntityCollection getProducts() {
+    EntityCollection retEntitySet = new EntityCollection();
+
+    for (Entity productEntity : this.productList) {
+      retEntitySet.getEntities().add(productEntity);
+    }
+
+    return retEntitySet;
+  }
+
+  private Entity getProduct(EdmEntityType edmEntityType, List<UriParameter> keyParams)
+					throws ODataApplicationException {
+
+    // the list of entities at runtime
+    EntityCollection entitySet = getProducts();
+
+    /* generic approach to find the requested entity */
+    Entity requestedEntity = Util.findEntity(edmEntityType, entitySet, keyParams);
+
+    if (requestedEntity == null) {
+      // this variable is null if our data doesn't contain an entity for the requested key
+      // Throw suitable exception
+      throw new ODataApplicationException("Entity for requested key doesn't exist",
           HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
-		}
-		
-		return requestedEntity;
-	}
-		
-	
-	private Entity createProduct(EdmEntityType edmEntityType, Entity entity) {
-		
-		// the ID of the newly created product entity is generated automatically
-		int newId = 1;
-		while (productIdExists(newId)){
-			newId++;
-		}
-		
-		Property idProperty = entity.getProperty("ID");
-		if(idProperty != null){
-			idProperty.setValue(ValueType.PRIMITIVE, new Integer(newId));
-		}else{
-			// as of OData v4 spec, the key property can be omitted from the POST request body
-			entity.getProperties().add(new Property(null, "ID", ValueType.PRIMITIVE, newId));
-		}
-		
-		this.productList.add(entity);
-
-		return entity;
-		
-	}
-
-
-	private boolean productIdExists(int id){
-		
-		for(Entity entity : this.productList){
-			Integer existingID = (Integer) entity.getProperty("ID").getValue();
-			if(existingID.intValue() == id){
-				return true;
-			}
-		}
-		
-		return false;
-	}
-	
-	
-	private void updateProduct(EdmEntityType edmEntityType, List<UriParameter> keyParams, Entity entity, HttpMethod httpMethod) throws ODataApplicationException{
-		
-		Entity productEntity = getProduct(edmEntityType, keyParams);
-		if(productEntity == null){
-			throw new ODataApplicationException("Entity not found", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
-		}
-		
-		// loop over all properties and replace the values with the values of the given payload
-		// Note: ignoring ComplexType, as we don't have it in our odata model
-		List<Property> existingProperties = productEntity.getProperties();
-		for(Property existingProp : existingProperties){
-			String propName = existingProp.getName();
-			
-			// ignore the key properties, they aren't updateable
-			if(isKey(edmEntityType, propName)){
-				continue;
-			}
-			
-			Property updateProperty = entity.getProperty(propName); 
-			// the request payload might not consider ALL properties, so it can be null
-			if(updateProperty == null){
-				// if a property has NOT been added to the request payload
-				// depending on the HttpMethod, our behavior is different
-				if(httpMethod.equals(HttpMethod.PATCH)){
-					// as of the OData spec, in case of PATCH, the existing property is not touched
-					continue; // do nothing
-				}else if(httpMethod.equals(HttpMethod.PUT)){
-					// as of the OData spec, in case of PUT, the existing property is set to null (or to default value)
-					existingProp.setValue(existingProp.getValueType(), null);
-					continue;
-				}
-			}
-			
-			// change the value of the properties 
-			existingProp.setValue(existingProp.getValueType(), updateProperty.getValue());
-		}
-	}
-
-	private void deleteProduct(EdmEntityType edmEntityType, List<UriParameter> keyParams) throws ODataApplicationException{ 
-		
-		Entity productEntity = getProduct(edmEntityType, keyParams);
-		if(productEntity == null){
-			throw new ODataApplicationException("Entity not found", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
-		}
-		
-		this.productList.remove(productEntity);
-	}
-	
-	
-	
-	/* HELPER */
-	
-	
-	private boolean isKey(EdmEntityType edmEntityType, String propertyName){
-		List<EdmKeyPropertyRef> keyPropertyRefs = edmEntityType.getKeyPropertyRefs();
-		for(EdmKeyPropertyRef propRef : keyPropertyRefs){
-			String keyPropertyName = propRef.getName();
-			if(keyPropertyName.equals(propertyName)){
-				return true;
-			}
-		}
-		return false;
-	}
-
-	
-	private void initSampleData(){
-
-		// add some sample product entities
-		productList.add(new Entity()
-			.addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 1))
-			.addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "Notebook Basic 15"))
-			.addProperty(new Property(null, "Description", ValueType.PRIMITIVE, "Notebook Basic, 1.7GHz - 15 XGA - 1024MB DDR2 SDRAM - 40GB")));
-
-		productList.add(new Entity()
-			.addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 2))
-			.addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "1UMTS PDA"))
-			.addProperty(new Property(null, "Description", ValueType.PRIMITIVE, "Ultrafast 3G UMTS/HSDPA Pocket PC, supports GSM network")));
-
-		productList.add(new Entity()
-			.addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 3))
-			.addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "Ergo Screen"))
-			.addProperty(new Property(null, "Description", ValueType.PRIMITIVE, "19 Optimum Resolution 1024 x 768 @ 85Hz, resolution 1280 x 960")));
-
-	}
+    }
+
+    return requestedEntity;
+  }
+
+  private Entity createProduct(EdmEntityType edmEntityType, Entity entity) {
+
+    // the ID of the newly created product entity is generated automatically
+    int newId = 1;
+    while (productIdExists(newId)) {
+      newId++;
+    }
+
+    Property idProperty = entity.getProperty("ID");
+    if (idProperty != null) {
+      idProperty.setValue(ValueType.PRIMITIVE, new Integer(newId));
+    } else {
+      // as of OData v4 spec, the key property can be omitted from the POST request body
+      entity.getProperties().add(new Property(null, "ID", ValueType.PRIMITIVE, newId));
+    }
+
+    this.productList.add(entity);
+
+    return entity;
+
+  }
+
+  private boolean productIdExists(int id) {
+
+    for (Entity entity : this.productList) {
+      Integer existingID = (Integer) entity.getProperty("ID").getValue();
+      if (existingID.intValue() == id) {
+        return true;
+      }
+    }
+
+    return false;
+  }
+
+  private void updateProduct(EdmEntityType edmEntityType, List<UriParameter> keyParams, Entity entity,
+      HttpMethod httpMethod) throws ODataApplicationException {
+
+    Entity productEntity = getProduct(edmEntityType, keyParams);
+    if (productEntity == null) {
+      throw new ODataApplicationException("Entity not found", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
+    }
+
+    // loop over all properties and replace the values with the values of the given payload
+    // Note: ignoring ComplexType, as we don't have it in our odata model
+    List<Property> existingProperties = productEntity.getProperties();
+    for (Property existingProp : existingProperties) {
+      String propName = existingProp.getName();
+
+      // ignore the key properties, they aren't updateable
+      if (isKey(edmEntityType, propName)) {
+        continue;
+      }
+
+      Property updateProperty = entity.getProperty(propName);
+      // the request payload might not consider ALL properties, so it can be null
+      if (updateProperty == null) {
+        // if a property has NOT been added to the request payload
+        // depending on the HttpMethod, our behavior is different
+        if (httpMethod.equals(HttpMethod.PATCH)) {
+          // as of the OData spec, in case of PATCH, the existing property is not touched
+          continue; // do nothing
+        } else if (httpMethod.equals(HttpMethod.PUT)) {
+          // as of the OData spec, in case of PUT, the existing property is set to null (or to default value)
+          existingProp.setValue(existingProp.getValueType(), null);
+          continue;
+        }
+      }
+
+      // change the value of the properties
+      existingProp.setValue(existingProp.getValueType(), updateProperty.getValue());
+    }
+  }
+
+  private void deleteProduct(EdmEntityType edmEntityType, List<UriParameter> keyParams)
+      throws ODataApplicationException {
+
+    Entity productEntity = getProduct(edmEntityType, keyParams);
+    if (productEntity == null) {
+      throw new ODataApplicationException("Entity not found", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
+    }
+
+    this.productList.remove(productEntity);
+  }
+
+  /* HELPER */
+
+  private boolean isKey(EdmEntityType edmEntityType, String propertyName) {
+    List<EdmKeyPropertyRef> keyPropertyRefs = edmEntityType.getKeyPropertyRefs();
+    for (EdmKeyPropertyRef propRef : keyPropertyRefs) {
+      String keyPropertyName = propRef.getName();
+      if (keyPropertyName.equals(propertyName)) {
+        return true;
+      }
+    }
+    return false;
+  }
+
+  private void initSampleData() {
+
+    // add some sample product entities
+    productList.add(new Entity()
+        .addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 1))
+        .addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "Notebook Basic 15"))
+        .addProperty(
+            new Property(null, "Description", ValueType.PRIMITIVE,
+                "Notebook Basic, 1.7GHz - 15 XGA - 1024MB DDR2 SDRAM - 40GB")));
+
+    productList.add(new Entity()
+        .addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 2))
+        .addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "1UMTS PDA"))
+        .addProperty(
+            new Property(null, "Description", ValueType.PRIMITIVE,
+                "Ultrafast 3G UMTS/HSDPA Pocket PC, supports GSM network")));
+
+    productList.add(new Entity()
+        .addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 3))
+        .addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "Ergo Screen"))
+        .addProperty(
+            new Property(null, "Description", ValueType.PRIMITIVE,
+                "19 Optimum Resolution 1024 x 768 @ 85Hz, resolution 1280 x 960")));
+
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/431938c1/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoEdmProvider.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoEdmProvider.java b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoEdmProvider.java
index 6a64b31..f842af8 100755
--- a/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoEdmProvider.java
+++ b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoEdmProvider.java
@@ -42,7 +42,6 @@ import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
  */
 public class DemoEdmProvider extends CsdlAbstractEdmProvider {
 
-
   // Service Namespace
   public static final String NAMESPACE = "OData.Demo";
 
@@ -87,9 +86,12 @@ public class DemoEdmProvider extends CsdlAbstractEdmProvider {
     if(entityTypeName.equals(ET_PRODUCT_FQN)){
 
       //create EntityType properties
-      CsdlProperty id = new CsdlProperty().setName("ID").setType(EdmPrimitiveTypeKind.Int32.getFullQualifiedName());
-      CsdlProperty name = new CsdlProperty().setName("Name").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
-      CsdlProperty  description = new CsdlProperty().setName("Description").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
+      CsdlProperty id = new CsdlProperty().setName("ID")
+              .setType(EdmPrimitiveTypeKind.Int32.getFullQualifiedName());
+      CsdlProperty name = new CsdlProperty().setName("Name")
+              .setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
+      CsdlProperty  description = new CsdlProperty().setName("Description")
+              .setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
 
       // create CsdlPropertyRef for Key element
       CsdlPropertyRef propertyRef = new CsdlPropertyRef();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/431938c1/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoEntityProcessor.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoEntityProcessor.java b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoEntityProcessor.java
index 10d5023..35d4203 100755
--- a/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoEntityProcessor.java
+++ b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoEntityProcessor.java
@@ -56,13 +56,11 @@ public class DemoEntityProcessor implements EntityProcessor {
 	private OData odata;
 	private Storage storage;
 	private ServiceMetadata serviceMetadata;
-	
-	
+
 	public DemoEntityProcessor(Storage storage) {
 		this.storage = storage;
 	}
 
-	
 	public void init(OData odata, ServiceMetadata serviceMetadata) {
 		this.odata = odata;
 		this.serviceMetadata = serviceMetadata;
@@ -111,7 +109,8 @@ public class DemoEntityProcessor implements EntityProcessor {
 			"Description":"17 Optimum Resolution 1024 x 768 @ 85Hz, resolution 1280 x 960"
 		}
 	 * */
-	public void createEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType requestFormat, ContentType responseFormat) 
+	public void createEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo,
+													 ContentType requestFormat, ContentType responseFormat)
 				throws ODataApplicationException, DeserializerException, SerializerException {
 		
 		// 1. Retrieve the entity type from the URI 
@@ -143,7 +142,8 @@ public class DemoEntityProcessor implements EntityProcessor {
 	}
 
 	
-	public void updateEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType requestFormat, ContentType responseFormat) 
+	public void updateEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo,
+                           ContentType requestFormat, ContentType responseFormat)
 							throws ODataApplicationException, DeserializerException, SerializerException {
 		
 		// 1. Retrieve the entity set which belongs to the requested entity 
@@ -171,7 +171,8 @@ public class DemoEntityProcessor implements EntityProcessor {
 	}
 
 	
-	public void deleteEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo) throws ODataApplicationException {
+	public void deleteEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo)
+          throws ODataApplicationException {
 		
 		// 1. Retrieve the entity set which belongs to the requested entity 
 		List<UriResource> resourcePaths = uriInfo.getUriResourceParts();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/431938c1/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoPrimitiveProcessor.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoPrimitiveProcessor.java b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoPrimitiveProcessor.java
index ec4ba3a..ccf6d2b 100755
--- a/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoPrimitiveProcessor.java
+++ b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoPrimitiveProcessor.java
@@ -63,7 +63,6 @@ public class DemoPrimitiveProcessor implements PrimitiveProcessor {
 		this.odata = odata;
 	}
 	
-
 	/*
 	 * In our example, the URL would be: http://localhost:8080/DemoService/DemoService.svc/Products(1)/Name
 	 * and the response:
@@ -97,13 +96,15 @@ public class DemoPrimitiveProcessor implements PrimitiveProcessor {
 		// 2.1. retrieve the entity data, for which the property has to be read
 		Entity entity = storage.readEntityData(edmEntitySet, keyPredicates);
 		if (entity == null) { // Bad request
-			throw new ODataApplicationException("Entity not found", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
+			throw new ODataApplicationException("Entity not found",
+							HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
 		} 
 		
 		// 2.2. retrieve the property data from the entity
 		Property property = entity.getProperty(edmPropertyName);
 		if (property == null) {
-			throw new ODataApplicationException("Property not found", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
+			throw new ODataApplicationException("Property not found",
+              HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
 		}		
 		
 		// 3. serialize
@@ -132,12 +133,14 @@ public class DemoPrimitiveProcessor implements PrimitiveProcessor {
 	 * These processor methods are not handled in this tutorial 
 	 *
 	 * */
-	public void updatePrimitive(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType requestFormat, ContentType responseFormat)
+	public void updatePrimitive(ODataRequest request, ODataResponse response, UriInfo uriInfo,
+                              ContentType requestFormat, ContentType responseFormat)
 								throws ODataApplicationException, DeserializerException, SerializerException {
 		throw new ODataApplicationException("Not supported.", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
 	}
 
-	public void deletePrimitive(ODataRequest request, ODataResponse response, UriInfo uriInfo) throws ODataApplicationException {
+	public void deletePrimitive(ODataRequest request, ODataResponse response, UriInfo uriInfo)
+          throws ODataApplicationException {
 		throw new ODataApplicationException("Not supported.", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
 	}
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/431938c1/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/util/Util.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/util/Util.java b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/util/Util.java
index 8ad19a0..035cc7b 100755
--- a/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/util/Util.java
+++ b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/util/Util.java
@@ -71,8 +71,7 @@ public class Util {
     return null;
   }
 
-  public static boolean
-      entityMatchesAllKeys(EdmEntityType edmEntityType, Entity entity, List<UriParameter> keyParams)
+  public static boolean entityMatchesAllKeys(EdmEntityType edmEntityType, Entity entity, List<UriParameter> keyParams)
           throws ODataApplicationException {
 
     // loop over all keys


[20/39] olingo-odata4 git commit: [OLINGO-694] Added 'samples' profile

Posted by ch...@apache.org.
[OLINGO-694] Added 'samples' profile


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

Branch: refs/heads/IEE754Compatible
Commit: 5e2c60dbfdfa9cbfb080b7b55eaeb731ccce9181
Parents: afda326
Author: Michael Bolz <mi...@sap.com>
Authored: Wed Jun 17 15:36:48 2015 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Wed Jun 17 15:36:48 2015 +0200

----------------------------------------------------------------------
 samples/pom.xml | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5e2c60db/samples/pom.xml
----------------------------------------------------------------------
diff --git a/samples/pom.xml b/samples/pom.xml
index a4c1e14..765bd95 100644
--- a/samples/pom.xml
+++ b/samples/pom.xml
@@ -23,7 +23,6 @@
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
 
-  <groupId>org.apache.olingo</groupId>
   <artifactId>odata-samples</artifactId>
   <packaging>pom</packaging>
   <name>${project.artifactId}</name>
@@ -38,4 +37,13 @@
   <modules>
     <module>server</module>
   </modules>
+
+  <profiles>
+    <profile>
+      <id>samples</id>
+      <modules>
+        <module>client</module>
+      </modules>
+    </profile>
+  </profiles>
 </project>


[33/39] olingo-odata4 git commit: [OLINGO-694] Exclude samples from cobertura coverage

Posted by ch...@apache.org.
[OLINGO-694] Exclude samples from cobertura coverage


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

Branch: refs/heads/IEE754Compatible
Commit: 4a002aabfd65874a4b9c34f13a77a21fcfdce365
Parents: fd513e2
Author: Michael Bolz <mi...@sap.com>
Authored: Mon Jun 22 13:51:04 2015 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Mon Jun 22 13:51:04 2015 +0200

----------------------------------------------------------------------
 fit/pom.xml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4a002aab/fit/pom.xml
----------------------------------------------------------------------
diff --git a/fit/pom.xml b/fit/pom.xml
index de9743d..80c8daa 100644
--- a/fit/pom.xml
+++ b/fit/pom.xml
@@ -191,6 +191,7 @@
         <configuration>
           <instrumentation>
             <excludes>
+              <exclude>org/apache/olingo/**/sample/**/*.class</exclude>
               <exclude>org/apache/olingo/**/tecsvc/**/*.class</exclude>
               <exclude>org/apache/olingo/**/fit/**/*.class</exclude>
               <exclude>org/apache/olingo/**/testutil/**/*.class</exclude>
@@ -201,7 +202,7 @@
           <aggregate>true</aggregate>
         </configuration>
       </plugin>
-      
+
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-failsafe-plugin</artifactId>


[25/39] olingo-odata4 git commit: [OLINGO-694] Adapted RAT plugin and fixed missing headers

Posted by ch...@apache.org.
[OLINGO-694] Adapted RAT plugin and fixed missing headers


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

Branch: refs/heads/IEE754Compatible
Commit: 89d134e62f4cbdc3728de34ae04a9bd4eba8ff38
Parents: f24c387
Author: Michael Bolz <mi...@sap.com>
Authored: Thu Jun 18 16:27:11 2015 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Thu Jun 18 16:27:11 2015 +0200

----------------------------------------------------------------------
 pom.xml                                           |  1 +
 .../java/myservice/mynamespace/data/Storage.java  | 18 ++++++++++++++++++
 .../mynamespace/service/DemoEdmProvider.java      | 18 ++++++++++++++++++
 .../service/DemoEntityCollectionProcessor.java    | 18 ++++++++++++++++++
 .../mynamespace/service/DemoEntityProcessor.java  | 18 ++++++++++++++++++
 .../service/DemoPrimitiveProcessor.java           | 18 ++++++++++++++++++
 6 files changed, 91 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/89d134e6/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 84ae718..144f56a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -552,6 +552,7 @@
             </goals>
             <configuration>
               <excludes>
+                <exclude>**/target/**</exclude>
                 <exclude>**/META-INF/**</exclude>
                 <exclude>**/*.txt</exclude>
                 <exclude>**/*.ini</exclude>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/89d134e6/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/data/Storage.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/data/Storage.java b/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/data/Storage.java
index be985f5..d5d16c2 100755
--- a/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/data/Storage.java
+++ b/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/data/Storage.java
@@ -1,3 +1,21 @@
+/*
+ * 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 myservice.mynamespace.data;
 
 import java.util.ArrayList;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/89d134e6/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoEdmProvider.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoEdmProvider.java b/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoEdmProvider.java
index 0b091ff..15140e1 100755
--- a/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoEdmProvider.java
+++ b/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoEdmProvider.java
@@ -1,3 +1,21 @@
+/*
+ * 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 myservice.mynamespace.service;
 
 import java.util.ArrayList;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/89d134e6/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoEntityCollectionProcessor.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoEntityCollectionProcessor.java b/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoEntityCollectionProcessor.java
index 0835a41..d69d529 100755
--- a/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoEntityCollectionProcessor.java
+++ b/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoEntityCollectionProcessor.java
@@ -1,3 +1,21 @@
+/*
+ * 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 myservice.mynamespace.service;
 
 import java.io.InputStream;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/89d134e6/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoEntityProcessor.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoEntityProcessor.java b/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoEntityProcessor.java
index dc633b1..e3c8767 100755
--- a/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoEntityProcessor.java
+++ b/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoEntityProcessor.java
@@ -1,3 +1,21 @@
+/*
+ * 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 myservice.mynamespace.service;
 
 import java.io.InputStream;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/89d134e6/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoPrimitiveProcessor.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoPrimitiveProcessor.java b/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoPrimitiveProcessor.java
index 7c5b315..1ba0c75 100755
--- a/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoPrimitiveProcessor.java
+++ b/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/service/DemoPrimitiveProcessor.java
@@ -1,3 +1,21 @@
+/*
+ * 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 myservice.mynamespace.service;
 
 import java.io.InputStream;


[17/39] olingo-odata4 git commit: [OLINGO-698] technical service supports preferences, part 1

Posted by ch...@apache.org.
[OLINGO-698] technical service supports preferences, part 1

Signed-off-by: Christian Amend <ch...@sap.com>


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

Branch: refs/heads/IEE754Compatible
Commit: e5fe04aeeb1efb22404eec493fc341bf4cd0f251
Parents: a298e1f
Author: Klaus Straubinger <kl...@sap.com>
Authored: Tue Jun 16 16:47:39 2015 +0200
Committer: Christian Amend <ch...@sap.com>
Committed: Tue Jun 16 16:50:15 2015 +0200

----------------------------------------------------------------------
 .../fit/tecsvc/client/ActionImportITCase.java   | 197 ++++++++++---------
 .../olingo/fit/tecsvc/client/BasicITCase.java   | 127 ++++++------
 .../tecsvc/client/PrimitiveComplexITCase.java   |  16 ++
 .../tecsvc/client/SystemQueryOptionITCase.java  |  23 ++-
 .../olingo/commons/api/http/HttpHeader.java     |  15 +-
 .../processor/TechnicalActionProcessor.java     | 180 +++++++++++------
 .../processor/TechnicalEntityProcessor.java     |  69 +++++--
 .../TechnicalPrimitiveComplexProcessor.java     |  29 ++-
 .../options/ServerSidePagingHandler.java        | 115 ++++++-----
 9 files changed, 479 insertions(+), 292 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e5fe04ae/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
index 0c40003..0e68a4a 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
@@ -25,6 +25,7 @@ import static org.junit.Assert.fail;
 import java.math.BigDecimal;
 import java.net.URI;
 import java.util.Calendar;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -32,6 +33,8 @@ import java.util.TimeZone;
 
 import org.apache.olingo.client.api.ODataClient;
 import org.apache.olingo.client.api.communication.ODataClientErrorException;
+import org.apache.olingo.client.api.communication.header.HeaderName;
+import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest;
 import org.apache.olingo.client.api.communication.response.ODataInvokeResponse;
 import org.apache.olingo.client.api.domain.ClientCollectionValue;
 import org.apache.olingo.client.api.domain.ClientComplexValue;
@@ -42,6 +45,7 @@ import org.apache.olingo.client.api.domain.ClientValue;
 import org.apache.olingo.client.core.ODataClientFactory;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.http.HttpStatusCode;
 import org.apache.olingo.fit.AbstractBaseTestITCase;
 import org.apache.olingo.fit.tecsvc.TecSvcConst;
 import org.junit.Test;
@@ -50,50 +54,62 @@ public class ActionImportITCase extends AbstractBaseTestITCase {
 
   @Test
   public void noReturnTypeAction() throws Exception {
-      URI actionURI =
-          getClient().newURIBuilder(TecSvcConst.BASE_URI).appendActionCallSegment("AIRT").build();
-      ODataInvokeResponse<ClientProperty> response =
-          getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ClientProperty.class).execute();
-      assertEquals(204, response.getStatusCode());
+    final URI actionURI = getClient().newURIBuilder(TecSvcConst.BASE_URI)
+        .appendActionCallSegment("AIRT").build();
+    ODataInvokeResponse<ClientProperty> response =
+        getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ClientProperty.class).execute();
+    assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
   }
-  
+
   @Test
-  public void primitveAction() throws Exception {
-    URI actionURI =
-        getClient().newURIBuilder(TecSvcConst.BASE_URI).appendActionCallSegment("AIRTString").build();
+  public void primitiveAction() throws Exception {
+    final URI actionURI = getClient().newURIBuilder(TecSvcConst.BASE_URI)
+        .appendActionCallSegment("AIRTString").build();
     ODataInvokeResponse<ClientProperty> response =
         getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ClientProperty.class).execute();
-    assertEquals(200, response.getStatusCode());
+    assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
     assertEquals("UARTString string value", response.getBody().getPrimitiveValue().toValue());
   }
 
   @Test
-  public void primitveActionInvalidParameters() throws Exception {
-    Map<String, ClientValue> parameters = new HashMap<String, ClientValue>();
-    parameters.put("Invalid", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(1));
-    URI actionURI =
-        getClient().newURIBuilder(TecSvcConst.BASE_URI).appendActionCallSegment("AIRTString").build();
+  public void primitiveActionMinimalResponse() throws Exception {
+    final URI actionURI = getClient().newURIBuilder(TecSvcConst.BASE_URI)
+        .appendActionCallSegment("AIRTString").build();
+    ODataInvokeRequest<ClientProperty> request = getClient().getInvokeRequestFactory()
+        .getActionInvokeRequest(actionURI, ClientProperty.class);
+    request.setPrefer(getClient().newPreferences().returnMinimal());
+    final ODataInvokeResponse<ClientProperty> response = request.execute();
+    assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
+    assertEquals("return=\"minimal\"", response.getHeader(HeaderName.preferenceApplied).iterator().next());
+  }
+
+  @Test
+  public void primitiveActionInvalidParameters() throws Exception {
+    final URI actionURI = getClient().newURIBuilder(TecSvcConst.BASE_URI)
+        .appendActionCallSegment("AIRTString").build();
+    Map<String, ClientValue> parameters = Collections.singletonMap("Invalid",
+        (ClientValue) getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(1));
     try {
       getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ClientProperty.class, parameters)
-      .execute();
+          .execute();
       fail("Expected an ODataClientErrorException");
     } catch (ODataClientErrorException e) {
-      assertEquals(400, e.getStatusLine().getStatusCode());
+      assertEquals(HttpStatusCode.BAD_REQUEST.getStatusCode(), e.getStatusLine().getStatusCode());
     }
   }
 
   @Test
-  public void primitveCollectionAction() throws Exception {
-    URI actionURI =
-        getClient().newURIBuilder(TecSvcConst.BASE_URI).appendActionCallSegment("AIRTCollStringTwoParam").build();
+  public void primitiveCollectionAction() throws Exception {
+    final URI actionURI = getClient().newURIBuilder(TecSvcConst.BASE_URI)
+        .appendActionCallSegment("AIRTCollStringTwoParam").build();
     Map<String, ClientValue> parameters = new HashMap<String, ClientValue>();
     parameters.put("ParameterInt16", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt16((short) 3));
-    parameters.put("ParameterDuration", getClient().getObjectFactory().newPrimitiveValueBuilder().setType(
-        EdmPrimitiveTypeKind.Duration).setValue(new BigDecimal(1)).build());
+    parameters.put("ParameterDuration", getClient().getObjectFactory().newPrimitiveValueBuilder()
+        .setType(EdmPrimitiveTypeKind.Duration).setValue(new BigDecimal(1)).build());
     ODataInvokeResponse<ClientProperty> response =
         getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ClientProperty.class, parameters)
-        .execute();
-    assertEquals(200, response.getStatusCode());
+            .execute();
+    assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
     ClientCollectionValue<ClientValue> valueArray = response.getBody().getCollectionValue();
     assertEquals(3, valueArray.size());
     Iterator<ClientValue> iterator = valueArray.iterator();
@@ -104,14 +120,14 @@ public class ActionImportITCase extends AbstractBaseTestITCase {
 
   @Test
   public void complexAction() throws Exception {
-    URI actionURI =
-        getClient().newURIBuilder(TecSvcConst.BASE_URI).appendActionCallSegment("AIRTCTTwoPrimParam").build();
-    Map<String, ClientValue> parameters = new HashMap<String, ClientValue>();
-    parameters.put("ParameterInt16", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt16((short) 3));
+    final URI actionURI = getClient().newURIBuilder(TecSvcConst.BASE_URI)
+        .appendActionCallSegment("AIRTCTTwoPrimParam").build();
+    Map<String, ClientValue> parameters = Collections.singletonMap("ParameterInt16",
+        (ClientValue) getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt16((short) 3));
     ODataInvokeResponse<ClientProperty> response =
         getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ClientProperty.class, parameters)
-        .execute();
-    assertEquals(200, response.getStatusCode());
+            .execute();
+    assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
     ClientComplexValue complexValue = response.getBody().getComplexValue();
     ClientProperty propInt16 = complexValue.get("PropertyInt16");
     assertNotNull(propInt16);
@@ -123,28 +139,28 @@ public class ActionImportITCase extends AbstractBaseTestITCase {
 
   @Test
   public void complexCollectionActionNoContent() throws Exception {
-    URI actionURI =
-        getClient().newURIBuilder(TecSvcConst.BASE_URI).appendActionCallSegment("AIRTCollCTTwoPrimParam").build();
-    Map<String, ClientValue> parameters = new HashMap<String, ClientValue>();
-    parameters.put("ParameterInt16", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt16((short) 0));
+    final URI actionURI = getClient().newURIBuilder(TecSvcConst.BASE_URI)
+        .appendActionCallSegment("AIRTCollCTTwoPrimParam").build();
+    Map<String, ClientValue> parameters = Collections.singletonMap("ParameterInt16",
+        (ClientValue) getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt16((short) 0));
     ODataInvokeResponse<ClientProperty> response =
         getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ClientProperty.class, parameters)
-        .execute();
-    assertEquals(200, response.getStatusCode());
+            .execute();
+    assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
     ClientCollectionValue<ClientValue> complexValueCollection = response.getBody().getCollectionValue();
     assertEquals(0, complexValueCollection.size());
   }
 
   @Test
   public void complexCollectionActionSubContent() throws Exception {
-    URI actionURI =
-        getClient().newURIBuilder(TecSvcConst.BASE_URI).appendActionCallSegment("AIRTCollCTTwoPrimParam").build();
-    Map<String, ClientValue> parameters = new HashMap<String, ClientValue>();
-    parameters.put("ParameterInt16", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt16((short) 1));
+    final URI actionURI = getClient().newURIBuilder(TecSvcConst.BASE_URI)
+        .appendActionCallSegment("AIRTCollCTTwoPrimParam").build();
+    Map<String, ClientValue> parameters = Collections.singletonMap("ParameterInt16",
+        (ClientValue) getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt16((short) 1));
     ODataInvokeResponse<ClientProperty> response =
         getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ClientProperty.class, parameters)
-        .execute();
-    assertEquals(200, response.getStatusCode());
+            .execute();
+    assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
     ClientCollectionValue<ClientValue> complexValueCollection = response.getBody().getCollectionValue();
     assertEquals(1, complexValueCollection.size());
     Iterator<ClientValue> iterator = complexValueCollection.iterator();
@@ -156,14 +172,14 @@ public class ActionImportITCase extends AbstractBaseTestITCase {
 
   @Test
   public void complexCollectionActionAllContent() throws Exception {
-    URI actionURI =
-        getClient().newURIBuilder(TecSvcConst.BASE_URI).appendActionCallSegment("AIRTCollCTTwoPrimParam").build();
-    Map<String, ClientValue> parameters = new HashMap<String, ClientValue>();
-    parameters.put("ParameterInt16", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt16((short) 3));
+    final URI actionURI = getClient().newURIBuilder(TecSvcConst.BASE_URI)
+        .appendActionCallSegment("AIRTCollCTTwoPrimParam").build();
+    Map<String, ClientValue> parameters = Collections.singletonMap("ParameterInt16",
+        (ClientValue) getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt16((short) 3));
     ODataInvokeResponse<ClientProperty> response =
         getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ClientProperty.class, parameters)
-        .execute();
-    assertEquals(200, response.getStatusCode());
+            .execute();
+    assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
     ClientCollectionValue<ClientValue> complexValueCollection = response.getBody().getCollectionValue();
     assertEquals(3, complexValueCollection.size());
     Iterator<ClientValue> iterator = complexValueCollection.iterator();
@@ -183,15 +199,14 @@ public class ActionImportITCase extends AbstractBaseTestITCase {
 
   @Test
   public void entityActionETTwoKeyTwoPrim() throws Exception {
-    URI actionURI =
-        getClient().newURIBuilder(TecSvcConst.BASE_URI).appendActionCallSegment("AIRTETTwoKeyTwoPrimParam").build();
-    Map<String, ClientValue> parameters = new HashMap<String, ClientValue>();
-    parameters
-    .put("ParameterInt16", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt16((short) -365));
+    final URI actionURI = getClient().newURIBuilder(TecSvcConst.BASE_URI)
+        .appendActionCallSegment("AIRTETTwoKeyTwoPrimParam").build();
+    Map<String, ClientValue> parameters = Collections.singletonMap("ParameterInt16",
+        (ClientValue) getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt16((short) -365));
     ODataInvokeResponse<ClientEntity> response =
         getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ClientEntity.class, parameters)
-        .execute();
-    assertEquals(200, response.getStatusCode());
+            .execute();
+    assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
     ClientEntity entity = response.getBody();
     ClientProperty propInt16 = entity.getProperty("PropertyInt16");
     assertNotNull(propInt16);
@@ -203,15 +218,14 @@ public class ActionImportITCase extends AbstractBaseTestITCase {
 
   @Test
   public void entityCollectionActionETKeyNav() throws Exception {
-    URI actionURI =
-        getClient().newURIBuilder(TecSvcConst.BASE_URI).appendActionCallSegment("AIRTCollETKeyNavParam").build();
-    Map<String, ClientValue> parameters = new HashMap<String, ClientValue>();
-    parameters
-    .put("ParameterInt16", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt16((short) 3));
+    final URI actionURI = getClient().newURIBuilder(TecSvcConst.BASE_URI)
+        .appendActionCallSegment("AIRTCollETKeyNavParam").build();
+    Map<String, ClientValue> parameters = Collections.singletonMap("ParameterInt16",
+        (ClientValue) getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt16((short) 3));
     ODataInvokeResponse<ClientEntitySet> response =
         getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ClientEntitySet.class, parameters)
-        .execute();
-    assertEquals(200, response.getStatusCode());
+            .execute();
+    assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
     ClientEntitySet entitySet = response.getBody();
     assertEquals(3, entitySet.getEntities().size());
     Integer key = 1;
@@ -223,51 +237,49 @@ public class ActionImportITCase extends AbstractBaseTestITCase {
 
   @Test
   public void entityCollectionActionETKeyNavEmptyCollection() throws Exception {
-    URI actionURI =
-        getClient().newURIBuilder(TecSvcConst.BASE_URI).appendActionCallSegment("AIRTCollETKeyNavParam").build();
-    Map<String, ClientValue> parameters = new HashMap<String, ClientValue>();
-    parameters
-    .put("ParameterInt16", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt16((short) 0));
+    final URI actionURI = getClient().newURIBuilder(TecSvcConst.BASE_URI)
+        .appendActionCallSegment("AIRTCollETKeyNavParam").build();
+    Map<String, ClientValue> parameters = Collections.singletonMap("ParameterInt16",
+        (ClientValue) getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt16((short) 0));
     ODataInvokeResponse<ClientEntitySet> response =
         getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ClientEntitySet.class, parameters)
-        .execute();
-    assertEquals(200, response.getStatusCode());
+            .execute();
+    assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
     ClientEntitySet entitySet = response.getBody();
     assertEquals(0, entitySet.getEntities().size());
   }
 
   @Test
   public void entityCollectionActionETKeyNavNegativeParam() throws Exception {
-    URI actionURI =
-        getClient().newURIBuilder(TecSvcConst.BASE_URI).appendActionCallSegment("AIRTCollETKeyNavParam").build();
-    Map<String, ClientValue> parameters = new HashMap<String, ClientValue>();
-    parameters
-    .put("ParameterInt16", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt16((short) -10));
+    final URI actionURI = getClient().newURIBuilder(TecSvcConst.BASE_URI)
+        .appendActionCallSegment("AIRTCollETKeyNavParam").build();
+    Map<String, ClientValue> parameters = Collections.singletonMap("ParameterInt16",
+        (ClientValue) getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt16((short) -10));
     ODataInvokeResponse<ClientEntitySet> response =
         getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ClientEntitySet.class, parameters)
-        .execute();
-    assertEquals(200, response.getStatusCode());
+            .execute();
+    assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
     ClientEntitySet entitySet = response.getBody();
     assertEquals(0, entitySet.getEntities().size());
   }
 
   @Test
   public void entityCollectionActionETAllPrim() throws Exception {
-    URI actionURI =
-        getClient().newURIBuilder(TecSvcConst.BASE_URI).appendActionCallSegment("AIRTCollESAllPrimParam").build();
+    final URI actionURI = getClient().newURIBuilder(TecSvcConst.BASE_URI)
+        .appendActionCallSegment("AIRTCollESAllPrimParam").build();
     Calendar time = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
     time.clear();
     time.set(Calendar.HOUR_OF_DAY, 3);
     time.set(Calendar.MINUTE, 0);
     time.set(Calendar.SECOND, 0);
-    Map<String, ClientValue> parameters = new HashMap<String, ClientValue>();
-    parameters
-    .put("ParameterTimeOfDay", getClient().getObjectFactory().newPrimitiveValueBuilder().setType(
-        EdmPrimitiveTypeKind.TimeOfDay).setValue(time).build());
+    Map<String, ClientValue> parameters = Collections.singletonMap(
+        "ParameterTimeOfDay",
+        (ClientValue) getClient().getObjectFactory().newPrimitiveValueBuilder()
+            .setType(EdmPrimitiveTypeKind.TimeOfDay).setValue(time).build());
     ODataInvokeResponse<ClientEntitySet> response =
         getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ClientEntitySet.class, parameters)
-        .execute();
-    assertEquals(200, response.getStatusCode());
+            .execute();
+    assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
     ClientEntitySet entitySet = response.getBody();
     assertEquals(3, entitySet.getEntities().size());
     Integer key = 1;
@@ -279,20 +291,19 @@ public class ActionImportITCase extends AbstractBaseTestITCase {
 
   @Test
   public void entityActionETAllPrim() throws Exception {
-    URI actionURI =
-        getClient().newURIBuilder(TecSvcConst.BASE_URI).appendActionCallSegment("AIRTESAllPrimParam").build();
+    final URI actionURI = getClient().newURIBuilder(TecSvcConst.BASE_URI)
+        .appendActionCallSegment("AIRTESAllPrimParam").build();
     Calendar dateTime = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
     dateTime.clear();
     dateTime.set(1012, 2, 0, 0, 0, 0);
-    Map<String, ClientValue> parameters = new HashMap<String, ClientValue>();
-    parameters
-    .put("ParameterDate", getClient().getObjectFactory().newPrimitiveValueBuilder().setType(
-        EdmPrimitiveTypeKind.Date).setValue(dateTime).build());
+    Map<String, ClientValue> parameters = Collections.singletonMap(
+        "ParameterDate",
+        (ClientValue) getClient().getObjectFactory().newPrimitiveValueBuilder()
+            .setType(EdmPrimitiveTypeKind.Date).setValue(dateTime).build());
     ODataInvokeResponse<ClientEntity> response =
         getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ClientEntity.class, parameters)
-        .execute();
-    // Check 201
-    assertEquals(201, response.getStatusCode());
+            .execute();
+    assertEquals(HttpStatusCode.CREATED.getStatusCode(), response.getStatusCode());
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e5fe04ae/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
index 819aab7..0f3a099 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
@@ -37,6 +37,7 @@ import java.util.List;
 import org.apache.olingo.client.api.EdmEnabledODataClient;
 import org.apache.olingo.client.api.ODataClient;
 import org.apache.olingo.client.api.communication.ODataClientErrorException;
+import org.apache.olingo.client.api.communication.header.HeaderName;
 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;
@@ -401,6 +402,24 @@ public class BasicITCase extends AbstractBaseTestITCase {
   }
 
   @Test
+  public void createEntityMinimalResponse() throws Exception {
+    final ODataClient client = getClient();
+    final ClientObjectFactory factory = client.getObjectFactory();
+    ClientEntity newEntity = factory.newEntity(new FullQualifiedName("olingo.odata.test1", "ETTwoPrim"));
+    newEntity.getProperties().add(factory.newPrimitiveProperty("PropertyString",
+        factory.newPrimitiveValueBuilder().buildString("new")));
+    ODataEntityCreateRequest<ClientEntity> request = client.getCUDRequestFactory().getEntityCreateRequest(
+        client.newURIBuilder(SERVICE_URI).appendEntitySetSegment("ESTwoPrim").build(),
+        newEntity);
+    request.setPrefer(getClient().newPreferences().returnMinimal());
+
+    final ODataEntityCreateResponse<ClientEntity> response = request.execute();
+    assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
+    assertEquals("return=\"minimal\"", response.getHeader(HeaderName.preferenceApplied).iterator().next());
+    assertEquals(SERVICE_URI + "/ESTwoPrim(1)", response.getHeader(HttpHeader.LOCATION).iterator().next());
+  }
+
+  @Test
   public void readEntityWithExpandedNavigationProperty() {
     final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
     client.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
@@ -459,30 +478,20 @@ public class BasicITCase extends AbstractBaseTestITCase {
     entity.getProperties().add(
         of.newCollectionProperty("CollPropertyComp",
             of.newCollectionValue("CTPrimComp")
-            .add(
-                of.newComplexValue("CTPrimComp")
-                .add(
-                            of.newPrimitiveProperty("PropertyInt16", of.newPrimitiveValueBuilder()
-                                .buildInt16(
-                                    (short) 42)))
-                            .add(
-                            of.newComplexProperty("PropertyComp", of.newComplexValue("CTAllPrim")
-                                .add(
-                                    of.newPrimitiveProperty("PropertyString", of
-                                        .newPrimitiveValueBuilder()
-                                        .buildString("42"))))))
-                                            .add(
-                                                of.newComplexValue("CTPrimComp")
-                                                .add(
-                            of.newPrimitiveProperty("PropertyInt16", of.newPrimitiveValueBuilder()
-                                .buildInt16(
-                                    (short) 43)))
-                                                            .add(
-                            of.newComplexProperty("PropertyComp", of.newComplexValue("CTAllPrim")
-                                .add(
-                                    of.newPrimitiveProperty("PropertyString", of
-                                        .newPrimitiveValueBuilder()
-                                        .buildString("43"))))))));
+                .add(of.newComplexValue("CTPrimComp")
+                    .add(of.newPrimitiveProperty("PropertyInt16",
+                        of.newPrimitiveValueBuilder().buildInt16((short) 42)))
+                    .add(of.newComplexProperty("PropertyComp",
+                        of.newComplexValue("CTAllPrim")
+                            .add(of.newPrimitiveProperty("PropertyString",
+                                of.newPrimitiveValueBuilder().buildString("42"))))))
+                .add(of.newComplexValue("CTPrimComp")
+                    .add(of.newPrimitiveProperty("PropertyInt16",
+                        of.newPrimitiveValueBuilder().buildInt16((short) 43)))
+                    .add(of.newComplexProperty("PropertyComp",
+                        of.newComplexValue("CTAllPrim")
+                            .add(of.newPrimitiveProperty("PropertyString",
+                                of.newPrimitiveValueBuilder().buildString("43"))))))));
 
     final URI uri = getClient().newURIBuilder(SERVICE_URI)
         .appendEntitySetSegment("ESKeyNav")
@@ -681,13 +690,15 @@ public class BasicITCase extends AbstractBaseTestITCase {
     entity.getProperties().add(of.newPrimitiveProperty("PropertyString", of.newPrimitiveValueBuilder()
         .buildString(null)));
 
-    final ODataEntityUpdateResponse<ClientEntity> updateResponse = client.getCUDRequestFactory()
-        .getEntityUpdateRequest(targetURI, UpdateType.PATCH, entity)
-        .execute();
+    ODataEntityUpdateRequest<ClientEntity> request = client.getCUDRequestFactory()
+        .getEntityUpdateRequest(targetURI, UpdateType.PATCH, entity);
+    request.setPrefer(getClient().newPreferences().returnRepresentation());
+    final ODataEntityUpdateResponse<ClientEntity> response = request.execute();
 
-    assertEquals(HttpStatusCode.OK.getStatusCode(), updateResponse.getStatusCode());
-    assertTrue(updateResponse.getBody().getProperty("PropertyString").hasNullValue());
-    assertEquals(34, updateResponse.getBody().getProperty("PropertyDecimal").getPrimitiveValue().toValue());
+    assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
+    assertEquals("return=\"representation\"", response.getHeader(HeaderName.preferenceApplied).iterator().next());
+    assertTrue(response.getBody().getProperty("PropertyString").hasNullValue());
+    assertEquals(34, response.getBody().getProperty("PropertyDecimal").getPrimitiveValue().toValue());
   }
 
   @Test(expected = ODataClientErrorException.class)
@@ -743,23 +754,23 @@ public class BasicITCase extends AbstractBaseTestITCase {
                 .expand("NavPropertyETKeyNavOne", "NavPropertyETKeyNavMany")
                 .build());
     entityRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
-    final ODataRetrieveResponse<ClientEntity> entitytResponse = entityRequest.execute();
+    final ODataRetrieveResponse<ClientEntity> entityResponse = entityRequest.execute();
 
-    assertEquals(HttpStatusCode.OK.getStatusCode(), entitytResponse.getStatusCode());
-    assertEquals(1, entitytResponse.getBody().getNavigationLink("NavPropertyETKeyNavOne")
+    assertEquals(HttpStatusCode.OK.getStatusCode(), entityResponse.getStatusCode());
+    assertEquals(1, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavOne")
         .asInlineEntity()
         .getEntity()
         .getProperty("PropertyInt16")
         .getPrimitiveValue()
         .toValue());
 
-    assertEquals(3, entitytResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
+    assertEquals(3, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
         .asInlineEntitySet()
         .getEntitySet()
         .getEntities()
         .size());
 
-    assertEquals(1, entitytResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
+    assertEquals(1, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
         .asInlineEntitySet()
         .getEntitySet()
         .getEntities()
@@ -768,7 +779,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
         .getPrimitiveValue()
         .toValue());
 
-    assertEquals(2, entitytResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
+    assertEquals(2, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
         .asInlineEntitySet()
         .getEntitySet()
         .getEntities()
@@ -777,7 +788,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
         .getPrimitiveValue()
         .toValue());
 
-    assertEquals(3, entitytResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
+    assertEquals(3, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
         .asInlineEntitySet()
         .getEntitySet()
         .getEntities()
@@ -786,7 +797,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
         .getPrimitiveValue()
         .toValue());
 
-    final Iterator<ClientValue> collectionIterator = entitytResponse.getBody()
+    final Iterator<ClientValue> collectionIterator = entityResponse.getBody()
         .getProperty("CollPropertyString")
         .getCollectionValue()
         .iterator();
@@ -794,7 +805,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
     assertEquals("Single entry!", collectionIterator.next().asPrimitive().toValue());
     assertFalse(collectionIterator.hasNext());
 
-    final ClientComplexValue complexValue = entitytResponse.getBody()
+    final ClientComplexValue complexValue = entityResponse.getBody()
         .getProperty("PropertyCompAllPrim")
         .getComplexValue();
 
@@ -825,14 +836,14 @@ public class BasicITCase extends AbstractBaseTestITCase {
         .add(of.newPrimitiveValueBuilder().buildString("Single entry!"))));
     entity.getProperties().add(of.newComplexProperty("PropertyCompAllPrim",
         of.newComplexValue("CTAllPrim")
-        .add(of.newPrimitiveProperty("PropertyString",
-                of.newPrimitiveValueBuilder().buildString("Changed")))));
+        .add(of.newPrimitiveProperty("PropertyString", of.newPrimitiveValueBuilder().buildString("Changed")))));
 
-    final ODataEntityUpdateResponse<ClientEntity> response = client.getCUDRequestFactory()
-        .getEntityUpdateRequest(targetURI, UpdateType.REPLACE, entity)
-        .execute();
-
-    assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
+    ODataEntityUpdateRequest<ClientEntity> request = client.getCUDRequestFactory()
+        .getEntityUpdateRequest(targetURI, UpdateType.REPLACE, entity);
+    request.setPrefer(getClient().newPreferences().returnMinimal());
+    final ODataEntityUpdateResponse<ClientEntity> response = request.execute();
+    assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
+    assertEquals("return=\"minimal\"", response.getHeader(HeaderName.preferenceApplied).iterator().next());
     final String cookie = response.getHeader(HttpHeader.SET_COOKIE).iterator().next();
 
     final ODataEntityRequest<ClientEntity> entityRequest = client.getRetrieveRequestFactory()
@@ -843,23 +854,23 @@ public class BasicITCase extends AbstractBaseTestITCase {
                 .expand("NavPropertyETKeyNavOne", "NavPropertyETKeyNavMany")
                 .build());
     entityRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
-    final ODataRetrieveResponse<ClientEntity> entitytResponse = entityRequest.execute();
+    final ODataRetrieveResponse<ClientEntity> entityResponse = entityRequest.execute();
 
-    assertEquals(HttpStatusCode.OK.getStatusCode(), entitytResponse.getStatusCode());
-    assertEquals(1, entitytResponse.getBody().getNavigationLink("NavPropertyETKeyNavOne")
+    assertEquals(HttpStatusCode.OK.getStatusCode(), entityResponse.getStatusCode());
+    assertEquals(1, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavOne")
         .asInlineEntity()
         .getEntity()
         .getProperty("PropertyInt16")
         .getPrimitiveValue()
         .toValue());
 
-    assertEquals(3, entitytResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
+    assertEquals(3, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
         .asInlineEntitySet()
         .getEntitySet()
         .getEntities()
         .size());
 
-    assertEquals(1, entitytResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
+    assertEquals(1, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
         .asInlineEntitySet()
         .getEntitySet()
         .getEntities()
@@ -868,7 +879,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
         .getPrimitiveValue()
         .toValue());
 
-    assertEquals(2, entitytResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
+    assertEquals(2, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
         .asInlineEntitySet()
         .getEntitySet()
         .getEntities()
@@ -877,7 +888,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
         .getPrimitiveValue()
         .toValue());
 
-    assertEquals(3, entitytResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
+    assertEquals(3, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
         .asInlineEntitySet()
         .getEntitySet()
         .getEntities()
@@ -886,7 +897,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
         .getPrimitiveValue()
         .toValue());
 
-    final Iterator<ClientValue> collectionIterator = entitytResponse.getBody()
+    final Iterator<ClientValue> collectionIterator = entityResponse.getBody()
         .getProperty("CollPropertyString")
         .getCollectionValue()
         .iterator();
@@ -894,7 +905,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
     assertEquals("Single entry!", collectionIterator.next().asPrimitive().toValue());
     assertFalse(collectionIterator.hasNext());
 
-    final ClientComplexValue propCompAllPrim = entitytResponse.getBody()
+    final ClientComplexValue propCompAllPrim = entityResponse.getBody()
         .getProperty("PropertyCompAllPrim")
         .getComplexValue();
 
@@ -902,15 +913,15 @@ public class BasicITCase extends AbstractBaseTestITCase {
     assertTrue(propCompAllPrim.get("PropertyInt16").hasNullValue());
     assertTrue(propCompAllPrim.get("PropertyDate").hasNullValue());
 
-    final ClientComplexValue propCompTwoPrim = entitytResponse.getBody()
+    final ClientComplexValue propCompTwoPrim = entityResponse.getBody()
         .getProperty("PropertyCompTwoPrim")
         .getComplexValue();
 
     assertEquals("Must not be null", propCompTwoPrim.get("PropertyString").getPrimitiveValue().toValue());
     assertEquals(42, propCompTwoPrim.get("PropertyInt16").getPrimitiveValue().toValue());
 
-    assertNotNull(entitytResponse.getBody().getProperty("PropertyCompNav").getComplexValue());
-    assertTrue(entitytResponse.getBody()
+    assertNotNull(entityResponse.getBody().getProperty("PropertyCompNav").getComplexValue());
+    assertTrue(entityResponse.getBody()
         .getProperty("PropertyCompNav")
         .getComplexValue()
         .get("PropertyInt16")

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e5fe04ae/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/PrimitiveComplexITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/PrimitiveComplexITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/PrimitiveComplexITCase.java
index 1dbd0e6..485aace 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/PrimitiveComplexITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/PrimitiveComplexITCase.java
@@ -33,6 +33,7 @@ import java.util.Iterator;
 import org.apache.commons.io.IOUtils;
 import org.apache.olingo.client.api.ODataClient;
 import org.apache.olingo.client.api.communication.ODataClientErrorException;
+import org.apache.olingo.client.api.communication.header.HeaderName;
 import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest;
 import org.apache.olingo.client.api.communication.request.cud.ODataPropertyUpdateRequest;
 import org.apache.olingo.client.api.communication.request.cud.ODataValueUpdateRequest;
@@ -368,6 +369,21 @@ public class PrimitiveComplexITCase extends AbstractBaseTestITCase {
   }
 
   @Test
+  public void updatePropertyValueMinimalResponse() throws Exception {
+    ODataValueUpdateRequest request = getClient().getCUDRequestFactory().getValueUpdateRequest(
+        getClient().newURIBuilder(SERVICE_URI).appendEntitySetSegment("ESTwoPrim").appendKeySegment(32766)
+            .appendPropertySegment("PropertyString")
+            .build(),
+        UpdateType.REPLACE,
+        getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("Test String1"));
+    request.setPrefer(getClient().newPreferences().returnMinimal());
+
+    final ODataValueUpdateResponse response = request.execute();
+    assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
+    assertEquals("return=\"minimal\"", response.getHeader(HeaderName.preferenceApplied).iterator().next());
+  }
+
+  @Test
   public void readPrimitiveCollectionCount() {
     final ODataValueRequest request = getClient().getRetrieveRequestFactory()
         .getValueRequest(getClient().newURIBuilder(SERVICE_URI)

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e5fe04ae/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/SystemQueryOptionITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/SystemQueryOptionITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/SystemQueryOptionITCase.java
index bbd9d51..9cd8e34 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/SystemQueryOptionITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/SystemQueryOptionITCase.java
@@ -25,6 +25,8 @@ import java.net.URI;
 
 import org.apache.olingo.client.api.ODataClient;
 import org.apache.olingo.client.api.communication.ODataClientErrorException;
+import org.apache.olingo.client.api.communication.header.HeaderName;
+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.ClientEntity;
 import org.apache.olingo.client.api.domain.ClientEntitySet;
@@ -211,7 +213,7 @@ public class SystemQueryOptionITCase extends AbstractBaseTestITCase {
 
     // Check initial next link format
     URI nextLink = response.getBody().getNext();
-    assertEquals(SERVICE_URI + "/ESServerSidePaging?%24skiptoken=1", nextLink.toASCIIString());
+    assertEquals(SERVICE_URI + "/ESServerSidePaging?%24skiptoken=1%2A10", nextLink.toASCIIString());
 
     // Check subsequent next links
     response = client.getRetrieveRequestFactory()
@@ -219,7 +221,7 @@ public class SystemQueryOptionITCase extends AbstractBaseTestITCase {
         .execute();
 
     nextLink = response.getBody().getNext();
-    assertEquals(SERVICE_URI + "/ESServerSidePaging?%24skiptoken=2", nextLink.toASCIIString());
+    assertEquals(SERVICE_URI + "/ESServerSidePaging?%24skiptoken=2%2A10", nextLink.toASCIIString());
   }
 
   @Test
@@ -236,7 +238,7 @@ public class SystemQueryOptionITCase extends AbstractBaseTestITCase {
 
     // Check initial next link format
     URI nextLink = response.getBody().getNext();
-    assertEquals(SERVICE_URI + "/ESServerSidePaging?%24count=true&%24skiptoken=1",
+    assertEquals(SERVICE_URI + "/ESServerSidePaging?%24count=true&%24skiptoken=1%2A10",
         nextLink.toASCIIString());
 
     int token = 1;
@@ -250,7 +252,7 @@ public class SystemQueryOptionITCase extends AbstractBaseTestITCase {
 
       nextLink = response.getBody().getNext();
       if (nextLink != null) {
-        assertEquals(SERVICE_URI + "/ESServerSidePaging?%24count=true&%24skiptoken=" + token,
+        assertEquals(SERVICE_URI + "/ESServerSidePaging?%24count=true&%24skiptoken=" + token + "%2A10",
             nextLink.toASCIIString());
       }
     }
@@ -259,6 +261,19 @@ public class SystemQueryOptionITCase extends AbstractBaseTestITCase {
   }
 
   @Test
+  public void nextLinkFormatWithClientPageSize() {
+    final ODataClient client = getClient();
+    final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_SERVER_SIDE_PAGING).build();
+    ODataEntitySetRequest<ClientEntitySet> request = client.getRetrieveRequestFactory().getEntitySetRequest(uri);
+    request.setPrefer(getClient().newPreferences().maxPageSize(7));
+
+    final ODataRetrieveResponse<ClientEntitySet> response = request.execute();
+    assertEquals("odata.maxpagesize=\"7\"", response.getHeader(HeaderName.preferenceApplied).iterator().next());
+    assertEquals(SERVICE_URI + '/' + ES_SERVER_SIDE_PAGING + "?%24skiptoken=1%2A" + 7,
+        response.getBody().getNext().toASCIIString());
+  }
+
+  @Test
   public void testNegativeSkip() {
     ODataClient client = getClient();
     URI uri = client.newURIBuilder(SERVICE_URI)

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e5fe04ae/lib/commons-api/src/main/java/org/apache/olingo/commons/api/http/HttpHeader.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/http/HttpHeader.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/http/HttpHeader.java
index ab284b1..de804fc 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/http/HttpHeader.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/http/HttpHeader.java
@@ -162,12 +162,17 @@ public interface HttpHeader {
    */
   public static final String ODATA_MAX_VERSION = "OData-MaxVersion";
 
-  // CHECKSTYLE:OFF
   /**
-   * OData Prefer Header
-   * See
-   * {@link <a href="http://docs.oasis-open.org/odata/odata/v4.0/errata01/os/complete/part1-protocol/odata-v4.0-errata01-os-part1-protocol-complete.html#_Toc399426728"> OData Version 4.0 Part 1: Protocol Plus Errata 01</a>}
+   * OData Prefer Header.
+   * See <a href="http://docs.oasis-open.org/odata/odata/v4.0/odata-v4.0-part1-protocol.html#_Toc406398233">
+   * OData Version 4.0 Part 1: Protocol</a> and <a href="https://www.ietf.org/rfc/rfc7240.txt">RFC 7240</a>.
    */
   public static final String PREFER = "Prefer";
-  // CHECKSTYLE:ON
+
+  /**
+   * OData Preference-Applied Header.
+   * See <a href="http://docs.oasis-open.org/odata/odata/v4.0/odata-v4.0-part1-protocol.html#_Toc406398247">
+   * OData Version 4.0 Part 1: Protocol</a> and <a href="https://www.ietf.org/rfc/rfc7240.txt">RFC 7240</a>.
+   */
+  public static final String PREFERENCE_APPLIED = "Preference-Applied";
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e5fe04ae/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalActionProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalActionProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalActionProcessor.java
index da8c5cc..b2a9ca4 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalActionProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalActionProcessor.java
@@ -40,6 +40,8 @@ import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
 import org.apache.olingo.server.api.ServiceMetadata;
 import org.apache.olingo.server.api.deserializer.DeserializerResult;
+import org.apache.olingo.server.api.prefer.Preferences.Return;
+import org.apache.olingo.server.api.prefer.PreferencesApplied;
 import org.apache.olingo.server.api.processor.ActionComplexCollectionProcessor;
 import org.apache.olingo.server.api.processor.ActionComplexProcessor;
 import org.apache.olingo.server.api.processor.ActionEntityCollectionProcessor;
@@ -58,7 +60,7 @@ import org.apache.olingo.server.tecsvc.data.DataProvider;
 import org.apache.olingo.server.tecsvc.data.EntityActionResult;
 
 /**
- * Technical Processor for entity-related functionality.
+ * Technical Processor for action-related functionality.
  */
 public class TechnicalActionProcessor extends TechnicalProcessor
     implements ActionEntityCollectionProcessor, ActionEntityProcessor,
@@ -92,16 +94,26 @@ public class TechnicalActionProcessor extends TechnicalProcessor
       throw new ODataApplicationException("The action could not be executed.",
           HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), Locale.ROOT);
     }
-    final EdmEntitySet edmEntitySet = getEdmEntitySet(uriInfo.asUriInfoResource());
-    final EdmEntityType type = (EdmEntityType) action.getReturnType().getType();
-    final ODataFormat format = ODataFormat.fromContentType(responseFormat);
-    EntityCollectionSerializerOptions options = EntityCollectionSerializerOptions.with()
-        .contextURL(format == ODataFormat.JSON_NO_METADATA ? null : getContextUrl(edmEntitySet, type, false))
-        .build();
-    response.setContent(odata.createSerializer(format)
-        .entityCollection(serviceMetadata, type, collection, options).getContent());
-    response.setStatusCode(HttpStatusCode.OK.getStatusCode());
-    response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+
+    final Return returnPreference = odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).getReturn();
+    if (returnPreference == null || returnPreference == Return.REPRESENTATION) {
+      final EdmEntitySet edmEntitySet = getEdmEntitySet(uriInfo.asUriInfoResource());
+      final EdmEntityType type = (EdmEntityType) action.getReturnType().getType();
+      final ODataFormat format = ODataFormat.fromContentType(responseFormat);
+      final EntityCollectionSerializerOptions options = EntityCollectionSerializerOptions.with()
+          .contextURL(format == ODataFormat.JSON_NO_METADATA ? null : getContextUrl(edmEntitySet, type, false))
+          .build();
+      response.setContent(odata.createSerializer(format)
+          .entityCollection(serviceMetadata, type, collection, options).getContent());
+      response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+      response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+    } else {
+      response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
+    }
+    if (returnPreference != null) {
+      response.setHeader(HttpHeader.PREFERENCE_APPLIED,
+          PreferencesApplied.with().returnRepresentation(returnPreference).build().toString());
+    }
   }
 
   @Override
@@ -129,18 +141,32 @@ public class TechnicalActionProcessor extends TechnicalProcessor
             HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), Locale.ROOT);
       }
     } else {
-      final ODataFormat format = ODataFormat.fromContentType(responseFormat);
-      response.setContent(odata.createSerializer(format).entity(
-          serviceMetadata,
-          type,
-          entityResult.getEntity(),
-          EntitySerializerOptions.with()
-              .contextURL(format == ODataFormat.JSON_NO_METADATA ? null : getContextUrl(edmEntitySet, type, true))
-              .build())
-          .getContent());
-      response.setStatusCode((entityResult.isCreated() ? HttpStatusCode.CREATED : HttpStatusCode.OK)
-          .getStatusCode());
-      response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+      final Return returnPreference = odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).getReturn();
+      if (returnPreference == null || returnPreference == Return.REPRESENTATION) {
+        final ODataFormat format = ODataFormat.fromContentType(responseFormat);
+        response.setContent(odata.createSerializer(format).entity(
+            serviceMetadata,
+            type,
+            entityResult.getEntity(),
+            EntitySerializerOptions.with()
+                .contextURL(format == ODataFormat.JSON_NO_METADATA ? null : getContextUrl(edmEntitySet, type, true))
+                .build())
+            .getContent());
+        response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+        response.setStatusCode((entityResult.isCreated() ? HttpStatusCode.CREATED : HttpStatusCode.OK)
+            .getStatusCode());
+      } else {
+        response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
+      }
+      if (returnPreference != null) {
+        response.setHeader(HttpHeader.PREFERENCE_APPLIED,
+            PreferencesApplied.with().returnRepresentation(returnPreference).build().toString());
+      }
+      if (entityResult.isCreated()) {
+        response.setHeader(HttpHeader.LOCATION,
+            request.getRawBaseUri() + '/'
+            + odata.createUriHelper().buildCanonicalURL(edmEntitySet, entityResult.getEntity()));
+      }
       if (entityResult.getEntity().getETag() != null) {
         response.setHeader(HttpHeader.ETAG, entityResult.getEntity().getETag());
       }
@@ -170,17 +196,25 @@ public class TechnicalActionProcessor extends TechnicalProcessor
       throw new ODataApplicationException("The action could not be executed.",
           HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), Locale.ROOT);
     }
-    EdmPrimitiveType type = (EdmPrimitiveType) action.getReturnType().getType();
-    ContextURL contextURL = ContextURL.with().type(type).asCollection().build();
-    PrimitiveSerializerOptions options = PrimitiveSerializerOptions.with().contextURL(contextURL).build();
-
-    SerializerResult result =
-        odata.createSerializer(ODataFormat.fromContentType(responseFormat))
-            .primitiveCollection(serviceMetadata, type, property, options);
 
-    response.setStatusCode(HttpStatusCode.OK.getStatusCode());
-    response.setContent(result.getContent());
-    response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+    final Return returnPreference = odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).getReturn();
+    if (returnPreference == null || returnPreference == Return.REPRESENTATION) {
+      final EdmPrimitiveType type = (EdmPrimitiveType) action.getReturnType().getType();
+      final ContextURL contextURL = ContextURL.with().type(type).asCollection().build();
+      final PrimitiveSerializerOptions options = PrimitiveSerializerOptions.with().contextURL(contextURL).build();
+      final SerializerResult result =
+          odata.createSerializer(ODataFormat.fromContentType(responseFormat))
+              .primitiveCollection(serviceMetadata, type, property, options);
+      response.setContent(result.getContent());
+      response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+      response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+    } else {
+      response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
+    }
+    if (returnPreference != null) {
+      response.setHeader(HttpHeader.PREFERENCE_APPLIED,
+          PreferencesApplied.with().returnRepresentation(returnPreference).build().toString());
+    }
   }
 
   @Override
@@ -205,15 +239,22 @@ public class TechnicalActionProcessor extends TechnicalProcessor
             HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), Locale.ROOT);
       }
     } else {
-      ContextURL contextURL = ContextURL.with().type(type).build();
-      PrimitiveSerializerOptions options = PrimitiveSerializerOptions.with().contextURL(contextURL).build();
-
-      SerializerResult result = odata.createSerializer(ODataFormat.fromContentType(responseFormat))
-          .primitive(serviceMetadata, type, property, options);
-
-      response.setStatusCode(HttpStatusCode.OK.getStatusCode());
-      response.setContent(result.getContent());
-      response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+      final Return returnPreference = odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).getReturn();
+      if (returnPreference == null || returnPreference == Return.REPRESENTATION) {
+        final ContextURL contextURL = ContextURL.with().type(type).build();
+        final PrimitiveSerializerOptions options = PrimitiveSerializerOptions.with().contextURL(contextURL).build();
+        final SerializerResult result = odata.createSerializer(ODataFormat.fromContentType(responseFormat))
+            .primitive(serviceMetadata, type, property, options);
+        response.setContent(result.getContent());
+        response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+        response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+      } else {
+        response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
+      }
+      if (returnPreference != null) {
+        response.setHeader(HttpHeader.PREFERENCE_APPLIED,
+            PreferencesApplied.with().returnRepresentation(returnPreference).build().toString());
+      }
     }
   }
 
@@ -240,17 +281,25 @@ public class TechnicalActionProcessor extends TechnicalProcessor
       throw new ODataApplicationException("The action could not be executed.",
           HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), Locale.ROOT);
     }
-    EdmComplexType type = (EdmComplexType) action.getReturnType().getType();
-    ContextURL contextURL = ContextURL.with().type(type).asCollection().build();
-    ComplexSerializerOptions options = ComplexSerializerOptions.with().contextURL(contextURL).build();
-
-    SerializerResult result =
-        odata.createSerializer(ODataFormat.fromContentType(responseFormat)).complexCollection(serviceMetadata, type,
-            property, options);
 
-    response.setStatusCode(HttpStatusCode.OK.getStatusCode());
-    response.setContent(result.getContent());
-    response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+    final Return returnPreference = odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).getReturn();
+    if (returnPreference == null || returnPreference == Return.REPRESENTATION) {
+      final EdmComplexType type = (EdmComplexType) action.getReturnType().getType();
+      final ContextURL contextURL = ContextURL.with().type(type).asCollection().build();
+      final ComplexSerializerOptions options = ComplexSerializerOptions.with().contextURL(contextURL).build();
+      final SerializerResult result =
+          odata.createSerializer(ODataFormat.fromContentType(responseFormat)).complexCollection(serviceMetadata, type,
+              property, options);
+      response.setContent(result.getContent());
+      response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+      response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+    } else {
+      response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
+    }
+    if (returnPreference != null) {
+      response.setHeader(HttpHeader.PREFERENCE_APPLIED,
+          PreferencesApplied.with().returnRepresentation(returnPreference).build().toString());
+    }
   }
 
   @Override
@@ -275,16 +324,23 @@ public class TechnicalActionProcessor extends TechnicalProcessor
             HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), Locale.ROOT);
       }
     } else {
-      ContextURL contextURL = ContextURL.with().type(type).build();
-      ComplexSerializerOptions options = ComplexSerializerOptions.with().contextURL(contextURL).build();
-
-      SerializerResult result =
-          odata.createSerializer(ODataFormat.fromContentType(responseFormat)).complex(serviceMetadata, type, property,
-              options);
-
-      response.setStatusCode(HttpStatusCode.OK.getStatusCode());
-      response.setContent(result.getContent());
-      response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+      final Return returnPreference = odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).getReturn();
+      if (returnPreference == null || returnPreference == Return.REPRESENTATION) {
+        final ContextURL contextURL = ContextURL.with().type(type).build();
+        final ComplexSerializerOptions options = ComplexSerializerOptions.with().contextURL(contextURL).build();
+        final SerializerResult result =
+            odata.createSerializer(ODataFormat.fromContentType(responseFormat)).complex(serviceMetadata, type, property,
+                options);
+        response.setContent(result.getContent());
+        response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+        response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+      } else {
+        response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
+      }
+      if (returnPreference != null) {
+        response.setHeader(HttpHeader.PREFERENCE_APPLIED,
+            PreferencesApplied.with().returnRepresentation(returnPreference).build().toString());
+      }
     }
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e5fe04ae/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
index 575b914..217d768 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
@@ -40,6 +40,8 @@ import org.apache.olingo.server.api.ODataResponse;
 import org.apache.olingo.server.api.ServiceMetadata;
 import org.apache.olingo.server.api.deserializer.DeserializerResult;
 import org.apache.olingo.server.api.deserializer.ODataDeserializer;
+import org.apache.olingo.server.api.prefer.PreferencesApplied;
+import org.apache.olingo.server.api.prefer.Preferences.Return;
 import org.apache.olingo.server.api.processor.CountEntityCollectionProcessor;
 import org.apache.olingo.server.api.processor.EntityCollectionProcessor;
 import org.apache.olingo.server.api.processor.EntityProcessor;
@@ -162,11 +164,20 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
       expand = deserializerResult.getExpandTree();
     }
 
-    final ODataFormat format = ODataFormat.fromContentType(responseFormat);
-    response.setContent(serializeEntity(entity, edmEntitySet, edmEntityType, format, expand, null)
-        .getContent());
-    response.setStatusCode(HttpStatusCode.CREATED.getStatusCode());
-    response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+    final Return returnPreference = odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).getReturn();
+    if (returnPreference == null || returnPreference == Return.REPRESENTATION) {
+      final ODataFormat format = ODataFormat.fromContentType(responseFormat);
+      response.setContent(serializeEntity(entity, edmEntitySet, edmEntityType, format, expand, null)
+          .getContent());
+      response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+      response.setStatusCode(HttpStatusCode.CREATED.getStatusCode());
+    } else {
+      response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
+    }
+    if (returnPreference != null) {
+      response.setHeader(HttpHeader.PREFERENCE_APPLIED,
+          PreferencesApplied.with().returnRepresentation(returnPreference).build().toString());
+    }
     response.setHeader(HttpHeader.LOCATION,
         request.getRawBaseUri() + '/' + odata.createUriHelper().buildCanonicalURL(edmEntitySet, entity));
     if (entity.getETag() != null) {
@@ -209,11 +220,20 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
     dataProvider.update(request.getRawBaseUri(), edmEntitySet, entity, changedEntity,
         request.getMethod() == HttpMethod.PATCH, false);
 
-    response.setStatusCode(HttpStatusCode.OK.getStatusCode());
-    final ODataFormat format = ODataFormat.fromContentType(responseFormat);
-    response.setContent(serializeEntity(entity, edmEntitySet, edmEntityType, format, null, null)
-        .getContent());
-    response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+    final Return returnPreference = odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).getReturn();
+    if (returnPreference == null || returnPreference == Return.REPRESENTATION) {
+      response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+      final ODataFormat format = ODataFormat.fromContentType(responseFormat);
+      response.setContent(serializeEntity(entity, edmEntitySet, edmEntityType, format, null, null)
+          .getContent());
+      response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+    } else {
+      response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
+    }
+    if (returnPreference != null) {
+      response.setHeader(HttpHeader.PREFERENCE_APPLIED,
+          PreferencesApplied.with().returnRepresentation(returnPreference).build().toString());
+    }
     if (entity.getETag() != null) {
       response.setHeader(HttpHeader.ETAG, entity.getETag());
     }
@@ -234,11 +254,20 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
     dataProvider.setMedia(entity, odata.createFixedFormatDeserializer().binary(request.getBody()),
         requestFormat.toContentTypeString());
 
-    final ODataFormat format = ODataFormat.fromContentType(responseFormat);
-    response.setContent(serializeEntity(entity, edmEntitySet, edmEntityType, format, null, null)
-        .getContent());
-    response.setStatusCode(HttpStatusCode.OK.getStatusCode());
-    response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+    final Return returnPreference = odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).getReturn();
+    if (returnPreference == null || returnPreference == Return.REPRESENTATION) {
+      final ODataFormat format = ODataFormat.fromContentType(responseFormat);
+      response.setContent(serializeEntity(entity, edmEntitySet, edmEntityType, format, null, null)
+          .getContent());
+      response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+      response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+    } else {
+      response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
+    }
+    if (returnPreference != null) {
+      response.setHeader(HttpHeader.PREFERENCE_APPLIED,
+          PreferencesApplied.with().returnRepresentation(returnPreference).build().toString());
+    }
     if (entity.getETag() != null) {
       response.setHeader(HttpHeader.ETAG, entity.getETag());
     }
@@ -414,10 +443,12 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
     SkipHandler.applySkipSystemQueryHandler(uriInfo.getSkipOption(), entitySet);
     TopHandler.applyTopSystemQueryOption(uriInfo.getTopOption(), entitySet);
 
-    ServerSidePagingHandler.applyServerSidePaging(uriInfo.getSkipTokenOption(),
+    final Integer pageSize = odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).getMaxPageSize();
+    final Integer serverPageSize = ServerSidePagingHandler.applyServerSidePaging(uriInfo.getSkipTokenOption(),
         entitySet,
         edmEntitySet,
-        request.getRawRequestUri());
+        request.getRawRequestUri(),
+        pageSize);
 
     // Apply expand system query option
     final ODataFormat format = ODataFormat.fromContentType(requestedContentType);
@@ -443,6 +474,10 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
     response.setContent(serializerResult.getContent());
     response.setStatusCode(HttpStatusCode.OK.getStatusCode());
     response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString());
+    if (pageSize != null) {
+      response.setHeader(HttpHeader.PREFERENCE_APPLIED,
+          PreferencesApplied.with().maxPageSize(serverPageSize).build().toString());
+    }
   }
 
   private SerializerResult serializeEntityCollection(final EntityCollection entityCollection,

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e5fe04ae/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
index 1c0d049..6a9af47 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
@@ -48,6 +48,8 @@ import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
 import org.apache.olingo.server.api.ServiceMetadata;
 import org.apache.olingo.server.api.deserializer.FixedFormatDeserializer;
+import org.apache.olingo.server.api.prefer.PreferencesApplied;
+import org.apache.olingo.server.api.prefer.Preferences.Return;
 import org.apache.olingo.server.api.processor.ComplexCollectionProcessor;
 import org.apache.olingo.server.api.processor.ComplexProcessor;
 import org.apache.olingo.server.api.processor.CountComplexCollectionProcessor;
@@ -305,17 +307,26 @@ public class TechnicalPrimitiveComplexProcessor extends TechnicalProcessor
 
     dataProvider.updateETag(entity);
 
-    response.setStatusCode(HttpStatusCode.OK.getStatusCode());
-    if (representationType == RepresentationType.VALUE) {
-      response.setContent(
-          serializePrimitiveValue(property, edmProperty, (EdmPrimitiveType) edmProperty.getType(), null));
+    final Return returnPreference = odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).getReturn();
+    if (returnPreference == null || returnPreference == Return.REPRESENTATION) {
+      response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+      if (representationType == RepresentationType.VALUE) {
+        response.setContent(
+            serializePrimitiveValue(property, edmProperty, (EdmPrimitiveType) edmProperty.getType(), null));
+      } else {
+        final ODataFormat format = ODataFormat.fromContentType(responseFormat);
+        final SerializerResult result = serializeProperty(entity, edmEntitySet, path, property, edmProperty,
+            edmProperty.getType(), null, representationType, format, null, null);
+        response.setContent(result.getContent());
+      }
+      response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
     } else {
-      final ODataFormat format = ODataFormat.fromContentType(responseFormat);
-      final SerializerResult result = serializeProperty(entity, edmEntitySet, path, property, edmProperty,
-          edmProperty.getType(), null, representationType, format, null, null);
-      response.setContent(result.getContent());
+      response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
+    }
+    if (returnPreference != null) {
+      response.setHeader(HttpHeader.PREFERENCE_APPLIED,
+          PreferencesApplied.with().returnRepresentation(returnPreference).build().toString());
     }
-    response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
     if (entity.getETag() != null) {
       response.setHeader(HttpHeader.ETAG, entity.getETag());
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e5fe04ae/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/ServerSidePagingHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/ServerSidePagingHandler.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/ServerSidePagingHandler.java
index 9c6b688..71496fd 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/ServerSidePagingHandler.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/ServerSidePagingHandler.java
@@ -34,77 +34,104 @@ public class ServerSidePagingHandler {
   private static final int MAX_PAGE_SIZE = 10;
   private static final String ES_SERVER_SIDE_PAGING = "ESServerSidePaging";
 
-  public static void applyServerSidePaging(final SkipTokenOption skipTokenOption, final EntityCollection entitySet,
-      final EdmEntitySet edmEntitySet, final String rawRequestUri) throws ODataApplicationException {
+  /**
+   * <p>Applies server-side paging to the given entity collection.</p>
+   * <p>The next link is constructed and set in the data. It must support client-specified
+   * page sizes. Therefore, the format <code>page*pageSize</code> (with a literal asterisk)
+   * has been chosen for the skiptoken.</p> 
+   * @param skipTokenOption   the current skiptoken option (from a previous response's next link)
+   * @param entityCollection  the data
+   * @param edmEntitySet      the EDM entity set to decide whether paging must be done
+   * @param rawRequestUri     the request URI (used to construct the next link)
+   * @param preferredPageSize the client's preference for page size
+   * @return the chosen page size (or <code>null</code> if no paging has been done);
+   *        could be used in the Preference-Applied HTTP header
+   * @throws ODataApplicationException
+   */
+  public static Integer applyServerSidePaging(final SkipTokenOption skipTokenOption, EntityCollection entityCollection,
+      final EdmEntitySet edmEntitySet, final String rawRequestUri, final Integer preferredPageSize)
+      throws ODataApplicationException {
 
     if (edmEntitySet != null && shouldApplyServerSidePaging(edmEntitySet)) {
-      final int maxPageSize = getMaxPageSize();
+      final int pageSize = getPageSize(getPageSize(skipTokenOption), preferredPageSize);
       final int page = getPage(skipTokenOption);
-      final int itemsToSkip = maxPageSize * page;
+      final int itemsToSkip = pageSize * page;
 
-      if (itemsToSkip <= entitySet.getEntities().size()) {
-        SkipHandler.popAtMost(entitySet, itemsToSkip);
-        final int remainingItems = entitySet.getEntities().size();
-        TopHandler.reduceToSize(entitySet, maxPageSize);
+      if (itemsToSkip <= entityCollection.getEntities().size()) {
+        SkipHandler.popAtMost(entityCollection, itemsToSkip);
+        final int remainingItems = entityCollection.getEntities().size();
+        TopHandler.reduceToSize(entityCollection, pageSize);
 
-        // Determine if a new next Link has to be provided
-        if (remainingItems > maxPageSize) {
-          entitySet.setNext(createNextLink(rawRequestUri, page + 1));
+        // Determine if a new next Link has to be provided.
+        if (remainingItems > pageSize) {
+          entityCollection.setNext(createNextLink(rawRequestUri, page + 1, pageSize));
         }
       } else {
         throw new ODataApplicationException("Nothing found.", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ROOT);
       }
+      return pageSize;
     }
+    return null;
   }
 
-  private static URI createNextLink(final String rawRequestUri, final Integer page)
+  private static URI createNextLink(final String rawRequestUri, final Integer page, final int pageSize)
       throws ODataApplicationException {
+    // Remove a maybe existing skiptoken, making sure that the query part is not empty.
+    String nextlink = rawRequestUri.contains("?") ?
+        rawRequestUri.replaceAll("(\\$|%24)skiptoken=.+&?", "").replaceAll("(\\?|&)$", "") :
+        rawRequestUri;
 
-    try {
-      // Remove skip token
-      String nextlink = rawRequestUri;
+    // Add a question mark or an ampersand, depending on the current query part.
+    nextlink += nextlink.contains("?") ? '&' : '?';
 
-      // Remove a may existing skiptoken, make sure that the query part is not empty
-      if (rawRequestUri.contains("?")) {
-        nextlink = rawRequestUri.replaceAll("(\\$|%24)skiptoken=.+&?", "").replaceAll("(\\?|&)$", "");
-      }
+    // Append the new skiptoken.
+    try {
+      return new URI(nextlink + Encoder.encode(SystemQueryOptionKind.SKIPTOKEN.toString()) + '='
+          + Encoder.encode(page.toString() + '*' + pageSize));
+    } catch (final URISyntaxException e) {
+      throw new ODataApplicationException("Exception while constructing next link",
+          HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), Locale.ROOT, e);
+    }
+  }
 
-      // Add a question mark or an ampersand, depending of the current query part
-      if (!nextlink.contains("?")) {
-        nextlink = nextlink + "?";
-      } else {
-        nextlink = nextlink + "&";
-      }
+  private static boolean shouldApplyServerSidePaging(final EdmEntitySet edmEntitySet) {
+    return ES_SERVER_SIDE_PAGING.equals(edmEntitySet.getName());
+  }
 
-      // Append the new nextlink
-      return new URI(nextlink + Encoder.encode(SystemQueryOptionKind.SKIPTOKEN.toString()) + "="
-          + Encoder.encode(page.toString()));
+  private static int getPageSize(final int skipTokenPageSize, final Integer preferredPageSize) {
+    return skipTokenPageSize > 0 ? skipTokenPageSize :
+        preferredPageSize == null || preferredPageSize >= MAX_PAGE_SIZE ?
+            MAX_PAGE_SIZE :
+            preferredPageSize;
+  }
 
-    } catch (URISyntaxException e) {
-      throw new ODataApplicationException("Exception while constructing next link",
-          HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), Locale.ROOT);
+  private static int getPageSize(final SkipTokenOption skipTokenOption) throws ODataApplicationException {
+    if (skipTokenOption != null && skipTokenOption.getValue().length() >= 3
+        && skipTokenOption.getValue().contains("*")) {
+      final String value = skipTokenOption.getValue();
+      try {
+        return Integer.parseInt(value.substring(value.indexOf('*') + 1));
+      } catch (final NumberFormatException e) {
+        throw new ODataApplicationException("Invalid skip token", HttpStatusCode.BAD_REQUEST.getStatusCode(),
+            Locale.ROOT, e);
+      }
+    } else {
+      return 0;
     }
   }
 
   private static int getPage(final SkipTokenOption skipTokenOption) throws ODataApplicationException {
-    if (skipTokenOption != null) {
+    if (skipTokenOption != null && skipTokenOption.getValue().length() >= 3
+        && skipTokenOption.getValue().contains("*")) {
+      final String value = skipTokenOption.getValue();
       try {
-        return Integer.parseInt(skipTokenOption.getValue());
-      } catch (NumberFormatException e) {
+        return Integer.parseInt(value.substring(0, value.indexOf('*')));
+      } catch (final NumberFormatException e) {
         throw new ODataApplicationException("Invalid skip token", HttpStatusCode.BAD_REQUEST.getStatusCode(),
-            Locale.ROOT);
+            Locale.ROOT, e);
       }
     } else {
       return 0;
     }
   }
-
-  private static boolean shouldApplyServerSidePaging(final EdmEntitySet edmEntitySet) {
-    return ES_SERVER_SIDE_PAGING.equals(edmEntitySet.getName());
-  }
-
-  private static int getMaxPageSize() {
-    // TODO Consider odata.maxpagesize preference?
-    return MAX_PAGE_SIZE;
-  }
 }


[16/39] olingo-odata4 git commit: [OLINGO-659] FIx felix maven build warnings

Posted by ch...@apache.org.
[OLINGO-659] FIx felix maven build warnings


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

Branch: refs/heads/IEE754Compatible
Commit: a298e1fb7c0e8f3669def849557775d5be5c0e1f
Parents: 2035125
Author: Christian Amend <ch...@sap.com>
Authored: Tue Jun 16 14:03:59 2015 +0200
Committer: Christian Amend <ch...@sap.com>
Committed: Tue Jun 16 14:03:59 2015 +0200

----------------------------------------------------------------------
 lib/client-api/pom.xml   | 1 +
 lib/client-core/pom.xml  | 1 +
 lib/commons-api/pom.xml  | 1 +
 lib/commons-core/pom.xml | 1 +
 lib/server-api/pom.xml   | 1 +
 lib/server-core/pom.xml  | 1 +
 6 files changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a298e1fb/lib/client-api/pom.xml
----------------------------------------------------------------------
diff --git a/lib/client-api/pom.xml b/lib/client-api/pom.xml
index 4bc7b79..abd5415 100644
--- a/lib/client-api/pom.xml
+++ b/lib/client-api/pom.xml
@@ -55,6 +55,7 @@
       <plugin>
         <groupId>org.apache.felix</groupId>
         <artifactId>maven-bundle-plugin</artifactId>
+		<version>${maven.bundle.plugin.version}</version>
         <extensions>true</extensions>
         <configuration>
           <instructions>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a298e1fb/lib/client-core/pom.xml
----------------------------------------------------------------------
diff --git a/lib/client-core/pom.xml b/lib/client-core/pom.xml
index 4e6068c..ce9fc28 100644
--- a/lib/client-core/pom.xml
+++ b/lib/client-core/pom.xml
@@ -80,6 +80,7 @@
       <plugin>
         <groupId>org.apache.felix</groupId>
         <artifactId>maven-bundle-plugin</artifactId>
+		<version>${maven.bundle.plugin.version}</version>
         <extensions>true</extensions>
         <configuration>
           <instructions>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a298e1fb/lib/commons-api/pom.xml
----------------------------------------------------------------------
diff --git a/lib/commons-api/pom.xml b/lib/commons-api/pom.xml
index 55ca40d..dc71493 100644
--- a/lib/commons-api/pom.xml
+++ b/lib/commons-api/pom.xml
@@ -60,6 +60,7 @@
       <plugin>
         <groupId>org.apache.felix</groupId>
         <artifactId>maven-bundle-plugin</artifactId>
+		<version>${maven.bundle.plugin.version}</version>
         <extensions>true</extensions>
         <configuration>
           <instructions>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a298e1fb/lib/commons-core/pom.xml
----------------------------------------------------------------------
diff --git a/lib/commons-core/pom.xml b/lib/commons-core/pom.xml
index c6d6f98..8b464a8 100644
--- a/lib/commons-core/pom.xml
+++ b/lib/commons-core/pom.xml
@@ -82,6 +82,7 @@
       <plugin>
         <groupId>org.apache.felix</groupId>
         <artifactId>maven-bundle-plugin</artifactId>
+		<version>${maven.bundle.plugin.version}</version>
         <extensions>true</extensions>
         <configuration>
           <instructions>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a298e1fb/lib/server-api/pom.xml
----------------------------------------------------------------------
diff --git a/lib/server-api/pom.xml b/lib/server-api/pom.xml
index 393939f..0d636f0 100644
--- a/lib/server-api/pom.xml
+++ b/lib/server-api/pom.xml
@@ -56,6 +56,7 @@
       <plugin>
         <groupId>org.apache.felix</groupId>
         <artifactId>maven-bundle-plugin</artifactId>
+		<version>${maven.bundle.plugin.version}</version>
         <extensions>true</extensions>
         <configuration>
           <instructions>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a298e1fb/lib/server-core/pom.xml
----------------------------------------------------------------------
diff --git a/lib/server-core/pom.xml b/lib/server-core/pom.xml
index 1c2d1f5..7d1758e 100644
--- a/lib/server-core/pom.xml
+++ b/lib/server-core/pom.xml
@@ -118,6 +118,7 @@
       <plugin>
         <groupId>org.apache.felix</groupId>
         <artifactId>maven-bundle-plugin</artifactId>
+		<version>${maven.bundle.plugin.version}</version>
         <extensions>true</extensions>
         <configuration>
           <instructions>