olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject [2/2] olingo-odata4 git commit: [OLINGO-659] Better data handling in technical service + clean-up
Date Wed, 09 Sep 2015 13:42:23 GMT
[OLINGO-659] Better data handling in technical service + clean-up

Signed-off-by: Michael Bolz <michael.bolz@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/e981aaad
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/e981aaad
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/e981aaad

Branch: refs/heads/master
Commit: e981aaad798d5e220760dc3642196790e4d47c0b
Parents: 8ffd80e
Author: Klaus Straubinger <klaus.straubinger@sap.com>
Authored: Wed Sep 9 15:27:52 2015 +0200
Committer: Michael Bolz <michael.bolz@sap.com>
Committed: Wed Sep 9 15:35:33 2015 +0200

----------------------------------------------------------------------
 .../client/AbstractParamTecSvcITCase.java       |  29 +-
 .../fit/tecsvc/client/AsyncSupportITCase.java   |  60 ++--
 .../api/deserializer/DeserializerResult.java    |  18 +-
 .../olingo/server/core/debug/DebugTabUri.java   |   3 +-
 .../deserializer/DeserializerResultImpl.java    |  10 +-
 .../deserializer/xml/ODataXmlDeserializer.java  |  15 +-
 .../core/serializer/xml/ODataXmlSerializer.java |  55 ++--
 .../olingo/server/core/uri/UriHelperImpl.java   |   4 +
 .../batchhandler/MockedBatchHandlerTest.java    |   7 +-
 .../olingo/server/tecsvc/TechnicalServlet.java  |  16 +-
 .../tecsvc/async/TechnicalAsyncService.java     |  22 +-
 .../olingo/server/tecsvc/data/ActionData.java   |  65 ++---
 .../olingo/server/tecsvc/data/DataCreator.java  | 276 +++++++++----------
 .../olingo/server/tecsvc/data/DataProvider.java |  28 +-
 .../olingo/server/tecsvc/data/FunctionData.java |  38 ++-
 .../tecsvc/processor/TechnicalProcessor.java    |   1 -
 .../server/tecsvc/provider/EdmTechProvider.java |  13 +-
 .../tecsvc/data/ActionDataProviderTest.java     |  70 ++---
 .../server/tecsvc/data/DataProviderTest.java    |  21 +-
 .../json/ODataJsonSerializerTest.java           |   7 +-
 .../serializer/xml/MetadataDocumentTest.java    |   3 +-
 .../serializer/xml/ODataXmlSerializerTest.java  |   5 +-
 .../olingo/server/core/uri/UriHelperTest.java   |   7 +-
 .../server/core/uri/parser/ParserTest.java      |   2 +-
 24 files changed, 348 insertions(+), 427 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e981aaad/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AbstractParamTecSvcITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AbstractParamTecSvcITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AbstractParamTecSvcITCase.java
index d00ec17..2d45d79 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AbstractParamTecSvcITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AbstractParamTecSvcITCase.java
@@ -18,36 +18,31 @@
  */
 package org.apache.olingo.fit.tecsvc.client;
 
+import java.util.Arrays;
+import java.util.List;
+
 import org.apache.olingo.commons.api.format.ContentType;
-import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 
-import java.util.Arrays;
-import java.util.Collection;
-
-import static org.junit.Assert.assertTrue;
-
 @RunWith(Parameterized.class)
