You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by sk...@apache.org on 2014/07/03 12:54:36 UTC

[1/3] git commit: [OLINGO-337] refactor requestedContentType

Repository: olingo-odata4
Updated Branches:
  refs/heads/olingo337 2bd066264 -> 62eccf9c1


[OLINGO-337] refactor requestedContentType


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

Branch: refs/heads/olingo337
Commit: d784a047c86643a1e68ab6344c369ed8e3a7b7d8
Parents: 2bd0662
Author: Stephan Klevenz <st...@sap.com>
Authored: Thu Jul 3 09:09:22 2014 +0200
Committer: Stephan Klevenz <st...@sap.com>
Committed: Thu Jul 3 09:13:54 2014 +0200

----------------------------------------------------------------------
 .../server/api/processor/CollectionProcessor.java       |  3 ++-
 .../olingo/server/api/processor/DefaultProcessor.java   | 10 +++++-----
 .../olingo/server/api/processor/EntityProcessor.java    |  4 +++-
 .../olingo/server/api/processor/MetadataProcessor.java  |  3 ++-
 .../server/api/processor/ServiceDocumentProcessor.java  |  4 +++-
 .../org/apache/olingo/server/core/ODataHandler.java     | 12 ++++++------
 .../olingo/server/core/ContentNegotiatorTest.java       | 12 ++++++------
 .../server/tecsvc/processor/SampleJsonProcessor.java    |  9 +++++----
 .../server/tecsvc/processor/TechnicalProcessor.java     |  8 ++++++--
 9 files changed, 38 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d784a047/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/CollectionProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/CollectionProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/CollectionProcessor.java
index bf45c3f..2d6f1f5 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/CollectionProcessor.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/CollectionProcessor.java
@@ -18,12 +18,13 @@
  */
 package org.apache.olingo.server.api.processor;
 
+import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
 import org.apache.olingo.server.api.uri.UriInfo;
 
 public interface CollectionProcessor extends Processor {
 
-  void readCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo, String format);
+  void readCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType requestedContentType);
 
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d784a047/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java
index 9251c73..97821f1 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java
@@ -21,8 +21,8 @@ package org.apache.olingo.server.api.processor;
 import java.io.InputStream;
 
 import org.apache.olingo.commons.api.edm.Edm;
+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.server.api.OData;
 import org.apache.olingo.server.api.ODataRequest;
@@ -43,7 +43,7 @@ public class DefaultProcessor implements MetadataProcessor, ServiceDocumentProce
 
   @Override
   public void readServiceDocument(final ODataRequest request, final ODataResponse response, final UriInfo uriInfo,
-      final String format) {
+      final ContentType requestedContentType) {
     ODataSerializer serializer;
     InputStream responseEntity;
 
@@ -51,22 +51,22 @@ public class DefaultProcessor implements MetadataProcessor, ServiceDocumentProce
     responseEntity = serializer.serviceDocument(edm, request.getRawBaseUri());
 
     response.setStatusCode(200);
-    response.setHeader(HttpHeader.CONTENT_TYPE, HttpContentType.APPLICATION_JSON);
     response.setContent(responseEntity);
+    response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString());
 
   }
 
   @Override
   public void readMetadata(final ODataRequest request, final ODataResponse response, final UriInfo uriInfo,
-      final String format) {
+      final ContentType requestedContentType) {
     ODataSerializer serializer;
     InputStream responseEntity;
 
     serializer = odata.createSerializer(ODataFormat.XML);
     responseEntity = serializer.metadataDocument(edm);
     response.setStatusCode(200);
-    response.setHeader(HttpHeader.CONTENT_TYPE, HttpContentType.APPLICATION_XML);
     response.setContent(responseEntity);
+    response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString());
   }
 
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d784a047/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/EntityProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/EntityProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/EntityProcessor.java
index b0b9476..a6ec6c2 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/EntityProcessor.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/EntityProcessor.java
@@ -18,11 +18,13 @@
  */
 package org.apache.olingo.server.api.processor;
 
+import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
 import org.apache.olingo.server.api.uri.UriInfo;
 
 public interface EntityProcessor extends Processor {
 
-  void readEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, String format);
+  void readEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType format);
+  
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d784a047/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/MetadataProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/MetadataProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/MetadataProcessor.java
index 89f8e53..ed187ea 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/MetadataProcessor.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/MetadataProcessor.java
@@ -18,11 +18,12 @@
  */
 package org.apache.olingo.server.api.processor;
 
+import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
 import org.apache.olingo.server.api.uri.UriInfo;
 
 public interface MetadataProcessor extends Processor {
 
-  void readMetadata(ODataRequest request, ODataResponse response, UriInfo uriInfo, String format);
+  void readMetadata(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType requestedContentType);
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d784a047/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ServiceDocumentProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ServiceDocumentProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ServiceDocumentProcessor.java
index a1ef668..dd90b38 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ServiceDocumentProcessor.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ServiceDocumentProcessor.java
@@ -18,12 +18,14 @@
  */
 package org.apache.olingo.server.api.processor;
 
+import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
 import org.apache.olingo.server.api.uri.UriInfo;
 
 public interface ServiceDocumentProcessor extends Processor {
 
-  void readServiceDocument(ODataRequest request, ODataResponse response, UriInfo uriInfo, String format);
+  void readServiceDocument(ODataRequest request, ODataResponse response, UriInfo uriInfo,
+      ContentType requestedContentType);
 
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d784a047/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
index 36a52a8..b8f7bbd 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
@@ -84,7 +84,7 @@ public class ODataHandler {
         requestedContentType =
             ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(), request, mp, MetadataProcessor.class);
 
-        mp.readMetadata(request, response, uriInfo, requestedContentType.toContentTypeString());
+        mp.readMetadata(request, response, uriInfo, requestedContentType);
         break;
       case service:
         if ("".equals(request.getRawODataPath())) {
@@ -97,7 +97,7 @@ public class ODataHandler {
               ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(), request, sdp,
                   ServiceDocumentProcessor.class);
 
-          sdp.readServiceDocument(request, response, uriInfo, requestedContentType.toContentTypeString());
+          sdp.readServiceDocument(request, response, uriInfo, requestedContentType);
         }
         break;
       case resource:
@@ -129,7 +129,7 @@ public class ODataHandler {
           requestedContentType =
               ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(), request, cp, CollectionProcessor.class);
 
-          cp.readCollection(request, response, uriInfo, requestedContentType.toContentTypeString());
+          cp.readCollection(request, response, uriInfo, requestedContentType);
         } else {
           throw new ODataRuntimeException("not implemented");
         }
@@ -140,7 +140,7 @@ public class ODataHandler {
           requestedContentType =
               ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(), request, ep, EntityProcessor.class);
 
-          ep.readEntity(request, response, uriInfo, requestedContentType.toContentTypeString());
+          ep.readEntity(request, response, uriInfo, requestedContentType);
         } else {
           throw new ODataRuntimeException("not implemented");
         }
