diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonSerializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonSerializer.java index 701c1db66..44a51d9e4 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonSerializer.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonSerializer.java @@ -380,7 +380,7 @@ public class JsonSerializer implements ODataSerializer { private boolean isODataMetadataNone() { return contentType.isCompatible(ContentType.APPLICATION_JSON) - && ContentType.VALUE_ODATA_METADATA_NONE.equals( + && ContentType.VALUE_ODATA_METADATA_NONE.equalsIgnoreCase( contentType.getParameter(ContentType.PARAMETER_ODATA_METADATA)); } } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmTypeInfo.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmTypeInfo.java index 16024a880..75e0bff8c 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmTypeInfo.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmTypeInfo.java @@ -212,27 +212,25 @@ public class EdmTypeInfo { public static EdmPrimitiveTypeKind determineTypeKind(final Object value) { if (value == null) { return null; - } - final Class cls = value.getClass(); - if (value instanceof Boolean || boolean.class.isAssignableFrom(cls)) { + } else if (value instanceof Boolean) { return EdmPrimitiveTypeKind.Boolean; } else if (value instanceof String) { return EdmPrimitiveTypeKind.String; } else if (value instanceof UUID) { return EdmPrimitiveTypeKind.Guid; - } else if (value instanceof Long || value instanceof BigInteger || long.class.isAssignableFrom(cls)) { + } else if (value instanceof Long || value instanceof BigInteger) { return EdmPrimitiveTypeKind.Int64; - } else if (value instanceof Integer || int.class.isAssignableFrom(cls)) { + } else if (value instanceof Integer) { return EdmPrimitiveTypeKind.Int32; - } else if (value instanceof Short || short.class.isAssignableFrom(cls)) { + } else if (value instanceof Short) { return EdmPrimitiveTypeKind.Int16; - } else if (value instanceof Byte || byte.class.isAssignableFrom(cls)) { + } else if (value instanceof Byte) { return EdmPrimitiveTypeKind.SByte; } else if (value instanceof BigDecimal) { return EdmPrimitiveTypeKind.Decimal; - } else if (value instanceof Double || double.class.isAssignableFrom(cls)) { + } else if (value instanceof Double) { return EdmPrimitiveTypeKind.Double; - } else if (value instanceof Float || float.class.isAssignableFrom(cls)) { + } else if (value instanceof Float) { return EdmPrimitiveTypeKind.Single; } else if (value instanceof Calendar || value instanceof Date || value instanceof java.sql.Timestamp) { return EdmPrimitiveTypeKind.DateTimeOffset; 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 b638ae7e8..37b59aab0 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 @@ -63,9 +63,9 @@ public class ODataImpl extends OData { if (contentType.isCompatible(ContentType.APPLICATION_JSON)) { final String metadata = contentType.getParameter(ContentType.PARAMETER_ODATA_METADATA); if (metadata == null - || ContentType.VALUE_ODATA_METADATA_MINIMAL.equals(metadata) - || ContentType.VALUE_ODATA_METADATA_NONE.equals(metadata) - || ContentType.VALUE_ODATA_METADATA_FULL.equals(metadata)) { + || ContentType.VALUE_ODATA_METADATA_MINIMAL.equalsIgnoreCase(metadata) + || ContentType.VALUE_ODATA_METADATA_NONE.equalsIgnoreCase(metadata) + || ContentType.VALUE_ODATA_METADATA_FULL.equalsIgnoreCase(metadata)) { serializer = new ODataJsonSerializer(contentType); } } else if (contentType.isCompatible(ContentType.APPLICATION_XML) diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java index 67f961f16..de1fa395f 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java @@ -62,6 +62,7 @@ import org.apache.olingo.server.api.deserializer.ODataDeserializer; import org.apache.olingo.server.core.deserializer.DeserializerResultImpl; import org.apache.olingo.server.core.deserializer.helper.ExpandTreeBuilder; import org.apache.olingo.server.core.deserializer.helper.ExpandTreeBuilderImpl; +import org.apache.olingo.server.core.serializer.utils.ContentTypeHelper; import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonParseException; @@ -82,17 +83,13 @@ public class ODataJsonDeserializer implements ODataDeserializer { private ServiceMetadata serviceMetadata; public ODataJsonDeserializer(final ContentType contentType) { - isIEEE754Compatible = isODataIEEE754Compatible(contentType); + this(contentType, null); } - + public ODataJsonDeserializer(final ContentType contentType, final ServiceMetadata serviceMetadata) { - isIEEE754Compatible = isODataIEEE754Compatible(contentType); + isIEEE754Compatible = ContentTypeHelper.isODataIEEE754Compatible(contentType); this.serviceMetadata = serviceMetadata; } - - public void setMetadata(ServiceMetadata metadata) { - this.serviceMetadata = metadata; - } @Override public DeserializerResult entityCollection(final InputStream stream, final EdmEntityType edmEntityType) @@ -827,12 +824,6 @@ public class ODataJsonDeserializer implements ODataDeserializer { } } - private boolean isODataIEEE754Compatible(final ContentType contentType) { - return contentType.getParameters().containsKey(ContentType.PARAMETER_IEEE754_COMPATIBLE) - && Boolean.TRUE.toString().equalsIgnoreCase( - contentType.getParameter(ContentType.PARAMETER_IEEE754_COMPATIBLE)); - } - private EdmType getDerivedType(final EdmStructuredType edmType, final JsonNode jsonNode) throws DeserializerException { JsonNode odataTypeNode = jsonNode.get(Constants.JSON_TYPE); 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 759ae5cac..adf8411fc 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 @@ -18,9 +18,6 @@ */ package org.apache.olingo.server.core.serializer.json; -import static org.apache.olingo.server.core.serializer.utils.ContentTypeHelper.isODataMetadataFull; -import static org.apache.olingo.server.core.serializer.utils.ContentTypeHelper.isODataMetadataNone; - import java.io.IOException; import java.io.OutputStream; import java.util.Collections; @@ -72,6 +69,7 @@ import org.apache.olingo.server.core.ODataWritableContent; import org.apache.olingo.server.core.serializer.AbstractODataSerializer; import org.apache.olingo.server.core.serializer.SerializerResultImpl; import org.apache.olingo.server.core.serializer.utils.CircleStreamBuffer; +import org.apache.olingo.server.core.serializer.utils.ContentTypeHelper; import org.apache.olingo.server.core.serializer.utils.ContextURLBuilder; import org.apache.olingo.server.core.serializer.utils.ExpandSelectHelper; import org.apache.olingo.server.core.uri.UriHelperImpl; @@ -82,11 +80,13 @@ import com.fasterxml.jackson.core.JsonGenerator; public class ODataJsonSerializer extends AbstractODataSerializer { private final boolean isIEEE754Compatible; - private final ContentType contentType; + private final boolean isODataMetadataNone; + private final boolean isODataMetadataFull; public ODataJsonSerializer(final ContentType contentType) { - this.contentType = contentType; - isIEEE754Compatible = isODataIEEE754Compatible(contentType); + isIEEE754Compatible = ContentTypeHelper.isODataIEEE754Compatible(contentType); + isODataMetadataNone = ContentTypeHelper.isODataMetadataNone(contentType); + isODataMetadataFull = ContentTypeHelper.isODataMetadataFull(contentType); } @Override @@ -99,8 +99,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer { CircleStreamBuffer buffer = new CircleStreamBuffer(); outputStream = buffer.getOutputStream(); JsonGenerator json = new JsonFactory().createGenerator(outputStream); - new ServiceDocumentJsonSerializer(metadata, serviceRoot, - isODataMetadataNone(contentType)).writeServiceDocument(json); + new ServiceDocumentJsonSerializer(metadata, serviceRoot, isODataMetadataNone).writeServiceDocument(json); json.close(); outputStream.close(); @@ -160,7 +159,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer { writeMetadataETag(metadata, json); if (options != null && options.getCount() != null && options.getCount().getValue()) { - writeCount(entitySet, json); + writeInlineCount("", entitySet.getCount(), json); } writeOperations(entitySet.getOperations(), json); json.writeFieldName(Constants.VALUE); @@ -207,7 +206,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer { writeMetadataETag(metadata, json); if (options != null && options.getCount() != null && options.getCount().getValue()) { - writeCount(entitySet, json); + writeInlineCount("", entitySet.getCount(), json); } json.writeFieldName(Constants.VALUE); if (options == null) { @@ -256,7 +255,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer { } ContextURL checkContextURL(final ContextURL contextURL) throws SerializerException { - if (isODataMetadataNone(contentType)) { + if (isODataMetadataNone) { return null; } else if (contextURL == null) { throw new SerializerException("ContextURL null!", SerializerException.MessageKeys.NO_CONTEXT_URL); @@ -313,7 +312,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer { final JsonGenerator json) throws IOException, SerializerException { json.writeStartObject(); - if (!isODataMetadataNone(contentType)) { + if (!isODataMetadataNone) { // top-level entity if (contextURL != null) { writeContextURL(contextURL, json); @@ -341,16 +340,14 @@ public class ODataJsonSerializer extends AbstractODataSerializer { json.writeStringField(Constants.JSON_ID, getEntityId(entity)); } else { final EdmEntityType resolvedType = resolveEntityType(metadata, entityType, entity.getType()); - if ((!isODataMetadataNone(contentType) && !resolvedType.equals(entityType)) - || isODataMetadataFull(contentType)) { + if ((!isODataMetadataNone && !resolvedType.equals(entityType)) || isODataMetadataFull) { json.writeStringField(Constants.JSON_TYPE, "#" + entity.getType()); } - if ((!isODataMetadataNone(contentType) && !areKeyPredicateNamesSelected(select, resolvedType)) - || isODataMetadataFull(contentType)) { + if ((!isODataMetadataNone && !areKeyPredicateNamesSelected(select, resolvedType)) || isODataMetadataFull) { json.writeStringField(Constants.JSON_ID, getEntityId(entity)); } - if (isODataMetadataFull(contentType)) { + if (isODataMetadataFull) { if (entity.getSelfLink() != null) { json.writeStringField(Constants.JSON_READ_LINK, entity.getSelfLink().getHref()); } @@ -368,7 +365,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer { private void writeOperations(final List operations, final JsonGenerator json) throws IOException { - if (isODataMetadataFull(contentType)) { + if (isODataMetadataFull) { for (Operation operation : operations) { json.writeObjectFieldStart(operation.getMetadataAnchor()); json.writeStringField(Constants.ATTR_TITLE, operation.getTitle()); @@ -391,15 +388,14 @@ public class ODataJsonSerializer extends AbstractODataSerializer { } EdmEntityType type = derivedType.getBaseType(); while (type != null) { - if (type.getFullQualifiedName().getFullQualifiedNameAsString() - .equals(baseType.getFullQualifiedName().getFullQualifiedNameAsString())) { + if (type.getFullQualifiedName().equals(baseType.getFullQualifiedName())) { return derivedType; } type = type.getBaseType(); } throw new SerializerException("Wrong base type", - SerializerException.MessageKeys.WRONG_BASE_TYPE, derivedTypeName, baseType - .getFullQualifiedName().getFullQualifiedNameAsString()); + SerializerException.MessageKeys.WRONG_BASE_TYPE, derivedTypeName, + baseType.getFullQualifiedName().getFullQualifiedNameAsString()); } protected EdmComplexType resolveComplexType(final ServiceMetadata metadata, final EdmComplexType baseType, @@ -415,15 +411,14 @@ public class ODataJsonSerializer extends AbstractODataSerializer { } EdmComplexType type = derivedType.getBaseType(); while (type != null) { - if (type.getFullQualifiedName().getFullQualifiedNameAsString() - .equals(baseType.getFullQualifiedName().getFullQualifiedNameAsString())) { + if (type.getFullQualifiedName().equals(baseType.getFullQualifiedName())) { return derivedType; } type = type.getBaseType(); } throw new SerializerException("Wrong base type", - SerializerException.MessageKeys.WRONG_BASE_TYPE, derivedTypeName, baseType - .getFullQualifiedName().getFullQualifiedNameAsString()); + SerializerException.MessageKeys.WRONG_BASE_TYPE, derivedTypeName, + baseType.getFullQualifiedName().getFullQualifiedNameAsString()); } protected void writeProperties(final ServiceMetadata metadata, final EdmStructuredType type, @@ -470,7 +465,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer { json); } } - } else if (isODataMetadataFull(contentType)) { + } else if (isODataMetadataFull) { for (final String propertyName : type.getNavigationPropertyNames()) { final Link navigationLink = linked.getNavigationLink(propertyName); if (navigationLink != null) { @@ -536,11 +531,11 @@ public class ODataJsonSerializer extends AbstractODataSerializer { final Set> selectedPaths, final JsonGenerator json) throws IOException, SerializerException { boolean isStreamProperty = isStreamProperty(edmProperty); - writePropertyType(edmProperty, property, json); + writePropertyType(edmProperty, json); if (!isStreamProperty) { json.writeFieldName(edmProperty.getName()); } - if ((property == null || property.isNull())) { + if (property == null || property.isNull()) { if (edmProperty.isNullable() == Boolean.FALSE) { throw new SerializerException("Non-nullable property not present!", SerializerException.MessageKeys.MISSING_PROPERTY, edmProperty.getName()); @@ -559,45 +554,43 @@ public class ODataJsonSerializer extends AbstractODataSerializer { } } - private void writePropertyType(final EdmProperty edmProperty, final Property property, - final JsonGenerator json) throws SerializerException, IOException { - if(!isODataMetadataFull(contentType)) { + private void writePropertyType(final EdmProperty edmProperty, JsonGenerator json) + throws SerializerException, IOException { + if (!isODataMetadataFull) { return; } - String typeName = edmProperty.getName()+Constants.JSON_TYPE; + String typeName = edmProperty.getName() + Constants.JSON_TYPE; final EdmType type = edmProperty.getType(); if (type.getKind() == EdmTypeKind.ENUM || type.getKind() == EdmTypeKind.DEFINITION) { if (edmProperty.isCollection()) { json.writeStringField(typeName, - "#Collection("+type.getFullQualifiedName().getFullQualifiedNameAsString()+")"); + "#Collection(" + type.getFullQualifiedName().getFullQualifiedNameAsString() + ")"); } else { - json.writeStringField(typeName, "#"+type.getFullQualifiedName().getFullQualifiedNameAsString()); - } + json.writeStringField(typeName, "#" + type.getFullQualifiedName().getFullQualifiedNameAsString()); + } } else if (edmProperty.isPrimitive()) { if (edmProperty.isCollection()) { - json.writeStringField(typeName, - "#Collection("+type.getFullQualifiedName().getName()+")"); + json.writeStringField(typeName, "#Collection(" + type.getFullQualifiedName().getName() + ")"); } else { // exclude the properties that can be heuristically determined if (type != EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Boolean) && type != EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Double) && type != EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.String)) { - json.writeStringField(typeName, - "#"+type.getFullQualifiedName().getName()); + json.writeStringField(typeName, "#" + type.getFullQualifiedName().getName()); } } } else if (type.getKind() == EdmTypeKind.COMPLEX) { // non-collection case written in writeComplex method directly. if (edmProperty.isCollection()) { json.writeStringField(typeName, - "#Collection("+type.getFullQualifiedName().getFullQualifiedNameAsString()+")"); + "#Collection(" + type.getFullQualifiedName().getFullQualifiedNameAsString() + ")"); } } else { throw new SerializerException("Property type not yet supported!", SerializerException.MessageKeys.UNSUPPORTED_PROPERTY_TYPE, edmProperty.getName()); } } - + private void writePropertyValue(final ServiceMetadata metadata, final EdmProperty edmProperty, final Property property, final Set> selectedPaths, final JsonGenerator json) throws IOException, SerializerException { @@ -720,7 +713,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer { } else if (type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Stream)) { if (primitiveValue instanceof Link) { Link stream = (Link)primitiveValue; - if (!isODataMetadataNone(contentType)) { + if (!isODataMetadataNone) { if (stream.getMediaETag() != null) { json.writeStringField(name+Constants.JSON_MEDIA_ETAG, stream.getMediaETag()); } @@ -728,7 +721,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer { json.writeStringField(name+Constants.JSON_MEDIA_CONTENT_TYPE, stream.getType()); } } - if (isODataMetadataFull(contentType)) { + if (isODataMetadataFull) { if (stream.getRel() != null && stream.getRel().equals(Constants.NS_MEDIA_READ_LINK_REL)) { json.writeStringField(name+Constants.JSON_MEDIA_READ_LINK, stream.getHref()); } @@ -750,7 +743,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer { final EdmComplexType resolvedType = resolveComplexType(metadata, type, complexProperty.getType()); - if (!isODataMetadataNone(contentType) && !resolvedType.equals(type) || isODataMetadataFull(contentType)) { + if (!isODataMetadataNone && !resolvedType.equals(type) || isODataMetadataFull) { json.writeStringField(Constants.JSON_TYPE, "#" + complexProperty.getType()); } @@ -832,7 +825,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer { writeContextURL(contextURL, json); writeMetadataETag(metadata, json); final EdmComplexType resolvedType = resolveComplexType(metadata, type, property.getType()); - if (!isODataMetadataNone(contentType) && !resolvedType.equals(type) || isODataMetadataFull(contentType)) { + if (!isODataMetadataNone && !resolvedType.equals(type) || isODataMetadataFull) { json.writeStringField(Constants.JSON_TYPE, "#" + property.getType()); } writeOperations(property.getOperations(), json); @@ -870,7 +863,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer { json.writeStartObject(); writeContextURL(contextURL, json); writeMetadataETag(metadata, json); - if (isODataMetadataFull(contentType)) { + if (isODataMetadataFull) { json.writeStringField(Constants.JSON_TYPE, "#Collection("+type.getFullQualifiedName().getName()+")"); } writeOperations(property.getOperations(), json); @@ -908,9 +901,9 @@ public class ODataJsonSerializer extends AbstractODataSerializer { json.writeStartObject(); writeContextURL(contextURL, json); writeMetadataETag(metadata, json); - if (isODataMetadataFull(contentType)) { + if (isODataMetadataFull) { json.writeStringField(Constants.JSON_TYPE, - "#Collection("+type.getFullQualifiedName().getFullQualifiedNameAsString()+")"); + "#Collection(" + type.getFullQualifiedName().getFullQualifiedNameAsString() + ")"); } writeOperations(property.getOperations(), json); json.writeFieldName(Constants.VALUE); @@ -976,7 +969,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer { writeContextURL(contextURL, json); if (options != null && options.getCount() != null && options.getCount().getValue()) { - writeCount(entityCollection, json); + writeInlineCount("", entityCollection.getCount(), json); } json.writeArrayFieldStart(Constants.VALUE); @@ -1005,13 +998,13 @@ public class ODataJsonSerializer extends AbstractODataSerializer { } void writeContextURL(final ContextURL contextURL, final JsonGenerator json) throws IOException { - if (!isODataMetadataNone(contentType) && contextURL != null) { + if (!isODataMetadataNone && contextURL != null) { json.writeStringField(Constants.JSON_CONTEXT, ContextURLBuilder.create(contextURL).toASCIIString()); } } void writeMetadataETag(final ServiceMetadata metadata, final JsonGenerator json) throws IOException { - if (!isODataMetadataNone(contentType) + if (!isODataMetadataNone && metadata != null && metadata.getServiceMetadataETagSupport() != null && metadata.getServiceMetadataETagSupport().getMetadataETag() != null) { @@ -1020,18 +1013,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer { } } - void writeCount(final AbstractEntityCollection entityCollection, final JsonGenerator json) throws IOException { - if (entityCollection.getCount() != null) { - if (isIEEE754Compatible) { - json.writeStringField(Constants.JSON_COUNT, entityCollection.getCount().toString()); - } else { - json.writeNumberField(Constants.JSON_COUNT, entityCollection.getCount()); - } - } - } - - void writeInlineCount(final String propertyName, - final Integer count, final JsonGenerator json) + void writeInlineCount(final String propertyName, final Integer count, final JsonGenerator json) throws IOException { if (count != null) { if (isIEEE754Compatible) { @@ -1047,10 +1029,4 @@ public class ODataJsonSerializer extends AbstractODataSerializer { json.writeStringField(Constants.JSON_NEXT_LINK, entitySet.getNext().toASCIIString()); } } - - private boolean isODataIEEE754Compatible(final ContentType contentType) { - return contentType.getParameters().containsKey(ContentType.PARAMETER_IEEE754_COMPATIBLE) - && Boolean.TRUE.toString().equalsIgnoreCase( - contentType.getParameter(ContentType.PARAMETER_IEEE754_COMPATIBLE).toLowerCase()); - } } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ContentTypeHelper.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ContentTypeHelper.java index 99c034373..5d0cfe32a 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ContentTypeHelper.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ContentTypeHelper.java @@ -28,11 +28,18 @@ public class ContentTypeHelper { public static boolean isODataMetadataNone(final ContentType contentType) { return contentType.isCompatible(ContentType.APPLICATION_JSON) - && ContentType.VALUE_ODATA_METADATA_NONE.equals(contentType.getParameter(ContentType.PARAMETER_ODATA_METADATA)); + && ContentType.VALUE_ODATA_METADATA_NONE.equalsIgnoreCase( + contentType.getParameter(ContentType.PARAMETER_ODATA_METADATA)); } - + public static boolean isODataMetadataFull(final ContentType contentType) { return contentType.isCompatible(ContentType.APPLICATION_JSON) - && ContentType.VALUE_ODATA_METADATA_FULL.equals(contentType.getParameter(ContentType.PARAMETER_ODATA_METADATA)); - } + && ContentType.VALUE_ODATA_METADATA_FULL.equalsIgnoreCase( + contentType.getParameter(ContentType.PARAMETER_ODATA_METADATA)); + } + + public static boolean isODataIEEE754Compatible(final ContentType contentType) { + return Boolean.TRUE.toString().equalsIgnoreCase( + contentType.getParameter(ContentType.PARAMETER_IEEE754_COMPATIBLE)); + } } 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 ddbfb1a62..c59bec948 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 @@ -257,7 +257,7 @@ public abstract class TechnicalProcessor implements Processor { protected boolean isODataMetadataNone(final ContentType contentType) { return contentType.isCompatible(ContentType.APPLICATION_JSON) - && ContentType.VALUE_ODATA_METADATA_NONE.equals( + && ContentType.VALUE_ODATA_METADATA_NONE.equalsIgnoreCase( contentType.getParameter(ContentType.PARAMETER_ODATA_METADATA)); } } 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 9540ddad1..1f550404e 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 @@ -67,7 +67,6 @@ import org.apache.olingo.server.api.uri.queryoption.ExpandItem; import org.apache.olingo.server.api.uri.queryoption.ExpandOption; import org.apache.olingo.server.api.uri.queryoption.SelectItem; import org.apache.olingo.server.api.uri.queryoption.SelectOption; -import org.apache.olingo.server.core.ServiceMetadataImpl; import org.apache.olingo.server.core.serializer.ExpandSelectMock; import org.apache.olingo.server.tecsvc.MetadataETagSupport; import org.apache.olingo.server.tecsvc.data.DataProvider; @@ -78,10 +77,10 @@ import org.junit.Test; import org.mockito.Mockito; public class ODataJsonSerializerTest { - private static final ServiceMetadata metadata = new ServiceMetadataImpl( + private static final OData odata = OData.newInstance(); + private static final ServiceMetadata metadata = odata.createServiceMetadata( new EdmTechProvider(), Collections. emptyList(), new MetadataETagSupport("W/\"metadataETag\"")); private static final EdmEntityContainer entityContainer = metadata.getEdm().getEntityContainer(); - private final OData odata = OData.newInstance(); private final DataProvider data = new DataProvider(odata, metadata.getEdm()); private final ODataSerializer serializer = new ODataJsonSerializer(ContentType.JSON); private final ODataSerializer serializerNoMetadata = new ODataJsonSerializer(ContentType.JSON_NO_METADATA); 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 dfbce28c1..530bdf799 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 @@ -368,6 +368,7 @@ public class CarsProcessor implements EntityCollectionProcessor, EntityProcessor public static boolean isODataMetadataNone(final ContentType contentType) { return contentType.isCompatible(ContentType.APPLICATION_JSON) - && ContentType.VALUE_ODATA_METADATA_NONE.equals(contentType.getParameter(ContentType.PARAMETER_ODATA_METADATA)); + && ContentType.VALUE_ODATA_METADATA_NONE.equalsIgnoreCase( + contentType.getParameter(ContentType.PARAMETER_ODATA_METADATA)); } } \ No newline at end of file