-public class AbstractParamTecSvcITCase extends AbstractTecSvcITCase {
+public abstract class AbstractParamTecSvcITCase extends AbstractTecSvcITCase {
 
   @Parameterized.Parameter
   public ContentType contentType;
 
-  @Parameterized.Parameters
-  public static Collection paras() {
-    return Arrays.asList(new Object[][]{
-            {ContentType.APPLICATION_JSON}, {ContentType.APPLICATION_XML}
-    });
+  /**
+   * Returns a list of parameter arrays, in this case a list of one-element arrays
+   * containing the content types to be used.
+   */
+  @Parameterized.Parameters(name = "{0}")
+  public static List<ContentType[]> parameters() {
+    return Arrays.asList(new ContentType[] { ContentType.APPLICATION_JSON },
+        new ContentType[] { ContentType.APPLICATION_XML });
   }
 
   @Override
   protected ContentType getContentType() {
     return contentType;
   }
-
-  @Test
-  public void dummyTest() {
-    assertTrue("Dummy Test method to please Junit.", true);
-  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e981aaad/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AsyncSupportITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AsyncSupportITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AsyncSupportITCase.java
index db22773..1741585 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AsyncSupportITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AsyncSupportITCase.java
@@ -26,8 +26,6 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.concurrent.TimeUnit;
 
 import org.apache.olingo.client.api.ODataClient;
 import org.apache.olingo.client.api.communication.ODataClientErrorException;
@@ -35,6 +33,7 @@ import org.apache.olingo.client.api.communication.request.AsyncBatchRequestWrapp
 import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
 import org.apache.olingo.client.api.communication.request.ODataRequest;
 import org.apache.olingo.client.api.communication.request.batch.ODataBatchRequest;
+import org.apache.olingo.client.api.communication.request.batch.ODataBatchResponseItem;
 import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
 import org.apache.olingo.client.api.communication.response.AsyncResponseWrapper;
@@ -45,7 +44,6 @@ 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;
 import org.apache.olingo.client.api.domain.ClientProperty;
-import org.apache.olingo.client.api.uri.URIBuilder;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.ResWrap;
@@ -54,7 +52,6 @@ import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.api.format.PreferenceName;
 import org.apache.olingo.commons.api.http.HttpHeader;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
-import org.junit.Ignore;
 import org.junit.Test;
 
 public final class AsyncSupportITCase extends AbstractTecSvcITCase {
@@ -200,51 +197,34 @@ public final class AsyncSupportITCase extends AbstractTecSvcITCase {
   }
 
   @Test
-  @Ignore("Does currently not work as expected -> issue in ODataClient?")
   public void getBatchRequest() throws Exception {
     ODataClient client = getClient();
     final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(SERVICE_URI);
-
-//    final BatchManager payload = request.payloadManager();
-
-    // create new request
-//    ODataEntityRequest<ClientEntity> getRequest = appendGetRequest(getClient(), payload, "ESAllPrim", 32767, false);
-//    payload.addRequest(getRequest);
-
     request.setPrefer(PreferenceName.RESPOND_ASYNC + "; " + TEC_ASYNC_SLEEP + "=1");
     ODataBatchableRequest getRequest = appendGetRequest(client, "ESAllPrim", 32767, false);
     AsyncBatchRequestWrapper asyncRequest =
         client.getAsyncRequestFactory().getAsyncBatchRequestWrapper(request);
     asyncRequest.addRetrieve(getRequest);
     AsyncResponseWrapper<ODataBatchResponse> asyncResponse = asyncRequest.execute();
-
-//    Future<ODataBatchResponse> test = payload.getAsyncResponse();
-//    ODataBatchResponse res = payload.getResponse();
-//
-//    while(!test.isDone()) {
-//      TimeUnit.SECONDS.sleep(1);
-//    }
-
-//    // Fetch result
-//    final ODataBatchResponse response = asyncResponse.getODataResponse();
+    assertTrue(asyncResponse.isPreferenceApplied());
+    assertFalse(asyncResponse.isDone());
 
     waitTillDone(asyncResponse, 3);
-//    assertEquals(HttpStatusCode.ACCEPTED.getStatusCode(), response.getStatusCode());
-//    assertEquals("Accepted", response.getStatusMessage());
 
-    ODataResponse firstResponse = asyncResponse.getODataResponse();
+    final ODataBatchResponse response = asyncResponse.getODataResponse();
+    final ODataBatchResponseItem item = response.getBody().next();
+    @SuppressWarnings("unchecked")
+    final ODataRetrieveResponse<ClientEntity> firstResponse = (ODataRetrieveResponse<ClientEntity>) item.next();
     assertEquals(HttpStatusCode.OK.getStatusCode(), firstResponse.getStatusCode());
-    assertEquals(2, firstResponse.getHeaderNames().size());
+    assertEquals(3, firstResponse.getHeaderNames().size());
     assertEquals("4.0", firstResponse.getHeader(HttpHeader.ODATA_VERSION).iterator().next());
 
-    ResWrap<Entity> firstWrap = client.getDeserializer(ContentType.APPLICATION_JSON)
-        .toEntity(firstResponse.getRawResponse());
-    Entity entity = firstWrap.getPayload();
-    assertEquals(32767, entity.getProperty("PropertyInt16").asPrimitive());
-    assertEquals("First Resource - positive values", entity.getProperty("PropertyString").asPrimitive());
+    final ClientEntity entity = firstResponse.getBody();
+    assertEquals(32767, entity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
+    assertEquals("First Resource - positive values",
+        entity.getProperty("PropertyString").getPrimitiveValue().toValue());
   }
 
-
   /**
    * Test delete with async prefer header but without async support from TecSvc.
    */
@@ -279,15 +259,11 @@ public final class AsyncSupportITCase extends AbstractTecSvcITCase {
   }
 
   private ODataEntityRequest<ClientEntity> appendGetRequest(final ODataClient client,
-      final String segment, final Object key, final boolean isRelative) throws URISyntaxException {
-
-    final URIBuilder targetURI = getClient().newURIBuilder(SERVICE_URI);
-    targetURI.appendEntitySetSegment(segment).appendKeySegment(key);
-    final URI uri = (isRelative) ? new URI(SERVICE_URI).relativize(targetURI.build()) : targetURI.build();
-
-    ODataEntityRequest<ClientEntity> queryReq = getClient().getRetrieveRequestFactory().getEntityRequest(uri);
-    queryReq.setFormat(ContentType.JSON);
-    return queryReq;
+      final String segment, final Object key, final boolean isRelative) {
+    final URI targetURI = client.newURIBuilder(SERVICE_URI)
+        .appendEntitySetSegment(segment).appendKeySegment(key).build();
+    final URI uri = isRelative ? URI.create(SERVICE_URI).relativize(targetURI) : targetURI;
+    return client.getRetrieveRequestFactory().getEntityRequest(uri);
   }
 
   private void checkEntityAvailableWith(ClientEntitySet entitySet, String property, Object value) {
@@ -305,7 +281,7 @@ public final class AsyncSupportITCase extends AbstractTecSvcITCase {
   private void waitTillDone(AsyncResponseWrapper<?> async, int maxWaitInSeconds) throws InterruptedException {
     int waitCounter = maxWaitInSeconds * 1000;
     while (!async.isDone() && waitCounter > 0) {
-      TimeUnit.MILLISECONDS.sleep(SLEEP_TIMEOUT_IN_MS);
+      Thread.sleep(SLEEP_TIMEOUT_IN_MS);
       waitCounter -= SLEEP_TIMEOUT_IN_MS;
     }
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e981aaad/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/DeserializerResult.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/DeserializerResult.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/DeserializerResult.java
index 3c6a3ee..c096118 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/DeserializerResult.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/DeserializerResult.java
@@ -33,42 +33,38 @@ import org.apache.olingo.server.api.uri.queryoption.ExpandOption;
  */
 public interface DeserializerResult {
   /**
-   * Return an entity
+   * Returns an entity.
    * @return an {@link Entity} or null
    */
   Entity getEntity();
 
   /**
-   * Returns a entity set
+   * Returns an entity collection.
    * @return an {@link EntityCollection} or null
    */
   EntityCollection getEntityCollection();
 
   /**
-   * Returns the ExpandOptions for serialized entities
+   * Returns the ExpandOptions for the deserialized entity.
    * @return an {@link ExpandOption} or null
    */
   ExpandOption getExpandTree();
 
   /**
-   * Returns the deserialized action-parameters of an {@link Entity} object.
-   * @return a collection {@link Parameter}
-   */
-  /**
-   * Returns the deserialized action-parameters as key value pairs.
+   * Returns the deserialized action parameters of an {@link Entity} as key/value pairs.
    * @return the action parameters
    */
   Map<String, Parameter> getActionParameters();
 
   /**
-   * Returns a Property or collections of properties (primitive & complex)
+   * Returns a Property or collections of properties (primitive & complex).
    * @return {@link Property} or collections of properties (primitive & complex) or null
    */
   Property getProperty();
 
   /**
-   * Returns the entity references from the provided document
-   * @return a collection of entity reference
+   * Returns the entity references from the provided document.
+   * @return a collection of entity references
    */
   List<URI> getEntityReferences();
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e981aaad/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabUri.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabUri.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabUri.java
index f67f02d..071bb3c 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabUri.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabUri.java
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.io.Writer;
 import java.util.List;
 
+import org.apache.olingo.commons.api.ex.ODataException;
 import org.apache.olingo.server.api.uri.UriInfo;
 import org.apache.olingo.server.api.uri.UriResource;
 import org.apache.olingo.server.api.uri.queryoption.CountOption;
@@ -194,7 +195,7 @@ public class DebugTabUri implements DebugTab {
     String expressionJsonString;
     try {
       expressionJsonString = expression.accept(new ExpressionJsonVisitor());
-    } catch (Exception e) {
+    } catch (final ODataException e) {
       expressionJsonString = "Exception in Debug Filter visitor occurred: " + e.getMessage();
     }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e981aaad/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/DeserializerResultImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/DeserializerResultImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/DeserializerResultImpl.java
index 654d37c..4ea30ad 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/DeserializerResultImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/DeserializerResultImpl.java
@@ -36,7 +36,7 @@ public class DeserializerResultImpl implements DeserializerResult {
   private EntityCollection entitySet;
   private ExpandOption expandOption;
   private Property property;
-  private Map<String, Parameter> actionParametes;
+  private Map<String, Parameter> actionParameters;
   private List<URI> entityReferences;
 
   private DeserializerResultImpl() {}
@@ -58,7 +58,7 @@ public class DeserializerResultImpl implements DeserializerResult {
 
   @Override
   public Map<String, Parameter> getActionParameters() {
-    return actionParametes;
+    return actionParameters;
   }
 
   @Override
@@ -80,7 +80,7 @@ public class DeserializerResultImpl implements DeserializerResult {
     private EntityCollection entitySet;
     private ExpandOption expandOption;
     private Property property;
-    private Map<String, Parameter> actionParametes;
+    private Map<String, Parameter> actionParameters;
     private List<URI> entityReferences;
 
     public DeserializerResult build() {
@@ -90,7 +90,7 @@ public class DeserializerResultImpl implements DeserializerResult {
       result.expandOption = expandOption;
       result.property = property;
       result.entityReferences = (entityReferences == null) ? new ArrayList<URI>() : entityReferences;
-      result.actionParametes = (actionParametes == null) ? new LinkedHashMap<String, Parameter>() : actionParametes;
+      result.actionParameters = (actionParameters == null) ? new LinkedHashMap<String, Parameter>() : actionParameters;
 
       return result;
     }
@@ -121,7 +121,7 @@ public class DeserializerResultImpl implements DeserializerResult {
     }
 
     public DeserializerResultBuilder actionParameters(final Map<String, Parameter> actionParameters) {
-      actionParametes = actionParameters;
+      this.actionParameters = actionParameters;
       return this;
     }
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e981aaad/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializer.java
index efbad95..241f32d 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializer.java
@@ -125,10 +125,8 @@ public class ODataXmlDeserializer implements ODataDeserializer {
     return value;
   }
 
-  private Object complex(final XMLEventReader reader, final StartElement start, EdmComplexType edmComplex, 
-      boolean validateType)
+  private Object complex(final XMLEventReader reader, final StartElement start, EdmComplexType edmComplex)
       throws XMLStreamException, EdmPrimitiveTypeException, DeserializerException {
-
     ComplexValue value = new ComplexValue();
     boolean foundEndProperty = false;
     while (reader.hasNext() && !foundEndProperty) {
@@ -158,9 +156,9 @@ public class ODataXmlDeserializer implements ODataDeserializer {
         if (edmType instanceof SingletonPrimitiveType) {
           values.add(primitive(reader, event.asStartElement(), edmProperty));          
         } else if (edmType instanceof EdmComplexType) {
-          values.add(complex(reader, event.asStartElement(), (EdmComplexType)edmType, false));                    
+          values.add(complex(reader, event.asStartElement(), (EdmComplexType) edmType));                    
         } else if (edmType instanceof EdmEnumType) {
-          values.add(readEnum(reader, event.asStartElement(), edmProperty));          
+          values.add(readEnum(reader, event.asStartElement()));          
         } else {
           // do not add null or empty values
         }
@@ -173,8 +171,7 @@ public class ODataXmlDeserializer implements ODataDeserializer {
     valuable.setValue(getValueType(edmType, true), values);
   }
 
-  private Object readEnum(XMLEventReader reader, StartElement start, EdmProperty edmProperty) 
-      throws XMLStreamException {
+  private Object readEnum(XMLEventReader reader, StartElement start) throws XMLStreamException {
     boolean foundEndProperty = false;
     Object value = null;
     while (reader.hasNext() && !foundEndProperty) {
@@ -245,10 +242,10 @@ public class ODataXmlDeserializer implements ODataDeserializer {
       valuable.setType(edmType.getFullQualifiedName().getFullQualifiedNameAsString());
       valuable.setValue(ValueType.PRIMITIVE, primitive(reader, start, edmProperty));          
     } else if (edmType instanceof EdmComplexType) {
-      valuable.setValue(ValueType.COMPLEX, complex(reader, start, (EdmComplexType)edmType, true));
+      valuable.setValue(ValueType.COMPLEX, complex(reader, start, (EdmComplexType) edmType));
       valuable.setType(edmType.getFullQualifiedName().getFullQualifiedNameAsString());
     } else if (edmType instanceof EdmEnumType) {
-      valuable.setValue(ValueType.ENUM, readEnum(reader, start, edmProperty));
+      valuable.setValue(ValueType.ENUM, readEnum(reader, start));
       valuable.setType(edmType.getFullQualifiedName().getFullQualifiedNameAsString());
     } else {
       // do not add null or empty values

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e981aaad/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializer.java
index f998fe7..382ef6f 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializer.java
@@ -218,7 +218,7 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
     if (options != null && options.onlyReferences()) {
       ReferenceCollectionSerializerOptions rso = ReferenceCollectionSerializerOptions.with()
           .contextURL(contextURL).build();
-      return entityReferenceCollection(metadata, entityType, entitySet, rso);
+      return entityReferenceCollection(entitySet, rso);
     }
 
     OutputStream outputStream = null;
@@ -252,10 +252,10 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
       }
 
       if (options == null) {
-        writeEntitySet(metadata, entityType, entitySet, null, null, false, writer);
+        writeEntitySet(metadata, entityType, entitySet, null, null, writer);
       } else {
         writeEntitySet(metadata, entityType, entitySet,
-            options.getExpand(), options.getSelect(), options.onlyReferences(), writer);
+            options.getExpand(), options.getSelect(), writer);
       }
 
       writer.writeEndElement();
@@ -285,9 +285,8 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
     final ContextURL contextURL = checkContextURL(options == null ? null : options.getContextURL());
 
     if (options != null && options.onlyReferences()) {
-      ReferenceSerializerOptions rso = ReferenceSerializerOptions.with()
-          .contextURL(contextURL).build();
-      return entityReference(metadata, entityType, entity, rso);
+      return entityReference(entity,
+          ReferenceSerializerOptions.with().contextURL(contextURL).build());
     }
 
     OutputStream outputStream = null;
@@ -299,8 +298,7 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
       writer.writeStartDocument(ODataSerializer.DEFAULT_CHARSET, "1.0");
       writeEntity(metadata, entityType, entity, contextURL,
           options == null ? null : options.getExpand(),
-          options == null ? null : options.getSelect(),
-          options == null ? false : options.onlyReferences(), writer, true);
+          options == null ? null : options.getSelect(), writer, true);
       writer.writeEndDocument();
 
       writer.flush();
@@ -340,17 +338,16 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
 
   protected void writeEntitySet(final ServiceMetadata metadata, final EdmEntityType entityType,
       final EntityCollection entitySet, final ExpandOption expand, final SelectOption select,
-      final boolean onlyReference, final XMLStreamWriter writer) throws XMLStreamException,
-      SerializerException {
+      final XMLStreamWriter writer) throws XMLStreamException, SerializerException {
     for (final Entity entity : entitySet.getEntities()) {
-      writeEntity(metadata, entityType, entity, null, expand, select, false, writer, false);
+      writeEntity(metadata, entityType, entity, null, expand, select, writer, false);
     }
   }
 
   protected void writeEntity(final ServiceMetadata metadata, final EdmEntityType entityType,
       final Entity entity, final ContextURL contextURL, final ExpandOption expand,
-      final SelectOption select, final boolean onlyReference, final XMLStreamWriter writer,
-      final boolean top) throws XMLStreamException, SerializerException {
+      final SelectOption select, final XMLStreamWriter writer, final boolean top)
+          throws XMLStreamException, SerializerException {
 
     writer.writeStartElement(ATOM, "entry", NS_ATOM);
     if (top) {
@@ -533,7 +530,6 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
             writeExpandedNavigationProperty(metadata, property, navigationLink,
                 innerOptions == null ? null : innerOptions.getExpandOption(),
                 innerOptions == null ? null : innerOptions.getSelectOption(),
-                innerOptions == null ? false : innerOptions.isRef(),
                 writer);
             writer.writeEndElement();
             writer.writeEndElement();
@@ -589,8 +585,7 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
 
   protected void writeExpandedNavigationProperty(final ServiceMetadata metadata,
       final EdmNavigationProperty property, final Link navigationLink,
-      final ExpandOption innerExpand, final SelectOption innerSelect, boolean onlyReference,
-      final XMLStreamWriter writer)
+      final ExpandOption innerExpand, final SelectOption innerSelect, final XMLStreamWriter writer)
       throws XMLStreamException, SerializerException {
     if (property.isCollection()) {
       if (navigationLink == null || navigationLink.getInlineEntitySet() == null) {
@@ -598,7 +593,7 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
       } else {
         writer.writeStartElement(ATOM, "feed", NS_ATOM);
         writeEntitySet(metadata, property.getType(), navigationLink.getInlineEntitySet(), innerExpand,
-            innerSelect, onlyReference, writer);
+            innerSelect, writer);
         writer.writeEndElement();
       }
     } else {
@@ -606,7 +601,7 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
         // nothing to write
       } else {
         writeEntity(metadata, property.getType(), navigationLink.getInlineEntity(), null,
-            innerExpand, innerSelect, onlyReference, writer, false);
+            innerExpand, innerSelect, writer, false);
       }
     }
   }
@@ -639,8 +634,7 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
     return type.getFullQualifiedName().getFullQualifiedNameAsString();
   }
 
-  private String derivedComplexType(ServiceMetadata metadata, EdmComplexType baseType, String definedType)
-      throws SerializerException {
+  private String derivedComplexType(EdmComplexType baseType, String definedType) throws SerializerException {
     String derived = baseType.getFullQualifiedName().getFullQualifiedNameAsString();
     if (derived.equals(definedType)) {
       return null;
@@ -716,7 +710,7 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
       throws XMLStreamException, SerializerException {
     for (Object value : property.asCollection()) {
       writer.writeStartElement(METADATA, "element", NS_METADATA);
-      if (derivedComplexType(metadata, type, property.getType()) != null) {
+      if (derivedComplexType(type, property.getType()) != null) {
         writer.writeAttribute(METADATA, NS_METADATA, "type", property.getType());
       }
       switch (property.getValueType()) {
@@ -997,11 +991,11 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
   @Override
   public SerializerResult reference(final ServiceMetadata metadata, final EdmEntitySet edmEntitySet,
       final Entity entity, final ReferenceSerializerOptions options) throws SerializerException {
-    return entityReference(metadata, edmEntitySet.getEntityType(), entity, options);
+    return entityReference(entity, options);
   }
 
-  protected SerializerResult entityReference(final ServiceMetadata metadata, final EdmEntityType entityType,
-      final Entity entity, ReferenceSerializerOptions options) throws SerializerException {
+  protected SerializerResult entityReference(final Entity entity, ReferenceSerializerOptions options)
+      throws SerializerException {
     OutputStream outputStream = null;
     SerializerException cachedException = null;
     try {
@@ -1009,7 +1003,7 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
       outputStream = buffer.getOutputStream();
       XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(outputStream, DEFAULT_CHARSET);
       writer.writeStartDocument(ODataSerializer.DEFAULT_CHARSET, "1.0");
-      writeReference(metadata, entityType, entity, options == null ? null : options.getContextURL(), writer, true);
+      writeReference(entity, options == null ? null : options.getContextURL(), writer, true);
       writer.writeEndDocument();
       writer.flush();
       writer.close();
@@ -1029,8 +1023,8 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
     }
   }
 
-  private void writeReference(ServiceMetadata metadata, EdmEntityType entityType,
-      Entity entity, ContextURL contextURL, XMLStreamWriter writer, boolean top) throws XMLStreamException {
+  private void writeReference(Entity entity, ContextURL contextURL, XMLStreamWriter writer, boolean top)
+      throws XMLStreamException {
     writer.writeStartElement(METADATA, "ref", NS_METADATA);
     if (top) {
       writer.writeNamespace(METADATA, NS_METADATA);
@@ -1047,11 +1041,10 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
   public SerializerResult referenceCollection(final ServiceMetadata metadata, final EdmEntitySet edmEntitySet,
       final EntityCollection entityCollection, ReferenceCollectionSerializerOptions options)
       throws SerializerException {
-    return entityReferenceCollection(metadata, edmEntitySet.getEntityType(), entityCollection, options);
+    return entityReferenceCollection(entityCollection, options);
   }
 
-  protected SerializerResult entityReferenceCollection(final ServiceMetadata metadata,
-      final EdmEntityType entityType, final EntityCollection entitySet,
+  protected SerializerResult entityReferenceCollection(final EntityCollection entitySet,
       ReferenceCollectionSerializerOptions options) throws SerializerException {
     OutputStream outputStream = null;
     SerializerException cachedException = null;
@@ -1075,7 +1068,7 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
         writeNextLink(entitySet, writer);
       }
       for (final Entity entity : entitySet.getEntities()) {
-        writeReference(metadata, entityType, entity, options == null ? null : options.getContextURL(), writer, false);
+        writeReference(entity, options == null ? null : options.getContextURL(), writer, false);
       }
       writer.writeEndElement();
       writer.writeEndDocument();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e981aaad/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriHelperImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriHelperImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriHelperImpl.java
index ae2700d..c463765 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriHelperImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriHelperImpl.java
@@ -76,6 +76,10 @@ public class UriHelperImpl implements UriHelper {
         result.append(Encoder.encode(keyName)).append('=');
       }
       final EdmProperty edmProperty = edmEntityType.getStructuralProperty(keyName);
+      if (edmProperty == null) {
+        throw new SerializerException("Property not found (possibly an alias): " + keyName,
+            SerializerException.MessageKeys.MISSING_PROPERTY, keyName);
+      }
       final EdmPrimitiveType type = (EdmPrimitiveType) edmProperty.getType();
       final Object propertyValue = entity.getProperty(keyName).getValue();
       try {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e981aaad/lib/server-core/src/test/java/org/apache/olingo/server/core/batchhandler/MockedBatchHandlerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/batchhandler/MockedBatchHandlerTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/batchhandler/MockedBatchHandlerTest.java
index 7d13d8a..48ff255 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/batchhandler/MockedBatchHandlerTest.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/batchhandler/MockedBatchHandlerTest.java
@@ -34,6 +34,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
+import org.apache.olingo.commons.api.ex.ODataException;
 import org.apache.olingo.commons.api.http.HttpContentType;
 import org.apache.olingo.commons.api.http.HttpHeader;
 import org.apache.olingo.commons.api.http.HttpMethod;
@@ -574,13 +575,13 @@ public class MockedBatchHandlerTest {
     }
 
     @Override
-    public ODataResponsePart processChangeSet(final BatchFacade fascade, final List<ODataRequest> requests) {
+    public ODataResponsePart processChangeSet(final BatchFacade facade, final List<ODataRequest> requests) {
       List<ODataResponse> responses = new ArrayList<ODataResponse>();
 
       for (ODataRequest request : requests) {
         try {
-          responses.add(fascade.handleODataRequest(request));
-        } catch (Exception e) {
+          responses.add(facade.handleODataRequest(request));
+        } catch (final ODataException e) {
           fail();
         }
       }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e981aaad/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java
index 5fcc8eb..644872d 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java
@@ -21,7 +21,6 @@ package org.apache.olingo.server.tecsvc;
 import java.io.IOException;
 import java.net.URI;
 import java.util.Collections;
-import java.util.List;
 import java.util.UUID;
 
 import javax.servlet.ServletException;
@@ -61,34 +60,35 @@ public class TechnicalServlet extends HttpServlet {
   private static final String metadataETag = "W/\"" + UUID.randomUUID() + "\"";
 
   @Override
-  protected void service(final HttpServletRequest request, final HttpServletResponse response)
+  protected void service(final HttpServletRequest request, HttpServletResponse response)
       throws ServletException, IOException {
     try {
       OData odata = OData.newInstance();
       EdmxReference reference = new EdmxReference(URI.create("../v4.0/cs02/vocabularies/Org.OData.Core.V1.xml"));
       reference.addInclude(new EdmxReferenceInclude("Org.OData.Core.V1", "Core"));
-      final List<EdmxReference> references = Collections.singletonList(reference);
       final ServiceMetadata serviceMetadata = odata.createServiceMetadata(
-          new EdmTechProvider(references), references, new MetadataETagSupport(metadataETag));
+          new EdmTechProvider(),
+          Collections.singletonList(reference),
+          new MetadataETagSupport(metadataETag));
 
       HttpSession session = request.getSession(true);
       DataProvider dataProvider = (DataProvider) session.getAttribute(DataProvider.class.getName());
       if (dataProvider == null) {
-        dataProvider = new DataProvider(serviceMetadata.getEdm());
+        dataProvider = new DataProvider(odata, serviceMetadata.getEdm());
         session.setAttribute(DataProvider.class.getName(), dataProvider);
         LOG.info("Created new data provider.");
       }
 
       ODataHttpHandler handler = odata.createHandler(serviceMetadata);
-      // Register processors
+      // Register processors.
       handler.register(new TechnicalEntityProcessor(dataProvider, serviceMetadata));
       handler.register(new TechnicalPrimitiveComplexProcessor(dataProvider, serviceMetadata));
       handler.register(new TechnicalActionProcessor(dataProvider, serviceMetadata));
       handler.register(new TechnicalBatchProcessor(dataProvider));
-      // Register Helper
+      // Register helpers.
       handler.register(new ETagSupport());
       handler.register(new DefaultDebugSupport());
-      // Process the request
+      // Process the request.
       handler.process(request, response);
     } catch (final RuntimeException e) {
       LOG.error("Server Error", e);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e981aaad/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/async/TechnicalAsyncService.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/async/TechnicalAsyncService.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/async/TechnicalAsyncService.java
index 521f7ab..c31f202 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/async/TechnicalAsyncService.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/async/TechnicalAsyncService.java
@@ -38,6 +38,7 @@ import java.io.Closeable;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.lang.reflect.InvocationTargetException;
 import java.nio.ByteBuffer;
 import java.nio.channels.Channels;
 import java.nio.channels.ReadableByteChannel;
@@ -243,18 +244,19 @@ public class TechnicalAsyncService {
    * Runnable for the AsyncProcessor.
    */
   static class AsyncRunner implements Runnable {
-    private final AsyncProcessor<?> dispatched;
+    private static final Pattern PATTERN = Pattern.compile("(" + TEC_ASYNC_SLEEP + "=)(\\d*)");
+    private final AsyncProcessor<? extends Processor> dispatched;
     private int defaultSleepTimeInSeconds = 0;
     private Exception exception;
     boolean finished = false;
 
-    public AsyncRunner(AsyncProcessor<?> wrap) {
+    public AsyncRunner(AsyncProcessor<? extends Processor> wrap) {
       this(wrap, 0);
     }
 
-    public AsyncRunner(AsyncProcessor<?> wrap, int defaultSleepTimeInSeconds) {
+    public AsyncRunner(AsyncProcessor<? extends Processor> wrap, int defaultSleepTimeInSeconds) {
       this.dispatched = wrap;
-      if(defaultSleepTimeInSeconds > 0) {
+      if (defaultSleepTimeInSeconds > 0) {
         this.defaultSleepTimeInSeconds = defaultSleepTimeInSeconds;
       }
     }
@@ -265,15 +267,19 @@ public class TechnicalAsyncService {
         int sleep = getSleepTime(dispatched);
         TimeUnit.SECONDS.sleep(sleep);
         dispatched.process();
-      } catch (Exception e) {
+      } catch (final InterruptedException e) {
+        exception = e;
+      } catch (final InvocationTargetException e) {
+        exception = e;
+      } catch (final IllegalAccessException e) {
         exception = e;
       }
       finished = true;
     }
 
-    private int getSleepTime(AsyncProcessor<?> wrap) {
+    private int getSleepTime(AsyncProcessor<? extends Processor> wrap) {
       String preferHeader = wrap.getPreferHeader();
-      Matcher matcher = Pattern.compile("(" + TEC_ASYNC_SLEEP + "=)(\\d*)").matcher(preferHeader);
+      Matcher matcher = PATTERN.matcher(preferHeader);
       if (matcher.find()) {
         String waitTimeAsString = matcher.group(2);
         return Integer.parseInt(waitTimeAsString);
@@ -289,7 +295,7 @@ public class TechnicalAsyncService {
       return finished;
     }
 
-    public AsyncProcessor<?> getDispatched() {
+    public AsyncProcessor<? extends Processor> getDispatched() {
       return dispatched;
     }
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e981aaad/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/ActionData.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/ActionData.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/ActionData.java
index 65a56c7..72c34b2 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/ActionData.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/ActionData.java
@@ -22,7 +22,6 @@ import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Calendar;
-import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
@@ -37,13 +36,15 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
 import org.apache.olingo.server.api.OData;
-import org.apache.olingo.server.api.ServiceMetadata;
-import org.apache.olingo.server.api.edmx.EdmxReference;
 import org.apache.olingo.server.tecsvc.data.DataProvider.DataProviderException;
-import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
 
 public class ActionData {
 
+  /**
+   * Performs the named action (i.e., does nothing, currently) and returns the primitive-type result.
+   * @param name       name of the action
+   * @param parameters parameters of the action 
+   */
   protected static Property primitiveAction(final String name, final Map<String, Parameter> parameters)
       throws DataProviderException {
     if ("UARTString".equals(name)) {
@@ -52,16 +53,16 @@ public class ActionData {
     throw new DataProviderException("Action " + name + " is not yet implemented.");
   }
 
-  protected static Property primitiveCollectionAction(final String name, final Map<String, Parameter> parameters)
-      throws DataProviderException {
+  protected static Property primitiveCollectionAction(final String name, final Map<String, Parameter> parameters,
+      final OData oData) throws DataProviderException {
     if ("UARTCollStringTwoParam".equals(name)) {
       Parameter paramInt16 = parameters.get("ParameterInt16");
       Parameter paramDuration = parameters.get("ParameterDuration");
-      if ((paramInt16 == null || paramInt16.isNull()) || (paramDuration == null || paramDuration.isNull())) {
+      if (paramInt16 == null || paramInt16.isNull() || paramDuration == null || paramDuration.isNull()) {
         try {
-          String param16String = valueAsString(paramInt16, EdmPrimitiveTypeKind.Int16);
-          String paramDurationString = valueAsString(paramDuration, EdmPrimitiveTypeKind.Duration);
-          
+          String param16String = valueAsString(paramInt16, EdmPrimitiveTypeKind.Int16, oData);
+          String paramDurationString = valueAsString(paramDuration, EdmPrimitiveTypeKind.Duration, oData);
+
           return new Property(null, name, ValueType.COLLECTION_PRIMITIVE, Arrays.asList(new String[] {
               name + " int16 value: " + param16String,
               name + " duration value: " + paramDurationString
@@ -72,7 +73,7 @@ public class ActionData {
       }
       short loopCount = (Short) paramInt16.asPrimitive();
       BigDecimal duration = (BigDecimal) paramDuration.asPrimitive();
-      EdmPrimitiveType primDuration = OData.newInstance().createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Duration);
+      EdmPrimitiveType primDuration = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Duration);
       BigDecimal addValue = new BigDecimal(1);
       List<Object> collectionValues = new ArrayList<Object>();
       for (int i = 0; i < loopCount; i++) {
@@ -89,24 +90,18 @@ public class ActionData {
     throw new DataProviderException("Action " + name + " is not yet implemented.");
   }
 
-  private static <T> String valueAsString(final Parameter parameter, final EdmPrimitiveTypeKind kind) 
+  private static String valueAsString(final Parameter parameter, final EdmPrimitiveTypeKind kind, final OData oData)
       throws EdmPrimitiveTypeException {
-    return parameter == null ? "null" 
-         : OData.newInstance().createPrimitiveTypeInstance(kind)
-                              .valueToString(parameter.asPrimitive(), null, null, null, null, null);
+    return parameter == null ? "null" :
+        oData.createPrimitiveTypeInstance(kind)
+            .valueToString(parameter.asPrimitive(), null, null, null, null, null);
   }
 
   protected static Property complexAction(final String name, final Map<String, Parameter> parameters)
       throws DataProviderException {
     if ("UARTCTTwoPrimParam".equals(name)) {
       Parameter paramInt16 = parameters.get("ParameterInt16");
-      Short number;
-      if (paramInt16 == null) {
-        number = new Short((short) 32767);
-      } else {
-        number = (Short) paramInt16.asPrimitive();
-      }
-
+      final Short number = paramInt16 == null ? (short) 32767 : (Short) paramInt16.asPrimitive();
       return createCTTwoPrimComplexProperty(number, "UARTCTTwoPrimParam string value");
     }
     throw new DataProviderException("Action " + name + " is not yet implemented.");
@@ -143,7 +138,6 @@ public class ActionData {
           complexCollection.clear();
         } else if (number >= 0 && number < complexCollection.size()) {
           complexCollection = complexCollection.subList(0, number);
-
         }
         Property complexCollProperty = new Property();
         complexCollProperty.setValue(ValueType.COLLECTION_COMPLEX, complexCollection);
@@ -153,21 +147,13 @@ public class ActionData {
     throw new DataProviderException("Action " + name + " is not yet implemented.");
   }
 
-  protected static EntityActionResult entityAction(final String name, final Map<String, Parameter> parameters)
-      throws DataProviderException {
-    final ServiceMetadata metadata = OData.newInstance().createServiceMetadata(new EdmTechProvider(), 
-        Collections.<EdmxReference> emptyList(),null);
-    
+  protected static EntityActionResult entityAction(final String name, final Map<String, Parameter> parameters,
+      final Map<String, EntityCollection> data) throws DataProviderException {
     if ("UARTETTwoKeyTwoPrimParam".equals(name)) {
       Parameter parameter = parameters.get("ParameterInt16");
-      Short number;
-      if (parameter != null) {
-        number = (Short) parameter.asPrimitive();
-      } else {
-        number = (short) 0;
-      }
+      final Short number = parameter == null ? 0 : (Short) parameter.asPrimitive();
 
-      EntityCollection entityCollection = new DataCreator(metadata.getEdm()).getData().get("ESTwoKeyTwoPrim");
+      EntityCollection entityCollection = data.get("ESTwoKeyTwoPrim");
       for (Entity entity : entityCollection.getEntities()) {
         Object asPrimitive = entity.getProperty("PropertyInt16").asPrimitive();
         if (number.equals(asPrimitive)) {
@@ -178,7 +164,7 @@ public class ActionData {
       throw new DataProviderException("Entity not found with key: " + number, HttpStatusCode.NOT_FOUND);
     } else if ("UARTETAllPrimParam".equals(name)) {
       Parameter paramDate = parameters.get("ParameterDate");
-      EntityCollection entityCollection = new DataCreator(metadata.getEdm()).getData().get("ESAllPrim");
+      EntityCollection entityCollection = data.get("ESAllPrim");
       if (paramDate != null) {
         Calendar date = (Calendar) paramDate.asPrimitive();
         boolean freeKey;
@@ -226,12 +212,7 @@ public class ActionData {
       throws DataProviderException {
     if ("UARTCollETKeyNavParam".equals(name)) {
       Parameter paramInt16 = parameters.get("ParameterInt16");
-      Short number;
-      if (paramInt16 == null) {
-        number = (short) 0;
-      } else {
-        number = (Short) paramInt16.asPrimitive();
-      }
+      final Short number = paramInt16 == null ? 0 : (Short) paramInt16.asPrimitive();
       EntityCollection collection = new EntityCollection();
       if (number > 0) {
         for (short i = 1; i <= number; i++) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e981aaad/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
index ce5daf3..01af921 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
@@ -39,8 +39,11 @@ import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ValueType;
 import org.apache.olingo.commons.api.edm.Edm;
+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.server.api.OData;
+import org.apache.olingo.server.api.serializer.SerializerException;
+import org.apache.olingo.server.api.uri.UriHelper;
 import org.apache.olingo.server.tecsvc.provider.EntityTypeProvider;
 
 public class DataCreator {
@@ -49,28 +52,28 @@ public class DataCreator {
 
   private final Map<String, EntityCollection> data;
 
-  public DataCreator(Edm edm) {
+  public DataCreator(final OData odata, final Edm edm) {
     data = new HashMap<String, EntityCollection>();
-    data.put("ESTwoPrim", createESTwoPrim(edm));
-    data.put("ESAllPrim", createESAllPrim(edm));
-    data.put("ESCompAllPrim", createESCompAllPrim(edm));
-    data.put("ESCollAllPrim", createESCollAllPrim(edm));
-    data.put("ESMixPrimCollComp", createESMixPrimCollComp(edm));
-    data.put("ESAllKey", createESAllKey(edm));
-    data.put("ESCompComp", createESCompComp(edm));
-    data.put("ESMedia", createESMedia(edm));
-    data.put("ESKeyNav", createESKeyNav(edm));
-    data.put("ESTwoKeyNav", createESTwoKeyNav(edm));
-    data.put("ESCompCollComp", createESCompCollComp(edm));
-    data.put("ESServerSidePaging", createESServerSidePaging(edm));
-    data.put("ESTwoKeyTwoPrim", createESTwoKeyTwoPrim(edm));
-    data.put("ESAllNullable", createESAllNullable(edm));
-    data.put("ESTwoBase", createESTwoBase(edm));
-    data.put("ESBaseTwoKeyNav", createESBaseTwoKeyNav(edm));
-    data.put("ESCompCollAllPrim", createESCompCollAllPrim(edm));
-    data.put("ESFourKeyAlias", createESFourKeyAlias(edm));
-    data.put("ESBase", createESBase(edm));
-    data.put("ESCompMixPrimCollComp", createESCompMixPrimCollComp(edm));
+    data.put("ESTwoPrim", createESTwoPrim(edm, odata));
+    data.put("ESAllPrim", createESAllPrim(edm, odata));
+    data.put("ESCompAllPrim", createESCompAllPrim(edm, odata));
+    data.put("ESCollAllPrim", createESCollAllPrim(edm, odata));
+    data.put("ESMixPrimCollComp", createESMixPrimCollComp(edm, odata));
+    data.put("ESAllKey", createESAllKey(edm, odata));
+    data.put("ESCompComp", createESCompComp(edm, odata));
+    data.put("ESMedia", createESMedia(edm, odata));
+    data.put("ESKeyNav", createESKeyNav(edm, odata));
+    data.put("ESTwoKeyNav", createESTwoKeyNav(edm, odata));
+    data.put("ESCompCollComp", createESCompCollComp(edm, odata));
+    data.put("ESServerSidePaging", createESServerSidePaging(edm, odata));
+    data.put("ESTwoKeyTwoPrim", createESTwoKeyTwoPrim(edm, odata));
+    data.put("ESAllNullable", createESAllNullable(edm, odata));
+    data.put("ESTwoBase", createESTwoBase(edm, odata));
+    data.put("ESBaseTwoKeyNav", createESBaseTwoKeyNav(edm, odata));
+    data.put("ESCompCollAllPrim", createESCompCollAllPrim(edm, odata));
+    data.put("ESFourKeyAlias", createESFourKeyAlias(edm, odata));
+    data.put("ESBase", createESBase(edm, odata));
+    data.put("ESCompMixPrimCollComp", createESCompMixPrimCollComp(edm, odata));
 
     linkESTwoPrim(data);
     linkESAllPrim(data);
@@ -78,24 +81,23 @@ public class DataCreator {
     linkESTwoKeyNav(data);
   }
 
-  private EntityCollection createESCompMixPrimCollComp(Edm edm) {
+  private EntityCollection createESCompMixPrimCollComp(final Edm edm, final OData odata) {
     final EntityCollection entityCollection = new EntityCollection();
     
     entityCollection.getEntities().add(createETCompMixPrimCollComp((short) 1));
     entityCollection.getEntities().add(createETCompMixPrimCollComp((short) 2));
     entityCollection.getEntities().add(createETCompMixPrimCollComp((short) 3));
 
-    EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETCompMixPrimCollComp);
-    setEntityType(entityCollection, type);
-    createEntityId("ESCompMixPrimCollComp", entityCollection, type.getKeyPropertyRefs());
+    setEntityType(entityCollection, edm.getEntityType(EntityTypeProvider.nameETCompMixPrimCollComp));
+    createEntityId(edm, odata, "ESCompMixPrimCollComp", entityCollection);
     
     return entityCollection;
   }
-  
+
   @SuppressWarnings("unchecked")
-  private Entity createETCompMixPrimCollComp(Short propertyInt16) {
+  private Entity createETCompMixPrimCollComp(final Short propertyInt16) {
     return new Entity()
-      .addProperty(createPrimitive("PropertyInt16",(short) 1))
+      .addProperty(createPrimitive("PropertyInt16", propertyInt16))
       .addProperty(createComplex("PropertyMixedPrimCollComp",
           createPrimitive("PropertyInt16",(short) 1),
           createPrimitiveCollection("CollPropertyString", 
@@ -119,8 +121,8 @@ public class DataCreator {
           )    
        ));
   }
-  
-  private EntityCollection createESBase(Edm edm) {
+
+  private EntityCollection createESBase(final Edm edm, final OData odata) {
     final EntityCollection entityCollection = new EntityCollection();
     
     entityCollection.getEntities().add(new Entity()
@@ -138,14 +140,13 @@ public class DataCreator {
         .addProperty(createPrimitive("PropertyString", "TEST C"))
         .addProperty(createPrimitive("AdditionalPropertyString_5", "TEST E 0815")));
 
-    EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETBase);
-    setEntityType(entityCollection, type);
-    createEntityId("ESBase", entityCollection, type.getKeyPropertyRefs());
+    setEntityType(entityCollection, edm.getEntityType(EntityTypeProvider.nameETBase));
+    createEntityId(edm, odata, "ESBase", entityCollection);
 
     return entityCollection;
   }
 
-  private EntityCollection createESFourKeyAlias(Edm edm) {
+  private EntityCollection createESFourKeyAlias(final Edm edm, final OData odata) {
     final EntityCollection entityCollection = new EntityCollection();
     
     entityCollection.getEntities().add(new Entity()
@@ -162,25 +163,23 @@ public class DataCreator {
         ))
     );
     
-    EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETFourKeyAlias);
-    setEntityType(entityCollection, type);
-    createEntityId("ESFourKeyAlias", entityCollection, type.getKeyPropertyRefs());
+    setEntityType(entityCollection, edm.getEntityType(EntityTypeProvider.nameETFourKeyAlias));
+    createEntityId(edm, odata, "ESFourKeyAlias", entityCollection);
 
     return entityCollection;
   }
 
-  private EntityCollection createESCompCollAllPrim(Edm edm) {
+  private EntityCollection createESCompCollAllPrim(final Edm edm, final OData odata) {
     final EntityCollection entityCollection = new EntityCollection();
     
     entityCollection.getEntities().add(createETCompCollAllPrim((short) 5678));
     entityCollection.getEntities().add(createETCompCollAllPrim((short) 12326));
     
-    EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETCompCollAllPrim);
-    setEntityType(entityCollection, type);
-    createEntityId("ESCompCollAllPrim", entityCollection, type.getKeyPropertyRefs());    
+    setEntityType(entityCollection, edm.getEntityType(EntityTypeProvider.nameETCompCollAllPrim));
+    createEntityId(edm, odata, "ESCompCollAllPrim", entityCollection);
     return entityCollection;
   }
-  
+
   private Entity createETCompCollAllPrim(short propertyInt16) {
     return new Entity() 
       .addProperty(createPrimitive("PropertyInt16", propertyInt16))
@@ -245,9 +244,9 @@ public class DataCreator {
                getDateTime(1948, 2, 17, 9, 9, 9)
            ),
            createPrimitiveCollection("CollPropertyDuration", 
-               getDurration(0, 0, 0, 13),
-               getDurration(0, 5, 28, 20),
-               getDurration(0, 1, 0, 0)
+               getDuration(0, 0, 0, 13),
+               getDuration(0, 5, 28, 20),
+               getDuration(0, 1, 0, 0)
            ),
            createPrimitiveCollection("CollPropertyGuid",
                UUID.fromString("ffffff67-89ab-cdef-0123-456789aaaaaa"),
@@ -262,7 +261,7 @@ public class DataCreator {
         ));
   }
   
-  private EntityCollection createESBaseTwoKeyNav(Edm edm) {
+  private EntityCollection createESBaseTwoKeyNav(final Edm edm, final OData odata) {
     final EntityCollection entityCollection = new EntityCollection();
     entityCollection.getEntities().add(
         createESTwoKeyNavEntity((short) 1, "1")
@@ -280,14 +279,13 @@ public class DataCreator {
         createESTwoKeyNavEntity((short) 3, "1")
           .addProperty(createPrimitive("PropertyDate", getDateTime(2013, 12, 12, 0, 0, 0))));
     
-    EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETBaseTwoKeyNav);
-    setEntityType(entityCollection, type);
-    createEntityId("ESBaseTwoKeyNav", entityCollection, type.getKeyPropertyRefs());
-    
+    setEntityType(entityCollection, edm.getEntityType(EntityTypeProvider.nameETBaseTwoKeyNav));
+    createEntityId(edm, odata, "ESBaseTwoKeyNav", entityCollection);
+
     return entityCollection;
   }
 
-  private EntityCollection createESTwoBase(Edm edm) {
+  private EntityCollection createESTwoBase(final Edm edm, final OData odata) {
     final EntityCollection entityCollection = new EntityCollection();
     entityCollection.getEntities().add(new Entity()
         .addProperty(createPrimitive("PropertyInt16",(short) 111))
@@ -307,14 +305,13 @@ public class DataCreator {
         .addProperty(createPrimitive("AdditionalPropertyString_5", "TEST E 0815"))
         .addProperty(createPrimitive("AdditionalPropertyString_6", "TEST F 0815")));
 
-    EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETTwoBase);
-    setEntityType(entityCollection, type);
-    createEntityId("ESTwoBase", entityCollection, type.getKeyPropertyRefs());
+    setEntityType(entityCollection, edm.getEntityType(EntityTypeProvider.nameETTwoBase));
+    createEntityId(edm, odata, "ESTwoBase", entityCollection);
 
     return entityCollection;
   }
 
-  private EntityCollection createESAllNullable(Edm edm) {
+  private EntityCollection createESAllNullable(final Edm edm, final OData odata) {
     final EntityCollection entityCollection = new EntityCollection();
     entityCollection.getEntities().add(
         new Entity()
@@ -388,9 +385,9 @@ public class DataCreator {
             null,
             getDateTime(1948, 2, 17, 9, 9, 9)))
         .addProperty(createPrimitiveCollection("CollPropertyDuration",
-            getDurration(0, 0, 0, 13),
+            getDuration(0, 0, 0, 13),
             null,
-            getDurration(0, 1, 0, 0)))
+            getDuration(0, 1, 0, 0)))
         .addProperty(createPrimitiveCollection("CollPropertyGuid", 
             UUID.fromString("ffffff67-89ab-cdef-0123-456789aaaaaa"),
             null,
@@ -401,9 +398,8 @@ public class DataCreator {
             getTime(0, 37, 13))
         ));
     
-    EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETAllNullable);
-    setEntityType(entityCollection, type);
-    createEntityId("ESAllNullable", entityCollection, type.getKeyPropertyRefs());
+    setEntityType(entityCollection, edm.getEntityType(EntityTypeProvider.nameETAllNullable));
+    createEntityId(edm, odata, "ESAllNullable", entityCollection);
     return entityCollection;
   }
 
@@ -411,51 +407,48 @@ public class DataCreator {
     return data;
   }
 
-  private EntityCollection createESTwoKeyTwoPrim(Edm edm) {
+  private EntityCollection createESTwoKeyTwoPrim(final Edm edm, final OData odata) {
     EntityCollection entityCollection = new EntityCollection();
     entityCollection.getEntities().add(createETTwoKeyTwoPrimEntity((short) 32767, "Test String1"));
     entityCollection.getEntities().add(createETTwoKeyTwoPrimEntity((short) -365, "Test String2"));
     entityCollection.getEntities().add(createETTwoKeyTwoPrimEntity((short) -32766, "Test String3"));
-    
-    EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETTwoKeyTwoPrim);
-    setEntityType(entityCollection, type);
-    createEntityId("ESTwoKeyTwoPrim", entityCollection, type.getKeyPropertyRefs());
-    
+
+    setEntityType(entityCollection, edm.getEntityType(EntityTypeProvider.nameETTwoKeyTwoPrim));
+    createEntityId(edm, odata, "ESTwoKeyTwoPrim", entityCollection);
+
     return entityCollection;
   }
 
   private Entity createETTwoKeyTwoPrimEntity(final short propertyInt16, final String propertyString) {
     return new Entity()
-    	.addProperty(createPrimitive("PropertyInt16", propertyInt16))
+        .addProperty(createPrimitive("PropertyInt16", propertyInt16))
         .addProperty(createPrimitive("PropertyString", propertyString));
   }
 
-  private EntityCollection createESServerSidePaging(Edm  edm) {
+  private EntityCollection createESServerSidePaging(final Edm edm, final OData odata) {
     EntityCollection entityCollection = new EntityCollection();
 
     for (short i = 1; i <= 503; i++) {
       entityCollection.getEntities().add(new Entity()
-      	.addProperty(createPrimitive("PropertyInt16", i))
-      	.addProperty(createPrimitive("PropertyString", "Number:" + i)));
+          .addProperty(createPrimitive("PropertyInt16", i))
+          .addProperty(createPrimitive("PropertyString", "Number:" + i)));
     }
 
-    EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETServerSidePaging);
-    setEntityType(entityCollection, type);
-    createEntityId("ESServerSidePaging", entityCollection, type.getKeyPropertyRefs());
+    setEntityType(entityCollection, edm.getEntityType(EntityTypeProvider.nameETServerSidePaging));
+    createEntityId(edm, odata, "ESServerSidePaging", entityCollection);
 
     return entityCollection;
   }
 
-  private EntityCollection createESKeyNav(Edm edm) {
+  private EntityCollection createESKeyNav(final Edm edm, final OData odata) {
     final EntityCollection entityCollection = new EntityCollection();
 
     entityCollection.getEntities().add(createETKeyNavEntity((short) 1, "I am String Property 1"));
     entityCollection.getEntities().add(createETKeyNavEntity((short) 2, "I am String Property 2"));
     entityCollection.getEntities().add(createETKeyNavEntity((short) 3, "I am String Property 3"));
 
-    EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETKeyNav);
-    setEntityType(entityCollection, type);
-    createEntityId("ESKeyNav", entityCollection, type.getKeyPropertyRefs());
+    setEntityType(entityCollection, edm.getEntityType(EntityTypeProvider.nameETKeyNav));
+    createEntityId(edm, odata, "ESKeyNav", entityCollection);
 
     return entityCollection;
   }
@@ -495,7 +488,7 @@ public class DataCreator {
         		    createPrimitive("PropertyInt16",(short) 1))));
   }
 
-  private EntityCollection createESTwoKeyNav(Edm edm) {
+  private EntityCollection createESTwoKeyNav(final Edm edm, final OData odata) {
     final EntityCollection entityCollection = new EntityCollection();
 
     entityCollection.getEntities().add(createESTwoKeyNavEntity((short) 1, "1"));
@@ -503,9 +496,8 @@ public class DataCreator {
     entityCollection.getEntities().add(createESTwoKeyNavEntity((short) 2, "1"));
     entityCollection.getEntities().add(createESTwoKeyNavEntity((short) 3, "1"));
 
-    EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETTwoKeyNav);
-    setEntityType(entityCollection, type);
-    createEntityId("ESTwoKeyNav", entityCollection, type.getKeyPropertyRefs());
+    setEntityType(entityCollection, edm.getEntityType(EntityTypeProvider.nameETTwoKeyNav));
+    createEntityId(edm, odata, "ESTwoKeyNav", entityCollection);
 
     return entityCollection;
   }
@@ -567,7 +559,7 @@ public class DataCreator {
   }
 
   @SuppressWarnings("unchecked")
-  private EntityCollection createESCompCollComp(Edm edm) {
+  private EntityCollection createESCompCollComp(final Edm edm, final OData odata) {
     final EntityCollection entityCollection = new EntityCollection();
 
     entityCollection.getEntities().add(new Entity()
@@ -598,14 +590,13 @@ public class DataCreator {
               createPrimitive("PropertyInt16",(short) 0),
               createPrimitive("PropertyString", "13 Test Complex in Complex Property"))))));
 
-    EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETCompCollComp);
-    setEntityType(entityCollection, type);
-    createEntityId("ESCompCollComp", entityCollection, type.getKeyPropertyRefs());
+    setEntityType(entityCollection, edm.getEntityType(EntityTypeProvider.nameETCompCollComp));
+    createEntityId(edm, odata, "ESCompCollComp", entityCollection);
 
     return entityCollection;
   }
 
-  private EntityCollection createESTwoPrim(Edm edm) {
+  private EntityCollection createESTwoPrim(final Edm edm, final OData odata) {
     EntityCollection entityCollection = new EntityCollection();
 
     entityCollection.getEntities().add(new Entity()
@@ -624,19 +615,18 @@ public class DataCreator {
     	.addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
       .addProperty(createPrimitive("PropertyString", "Test String4")));
 
-    EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETTwoPrim);
-    setEntityType(entityCollection, type);
-    createEntityId("ESTwoPrim", entityCollection, type.getKeyPropertyRefs());
+    setEntityType(entityCollection, edm.getEntityType(EntityTypeProvider.nameETTwoPrim));
+    createEntityId(edm, odata, "ESTwoPrim", entityCollection);
     return entityCollection;
   }
 
-  private void setEntityType(EntityCollection entityCollection, EdmEntityType type) {
-    for (Entity entity:entityCollection.getEntities()) {
+  private void setEntityType(EntityCollection entityCollection, final EdmEntityType type) {
+    for (Entity entity : entityCollection.getEntities()) {
       entity.setType(type.getFullQualifiedName().getFullQualifiedNameAsString());
     }
   }
 
-  private EntityCollection createESAllPrim(Edm edm) {
+  private EntityCollection createESAllPrim(final Edm edm, final OData odata) {
     EntityCollection entityCollection = new EntityCollection();
 
     entityCollection.getEntities().add(new Entity()
@@ -695,14 +685,13 @@ public class DataCreator {
         .addProperty(createPrimitive("PropertyGuid", UUID.fromString("76543201-23ab-cdef-0123-456789cccddd")))
         .addProperty(createPrimitive("PropertyTimeOfDay", getTime(0, 1, 1))));
 
-    EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETAllPrim);
-    setEntityType(entityCollection, type);
-    createEntityId("ESAllPrim", entityCollection, type.getKeyPropertyRefs());
+    setEntityType(entityCollection, edm.getEntityType(EntityTypeProvider.nameETAllPrim));
+    createEntityId(edm, odata, "ESAllPrim", entityCollection);
 
     return entityCollection;
   }
 
-  private EntityCollection createESCompAllPrim(Edm edm) {
+  private EntityCollection createESCompAllPrim(final Edm edm, final OData odata) {
     EntityCollection entityCollection = new EntityCollection();
 
     Entity entity = new Entity()
@@ -796,28 +785,26 @@ public class DataCreator {
     entity.setETag("W/\"-32768\"");
     entityCollection.getEntities().add(entity);
 
-    EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETCompAllPrim);
-    setEntityType(entityCollection, type);
-    createEntityId("ESCompAllPrim", entityCollection, type.getKeyPropertyRefs());
+    setEntityType(entityCollection, edm.getEntityType(EntityTypeProvider.nameETCompAllPrim));
+    createEntityId(edm, odata, "ESCompAllPrim", entityCollection);
 
     return entityCollection;
   }
 
-  private EntityCollection createESCollAllPrim(Edm edm) {
+  private EntityCollection createESCollAllPrim(final Edm edm, final OData odata) {
     EntityCollection entityCollection = new EntityCollection();
 
     entityCollection.getEntities().add(createETCollAllPrim((short) 1));
     entityCollection.getEntities().add(createETCollAllPrim((short) 2));
     entityCollection.getEntities().add(createETCollAllPrim((short) 3));
 
-    EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETCollAllPrim);
-    setEntityType(entityCollection, type);
-    createEntityId("ESCollAllPrim", entityCollection, type.getKeyPropertyRefs());
+    setEntityType(entityCollection, edm.getEntityType(EntityTypeProvider.nameETCollAllPrim));
+    createEntityId(edm, odata, "ESCollAllPrim", entityCollection);
 
     return entityCollection;
   }
   
-  private Entity createETCollAllPrim(Short propertyInt16) {
+  private Entity createETCollAllPrim(final Short propertyInt16) {
 	  return new Entity()
 	  	.addProperty(createPrimitive("PropertyInt16", propertyInt16))
 	  	.addProperty(createPrimitiveCollection("CollPropertyString", 
@@ -885,8 +872,8 @@ public class DataCreator {
 	      		getTime(23, 59, 59),
             getTime(1, 12, 33)));
   }
-  
-  private EntityCollection createESMixPrimCollComp(Edm edm) {
+
+  private EntityCollection createESMixPrimCollComp(final Edm edm, final OData odata) {
     EntityCollection entityCollection = new EntityCollection();
 
     entityCollection.getEntities().add(new Entity()
@@ -922,9 +909,8 @@ public class DataCreator {
         createPrimitive("PropertyString", "TEST C")))
       .addProperty(createColPropertyComp()));
 
-    EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETMixPrimCollComp);
-    setEntityType(entityCollection, type);
-    createEntityId("ESMixPrimCollComp", entityCollection, type.getKeyPropertyRefs());
+    setEntityType(entityCollection, edm.getEntityType(EntityTypeProvider.nameETMixPrimCollComp));
+    createEntityId(edm, odata, "ESMixPrimCollComp", entityCollection);
     
     return entityCollection;
   }
@@ -943,7 +929,7 @@ public class DataCreator {
 				createPrimitive("PropertyString", "TEST 3")));
 	}
   
-	private EntityCollection createESAllKey(Edm edm) {
+	private EntityCollection createESAllKey(final Edm edm, final OData odata) {
     EntityCollection entityCollection = new EntityCollection();
 
     entityCollection.getEntities().add(new Entity()
@@ -976,14 +962,13 @@ public class DataCreator {
         .addProperty(createPrimitive("PropertyGuid", GUID))
         .addProperty(createPrimitive("PropertyTimeOfDay", getTime(2, 48, 21))));
     
-    EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETAllKey);
-    setEntityType(entityCollection, type);
-    createEntityId("ESAllKey", entityCollection, type.getKeyPropertyRefs());
+    setEntityType(entityCollection, edm.getEntityType(EntityTypeProvider.nameETAllKey));
+    createEntityId(edm, odata, "ESAllKey", entityCollection);
 
     return entityCollection;
   }
 
-  private EntityCollection createESCompComp(Edm edm) {
+  private EntityCollection createESCompComp(final Edm edm, final OData odata) {
     EntityCollection entityCollection = new EntityCollection();
 
     Entity entity = new Entity();
@@ -1002,14 +987,13 @@ public class DataCreator {
             createPrimitive("PropertyString", "String 2"))));
     entityCollection.getEntities().add(entity);
 
-    EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETCompComp);
-    setEntityType(entityCollection, type);
-    createEntityId("ESCompComp", entityCollection, type.getKeyPropertyRefs());
+    setEntityType(entityCollection, edm.getEntityType(EntityTypeProvider.nameETCompComp));
+    createEntityId(edm, odata, "ESCompComp", entityCollection);
 
     return entityCollection;
   }
 
-  private EntityCollection createESMedia(Edm edm) {
+  private EntityCollection createESMedia(final Edm edm, final OData odata) {
     EntityCollection entityCollection = new EntityCollection();
 
     Entity entity = new Entity()
@@ -1044,9 +1028,8 @@ public class DataCreator {
     entity.getMediaEditLinks().add(buildMediaLink("ESMedia", "ESMedia(4)/$value"));
     entityCollection.getEntities().add(entity);
 
-    EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETMedia);
-    setEntityType(entityCollection, type);
-    createEntityId("ESMedia", entityCollection, type.getKeyPropertyRefs());
+    setEntityType(entityCollection, edm.getEntityType(EntityTypeProvider.nameETMedia));
+    createEntityId(edm, odata, "ESMedia", entityCollection);
 
     return entityCollection;
   }
@@ -1184,13 +1167,13 @@ public class DataCreator {
     return dateTime;
   }
 
-  protected static int getDurration(final int days, int hours, int minutes, int seconds) {
+  protected static int getDuration(final int days, final int hours, final int minutes, final int seconds) {
     return days * 24   * 60 * 60 
               + hours  * 60 * 60 
                   + minutes * 60 
                   + seconds;
   }
-  
+
   protected static Calendar getTime(final int hour, final int minute, final int second) {
     Calendar time = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
     time.clear();
@@ -1214,12 +1197,12 @@ public class DataCreator {
     link.setHref(href);
     return link;
   }
-  
+
   protected static void setLink(final Entity entity, final String navigationPropertyName, final Entity target) {
     Link link = entity.getNavigationLink(navigationPropertyName);
     if (link == null) {
       link = new Link();
-      link.setRel("http://docs.oasis-open.org/odata/ns/related/"+navigationPropertyName);
+      link.setRel(Constants.NS_NAVIGATION_LINK_REL + navigationPropertyName);
       link.setType(Constants.ENTITY_NAVIGATION_LINK_TYPE);
       link.setTitle(navigationPropertyName);
       link.setHref(target.getId().toASCIIString());
@@ -1232,42 +1215,29 @@ public class DataCreator {
     Link link = entity.getNavigationLink(navigationPropertyName);
     if (link == null) {
       link = new Link();
-      link.setRel("http://docs.oasis-open.org/odata/ns/related/"+navigationPropertyName);
+      link.setRel(Constants.NS_NAVIGATION_LINK_REL + navigationPropertyName);
       link.setType(Constants.ENTITY_SET_NAVIGATION_LINK_TYPE);
       link.setTitle(navigationPropertyName);
       EntityCollection target = new EntityCollection();
       target.getEntities().addAll(Arrays.asList(targets));
       link.setInlineEntitySet(target);
-      link.setHref(entity.getId().toASCIIString()+"/"+navigationPropertyName);
+      link.setHref(entity.getId().toASCIIString() + "/" + navigationPropertyName);
       entity.getNavigationLinks().add(link);
     } else {
       link.getInlineEntitySet().getEntities().addAll(Arrays.asList(targets));
     }
   }
-  
-  protected static void createEntityId (String esName, EntityCollection entities, List<EdmKeyPropertyRef> keys) {
-    for (Entity entity:entities.getEntities()) {
-      createEntityId(esName, entity, keys);
-    }
-  }  
-  protected static void createEntityId (String esName, Entity entity, List<EdmKeyPropertyRef> keys) {
-    try {
-      if(keys.size() == 1) {
-        entity.setId(URI.create(esName+"("+entity.getProperty(keys.get(0).getName()).asPrimitive()+")"));
-      } else {
-        StringBuilder sb = new StringBuilder();
-        sb.append(esName).append("(");
-        for (int i = 0; i < keys.size(); i++) {
-          if (i != 0) {
-            sb.append(",");
-          }
-          sb.append(keys.get(i)).append("=").append(entity.getProperty(keys.get(i).getName()).asPrimitive());
-        }
-        sb.append(")");
-        entity.setId(URI.create(sb.toString()));
+
+  private void createEntityId(final Edm edm, final OData odata,
+      final String entitySetName, final EntityCollection entities) {
+    final EdmEntitySet entitySet = edm.getEntityContainer().getEntitySet(entitySetName);
+    final UriHelper helper = odata.createUriHelper();
+    for (Entity entity : entities.getEntities()) {
+      try {
+        entity.setId(URI.create(helper.buildCanonicalURL(entitySet, entity)));
+      } catch (final SerializerException e) {
+        entity.setId(URI.create("id"));
       }
-    } catch (Exception e) {
-      entity.setId(URI.create("id"));
     }
-  }  
-}
\ No newline at end of file
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e981aaad/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
index 0dd530e..1d3ef71 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
@@ -54,6 +54,7 @@ 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.deserializer.DeserializerException;
+import org.apache.olingo.server.api.serializer.SerializerException;
 import org.apache.olingo.server.api.uri.UriParameter;
 import org.apache.olingo.server.api.uri.UriResourceEntitySet;
 
@@ -66,16 +67,13 @@ public class DataProvider {
   private AtomicLong KEY_STRING = new AtomicLong(0);
 
   private Map<String, EntityCollection> data;
-  private Edm edm;
-  private OData odata;
+  private final OData odata;
+  private final Edm edm;
 
-  public DataProvider(final Edm edm) {
-    this.edm = edm;
-    data = new DataCreator(edm).getData();
-  }
-
-  public void setOData(final OData odata) {
+  public DataProvider(final OData odata, final Edm edm) {
     this.odata = odata;
+    this.edm = edm;
+    data = new DataCreator(odata, edm).getData();
   }
 
   public EntityCollection readAll(final EdmEntitySet edmEntitySet) throws DataProviderException {
@@ -143,7 +141,7 @@ public class DataProvider {
       }
     }
   }
-  
+
   public Entity create(final EdmEntitySet edmEntitySet) throws DataProviderException {
     final EdmEntityType edmEntityType = edmEntitySet.getEntityType();
     EntityCollection entitySet = readAll(edmEntitySet);
@@ -156,7 +154,11 @@ public class DataProvider {
     }
 
     createProperties(edmEntityType, newEntity.getProperties());
-    DataCreator.createEntityId(edmEntitySet.getName(), newEntity, edmEntityType.getKeyPropertyRefs());
+    try {
+      newEntity.setId(URI.create(odata.createUriHelper().buildCanonicalURL(edmEntitySet, newEntity)));
+    } catch (final SerializerException e) {
+      throw new DataProviderException("Unable to set entity ID!", e);
+    }
     entities.add(newEntity);
 
     return newEntity;
@@ -518,7 +520,7 @@ public class DataProvider {
 
   public Property readFunctionPrimitiveComplex(final EdmFunction function, final List<UriParameter> parameters)
       throws DataProviderException {
-    return FunctionData.primitiveComplexFunction(function.getName(), parameters, data);
+    return FunctionData.primitiveComplexFunction(function.getName(), parameters, data, odata);
   }
 
   public Property processActionPrimitive(final String name, final Map<String, Parameter> actionParameters)
@@ -538,12 +540,12 @@ public class DataProvider {
 
   public Property processActionPrimitiveCollection(final String name, final Map<String, Parameter> actionParameters)
       throws DataProviderException {
-    return ActionData.primitiveCollectionAction(name, actionParameters);
+    return ActionData.primitiveCollectionAction(name, actionParameters, odata);
   }
 
   public EntityActionResult processActionEntity(final String name, final Map<String, Parameter> actionParameters)
       throws DataProviderException {
-    return ActionData.entityAction(name, actionParameters);
+    return ActionData.entityAction(name, actionParameters, data);
   }
 
   public EntityCollection processActionEntityCollection(final String name,

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e981aaad/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/FunctionData.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/FunctionData.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/FunctionData.java
index 65099dc..4037297 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/FunctionData.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/FunctionData.java
@@ -77,7 +77,7 @@ public class FunctionData {
 
   @SuppressWarnings("unchecked")
   protected static Property primitiveComplexFunction(final String name, final List<UriParameter> parameters,
-      final Map<String, EntityCollection> data) throws DataProviderException {
+      final Map<String, EntityCollection> data, final OData oData) throws DataProviderException {
     if (name.equals("UFNRTInt16")) {
       return DataCreator.createPrimitive(name, (short) 12345);
     } else if (name.equals("UFCRTString")) {
@@ -90,17 +90,15 @@ public class FunctionData {
           DataCreator.createPrimitive("PropertyString", "UFCRTCTTwoPrim string value"));
     } else if (name.equals("UFCRTCTTwoPrimParam")) {
       try {
-
-        OData oData = OData.newInstance();
         return DataCreator.createComplex(name,
             DataCreator.createPrimitive("PropertyInt16", oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Int16)
                 .valueOfString(getParameterText("ParameterInt16", parameters),
                     null, null, null, null, null, Short.class)),
-            DataCreator.createPrimitive("PropertyString", oData
-                .createPrimitiveTypeInstance(EdmPrimitiveTypeKind.String)
-                .valueOfString(oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.String)
-                    .fromUriLiteral(getParameterText("ParameterString", parameters)),
-                    null, null, null, null, null, String.class)));
+            DataCreator.createPrimitive("PropertyString",
+                oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.String)
+                    .valueOfString(oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.String)
+                        .fromUriLiteral(getParameterText("ParameterString", parameters)),
+                        null, null, null, null, null, String.class)));
       } catch (final EdmPrimitiveTypeException e) {
         throw new DataProviderException("Error in function " + name + ".", e);
       }
@@ -117,19 +115,19 @@ public class FunctionData {
       final String parameterInt16Raw = getParameterText("ParameterInt16", parameters);
       
       // ParameterString is not provided
-      if(parameterStringRaw == null) {
+      if (parameterStringRaw == null) {
         return new Property(null, "value", ValueType.PRIMITIVE, null);
       } else {
         try {
-          EdmPrimitiveType edmInt16 = OData.newInstance().createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Int16);
-          EdmPrimitiveType edmString = OData.newInstance().createPrimitiveTypeInstance(EdmPrimitiveTypeKind.String);
-          Short parameterInt16 =  edmInt16.valueOfString(parameterInt16Raw, null, null, null, null, null, Short.class);
-          String parameterString = edmString.fromUriLiteral(parameterStringRaw);
+          final EdmPrimitiveType edmInt16 = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Int16);
+          final EdmPrimitiveType edmString = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.String);
+          final Short parameterInt16 =  edmInt16.valueOfString(parameterInt16Raw, null, null, null, null, null,
+              Short.class);
+          final String parameterString = edmString.fromUriLiteral(parameterStringRaw);
           final StringBuilder builder = new StringBuilder();
-          
           // if parameterInt16 <= 0 return an empty string
-          for(short i = parameterInt16; i > 0; i--) {
-            if(builder.length() != 0) {
+          for (short i = parameterInt16; i > 0; i--) {
+            if (builder.length() != 0) {
               builder.append(',');
             }
             builder.append('"');
@@ -137,15 +135,15 @@ public class FunctionData {
             builder.append('"');
           }
           return new Property(null, "value", ValueType.PRIMITIVE, builder.toString());
-        } catch (EdmPrimitiveTypeException e) {
+        } catch (final EdmPrimitiveTypeException e) {
           throw new DataProviderException("Invalid function parameter.");
         }
       }
-    } else if(name.equals("UFCRTCollCTTwoPrimTwoParam")) {
+    } else if (name.equals("UFCRTCollCTTwoPrimTwoParam")) {
       String parameterStringRaw = getParameterText("ParameterString", parameters);
       String parameteInt16Raw = getParameterText("ParameterInt16", parameters);
-      EdmPrimitiveType edmInt16 = OData.newInstance().createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Int16);
-      EdmPrimitiveType edmString = OData.newInstance().createPrimitiveTypeInstance(EdmPrimitiveTypeKind.String);
+      EdmPrimitiveType edmInt16 = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Int16);
+      EdmPrimitiveType edmString = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.String);
       try {
         Short parameterInt16 = edmInt16.valueOfString(parameteInt16Raw, null, null, null, null, null, Short.class);
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e981aaad/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java
index cb77b43..af82eed 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java
@@ -67,7 +67,6 @@ public abstract class TechnicalProcessor implements Processor {
   public void init(final OData odata, final ServiceMetadata serviceMetadata) {
     this.odata = odata;
     this.serviceMetadata = serviceMetadata;
-    dataProvider.setOData(odata);
   }
 
   protected EdmEntitySet getEdmEntitySet(final UriInfoResource uriInfo) throws ODataApplicationException {


Mime
View raw message