@@ -154,7 +154,7 @@ public class ODataHandler {
           requestedContentType =
               ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(), request, cp, CollectionProcessor.class);
 
-          cp.readCollection(request, response, uriInfo, requestedContentType.toContentTypeString());
+          cp.readCollection(request, response, uriInfo, requestedContentType);
         } else {
           throw new ODataRuntimeException("not implemented");
         }
@@ -165,7 +165,7 @@ public class ODataHandler {
           requestedContentType =
               ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(), request, ep, EntityProcessor.class);
 
-          ep.readEntity(request, response, uriInfo, requestedContentType.toContentTypeString());
+          ep.readEntity(request, response, uriInfo, requestedContentType);
         } else {
           throw new ODataRuntimeException("not implemented");
         }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d784a047/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java
index 10df086..cc766f4 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java
@@ -214,20 +214,20 @@ public class ContentNegotiatorTest {
 
     @Override
     public void readServiceDocument(final ODataRequest request, final ODataResponse response, final UriInfo uriInfo,
-        final String format) {
-      response.setHeader(HttpHeader.CONTENT_TYPE, format);
+        final ContentType format) {
+      response.setHeader(HttpHeader.CONTENT_TYPE, format.toContentTypeString());
     }
 
     @Override
     public void readCollection(final ODataRequest request, final ODataResponse response, final UriInfo uriInfo,
-        final String format) {
-      response.setHeader(HttpHeader.CONTENT_TYPE, format);
+        final ContentType requestedContentType) {
+      response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString());
     }
 
     @Override
     public void readMetadata(final ODataRequest request, final ODataResponse response, final UriInfo uriInfo,
-        final String format) {
-      response.setHeader(HttpHeader.CONTENT_TYPE, format);
+        final ContentType requestedContentType) {
+      response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString());
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d784a047/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
index e7d6717..b3dc02d 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
@@ -30,6 +30,7 @@ import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
 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.commons.core.data.EntityImpl;
 import org.apache.olingo.commons.core.data.EntitySetImpl;
@@ -58,7 +59,7 @@ public class SampleJsonProcessor implements CollectionProcessor, EntityProcessor
 
   @Override
   public void readCollection(final ODataRequest request, final ODataResponse response, final UriInfo uriInfo,
-      final String format) {
+      final ContentType requestedContentType) {
     long time = System.nanoTime();
 
     EntitySet entitySet = createEntitySet();
@@ -74,12 +75,12 @@ public class SampleJsonProcessor implements CollectionProcessor, EntityProcessor
     LOG.info("Finished in " + (System.nanoTime() - time) / 1000 + " microseconds");
 
     response.setStatusCode(HttpStatusCode.OK.getStatusCode());
-    response.setHeader("Content-Type", ContentType.APPLICATION_JSON.toContentTypeString());
+    response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString());
   }
 
   @Override
   public void readEntity(final ODataRequest request, final ODataResponse response, final UriInfo uriInfo,
-      final String format) {
+      final ContentType requestedContentType) {
     long time = System.nanoTime();
     Entity entity = createEntity();
 
@@ -94,7 +95,7 @@ public class SampleJsonProcessor implements CollectionProcessor, EntityProcessor
     LOG.info("Finished in " + (System.nanoTime() - time) / 1000 + " microseconds");
 
     response.setStatusCode(HttpStatusCode.OK.getStatusCode());
-    response.setHeader("Content-Type", ContentType.APPLICATION_JSON.toContentTypeString());
+    response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString());
   }
 
   protected Entity createEntity() {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d784a047/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 b3c671c..7c5a267 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
@@ -21,6 +21,8 @@ package org.apache.olingo.server.tecsvc.processor;
 import java.io.ByteArrayInputStream;
 
 import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.commons.api.http.HttpHeader;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
@@ -38,15 +40,17 @@ public class TechnicalProcessor implements CollectionProcessor, EntityProcessor
 
   @Override
   public void readEntity(final ODataRequest request, final ODataResponse response, final UriInfo uriInfo,
-      final String format) {
+      final ContentType requestedContentType) {
     response.setContent(new ByteArrayInputStream("Entity".getBytes()));
     response.setStatusCode(200);
+    response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString());
   }
 
   @Override
   public void readCollection(final ODataRequest request, final ODataResponse response, final UriInfo uriInfo,
-      final String format) {
+      final ContentType requestedContentType) {
     response.setContent(new ByteArrayInputStream("EntitySet".getBytes()));
     response.setStatusCode(200);
+    response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString());
   }
 }


[2/3] git commit: [OLINGO-337] javadoc

Posted by sk...@apache.org.
[OLINGO-337] javadoc


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

Branch: refs/heads/olingo337
Commit: 1a1c0614636a8a49ef12f3e151e49baeea0318ec
Parents: d784a04
Author: Stephan Klevenz <st...@sap.com>
Authored: Thu Jul 3 10:45:37 2014 +0200
Committer: Stephan Klevenz <st...@sap.com>
Committed: Thu Jul 3 10:45:37 2014 +0200

