olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chr...@apache.org
Subject [05/15] olingo-odata4 git commit: [OLINGO-704] Class ODataFormat removed
Date Wed, 24 Jun 2015 14:42:37 GMT
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/588df780/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java
index a134887..55c6b71 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java
@@ -24,7 +24,7 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.provider.CsdlEdmProvider;
 import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.format.Format;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ODataHttpHandler;
@@ -51,7 +51,7 @@ public class ODataImpl extends OData {
 
   @Override
   public ODataSerializer createSerializer(final ContentType contentType) throws SerializerException
{
-    final ODataFormat format = ODataFormat.fromContentType(contentType);
+    final Format format = contentType.getODataFormat();
     ODataSerializer serializer;
 
     switch (format) {
@@ -105,7 +105,7 @@ public class ODataImpl extends OData {
 
   @Override
   public ODataDeserializer createDeserializer(final ContentType contentType) throws DeserializerException
{
-    final ODataFormat format = ODataFormat.fromContentType(contentType);
+    final Format format = contentType.getODataFormat();
     ODataDeserializer deserializer;
 
     switch (format) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/588df780/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
index 13c0fad..671a069 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
@@ -42,7 +42,7 @@ import org.apache.olingo.commons.api.edm.EdmProperty;
 import org.apache.olingo.commons.api.edm.EdmStructuredType;
 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.format.Format;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
 import org.apache.olingo.server.api.ODataServerError;
 import org.apache.olingo.server.api.ServiceMetadata;
@@ -75,12 +75,12 @@ public class ODataJsonSerializer implements ODataSerializer {
 
   private static final Logger log = LoggerFactory.getLogger(ODataJsonSerializer.class);
 
-  private final ODataFormat format;
+  private final ContentType contentType;
   private final boolean isIEEE754Compatible;
   
   public ODataJsonSerializer(final ContentType contentType) {
     this.isIEEE754Compatible = isODataIEEE754Compatible(contentType);
-    this.format = ODataFormat.fromContentType(contentType);
+    this.contentType = contentType;
   }
 
   @Override
@@ -94,7 +94,7 @@ public class ODataJsonSerializer implements ODataSerializer {
       gen = new JsonFactory().createGenerator(buffer.getOutputStream())
           .setPrettyPrinter(new DefaultPrettyPrinter());
 
-      new ServiceDocumentJsonSerializer(metadata, serviceRoot, format).writeServiceDocument(gen);
+      new ServiceDocumentJsonSerializer(metadata, serviceRoot, contentType).writeServiceDocument(gen);
 
       gen.close();
 
@@ -196,7 +196,7 @@ public class ODataJsonSerializer implements ODataSerializer {
   }
 
   private ContextURL checkContextURL(final ContextURL contextURL) throws SerializerException
{
-    if (format == ODataFormat.JSON_NO_METADATA) {
+    if (contentType.getODataFormat() == Format.JSON_NO_METADATA) {
       return null;
     } else if (contextURL == null) {
       throw new SerializerException("ContextURL null!", SerializerException.MessageKeys.NO_CONTEXT_URL);
@@ -205,7 +205,7 @@ public class ODataJsonSerializer implements ODataSerializer {
   }
 
   private void writeMetadataETag(final ServiceMetadata metadata, JsonGenerator json) throws
IOException {
-    if (format != ODataFormat.JSON_NO_METADATA
+    if (contentType.getODataFormat() != Format.JSON_NO_METADATA
         && metadata != null
         && metadata.getServiceMetadataETagSupport() != null
         && metadata.getServiceMetadataETagSupport().getMetadataETag() != null) {
@@ -236,7 +236,7 @@ public class ODataJsonSerializer implements ODataSerializer {
       final SelectOption select, final boolean onlyReference, final JsonGenerator json) 
           throws IOException, SerializerException {
     json.writeStartObject();
-    if (format != ODataFormat.JSON_NO_METADATA) {
+    if (contentType.getODataFormat() != Format.JSON_NO_METADATA) {
       if (contextURL != null) { // top-level entity
         json.writeStringField(Constants.JSON_CONTEXT, ContextURLBuilder.create(contextURL).toASCIIString());
         writeMetadataETag(metadata, json);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/588df780/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentJsonSerializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentJsonSerializer.java
b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentJsonSerializer.java
index 65b4673..ad98aa7 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentJsonSerializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentJsonSerializer.java
@@ -26,7 +26,8 @@ import org.apache.olingo.commons.api.edm.EdmEntityContainer;
 import org.apache.olingo.commons.api.edm.EdmEntitySet;
 import org.apache.olingo.commons.api.edm.EdmFunctionImport;
 import org.apache.olingo.commons.api.edm.EdmSingleton;
-import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.commons.api.format.Format;
 import org.apache.olingo.server.api.ServiceMetadata;
 
 import com.fasterxml.jackson.core.JsonGenerator;
@@ -40,13 +41,13 @@ public class ServiceDocumentJsonSerializer {
 
   private final ServiceMetadata metadata;
   private final String serviceRoot;
-  private final ODataFormat format;
+  private final ContentType contentType;
 
   public ServiceDocumentJsonSerializer(final ServiceMetadata metadata, final String serviceRoot,
-      final ODataFormat format) {
+      final ContentType contentType) {
     this.metadata = metadata;
     this.serviceRoot = serviceRoot;
-    this.format = format;
+    this.contentType = contentType;
   }
 
   public void writeServiceDocument(final JsonGenerator gen) throws IOException {
@@ -58,7 +59,7 @@ public class ServiceDocumentJsonSerializer {
         + Constants.METADATA;
     gen.writeObjectField(Constants.JSON_CONTEXT, metadataUri);
 
-    if (format != ODataFormat.JSON_NO_METADATA
+    if (contentType.getODataFormat() != Format.JSON_NO_METADATA
         && metadata != null
         && metadata.getServiceMetadataETagSupport() != null
         && metadata.getServiceMetadataETagSupport().getMetadataETag() != null) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/588df780/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java
b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java
index 6391212..69651b3 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java
@@ -32,7 +32,7 @@ import org.antlr.v4.runtime.atn.PredictionMode;
 import org.antlr.v4.runtime.misc.ParseCancellationException;
 import org.apache.olingo.commons.api.ODataRuntimeException;
 import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.format.Format;
 import org.apache.olingo.server.api.uri.UriInfo;
 import org.apache.olingo.server.api.uri.UriInfoKind;
 import org.apache.olingo.server.api.uri.UriResource;
@@ -177,9 +177,9 @@ public class Parser {
             FormatOptionImpl formatOption = new FormatOptionImpl();
             formatOption.setName(option.name);
             formatOption.setText(option.value);
-            if (option.value.equalsIgnoreCase(ODataFormat.JSON.name())
-                || option.value.equalsIgnoreCase(ODataFormat.XML.name())
-                || option.value.equalsIgnoreCase(ODataFormat.ATOM.name())
+            if (option.value.equalsIgnoreCase(Format.JSON.name())
+                || option.value.equalsIgnoreCase(Format.XML.name())
+                || option.value.equalsIgnoreCase(Format.ATOM.name())
                 || isFormatSyntaxValid(option.value)) {
               formatOption.setFormat(option.value);
             } else {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/588df780/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 b959bb6..07e06ca 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
@@ -31,7 +31,6 @@ import java.util.Arrays;
 import java.util.List;
 
 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.ODataRequest;
@@ -154,7 +153,7 @@ public class ContentNegotiatorTest {
 
   @Test
   public void checkSupport() throws Exception {
-    ContentNegotiator.checkSupport(ODataFormat.JSON.getContentType(), null,
+    ContentNegotiator.checkSupport(ContentType.JSON, null,
         RepresentationType.ENTITY);
     ContentNegotiator.checkSupport(ContentType.TEXT_PLAIN, null, RepresentationType.VALUE);
     try {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/588df780/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerBasicTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerBasicTest.java
b/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerBasicTest.java
index da34caa..d29fdf8 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerBasicTest.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerBasicTest.java
@@ -26,7 +26,7 @@ import java.io.InputStream;
 import java.net.URI;
 import java.util.List;
 
-import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.deserializer.DeserializerException;
 import org.apache.olingo.server.api.deserializer.ODataDeserializer;
@@ -36,15 +36,15 @@ public class ODataJsonDeserializerBasicTest {
   
   @Test
   public void checkSupportedJsonFormats() throws Exception {
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON.getContentType());
+    ODataDeserializer deserializer = OData.newInstance().createDeserializer(ContentType.JSON);
     assertNotNull(deserializer);
     deserializer = null;
 
-    deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON_NO_METADATA.getContentType());
+    deserializer = OData.newInstance().createDeserializer(ContentType.JSON_NO_METADATA);
     assertNotNull(deserializer);
     deserializer = null;
 
-    deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON_FULL_METADATA.getContentType());
+    deserializer = OData.newInstance().createDeserializer(ContentType.JSON_FULL_METADATA);
     assertNotNull(deserializer);
     deserializer = null;
   }
@@ -58,7 +58,7 @@ public class ODataJsonDeserializerBasicTest {
         "    { \"@odata.id\": \"Orders(10759)\" }\n" +
         "  ]\n" +
         "}";
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON.getContentType());
+    ODataDeserializer deserializer = OData.newInstance().createDeserializer(ContentType.JSON);
     List<URI> values = deserializer.entityReferences(new ByteArrayInputStream(payload.getBytes()))
         .getEntityReferences();
     assertEquals(2, values.size());
@@ -72,7 +72,7 @@ public class ODataJsonDeserializerBasicTest {
         "  \"@odata.context\": \"http://host/service/$metadata#$ref\",\n" +
         "  \"@odata.id\": \"Orders(10643)\"\n" +
         "}";
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON.getContentType());
+    ODataDeserializer deserializer = OData.newInstance().createDeserializer(ContentType.JSON);
     List<URI> values = deserializer.entityReferences(new ByteArrayInputStream(payload
         .getBytes())).getEntityReferences();
     assertEquals(1, values.size());
@@ -87,7 +87,7 @@ public class ODataJsonDeserializerBasicTest {
         + "}";
 
     InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON.getContentType());
+    ODataDeserializer deserializer = OData.newInstance().createDeserializer(ContentType.JSON);
     final List<URI> entityReferences = deserializer.entityReferences(stream).getEntityReferences();
     
     assertEquals(1, entityReferences.size());
@@ -105,7 +105,7 @@ public class ODataJsonDeserializerBasicTest {
         "}";
 
     InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON.getContentType());
+    ODataDeserializer deserializer = OData.newInstance().createDeserializer(ContentType.JSON);
     final List<URI> entityReferences = deserializer.entityReferences(stream).getEntityReferences();
     
     assertEquals(2, entityReferences.size());
@@ -124,7 +124,7 @@ public class ODataJsonDeserializerBasicTest {
         "}";
 
     InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON.getContentType());
+    ODataDeserializer deserializer = OData.newInstance().createDeserializer(ContentType.JSON);
     final List<URI> entityReferences = deserializer.entityReferences(stream).getEntityReferences();
     
     assertEquals(1, entityReferences.size());
@@ -142,7 +142,7 @@ public class ODataJsonDeserializerBasicTest {
         "}";
 
     InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON.getContentType());
+    ODataDeserializer deserializer = OData.newInstance().createDeserializer(ContentType.JSON);
     final List<URI> entityReferences = deserializer.entityReferences(stream).getEntityReferences();
     
     assertEquals(1, entityReferences.size());
@@ -158,7 +158,7 @@ public class ODataJsonDeserializerBasicTest {
         "}";
 
     InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON.getContentType());
+    ODataDeserializer deserializer = OData.newInstance().createDeserializer(ContentType.JSON);
     final List<URI> entityReferences = deserializer.entityReferences(stream).getEntityReferences();
     
     assertEquals(0, entityReferences.size());
@@ -173,7 +173,7 @@ public class ODataJsonDeserializerBasicTest {
     String entityString = "{ }";
 
     InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON.getContentType());
+    ODataDeserializer deserializer = OData.newInstance().createDeserializer(ContentType.JSON);
     final List<URI> entityReferences = deserializer.entityReferences(stream).getEntityReferences();
     
     assertEquals(0, entityReferences.size());
@@ -187,7 +187,7 @@ public class ODataJsonDeserializerBasicTest {
         "}";
 
     InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON.getContentType());
+    ODataDeserializer deserializer = OData.newInstance().createDeserializer(ContentType.JSON);
     deserializer.entityReferences(stream);
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/588df780/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
index ad09ff9..1994e0c 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
@@ -32,7 +32,7 @@ import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.ContextURL;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ValueType;
-import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.server.api.serializer.ComplexSerializerOptions;
 import org.junit.Test;
 
@@ -44,7 +44,7 @@ public class ODataJsonSerializerTest {
     col.add(getValues(2));
     final Property complexCollection = new Property(null, "ComplexCol", ValueType.COLLECTION_COMPLEX,
col);
 
-    final ODataJsonSerializer serializer = new ODataJsonSerializer(ODataFormat.APPLICATION_JSON.getContentType());
+    final ODataJsonSerializer serializer = new ODataJsonSerializer(ContentType.APPLICATION_JSON);
     final ComplexSerializerOptions options = ComplexSerializerOptions.with()
         .contextURL(ContextURL.with().selectList("ComplexCollection").build()).build();
     final InputStream in = serializer.complexCollection(null, ComplexTypeHelper.createType(),

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/588df780/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ServerErrorSerializerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ServerErrorSerializerTest.java
b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ServerErrorSerializerTest.java
index 9f67e49..3242076 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ServerErrorSerializerTest.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ServerErrorSerializerTest.java
@@ -27,9 +27,9 @@ import java.util.List;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.olingo.commons.api.ODataErrorDetail;
-import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.server.api.ODataServerError;
+import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.ODataServerError;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
 import org.apache.olingo.server.api.serializer.SerializerException;
 import org.junit.Before;
@@ -45,7 +45,7 @@ public class ServerErrorSerializerTest {
 
   @Before
   public void before() throws Exception {
-    ser = OData.newInstance().createSerializer(ODataFormat.JSON.getContentType());
+    ser = OData.newInstance().createSerializer(ContentType.JSON);
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/588df780/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java
b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java
index 752b254..4423308 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java
@@ -57,7 +57,7 @@ import org.apache.olingo.commons.api.edm.provider.CsdlPropertyRef;
 import org.apache.olingo.commons.api.edm.provider.CsdlReturnType;
 import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
 import org.apache.olingo.commons.api.edm.provider.CsdlSingleton;
-import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.core.edm.EdmComplexTypeImpl;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ServiceMetadata;
@@ -76,7 +76,7 @@ public class MetadataDocumentXmlSerializerTest {
 
   @BeforeClass
   public static void init() throws SerializerException {
-    serializer = OData.newInstance().createSerializer(ODataFormat.XML.getContentType());
+    serializer = OData.newInstance().createSerializer(ContentType.APPLICATION_XML);
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/588df780/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalActionProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalActionProcessor.java
b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalActionProcessor.java
index fe1c1da..b6159ff 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalActionProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalActionProcessor.java
@@ -31,7 +31,7 @@ import org.apache.olingo.commons.api.edm.EdmEntitySet;
 import org.apache.olingo.commons.api.edm.EdmEntityType;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
 import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.format.Format;
 import org.apache.olingo.commons.api.http.HttpHeader;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
 import org.apache.olingo.server.api.ODataApplicationException;
@@ -93,10 +93,9 @@ public class TechnicalActionProcessor extends TechnicalProcessor
     }
     final EdmEntitySet edmEntitySet = getEdmEntitySet(uriInfo.asUriInfoResource());
     final EdmEntityType type = (EdmEntityType) action.getReturnType().getType();
-    final ODataFormat format = ODataFormat.fromContentType(responseFormat);
     EntityCollectionSerializerOptions options = EntityCollectionSerializerOptions.with()
-        .contextURL(format == ODataFormat.JSON_NO_METADATA ? null : getContextUrl(edmEntitySet,
type, false))
-        .build();
+        .contextURL(responseFormat.getODataFormat() == Format.JSON_NO_METADATA ? null : 
+          getContextUrl(edmEntitySet, type, false)).build();
     response.setContent(odata.createSerializer(requestFormat)
         .entityCollection(serviceMetadata, type, collection, options).getContent());
     response.setStatusCode(HttpStatusCode.OK.getStatusCode());
@@ -127,14 +126,13 @@ public class TechnicalActionProcessor extends TechnicalProcessor
             HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), Locale.ROOT);
       }
     } else {
-      final ODataFormat format = ODataFormat.fromContentType(responseFormat);
       response.setContent(odata.createSerializer(requestFormat).entity(
           serviceMetadata,
           type,
           entityResult.getEntity(),
           EntitySerializerOptions.with()
-              .contextURL(format == ODataFormat.JSON_NO_METADATA ? null : getContextUrl(edmEntitySet,
type, true))
-              .build())
+              .contextURL(responseFormat.getODataFormat() == Format.JSON_NO_METADATA ? null
: 
+                getContextUrl(edmEntitySet, type, true)).build())
           .getContent());
       response.setStatusCode((entityResult.isCreated() ? HttpStatusCode.CREATED : HttpStatusCode.OK)
           .getStatusCode());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/588df780/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
index 61dbfc9..32f76b1 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
@@ -28,7 +28,7 @@ import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.edm.EdmEntitySet;
 import org.apache.olingo.commons.api.edm.EdmEntityType;
 import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.format.Format;
 import org.apache.olingo.commons.api.http.HttpContentType;
 import org.apache.olingo.commons.api.http.HttpHeader;
 import org.apache.olingo.commons.api.http.HttpMethod;
@@ -451,7 +451,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
         edmEntityType,
         entityCollection,
         EntityCollectionSerializerOptions.with()
-            .contextURL(ODataFormat.fromContentType(requestedFormat) == ODataFormat.JSON_NO_METADATA
? null :
+            .contextURL(requestedFormat.getODataFormat() == Format.JSON_NO_METADATA ? null
:
                 getContextUrl(edmEntitySet, edmEntityType, false, expand, select))
             .count(countOption)
             .expand(expand).select(select)
@@ -484,7 +484,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
         edmEntityType,
         entity,
         EntitySerializerOptions.with()
-            .contextURL(ODataFormat.fromContentType(requestedFormat) == ODataFormat.JSON_NO_METADATA
? null :
+            .contextURL(requestedFormat.getODataFormat() == Format.JSON_NO_METADATA ? null
:
                 getContextUrl(edmEntitySet, edmEntityType, true, expand, select))
             .expand(expand).select(select)
             .build());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/588df780/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
index e8257dd..50e1c1b 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
@@ -38,7 +38,7 @@ import org.apache.olingo.commons.api.edm.EdmStructuredType;
 import org.apache.olingo.commons.api.edm.EdmType;
 import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
 import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.format.Format;
 import org.apache.olingo.commons.api.http.HttpHeader;
 import org.apache.olingo.commons.api.http.HttpMethod;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
@@ -396,7 +396,7 @@ public class TechnicalPrimitiveComplexProcessor extends TechnicalProcessor
       final RepresentationType representationType, final ContentType responseFormat,
       final ExpandOption expand, final SelectOption select) throws ODataLibraryException
{
     ODataSerializer serializer = odata.createSerializer(responseFormat);
-    final ContextURL contextURL = ODataFormat.fromContentType(responseFormat) == ODataFormat.JSON_NO_METADATA
? null :
+    final ContextURL contextURL = responseFormat.getODataFormat() == Format.JSON_NO_METADATA
? null :
         getContextUrl(edmEntitySet, entity, path, type, representationType, expand, select);
     SerializerResult result = null;
     switch (representationType) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/588df780/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
b/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
index 755c4f1..c9a5f32 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
@@ -43,16 +43,15 @@ import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.api.edm.provider.CsdlAbstractEdmProvider;
 import org.apache.olingo.commons.api.edm.provider.CsdlEntitySet;
 import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.http.HttpContentType;
 import org.apache.olingo.commons.api.http.HttpHeader;
 import org.apache.olingo.commons.api.http.HttpMethod;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
-import org.apache.olingo.server.api.ODataServerError;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
+import org.apache.olingo.server.api.ODataServerError;
 import org.apache.olingo.server.api.ServiceMetadata;
 import org.apache.olingo.server.api.edmx.EdmxReference;
 import org.apache.olingo.server.api.processor.ActionComplexCollectionProcessor;
@@ -736,7 +735,7 @@ public class ODataHandlerTest {
 
     if (request.getHeaders(HttpHeader.CONTENT_TYPE) == null) {
       request.addHeader(HttpHeader.CONTENT_TYPE, Collections.singletonList(
-          ODataFormat.JSON.getContentType().toContentTypeString()));
+          ContentType.JSON.toContentTypeString()));
     }
 
     final OData odata = OData.newInstance();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/588df780/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/AbstractODataDeserializerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/AbstractODataDeserializerTest.java
b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/AbstractODataDeserializerTest.java
index 7030b13..c0e188a 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/AbstractODataDeserializerTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/AbstractODataDeserializerTest.java
@@ -24,13 +24,12 @@ import java.util.Collections;
 
 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.server.api.OData;
 import org.apache.olingo.server.api.edmx.EdmxReference;
 import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
 
 public class AbstractODataDeserializerTest {
-  protected static final ContentType CONTENT_TYPE_JSON = ODataFormat.JSON.getContentType();
+  protected static final ContentType CONTENT_TYPE_JSON = ContentType.JSON;
   protected static final ContentType CONTENT_TYPE_JSON_IEEE754Compatible = 
       ContentType.parse("application/json;odata.format=minimal;IEEE754Compatible=true");
   

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/588df780/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
index c7d1782..15dd99b 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
@@ -37,7 +37,6 @@ import org.apache.olingo.commons.api.edm.EdmEntityType;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
 import org.apache.olingo.commons.api.edm.EdmProperty;
 import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.server.api.ServiceMetadata;
 import org.apache.olingo.server.api.edmx.EdmxReference;
 import org.apache.olingo.server.api.serializer.ComplexSerializerOptions;
@@ -71,7 +70,7 @@ public class ODataJsonSerializerTest {
       new EdmTechProvider(), Collections.<EdmxReference> emptyList(), new MetadataETagSupport("W/\"metadataETag\""));
   private static final EdmEntityContainer entityContainer = metadata.getEdm().getEntityContainer();
   private final DataProvider data = new DataProvider();
-  private final ODataSerializer serializer = new ODataJsonSerializer(ODataFormat.JSON.getContentType());
+  private final ODataSerializer serializer = new ODataJsonSerializer(ContentType.JSON);
   private final ODataSerializer serializerIEEECompatible = 
       new ODataJsonSerializer(ContentType.parse("application/json;odata.metadata=minimal;IEEE754Compatible=true"));
   private final UriHelper helper = new UriHelperImpl();
@@ -307,7 +306,7 @@ public class ODataJsonSerializerTest {
   public void entityTwoPrimNoMetadata() throws Exception {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESTwoPrim");
     final Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
-    InputStream result = new ODataJsonSerializer(ODataFormat.JSON_NO_METADATA.getContentType())
+    InputStream result = new ODataJsonSerializer(ContentType.JSON_NO_METADATA)
                                       .entity(metadata, edmEntitySet.getEntityType(), entity,
null).getContent();
     final String resultString = IOUtils.toString(result);
     final String expectedResult = "{\"PropertyInt16\":32766,\"PropertyString\":\"Test String1\"}";
@@ -318,7 +317,7 @@ public class ODataJsonSerializerTest {
   public void entitySetTwoPrimNoMetadata() throws Exception {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESTwoPrim");
     final EntityCollection entitySet = data.readAll(edmEntitySet);
-    InputStream result = new ODataJsonSerializer(ODataFormat.JSON_NO_METADATA.getContentType())
+    InputStream result = new ODataJsonSerializer(ContentType.JSON_NO_METADATA)
     .entityCollection(metadata, edmEntitySet.getEntityType(), entitySet,
         EntityCollectionSerializerOptions.with()
         .contextURL(ContextURL.with().entitySet(edmEntitySet).build()).build()).getContent();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/588df780/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java
b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java
index 8451976..bd4a551 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java
@@ -26,7 +26,7 @@ import java.io.InputStream;
 import java.util.Collections;
 
 import org.apache.commons.io.IOUtils;
-import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ServiceMetadata;
 import org.apache.olingo.server.api.edmx.EdmxReference;
@@ -47,7 +47,7 @@ public class ServiceDocumentTest {
     OData server = OData.newInstance();
     assertNotNull(server);
 
-    ODataSerializer serializer = server.createSerializer(ODataFormat.JSON.getContentType());
+    ODataSerializer serializer = server.createSerializer(ContentType.JSON);
     assertNotNull(serializer);
 
     InputStream result = serializer.serviceDocument(metadata, serviceRoot).getContent();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/588df780/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
index f69ee60..ef27e24 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
@@ -27,7 +27,7 @@ import java.util.Arrays;
 import java.util.List;
 
 import org.apache.commons.io.IOUtils;
-import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ServiceMetadata;
 import org.apache.olingo.server.api.edmx.EdmxReference;
@@ -48,7 +48,7 @@ public class MetadataDocumentTest {
         new EdmTechProvider(references), references);
 
     final String metadata = IOUtils.toString(
-        odata.createSerializer(ODataFormat.XML.getContentType()).metadataDocument(serviceMetadata).getContent());
+        odata.createSerializer(ContentType.APPLICATION_XML).metadataDocument(serviceMetadata).getContent());
     assertNotNull(metadata);
     assertThat(metadata,
         containsString("<edmx:Reference Uri=\"" + CORE_VOCABULARY + "\">"

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/588df780/samples/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java
----------------------------------------------------------------------
diff --git a/samples/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java
b/samples/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java
index 27e77f6..013462c 100644
--- a/samples/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java
+++ b/samples/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java
@@ -34,7 +34,7 @@ import org.apache.olingo.commons.api.edm.EdmEntitySet;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
 import org.apache.olingo.commons.api.edm.EdmProperty;
 import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.format.Format;
 import org.apache.olingo.commons.api.http.HttpContentType;
 import org.apache.olingo.commons.api.http.HttpHeader;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
@@ -102,7 +102,6 @@ public class CarsProcessor implements EntityCollectionProcessor, EntityProcessor
 
     // Next we create a serializer based on the requested format. This could also be a custom
format but we do not
     // support them in this example
-    final ODataFormat format = ODataFormat.fromContentType(requestedContentType);
     ODataSerializer serializer = odata.createSerializer(requestedContentType);
 
     // Now the content is serialized using the serializer.
@@ -110,7 +109,7 @@ public class CarsProcessor implements EntityCollectionProcessor, EntityProcessor
     final SelectOption select = uriInfo.getSelectOption();
     InputStream serializedContent = serializer.entityCollection(edm, edmEntitySet.getEntityType(),
entitySet,
         EntityCollectionSerializerOptions.with()
-            .contextURL(format == ODataFormat.JSON_NO_METADATA ? null :
+            .contextURL(requestedContentType.getODataFormat() == Format.JSON_NO_METADATA
? null :
                 getContextUrl(edmEntitySet, false, expand, select, null))
             .count(uriInfo.getCountOption())
             .expand(expand).select(select)
@@ -142,13 +141,12 @@ public class CarsProcessor implements EntityCollectionProcessor, EntityProcessor
           .getStatusCode(), Locale.ENGLISH);
     } else {
       // If an entity was found we proceed by serializing it and sending it to the client.
-      final ODataFormat format = ODataFormat.fromContentType(requestedContentType);
       ODataSerializer serializer = odata.createSerializer(requestedContentType);
       final ExpandOption expand = uriInfo.getExpandOption();
       final SelectOption select = uriInfo.getSelectOption();
       InputStream serializedContent = serializer.entity(edm, edmEntitySet.getEntityType(),
entity,
           EntitySerializerOptions.with()
-              .contextURL(format == ODataFormat.JSON_NO_METADATA ? null :
+              .contextURL(requestedContentType.getODataFormat() == Format.JSON_NO_METADATA
? null :
                   getContextUrl(edmEntitySet, true, expand, select, null))
               .expand(expand).select(select)
               .build()).getContent();
@@ -254,9 +252,8 @@ public class CarsProcessor implements EntityCollectionProcessor, EntityProcessor
         if (property.getValue() == null) {
           response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
         } else {
-          final ODataFormat format = ODataFormat.fromContentType(contentType);
           ODataSerializer serializer = odata.createSerializer(contentType);
-          final ContextURL contextURL = format == ODataFormat.JSON_NO_METADATA ? null :
+          final ContextURL contextURL = contentType.getODataFormat() == Format.JSON_NO_METADATA
? null :
               getContextUrl(edmEntitySet, true, null, null, edmProperty.getName());
           InputStream serializerContent = complex ?
               serializer.complex(edm, (EdmComplexType) edmProperty.getType(), property,


Mime
View raw message