----------------------------------------------------------------------
 .../org/apache/olingo/server/api/OData.java     | 18 +++++++++
 .../olingo/server/api/ODataHttpHandler.java     | 13 +++++++
 .../apache/olingo/server/api/ODataRequest.java  | 24 ++++++++++++
 .../apache/olingo/server/api/ODataResponse.java |  3 ++
 .../api/processor/CollectionProcessor.java      | 10 +++++
 .../api/processor/CustomContentTypeSupport.java | 28 -------------
 .../CustomContentTypeSupportProcessor.java      | 41 ++++++++++++++++++++
 .../server/api/processor/DefaultProcessor.java  |  8 +++-
 .../server/api/processor/EntityProcessor.java   | 10 +++++
 .../api/processor/FormatContentTypeMapping.java | 28 +++++++------
 .../server/api/processor/MetadataProcessor.java | 10 +++++
 .../olingo/server/api/processor/Processor.java  |  9 +++++
 .../api/processor/ServiceDocumentProcessor.java | 10 +++++
 .../olingo/server/core/ContentNegotiator.java   |  7 ++--
 .../server/core/ContentNegotiatorTest.java      |  4 +-
 15 files changed, 176 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1a1c0614/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 2fae3ac..85a6772 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
@@ -24,6 +24,11 @@ import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.server.api.edm.provider.EdmProvider;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
 
+/**
+ * Root object for serving factory tasks and support loosely coupling of implementation (core) from the api. This is not
+ * a singleton (static variables) to avoid issues with synchronization, OSGi, hot deployment and so on. Each thread
+ * (request) should keep its own instance.
+ */
 public abstract class OData {
 
   private static final String IMPLEMENTATION = "org.apache.olingo.server.core.ODataImpl";
@@ -46,10 +51,23 @@ public abstract class OData {
     }
   }
 
+  /**
+   * Create a new serializer object for rendering content in the specified format. Serializers are used in Processor
+   * implementations.
+   * @param format - Any format supported by Olingo (XML, JSON ...)
+   */
   public abstract ODataSerializer createSerializer(ODataFormat format);
 
+  /**
+   * Create a new ODataHttpHandler for handling OData requests in a http context. 
+   * @param edm - metadata object required to handle an OData request
+   */
   public abstract ODataHttpHandler createHandler(Edm edm);
 
+  /**
+   * Create an metadata object.
+   * @param edmProvider - A custom or default implementation for creating metadata
+   */
   public abstract Edm createEdm(EdmProvider edmProvider);
 
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1a1c0614/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataHttpHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataHttpHandler.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataHttpHandler.java
index 8372f80..1765d33 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataHttpHandler.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataHttpHandler.java
@@ -23,10 +23,23 @@ import javax.servlet.http.HttpServletResponse;
 
 import org.apache.olingo.server.api.processor.Processor;
 
+/**
+ * Handels http requests as OData requests.
+ */
 public interface ODataHttpHandler {
 
+  /**
+   * Process an OData request. This includes uri parsing, content negotiation, dispatching the request to a specific
+   * custom processor implementation for handling data and creating the serialized content for the response object.
+   * @param request - must be a http OData request
+   * @param response - http OData response
+   */
   void process(HttpServletRequest request, HttpServletResponse response);
 
+  /**
+   * Register additional custom processor implementations for handling OData requests. If a request processing requires
+   * a processor which is not registered then an not implemented exception will happen.
+   */
   void register(Processor processor);
 
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1a1c0614/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataRequest.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataRequest.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataRequest.java
index 120b950..e91c657 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataRequest.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataRequest.java
@@ -26,6 +26,9 @@ import java.util.Map;
 
 import org.apache.olingo.commons.api.http.HttpMethod;
 
+/**
+ * Request object carry http information optimized and required to handle OData requests only. 
+ */
 public class ODataRequest {
   private HttpMethod method;
   private Map<String, List<String>> headers = new HashMap<String, List<String>>();
@@ -36,6 +39,9 @@ public class ODataRequest {
   private String rawBaseUri;
   private String rawServiceResolutionUri;
 
+  /**
+   * @return the http method (GET, PUT, POST ...)
+   */
   public HttpMethod getMethod() {
     return method;
   }
@@ -73,6 +79,9 @@ public class ODataRequest {
     return headers.get(name.toUpperCase());
   }
 
+  /**
+   * @return the request payload or null
+   */
   public InputStream getBody() {
     return body;
   }
@@ -81,6 +90,9 @@ public class ODataRequest {
     this.body = body;
   }
 
+  /**
+   * @return decoded query options e.g. "$format=json"
+   */
   public String getRawQueryPath() {
     return rawQueryPath;
   }
@@ -89,14 +101,23 @@ public class ODataRequest {
     this.rawQueryPath = rawQueryPath;
   }
 
+  /**
+   * @return encoded base uri e.g. "http://localhost/my%20service"
+   */
   public String getRawBaseUri() {
     return rawBaseUri;
   }
 
+  /**
+   * @return encoded request uri e.g. "http://localhost/my%20service/sys1/Employees?$format=json"
+   */
   public String getRawRequestUri() {
     return rawRequestUri;
   }
 
+  /**
+   * @return encoded OData path segments e.g. "/Employees"
+   */
   public String getRawODataPath() {
     return rawODataPath;
   }
@@ -114,6 +135,9 @@ public class ODataRequest {
     this.rawBaseUri = rawBaseUri;
   }
 
+  /**
+   * @return a decoded path segment that does not belong to the OData url schema or null  e.g. "sys1" 
+   */
   public String getRawServiceResolutionUri() {
     return rawServiceResolutionUri;
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1a1c0614/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataResponse.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataResponse.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataResponse.java
index 4de7aaa..c1a16c0 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataResponse.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataResponse.java
@@ -23,6 +23,9 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
+/**
+ * Response object to carry OData relevant http information (statusCode, content & response headers)
+ */
 public class ODataResponse {
 
   private int statusCode;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1a1c0614/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/CollectionProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/CollectionProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/CollectionProcessor.java
index 2d6f1f5..d61734c 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/CollectionProcessor.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/CollectionProcessor.java
@@ -23,8 +23,18 @@ import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
 import org.apache.olingo.server.api.uri.UriInfo;
 
+/**
+ * Processor interface for handling collections of entities (collections, EntitySets or feeds).
+ */
 public interface CollectionProcessor extends Processor {
 
+  /**
+   * Read entities data from persistency and puts serialized content and status into the response.
+   *  @param request - OData request object containing raw http information.
+   *  @param response - OData response object for collecting response data
+   *  @param uriInfo - information of a parsed OData uri
+   *  @param requestedContentType - requested content type after content negotiation
+   */
   void readCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType requestedContentType);
 
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1a1c0614/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/CustomContentTypeSupport.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/CustomContentTypeSupport.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/CustomContentTypeSupport.java
deleted file mode 100644
index 75a57b1..0000000
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/CustomContentTypeSupport.java
+++ /dev/null
@@ -1,28 +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.api.processor;
-
-import java.util.List;
-
-public interface CustomContentTypeSupport {
-
-  public List<FormatContentTypeMapping> modifySupportedContentTypes(
-      List<FormatContentTypeMapping> supportedContentTypes, Class<? extends Processor> processorClass);
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1a1c0614/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/CustomContentTypeSupportProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/CustomContentTypeSupportProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/CustomContentTypeSupportProcessor.java
new file mode 100644
index 0000000..edcad72
--- /dev/null
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/CustomContentTypeSupportProcessor.java
@@ -0,0 +1,41 @@
+/*
+ * 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.processor;
+
+import java.util.List;
+
+/**
+ * A processor which supports custom content types can implement this interface. The processor can also remove default
+ * content types if the default serializer of Olingo are not used. By default this interface is not implemented and
+ * a processor supports content types implemented by Olingos default serializer (e.g. application/xml for metadata and
+ * application/json for service document).
+ * Requesting a content type which is not supported results in a http error 406 (Not Acceptable).
+ */
+public interface CustomContentTypeSupportProcessor {
+
+  /**
+   * Returns a list of supported content types.
+   * @param defaultContentTypes content types supported by Olingos serializer
+   * @return modified list of supported content types
+   * 
+   */
+  public List<FormatContentTypeMapping> modifySupportedContentTypes(
+      List<FormatContentTypeMapping> defaultContentTypes, Class<? extends Processor> processorClass);
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1a1c0614/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java
index 97821f1..49bdae0 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java
@@ -30,6 +30,10 @@ import org.apache.olingo.server.api.ODataResponse;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
 import org.apache.olingo.server.api.uri.UriInfo;
 
+/**
+ * Processor implementation for handling of metadata and service document. This implementation is registerd in the 
+ * ODataHandler by default. The default can be replaced by re-registering an custom implementation.
+ */
 public class DefaultProcessor implements MetadataProcessor, ServiceDocumentProcessor {
 
   private OData odata;
@@ -47,7 +51,7 @@ public class DefaultProcessor implements MetadataProcessor, ServiceDocumentProce
     ODataSerializer serializer;
     InputStream responseEntity;
 
-    serializer = odata.createSerializer(ODataFormat.JSON);
+    serializer = odata.createSerializer(ODataFormat.fromContentType(requestedContentType));
     responseEntity = serializer.serviceDocument(edm, request.getRawBaseUri());
 
     response.setStatusCode(200);
@@ -62,7 +66,7 @@ public class DefaultProcessor implements MetadataProcessor, ServiceDocumentProce
     ODataSerializer serializer;
     InputStream responseEntity;
 
-    serializer = odata.createSerializer(ODataFormat.XML);
+    serializer = odata.createSerializer(ODataFormat.fromContentType(requestedContentType));
     responseEntity = serializer.metadataDocument(edm);
     response.setStatusCode(200);
     response.setContent(responseEntity);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1a1c0614/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/EntityProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/EntityProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/EntityProcessor.java
index a6ec6c2..7e00f22 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/EntityProcessor.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/EntityProcessor.java
@@ -23,8 +23,18 @@ import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
 import org.apache.olingo.server.api.uri.UriInfo;
 
+/**
+ * Processor interface for handling a single entry (e.g. atom entry).
+ */
 public interface EntityProcessor extends Processor {
 
+  /**
+   * Read entity data from persistency and puts serialized content and status into the response.
+   *  @param request - OData request object containing raw http information.
+   *  @param response - OData response object for collecting response data
+   *  @param uriInfo - information of a parsed OData uri
+   *  @param requestedContentType - requested content type after content negotiation
+   */
   void readEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType format);
   
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1a1c0614/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/FormatContentTypeMapping.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/FormatContentTypeMapping.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/FormatContentTypeMapping.java
index e12c127..38ce7d6 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/FormatContentTypeMapping.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/FormatContentTypeMapping.java
@@ -18,36 +18,40 @@
  */
 package org.apache.olingo.server.api.processor;
 
+/**
+ * Mapping between an uri $format option value and a content types. For instance the $format option "xml" maps to
+ * content type "application/xml".
+ */
 public class FormatContentTypeMapping {
 
-  private String formatAlias;
-  private String contentType;
+  private String formatOptionValue;
+  private String contentTypeValue;
 
-  public FormatContentTypeMapping(final String formatAlias, final String contentType) {
+  public FormatContentTypeMapping(final String formatOptionValue, final String contentTypeValue) {
     super();
-    this.formatAlias = formatAlias;
-    this.contentType = contentType;
+    this.formatOptionValue = formatOptionValue;
+    this.contentTypeValue = contentTypeValue;
   }
 
   public String getFormatAlias() {
-    return formatAlias;
+    return formatOptionValue;
   }
 
   public String getContentType() {
-    return contentType;
+    return contentTypeValue;
   }
 
-  public void setFormatAlias(final String formatAlias) {
-    this.formatAlias = formatAlias;
+  public void setFormatAlias(final String formatOptionValue) {
+    this.formatOptionValue = formatOptionValue;
   }
 
-  public void setContentType(final String contentType) {
-    this.contentType = contentType;
+  public void setContentType(final String contentTypeValue) {
+    this.contentTypeValue = contentTypeValue;
   }
 
   @Override
   public String toString() {
-    return "('" + formatAlias + "', '" + contentType + "')";
+    return "('" + formatOptionValue + "', '" + contentTypeValue + "')";
   }
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1a1c0614/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/MetadataProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/MetadataProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/MetadataProcessor.java
index ed187ea..b1caebd 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/MetadataProcessor.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/MetadataProcessor.java
@@ -23,7 +23,17 @@ import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
 import org.apache.olingo.server.api.uri.UriInfo;
 
+/**
+ * Processor interface for handling the metadata document.
+ */
 public interface MetadataProcessor extends Processor {
 
+  /**
+   * Read data from persistency and puts serialized content and status into the response.
+   *  @param request - OData request object containing raw http information.
+   *  @param response - OData response object for collecting response data
+   *  @param uriInfo - information of a parsed OData uri
+   *  @param requestedContentType - requested content type after content negotiation
+   */
   void readMetadata(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType requestedContentType);
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1a1c0614/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/Processor.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/Processor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/Processor.java
index 014fba7..5d27ec8 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/Processor.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/Processor.java
@@ -21,8 +21,17 @@ package org.apache.olingo.server.api.processor;
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.server.api.OData;
 
+/**
+ * Base interface for all processor types. Processors are responsible to read and write data and marshaling content
+ * within a request - response cycle.
+ */
 public interface Processor {
 
+  /**
+   * Initialize processor for each http request - response cycle.
+   * @param odata - Olingos root object which acts as a factory for various object types
+   * @param edm - the edm which needs to be created before the OData request handling takes place
+   */
   void init(OData odata, Edm edm);
 
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1a1c0614/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ServiceDocumentProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ServiceDocumentProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ServiceDocumentProcessor.java
index dd90b38..4deba80 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ServiceDocumentProcessor.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ServiceDocumentProcessor.java
@@ -23,8 +23,18 @@ import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
 import org.apache.olingo.server.api.uri.UriInfo;
 
+/**
+ * Processor interface for handling the service document.
+ */
 public interface ServiceDocumentProcessor extends Processor {
 
+  /**
+   * Read service document information from persistency and puts serialized content and status into the response.
+   * @param request - OData request object containing raw http information.
+   * @param response - OData response object for collecting response data
+   * @param uriInfo - information of a parsed OData uri
+   * @param requestedContentType - requested content type after content negotiation
+   */
   void readServiceDocument(ODataRequest request, ODataResponse response, UriInfo uriInfo,
       ContentType requestedContentType);
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1a1c0614/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java
index 9405007..749fd27 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java
@@ -25,7 +25,7 @@ import org.apache.olingo.commons.api.format.AcceptType;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.api.http.HttpHeader;
 import org.apache.olingo.server.api.ODataRequest;
-import org.apache.olingo.server.api.processor.CustomContentTypeSupport;
+import org.apache.olingo.server.api.processor.CustomContentTypeSupportProcessor;
 import org.apache.olingo.server.api.processor.FormatContentTypeMapping;
 import org.apache.olingo.server.api.processor.MetadataProcessor;
 import org.apache.olingo.server.api.processor.Processor;
@@ -59,9 +59,10 @@ public class ContentNegotiator {
 
     List<FormatContentTypeMapping> supportedContentTypes = getDefaultSupportedContentTypes(processorClass);
 
-    if (processor instanceof CustomContentTypeSupport) {
+    if (processor instanceof CustomContentTypeSupportProcessor) {
       supportedContentTypes =
-          ((CustomContentTypeSupport) processor).modifySupportedContentTypes(supportedContentTypes, processorClass);
+          ((CustomContentTypeSupportProcessor) processor).modifySupportedContentTypes(supportedContentTypes,
+              processorClass);
     }
 
     return supportedContentTypes;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1a1c0614/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java
index cc766f4..88896da 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java
@@ -37,7 +37,7 @@ import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
 import org.apache.olingo.server.api.processor.CollectionProcessor;
-import org.apache.olingo.server.api.processor.CustomContentTypeSupport;
+import org.apache.olingo.server.api.processor.CustomContentTypeSupportProcessor;
 import org.apache.olingo.server.api.processor.FormatContentTypeMapping;
 import org.apache.olingo.server.api.processor.MetadataProcessor;
 import org.apache.olingo.server.api.processor.Processor;
@@ -191,7 +191,7 @@ public class ContentNegotiatorTest {
 
   private class ProcessorStub implements ServiceDocumentProcessor, MetadataProcessor,
       CollectionProcessor,
-      CustomContentTypeSupport {
+      CustomContentTypeSupportProcessor {
 
     List<FormatContentTypeMapping> customMapping;
 


[3/3] git commit: [OLINGO-337] improve AcceptType class to allow '*'

Posted by sk...@apache.org.
[OLINGO-337] improve AcceptType class to allow '*'


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

Branch: refs/heads/olingo337
Commit: 62eccf9c19fef21d436309bea70c8aef0a6df1cb
Parents: 1a1c061
Author: Stephan Klevenz <st...@sap.com>
Authored: Thu Jul 3 12:54:07 2014 +0200
Committer: Stephan Klevenz <st...@sap.com>
Committed: Thu Jul 3 12:54:07 2014 +0200

----------------------------------------------------------------------
 .../apache/olingo/fit/tecsvc/PingITCase.java    |  3 -
 .../olingo/commons/api/format/AcceptType.java   | 59 ++++++++++-----
 .../olingo/commons/api/format/ContentType.java  | 78 +++++---------------
 .../olingo/commons/api/format/TypeUtil.java     | 70 ++++++++++++++++++
 .../commons/api/format/AcceptTypeTest.java      | 12 ++-
 .../commons/api/format/ContentTypeTest.java     | 23 ++++++
 6 files changed, 161 insertions(+), 84 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/62eccf9c/fit/src/test/java/org/apache/olingo/fit/tecsvc/PingITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/PingITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/PingITCase.java
index 44438fd..46ea276 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/PingITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/PingITCase.java
@@ -23,7 +23,6 @@ import static org.junit.Assert.assertEquals;
 import java.net.HttpURLConnection;
 import java.net.URL;
 
-import org.apache.olingo.commons.api.http.HttpHeader;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -43,7 +42,6 @@ public class PingITCase {
 
     HttpURLConnection connection = (HttpURLConnection) url.openConnection();
     connection.setRequestMethod("GET");
-    connection.setRequestProperty(HttpHeader.ACCEPT, "application/json");
     connection.connect();
 
     int code = connection.getResponseCode();
@@ -59,7 +57,6 @@ public class PingITCase {
 
     HttpURLConnection connection = (HttpURLConnection) url.openConnection();
     connection.setRequestMethod("GET");
-    connection.setRequestProperty(HttpHeader.ACCEPT, "application/json");
     connection.connect();
 
     int code = connection.getResponseCode();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/62eccf9c/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/AcceptType.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/AcceptType.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/AcceptType.java
index 7a460f1..39bdf75 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/AcceptType.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/AcceptType.java
@@ -46,11 +46,8 @@ import java.util.regex.Pattern;
  */
 public class AcceptType {
 
-  private static final String MEDIA_TYPE_WILDCARD = "*";
-  private static final String PARAMETER_Q = "q";
-  private static final Pattern Q_PARAMETER_VALUE_PATTERN = Pattern.compile("1|0|1\\.0{1,3}|0\\.\\d{1,3}");
-
-  public static final AcceptType WILDCARD = create(MEDIA_TYPE_WILDCARD, MEDIA_TYPE_WILDCARD, createParameterMap(), 1F);
+  public static final AcceptType WILDCARD = create(TypeUtil.MEDIA_TYPE_WILDCARD, TypeUtil.MEDIA_TYPE_WILDCARD,
+      createParameterMap(), 1F);
 
   private final String type;
   private final String subtype;
@@ -81,23 +78,49 @@ public class AcceptType {
     }
     List<String> typeSubtype = new ArrayList<String>();
     parameters = createParameterMap();
-    ContentType.parse(type, typeSubtype, parameters);
+    parse(type, typeSubtype, parameters);
     this.type = typeSubtype.get(0);
     subtype = typeSubtype.get(1);
-    if (MEDIA_TYPE_WILDCARD.equals(this.type) && !MEDIA_TYPE_WILDCARD.equals(subtype)) {
+    if (TypeUtil.MEDIA_TYPE_WILDCARD.equals(this.type) && !TypeUtil.MEDIA_TYPE_WILDCARD.equals(subtype)) {
       throw new IllegalArgumentException("Illegal combination of WILDCARD type with NONE WILDCARD subtype.");
     }
-    final String q = parameters.get(PARAMETER_Q);
+    final String q = parameters.get(TypeUtil.PARAMETER_Q);
     if (q == null) {
       quality = 1F;
     } else {
-      if (Q_PARAMETER_VALUE_PATTERN.matcher(q).matches()) {
+      try {
         quality = Float.valueOf(q);
+      } catch (IllegalArgumentException e) {
+        throw new IllegalArgumentException("Illegal quality parameter.", e);
+      }
+    }
+  }
+
+  private static void
+      parse(final String format, final List<String> typeSubtype, final Map<String, String> parameters) {
+    final String[] typesAndParameters = format.split(TypeUtil.PARAMETER_SEPARATOR, 2);
+    final String types = typesAndParameters[0];
+    final String params = (typesAndParameters.length > 1 ? typesAndParameters[1] : null);
+
+    String[] tokens = types.split(TypeUtil.TYPE_SUBTYPE_SEPARATOR);
+    if (tokens.length == 1) {
+      typeSubtype.add(tokens[0]);
+      typeSubtype.add(TypeUtil.MEDIA_TYPE_WILDCARD);
+    } else if (tokens.length == 2) {
+      if (tokens[0] == null || tokens[0].isEmpty()) {
+        throw new IllegalArgumentException("No type found in format '" + format + "'.");
+      } else if (tokens[1] == null || tokens[1].isEmpty()) {
+        throw new IllegalArgumentException("No subtype found in format '" + format + "'.");
       } else {
-        throw new IllegalArgumentException("Illegal quality parameter.");
+        typeSubtype.add(tokens[0]);
+        typeSubtype.add(tokens[1]);
       }
-      parameters.remove(PARAMETER_Q);
+    } else {
+      throw new IllegalArgumentException("Too many '" + TypeUtil.TYPE_SUBTYPE_SEPARATOR + "' in format '" + format
+          + "'.");
     }
+
+    TypeUtil.parseParameters(params, parameters);
   }
 
   /**
@@ -172,7 +195,7 @@ public class AcceptType {
       result.append(';').append(key).append('=').append(parameters.get(key));
     }
     if (quality < 1F) {
-      result.append(';').append(PARAMETER_Q).append('=').append(quality);
+      result.append(';').append(TypeUtil.PARAMETER_Q).append('=').append(quality);
     }
     return result.toString();
   }
@@ -189,13 +212,13 @@ public class AcceptType {
    * @return whether this accept type matches the given content type
    */
   public boolean matches(final ContentType contentType) {
-    if (type.equals(MEDIA_TYPE_WILDCARD)) {
+    if (type.equals(TypeUtil.MEDIA_TYPE_WILDCARD)) {
       return true;
     }
     if (!type.equalsIgnoreCase(contentType.getType())) {
       return false;
     }
-    if (subtype.equals(MEDIA_TYPE_WILDCARD)) {
+    if (subtype.equals(TypeUtil.MEDIA_TYPE_WILDCARD)) {
       return true;
     }
     if (!subtype.equalsIgnoreCase(contentType.getSubtype())) {
@@ -246,13 +269,13 @@ public class AcceptType {
             if (compare != 0) {
               return compare;
             }
-            compare = (a1.getType().equals(MEDIA_TYPE_WILDCARD) ? 1 : 0)
-                - (a2.getType().equals(MEDIA_TYPE_WILDCARD) ? 1 : 0);
+            compare = (a1.getType().equals(TypeUtil.MEDIA_TYPE_WILDCARD) ? 1 : 0)
+                - (a2.getType().equals(TypeUtil.MEDIA_TYPE_WILDCARD) ? 1 : 0);
             if (compare != 0) {
               return compare;
             }
-            compare = (a1.getSubtype().equals(MEDIA_TYPE_WILDCARD) ? 1 : 0)
-                - (a2.getSubtype().equals(MEDIA_TYPE_WILDCARD) ? 1 : 0);
+            compare = (a1.getSubtype().equals(TypeUtil.MEDIA_TYPE_WILDCARD) ? 1 : 0)
+                - (a2.getSubtype().equals(TypeUtil.MEDIA_TYPE_WILDCARD) ? 1 : 0);
             if (compare != 0) {
               return compare;
             }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/62eccf9c/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java
index 9482f44..3506ffb 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java
@@ -24,7 +24,6 @@ import java.util.Comparator;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Locale;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.TreeMap;
@@ -46,36 +45,28 @@ import java.util.TreeMap;
  */
 public class ContentType {
 
-  private static final char WHITESPACE_CHAR = ' ';
-  private static final String PARAMETER_SEPARATOR = ";";
-  private static final String PARAMETER_KEY_VALUE_SEPARATOR = "=";
-  private static final String TYPE_SUBTYPE_SEPARATOR = "/";
-
-  public static final String PARAMETER_TYPE = "type";
-  public static final String PARAMETER_CHARSET = "charset";
-  public static final String CHARSET_UTF_8 = "UTF-8";
 
   public static final ContentType APPLICATION_XML = create("application", "xml");
-  public static final ContentType APPLICATION_XML_CS_UTF_8 = create(APPLICATION_XML, PARAMETER_CHARSET,
-      CHARSET_UTF_8);
+  public static final ContentType APPLICATION_XML_CS_UTF_8 = create(APPLICATION_XML, TypeUtil.PARAMETER_CHARSET,
+      TypeUtil.CHARSET_UTF_8);
   public static final ContentType APPLICATION_ATOM_XML = create("application", "atom+xml");
   public static final ContentType APPLICATION_ATOM_XML_CS_UTF_8 = create(APPLICATION_ATOM_XML,
-      PARAMETER_CHARSET, CHARSET_UTF_8);
-  public static final ContentType APPLICATION_ATOM_XML_ENTRY = create(APPLICATION_ATOM_XML, PARAMETER_TYPE, "entry");
+      TypeUtil.PARAMETER_CHARSET, TypeUtil.CHARSET_UTF_8);
+  public static final ContentType APPLICATION_ATOM_XML_ENTRY = create(APPLICATION_ATOM_XML,TypeUtil. PARAMETER_TYPE, "entry");
   public static final ContentType APPLICATION_ATOM_XML_ENTRY_CS_UTF_8 = create(APPLICATION_ATOM_XML_ENTRY,
-      PARAMETER_CHARSET, CHARSET_UTF_8);
-  public static final ContentType APPLICATION_ATOM_XML_FEED = create(APPLICATION_ATOM_XML, PARAMETER_TYPE, "feed");
+      TypeUtil.  PARAMETER_CHARSET, TypeUtil.CHARSET_UTF_8);
+  public static final ContentType APPLICATION_ATOM_XML_FEED = create(APPLICATION_ATOM_XML,TypeUtil. PARAMETER_TYPE, "feed");
   public static final ContentType APPLICATION_ATOM_XML_FEED_CS_UTF_8 = create(APPLICATION_ATOM_XML_FEED,
-      PARAMETER_CHARSET, CHARSET_UTF_8);
+      TypeUtil.  PARAMETER_CHARSET,TypeUtil.CHARSET_UTF_8);
   public static final ContentType APPLICATION_ATOM_SVC = create("application", "atomsvc+xml");
   public static final ContentType APPLICATION_ATOM_SVC_CS_UTF_8 = create(APPLICATION_ATOM_SVC,
-      PARAMETER_CHARSET, CHARSET_UTF_8);
+      TypeUtil. PARAMETER_CHARSET, TypeUtil.CHARSET_UTF_8);
   public static final ContentType APPLICATION_JSON = create("application", "json");
   public static final ContentType APPLICATION_JSON_CS_UTF_8 = create(APPLICATION_JSON,
-      PARAMETER_CHARSET, CHARSET_UTF_8);
+      TypeUtil.  PARAMETER_CHARSET,TypeUtil. CHARSET_UTF_8);
   public static final ContentType APPLICATION_OCTET_STREAM = create("application", "octet-stream");
   public static final ContentType TEXT_PLAIN = create("text", "plain");
-  public static final ContentType TEXT_PLAIN_CS_UTF_8 = create(TEXT_PLAIN, PARAMETER_CHARSET, CHARSET_UTF_8);
+  public static final ContentType TEXT_PLAIN_CS_UTF_8 = create(TEXT_PLAIN, TypeUtil.PARAMETER_CHARSET,TypeUtil. CHARSET_UTF_8);
   public static final ContentType MULTIPART_MIXED = create("multipart", "mixed");
 
   public static final ContentType APPLICATION_XHTML_XML = create("application", "xhtml+xml");
@@ -118,7 +109,7 @@ public class ContentType {
     }
     int len = type.length();
     for (int i = 0; i < len; i++) {
-      if (type.charAt(i) == WHITESPACE_CHAR) {
+      if (type.charAt(i) == TypeUtil.WHITESPACE_CHAR) {
         throw new IllegalArgumentException("Illegal whitespace found for type '" + type + "'.");
       }
     }
@@ -196,14 +187,14 @@ public class ContentType {
     }
   }
 
-  protected static void
+  private static void
       parse(final String format, final List<String> typeSubtype, final Map<String, String> parameters) {
-    final String[] typesAndParameters = format.split(PARAMETER_SEPARATOR, 2);
+    final String[] typesAndParameters = format.split(TypeUtil.PARAMETER_SEPARATOR, 2);
     final String types = typesAndParameters[0];
     final String params = (typesAndParameters.length > 1 ? typesAndParameters[1] : null);
 
-    if (types.contains(TYPE_SUBTYPE_SEPARATOR)) {
-      String[] tokens = types.split(TYPE_SUBTYPE_SEPARATOR);
+    if (types.contains(TypeUtil.TYPE_SUBTYPE_SEPARATOR)) {
+      String[] tokens = types.split(TypeUtil.TYPE_SUBTYPE_SEPARATOR);
       if (tokens.length == 2) {
         if (tokens[0] == null || tokens[0].isEmpty()) {
           throw new IllegalArgumentException("No type found in format '" + format + "'.");
@@ -214,45 +205,14 @@ public class ContentType {
           typeSubtype.add(tokens[1]);
         }
       } else {
-        throw new IllegalArgumentException("Too many '" + TYPE_SUBTYPE_SEPARATOR + "' in format '" + format + "'.");
+        throw new IllegalArgumentException("Too many '" +TypeUtil.TYPE_SUBTYPE_SEPARATOR + "' in format '" + format + "'.");
       }
     } else {
-      throw new IllegalArgumentException("No separator '" + TYPE_SUBTYPE_SEPARATOR
+      throw new IllegalArgumentException("No separator '" +TypeUtil.TYPE_SUBTYPE_SEPARATOR
           + "' was found in format '" + format + "'.");
     }
 
-    parseParameters(params, parameters);
-  }
-
-  /**
-   * Valid input are <code>;</code> separated <code>key=value</code> pairs
-   * without spaces between key and value.
-   * <p>
-   * See RFC 7231:
-   * The type, subtype, and parameter name tokens are case-insensitive.
-   * Parameter values might or might not be case-sensitive, depending on
-   * the semantics of the parameter name. The presence or absence of a
-   * parameter might be significant to the processing of a media-type,
-   * depending on its definition within the media type registry.
-   * </p>
-   * 
-   * @param parameters
-   * @param parameterMap
-   */
-  private static void parseParameters(final String parameters, final Map<String, String> parameterMap) {
-    if (parameters != null) {
-      String[] splittedParameters = parameters.split(PARAMETER_SEPARATOR);
-      for (String parameter : splittedParameters) {
-        String[] keyValue = parameter.split(PARAMETER_KEY_VALUE_SEPARATOR);
-        String key = keyValue[0].trim().toLowerCase(Locale.ENGLISH);
-        String value = keyValue.length > 1 ? keyValue[1] : null;
-        if (value != null && Character.isWhitespace(value.charAt(0))) {
-          throw new IllegalArgumentException(
-              "Value of parameter '" + key + "' starts with whitespace ('" + parameters + "').");
-        }
-        parameterMap.put(key, value);
-      }
-    }
+    TypeUtil.parseParameters(params, parameters);
   }
 
   public String getType() {
@@ -406,7 +366,7 @@ public class ContentType {
   public String toContentTypeString() {
     StringBuilder sb = new StringBuilder();
 
-    sb.append(type).append(TYPE_SUBTYPE_SEPARATOR).append(subtype);
+    sb.append(type).append(TypeUtil.TYPE_SUBTYPE_SEPARATOR).append(subtype);
 
     for (String key : parameters.keySet()) {
       sb.append(";").append(key).append("=").append(parameters.get(key));

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/62eccf9c/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/TypeUtil.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/TypeUtil.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/TypeUtil.java
new file mode 100644
index 0000000..bbc4463
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/TypeUtil.java
@@ -0,0 +1,70 @@
+/*
+ * 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.format;
+
+import java.util.Locale;
+import java.util.Map;
+
+class TypeUtil {
+
+  static final String MEDIA_TYPE_WILDCARD = "*";
+  static final String PARAMETER_Q = "q";
+
+  static final char WHITESPACE_CHAR = ' ';
+  static final String PARAMETER_SEPARATOR = ";";
+  static final String PARAMETER_KEY_VALUE_SEPARATOR = "=";
+  static final String TYPE_SUBTYPE_SEPARATOR = "/";
+  static final String TYPE_SUBTYPE_WILDCARD = "*";
+
+  static final String PARAMETER_TYPE = "type";
+  static final String PARAMETER_CHARSET = "charset";
+  static final String CHARSET_UTF_8 = "UTF-8";
+
+  /**
+   * Valid input are <code>;</code> separated <code>key=value</code> pairs
+   * without spaces between key and value.
+   * <p>
+   * See RFC 7231:
+   * The type, subtype, and parameter name tokens are case-insensitive.
+   * Parameter values might or might not be case-sensitive, depending on
+   * the semantics of the parameter name. The presence or absence of a
+   * parameter might be significant to the processing of a media-type,
+   * depending on its definition within the media type registry.
+   * </p>
+   * 
+   * @param parameters
+   * @param parameterMap
+   */
+  static void parseParameters(final String parameters, final Map<String, String> parameterMap) {
+    if (parameters != null) {
+      String[] splittedParameters = parameters.split(TypeUtil.PARAMETER_SEPARATOR);
+      for (String parameter : splittedParameters) {
+        String[] keyValue = parameter.split(TypeUtil.PARAMETER_KEY_VALUE_SEPARATOR);
+        String key = keyValue[0].trim().toLowerCase(Locale.ENGLISH);
+        String value = keyValue.length > 1 ? keyValue[1] : null;
+        if (value != null && Character.isWhitespace(value.charAt(0))) {
+          throw new IllegalArgumentException(
+              "Value of parameter '" + key + "' starts with whitespace ('" + parameters + "').");
+        }
+        parameterMap.put(key, value);
+      }
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/62eccf9c/lib/commons-api/src/test/java/org/apache/olingo/commons/api/format/AcceptTypeTest.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/test/java/org/apache/olingo/commons/api/format/AcceptTypeTest.java b/lib/commons-api/src/test/java/org/apache/olingo/commons/api/format/AcceptTypeTest.java
index 211a74b..4427bf0 100644
--- a/lib/commons-api/src/test/java/org/apache/olingo/commons/api/format/AcceptTypeTest.java
+++ b/lib/commons-api/src/test/java/org/apache/olingo/commons/api/format/AcceptTypeTest.java
@@ -23,7 +23,6 @@ import static org.junit.Assert.assertNotNull;
 
 import java.util.List;
 
-import org.junit.Ignore;
 import org.junit.Test;
 
 public class AcceptTypeTest {
@@ -45,16 +44,21 @@ public class AcceptTypeTest {
     assertEquals(1, atl.size());
     assertEquals("a/a", atl.get(0).toString());
   }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testWrongQParameter() {
+    AcceptType.create(" a/a;q=z ");
+  }
   
   @Test
-  @Ignore("buggy and not yet fixed")
   public void testWildcard() {
     List<AcceptType> atl = AcceptType.create("*; q=.2");
     
     assertNotNull(atl);
     assertEquals(1, atl.size());
-    assertEquals("", atl.get(0).getType());
-    assertEquals("", atl.get(0).getSubtype());
+    assertEquals("*", atl.get(0).getType());
+    assertEquals("*", atl.get(0).getSubtype());
     assertEquals(".2", atl.get(0).getParameters().get("q"));
+    assertEquals(new Float(0.2), atl.get(0).getQuality());
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/62eccf9c/lib/commons-api/src/test/java/org/apache/olingo/commons/api/format/ContentTypeTest.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/test/java/org/apache/olingo/commons/api/format/ContentTypeTest.java b/lib/commons-api/src/test/java/org/apache/olingo/commons/api/format/ContentTypeTest.java
new file mode 100644
index 0000000..e2098f6
--- /dev/null
+++ b/lib/commons-api/src/test/java/org/apache/olingo/commons/api/format/ContentTypeTest.java
@@ -0,0 +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.
+ */
+package org.apache.olingo.commons.api.format;
+
+public class ContentTypeTest {
+
+}