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/08 10:17:19 UTC
[01/18] git commit: [OLINGO-317] Added additional tests
Repository: olingo-odata4
Updated Branches:
refs/heads/olingo337 f11715442 -> 233651a8b
[OLINGO-317] Added additional tests
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/839e9604
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/839e9604
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/839e9604
Branch: refs/heads/olingo337
Commit: 839e96045a1240a1e35743b5da7ea3a34e806905
Parents: 4c4f82e
Author: mibo <mi...@mirb.de>
Authored: Mon Jun 30 15:01:28 2014 +0200
Committer: mibo <mi...@mirb.de>
Committed: Mon Jun 30 15:15:28 2014 +0200
----------------------------------------------------------------------
.../olingo/commons/core/data/PropertyImpl.java | 2 +-
.../core/edm/primitivetype/EdmString.java | 3 +-
.../json/ODataJsonSerializerTest.java | 312 +++++++++++++++++--
3 files changed, 294 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/839e9604/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java
index b6f2f36..4ad374d 100755
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java
@@ -35,7 +35,7 @@ public class PropertyImpl extends AbstractValuable implements Property {
}
public PropertyImpl(String type, String name, ValueType valueType, Object value) {
- this(name, type);
+ this(type, name);
setValue(valueType, value);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/839e9604/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmString.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmString.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmString.java
index 4defe91..600467a 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmString.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmString.java
@@ -74,7 +74,8 @@ public final class EdmString extends SingletonPrimitiveType {
if (isUnicode != null && !isUnicode && !PATTERN_ASCII.matcher(result).matches()
|| maxLength != null && maxLength < result.length()) {
throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.VALUE_FACETS_NOT_MATCHED.addContent(value, facets)");
+ "EdmPrimitiveTypeException.VALUE_FACETS_NOT_MATCHED.addContent('" +
+ value + "', facets)");
}
return result;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/839e9604/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 79a1b65..1008c5f 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
@@ -18,14 +18,20 @@
*/
package org.apache.olingo.server.core.serializer.json;
+import org.apache.olingo.commons.api.ODataRuntimeException;
import org.apache.olingo.commons.api.data.ContextURL;
import org.apache.olingo.commons.api.data.Entity;
import org.apache.olingo.commons.api.data.ValueType;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
import org.apache.olingo.commons.api.edm.EdmEntityType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.EdmProperty;
+import org.apache.olingo.commons.api.edm.EdmType;
+import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
import org.apache.olingo.commons.core.data.EntityImpl;
+import org.apache.olingo.commons.core.data.EntitySetImpl;
import org.apache.olingo.commons.core.data.PropertyImpl;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmString;
+import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -36,50 +42,314 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Calendar;
import java.util.List;
+import java.util.UUID;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
public class ODataJsonSerializerTest {
- public static final String PROPERTY_1 = "Property1";
+ private static final String ETAllPrim = "ETAllPrim";
+ private static final String ETCompAllPrim = "ETCompAllPrim";
+ private static final String CTAllPrim = "CTAllPrim";
+ private static final String CTAllPrim_Type = "com.sap.odata.test1.CTAllPrim";
+
+ interface TechProperty {
+ String getName();
+ String getTypeName();
+ EdmPrimitiveTypeKind getType();
+ }
+
+ public static class TecComplexProperty implements TechProperty {
+
+ final String name;
+ final String typeName;
+ public TecComplexProperty(String typeName, String name) {
+ this.name = name;
+ this.typeName = typeName;
+ }
+ @Override
+ public String getName() {
+ return name;
+ }
+ @Override
+ public String getTypeName() {
+ return typeName;
+ }
+ @Override
+ public EdmPrimitiveTypeKind getType() {
+ return null;
+ }
+ }
+
+ enum TecSimpleProperty implements TechProperty {
+ Int16("PropertyInt16", EdmPrimitiveTypeKind.Int16),
+ String("PropertyString", EdmPrimitiveTypeKind.String),
+ Boolean("PropertyBoolean", EdmPrimitiveTypeKind.Boolean),
+ Byte("PropertyByte", EdmPrimitiveTypeKind.Byte),
+ SByte("PropertySByte", EdmPrimitiveTypeKind.SByte),
+ Int32("PropertyInt32", EdmPrimitiveTypeKind.Int32),
+ Int64("PropertyInt64", EdmPrimitiveTypeKind.Int64),
+ Single("PropertySingle", EdmPrimitiveTypeKind.Single),
+ Double("PropertyDouble", EdmPrimitiveTypeKind.Double),
+ Decimal("PropertyDecimal", EdmPrimitiveTypeKind.Decimal),
+ Binary("PropertyBinary", EdmPrimitiveTypeKind.Binary),
+ Date("PropertyDate", EdmPrimitiveTypeKind.Date),
+ DateTimeOffset("PropertyDateTimeOffset", EdmPrimitiveTypeKind.DateTimeOffset),
+ Duration("PropertyDuration", EdmPrimitiveTypeKind.Duration),
+ Guid("PropertyGuid", EdmPrimitiveTypeKind.Guid),
+ TimeOfDay("PropertyTimeOfDay", EdmPrimitiveTypeKind.TimeOfDay);
+ // <NavigationProperty Name="NavPropertyETTwoPrimOne" Type="test1.ETTwoPrim" Nullable="false"/>
+// NavETTwoPrimOne = "NavPropertyETTwoPrimOne", EdmPrimitiveTypeKind.),
+ // <NavigationProperty Name="NavPropertyETTwoPrimMany" Type="Collection(test1.ETTwoPrim)" Nullable="false"/>
+// NavETTwoPrimMany("NavPropertyETTwoPrimMany", EdmCom.);
+
+ final String name;
+ final EdmPrimitiveTypeKind type;
+
+ TecSimpleProperty(String name, EdmPrimitiveTypeKind type) {
+ this.name = name;
+ this.type = type;
+ }
+
+ @Override
+ public String getTypeName() {
+ return type.name();
+ }
+
+ @Override
+ public EdmPrimitiveTypeKind getType() {
+ return type;
+ }
+ @Override
+ public String getName() {
+ return name;
+ }
+ }
private ContextURL contextUrl;
- private EdmEntityType edmEntityType;
- private final Logger LOG = LoggerFactory.getLogger(ODataJsonSerializerTest.class);
+ private EdmEntitySet edmESAllPrim;
+ private EdmEntityType edmETAllPrim;
+ private EdmEntityType edmETCompAllPrim;
private ODataJsonSerializer serializer = new ODataJsonSerializer();
@Before
public void prepare() throws Exception {
contextUrl = ContextURL.getInstance(new URI("http://localhost:8080/test.svc"));
- edmEntityType = Mockito.mock(EdmEntityType.class);
- List<String> propertyNames = Arrays.asList(PROPERTY_1);
- Mockito.when(edmEntityType.getPropertyNames()).thenReturn(propertyNames);
+ edmETAllPrim = Mockito.mock(EdmEntityType.class);
+ Mockito.when(edmETAllPrim.getName()).thenReturn(ETAllPrim);
+ List<EdmProperty> properties = Arrays.asList(
+ mockProperty(TecSimpleProperty.Int16, false),
+ mockProperty(TecSimpleProperty.String),
+ mockProperty(TecSimpleProperty.Boolean),
+ mockProperty(TecSimpleProperty.Byte),
+ mockProperty(TecSimpleProperty.SByte),
+ mockProperty(TecSimpleProperty.Int32),
+ mockProperty(TecSimpleProperty.Int64),
+ mockProperty(TecSimpleProperty.Single),
+ mockProperty(TecSimpleProperty.Double),
+ mockProperty(TecSimpleProperty.Decimal),
+ mockProperty(TecSimpleProperty.Binary),
+ mockProperty(TecSimpleProperty.Date),
+ mockProperty(TecSimpleProperty.DateTimeOffset),
+ mockProperty(TecSimpleProperty.Duration),
+ mockProperty(TecSimpleProperty.Guid),
+ mockProperty(TecSimpleProperty.TimeOfDay)
+// mockProperty(NavPropertyETTwoPrimOne, false),
+// mockProperty(NavPropertyETTwoPrimMany, false)
+ );
+ List<String> propertyNames = new ArrayList<String>();
+
+ for (EdmProperty property : properties) {
+ propertyNames.add(property.getName());
+ Mockito.when(edmETAllPrim.getProperty(property.getName())).thenReturn(property);
+ }
+ Mockito.when(edmETAllPrim.getPropertyNames()).thenReturn(propertyNames);
+
+ // Entity Set All Primitive
+ edmESAllPrim = Mockito.mock(EdmEntitySet.class);
+ Mockito.when(edmESAllPrim.getName()).thenReturn("ESAllPrim");
+ Mockito.when(edmESAllPrim.getEntityType()).thenReturn(edmETAllPrim);
+
+ // Entity Type Complex All Primitive
+ edmETCompAllPrim = Mockito.mock(EdmEntityType.class);
+ Mockito.when(edmETCompAllPrim.getName()).thenReturn(ETCompAllPrim);
+ List<EdmProperty> capProperties = Arrays.asList(
+ mockProperty(TecSimpleProperty.Int16, false),
+ mockProperty(new TecComplexProperty(CTAllPrim_Type, CTAllPrim), false, true)
+ );
+ List<String> capPropertyNames = new ArrayList<String>();
+
+ for (EdmProperty property : capProperties) {
+ capPropertyNames.add(property.getName());
+ Mockito.when(edmETCompAllPrim.getProperty(property.getName())).thenReturn(property);
+ }
+ Mockito.when(edmETCompAllPrim.getPropertyNames()).thenReturn(capPropertyNames);
+ }
+
+ private EdmProperty mockProperty(TechProperty name) {
+ return mockProperty(name, true, false);
+ }
+
+ private EdmProperty mockProperty(TechProperty name, boolean nullable) {
+ return mockProperty(name, nullable, false);
+ }
+
+ private EdmProperty mockProperty(TechProperty tecProperty, boolean nullable, boolean complex) {
EdmProperty edmElement = Mockito.mock(EdmProperty.class);
- Mockito.when(edmElement.getName()).thenReturn(PROPERTY_1);
- Mockito.when(edmElement.isPrimitive()).thenReturn(true);
- Mockito.when(edmElement.getMaxLength()).thenReturn(20);
- Mockito.when(edmElement.getType()).thenReturn(EdmString.getInstance());
- Mockito.when(edmEntityType.getProperty(PROPERTY_1)).thenReturn(edmElement);
+ Mockito.when(edmElement.getName()).thenReturn(tecProperty.getName());
+ if(complex) {
+ Mockito.when(edmElement.isPrimitive()).thenReturn(false);
+ EdmType type = Mockito.mock(EdmType.class);
+ Mockito.when(type.getKind()).thenReturn(EdmTypeKind.COMPLEX);
+ Mockito.when(type.getName()).thenReturn(tecProperty.getTypeName());
+ Mockito.when(edmElement.getType()).thenReturn(type);
+ } else {
+ Mockito.when(edmElement.isPrimitive()).thenReturn(true);
+ // TODO: set default values
+ Mockito.when(edmElement.getMaxLength()).thenReturn(40);
+ Mockito.when(edmElement.getPrecision()).thenReturn(10);
+ Mockito.when(edmElement.getScale()).thenReturn(10);
+ Mockito.when(edmElement.getType()).thenReturn(EdmPrimitiveTypeFactory.getInstance(tecProperty.getType()));
+ }
+ Mockito.when(edmElement.isNullable()).thenReturn(nullable);
+ return edmElement;
+ }
+
+ private PropertyImpl createProperty(TechProperty property, ValueType vType, Object value) {
+ return new PropertyImpl(property.getTypeName(), property.getName(), vType, value);
+ }
+ private PropertyImpl createProperty(String type, TecSimpleProperty property, ValueType vType, Object value) {
+ return new PropertyImpl(type, property.name, vType, value);
}
@Test
public void entitySimple() throws Exception {
+ Entity entity = createETAllPrim();
+
+ InputStream result = serializer.entity(edmETAllPrim, entity, contextUrl);
+ String resultString = streamToString(result);
+ String expectedResult = "{" +
+ "\"@odata.context\":\"http://localhost:8080/test.svc\"," +
+ "\"PropertyInt16\":4711," +
+ "\"PropertyString\":\"StringValue\"," +
+ "\"PropertyBoolean\":true," +
+ "\"PropertyByte\":19," +
+ "\"PropertySByte\":1," +
+ "\"PropertyInt32\":2147483647," +
+ "\"PropertyInt64\":9223372036854775807," +
+ "\"PropertySingle\":47.11," +
+ "\"PropertyDouble\":4.711," +
+ "\"PropertyDecimal\":4711.1174," +
+ "\"PropertyBinary\":\"BAcBAQ==\"," +
+ "\"PropertyDate\":\"2014-03-19\"," +
+ "\"PropertyDateTimeOffset\":\"2014-03-19T10:12:00+01:00\"," +
+ "\"PropertyDuration\":\"P16148383DT8H0S\"," +
+ "\"PropertyGuid\":\"0000aaaa-00bb-00cc-00dd-000000ffffff\"," +
+ "\"PropertyTimeOfDay\":\"10:12:00\"" +
+ "}";
+ Assert.assertEquals(expectedResult, resultString);
+ }
+
+
+ @Test
+ public void entitySetETAllPrim() throws Exception {
+ EdmEntitySet edmEntitySet = edmESAllPrim;
+ EntitySetImpl entitySet = new EntitySetImpl();
+ for (int i = 0; i < 100; i++) {
+ entitySet.getEntities().add(createETAllPrim(i));
+ }
+ entitySet.setCount(entitySet.getEntities().size());
+ entitySet.setNext(URI.create(contextUrl.getURI().toASCIIString() + "/next"));
+
+ InputStream result = serializer.entitySet(edmEntitySet, entitySet, contextUrl);
+ String resultString = streamToString(result);
+
+ Assert.assertTrue(resultString.matches("\\{" +
+ "\"@odata\\.context\":\"http://localhost:8080/test.svc\"," +
+ "\"@odata\\.count\":100," +
+ "\"value\":\\[.*\\]," +
+ "\"@odata\\.nextLink\":\"http://localhost:8080/test.svc/next\"" +
+ "\\}"));
+
+ Matcher matcher = Pattern.compile("(\\{[a-z0-9:\\=\"\\-,\\.\\+]*\\})",
+ Pattern.CASE_INSENSITIVE).matcher(resultString);
+ int count = 0;
+ while(matcher.find()) {
+ Assert.assertTrue(matcher.group().contains("PropertyInt16\":" + count++));
+ }
+ Assert.assertEquals(100, count);
+ }
+
+ @Test(expected = ODataRuntimeException.class)
+ public void entityETCompAllPrim() throws Exception {
+ Entity complexCtAllPrim = createETAllPrim();
-// Entity entity = new EntityImpl();
-// entity.addProperty(new PropertyImpl("Edm.String", PROPERTY_1, ValueType.PRIMITIVE, "Value_1"));
Entity entity = new EntityImpl();
- PropertyImpl property = new PropertyImpl("Edm.String", PROPERTY_1);
- property.setValue(ValueType.PRIMITIVE, "Value_1");
- entity.addProperty(property);
+ entity.addProperty(new PropertyImpl("Edm.Int16", TecSimpleProperty.Int16.name, ValueType.PRIMITIVE, 4711));
+ entity.addProperty(createProperty(new TecComplexProperty(CTAllPrim_Type, CTAllPrim),
+ ValueType.COMPLEX, complexCtAllPrim));
- InputStream result = serializer.entity(edmEntityType, entity, contextUrl);
+ InputStream result = serializer.entity(edmETCompAllPrim, entity, contextUrl);
String resultString = streamToString(result);
-// System.out.println(resultString);
- Assert.assertEquals("{\"@odata.context\":\"http://localhost:8080/test.svc\",\"Property1\":\"Value_1\"}",
- resultString);
+ String expectedResult = "{" +
+ "\"@odata.context\":\"http://localhost:8080/test.svc\"," +
+ "\"PropertyInt16\":4711," +
+ "\"PropertyString\":\"StringValue\"," +
+ "\"PropertyBoolean\":true," +
+ "\"PropertyByte\":19," +
+ "\"PropertySByte\":1," +
+ "\"PropertyInt32\":2147483647," +
+ "\"PropertyInt64\":9223372036854775807," +
+ "\"PropertySingle\":47.11," +
+ "\"PropertyDouble\":4.711," +
+ "\"PropertyDecimal\":4711.1174," +
+ "\"PropertyBinary\":\"BAcBAQ==\"," +
+ "\"PropertyDate\":\"2014-03-19\"," +
+ "\"PropertyDateTimeOffset\":\"2014-03-19T10:12:00+01:00\"," +
+ "\"PropertyDuration\":\"P16148383DT8H0S\"," +
+ "\"PropertyGuid\":\"0000aaaa-00bb-00cc-00dd-000000ffffff\"," +
+ "\"PropertyTimeOfDay\":\"10:12:00\"" +
+ "}";
+ Assert.assertEquals(expectedResult, resultString);
+ }
+
+ private Entity createETAllPrim() {
+ return createETAllPrim(4711);
+ }
+
+ private Entity createETAllPrim(int id) {
+ Entity entity = new EntityImpl();
+ Calendar date = Calendar.getInstance();
+ date.set(2014, Calendar.MARCH, 19, 10, 12, 0);
+ date.set(Calendar.MILLISECOND, 0);
+ entity.addProperty(createProperty("Edm.Int16", TecSimpleProperty.Int16, ValueType.PRIMITIVE, id));
+ entity.addProperty(createProperty("Edm.String", TecSimpleProperty.String, ValueType.PRIMITIVE, "StringValue"));
+ entity.addProperty(createProperty("Edm.Boolean", TecSimpleProperty.Boolean, ValueType.PRIMITIVE, Boolean.TRUE));
+ entity.addProperty(createProperty("Edm.Byte", TecSimpleProperty.Byte, ValueType.PRIMITIVE, Byte.valueOf("19")));
+ entity.addProperty(createProperty("Edm.SByte", TecSimpleProperty.SByte, ValueType.PRIMITIVE, Short.valueOf("1")));
+ entity.addProperty(createProperty("Edm.Int32", TecSimpleProperty.Int32, ValueType.PRIMITIVE, Integer.MAX_VALUE));
+ entity.addProperty(createProperty("Edm.Int64", TecSimpleProperty.Int64, ValueType.PRIMITIVE, Long.MAX_VALUE));
+ entity.addProperty(createProperty("Edm.Single", TecSimpleProperty.Single, ValueType.PRIMITIVE, 47.11));
+ entity.addProperty(createProperty("Edm.Double", TecSimpleProperty.Double, ValueType.PRIMITIVE, 4.711));
+ entity.addProperty(createProperty("Edm.Decimal", TecSimpleProperty.Decimal, ValueType.PRIMITIVE, 4711.1174));
+ entity.addProperty(createProperty("Edm.Binary", TecSimpleProperty.Binary, ValueType.PRIMITIVE,
+ new byte[]{0x04, 0x07, 0x01, 0x01}));
+ entity.addProperty(createProperty("Edm.Date", TecSimpleProperty.Date, ValueType.PRIMITIVE, date));
+ entity.addProperty(createProperty("Edm.DateTimeOffset", TecSimpleProperty.DateTimeOffset, ValueType.PRIMITIVE,
+ date.getTime()));
+ entity.addProperty(createProperty("Edm.Duration", TecSimpleProperty.Duration, ValueType.PRIMITIVE,
+ date.getTimeInMillis()));
+ entity.addProperty(createProperty("Edm.Guid", TecSimpleProperty.Guid, ValueType.PRIMITIVE,
+ UUID.fromString("AAAA-BB-CC-DD-FFFFFF")));
+ entity.addProperty(createProperty("Edm.TimeOfDay", TecSimpleProperty.TimeOfDay, ValueType.PRIMITIVE, date));
+ return entity;
}
private String streamToString(InputStream result) throws IOException {
[02/18] git commit: [OLINGO-317] Added complex type handling
Posted by sk...@apache.org.
[OLINGO-317] Added complex type handling
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/71bdaed3
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/71bdaed3
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/71bdaed3
Branch: refs/heads/olingo337
Commit: 71bdaed3003a6c903888a3465c9a338703596138
Parents: 839e960
Author: Michael Bolz <mi...@sap.com>
Authored: Tue Jul 1 13:11:36 2014 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Tue Jul 1 16:21:42 2014 +0200
----------------------------------------------------------------------
.../serializer/json/ODataJsonSerializer.java | 107 +++++++++----------
.../json/ODataJsonSerializerTest.java | 61 ++++++-----
.../tecsvc/processor/SampleJsonProcessor.java | 82 +++++++++++---
3 files changed, 151 insertions(+), 99 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/71bdaed3/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 8cb5f0c..c3fe720 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,36 +18,24 @@
*/
package org.apache.olingo.server.core.serializer.json;
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStreamWriter;
-import java.util.List;
-
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import org.apache.olingo.commons.api.Constants;
import org.apache.olingo.commons.api.ODataRuntimeException;
-import org.apache.olingo.commons.api.data.ContextURL;
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
-import org.apache.olingo.commons.api.data.LinkedComplexValue;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.EdmComplexType;
-import org.apache.olingo.commons.api.edm.EdmEntitySet;
-import org.apache.olingo.commons.api.edm.EdmEntityType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.EdmProperty;
+import org.apache.olingo.commons.api.data.*;
+import org.apache.olingo.commons.api.edm.*;
import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
import org.apache.olingo.server.api.serializer.ODataSerializer;
import org.apache.olingo.server.core.serializer.utils.CircleStreamBuffer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStreamWriter;
+import java.util.List;
public class ODataJsonSerializer implements ODataSerializer {
@@ -148,38 +136,14 @@ public class ODataJsonSerializer implements ODataSerializer {
}
} else {
if (edmProperty.isPrimitive()) {
- if (property.isPrimitive()) {
- writePrimitiveValue(edmProperty, property.asPrimitive(), json);
- } else if (property.isGeospatial()) {
- throw new ODataRuntimeException("Property type not yet supported!");
- } else if (property.isEnum()) {
- json.writeString(property.asEnum().toString());
- } else {
- throw new ODataRuntimeException("Inconsistent property type!");
- }
+ handlePrimitive(edmProperty, property, json);
} else if (edmProperty.isCollection()) {
- json.writeStartArray();
- for (Object value : property.asCollection()) {
- switch (property.getValueType()) {
- case COLLECTION_PRIMITIVE:
- writePrimitiveValue(edmProperty, value, json);
- break;
- case COLLECTION_GEOSPATIAL:
- throw new ODataRuntimeException("Property type not yet supported!");
- case COLLECTION_ENUM:
- json.writeString(value.toString());
- break;
- case COLLECTION_LINKED_COMPLEX:
- writeLinkedComplexValue(edmProperty, (LinkedComplexValue) value, json);
- break;
- default:
- throw new ODataRuntimeException("Property type not yet supported!");
- }
- }
- json.writeEndArray();
+ handleCollection(edmProperty, property, json);
} else {
if (property.isLinkedComplex()) {
- writeLinkedComplexValue(edmProperty, property.asLinkedComplex(), json);
+ writeComplexValue(edmProperty, property.asLinkedComplex().getValue(), json);
+ } else if(property.isComplex()) {
+ writeComplexValue(edmProperty, property.asComplex(), json);
} else {
throw new ODataRuntimeException("Property type not yet supported!");
}
@@ -187,6 +151,42 @@ public class ODataJsonSerializer implements ODataSerializer {
}
}
+ private void handleCollection(EdmProperty edmProperty, Property property, JsonGenerator json)
+ throws IOException, EdmPrimitiveTypeException {
+ json.writeStartArray();
+ for (Object value : property.asCollection()) {
+ switch (property.getValueType()) {
+ case COLLECTION_PRIMITIVE:
+ writePrimitiveValue(edmProperty, value, json);
+ break;
+ case COLLECTION_GEOSPATIAL:
+ throw new ODataRuntimeException("Property type not yet supported!");
+ case COLLECTION_ENUM:
+ json.writeString(value.toString());
+ break;
+ case COLLECTION_LINKED_COMPLEX:
+ writeComplexValue(edmProperty, ((LinkedComplexValue) value).getValue(), json);
+ break;
+ default:
+ throw new ODataRuntimeException("Property type not yet supported!");
+ }
+ }
+ json.writeEndArray();
+ }
+
+ private void handlePrimitive(EdmProperty edmProperty, Property property, JsonGenerator json)
+ throws EdmPrimitiveTypeException, IOException {
+ if (property.isPrimitive()) {
+ writePrimitiveValue(edmProperty, property.asPrimitive(), json);
+ } else if (property.isGeospatial()) {
+ throw new ODataRuntimeException("Property type not yet supported!");
+ } else if (property.isEnum()) {
+ json.writeString(property.asEnum().toString());
+ } else {
+ throw new ODataRuntimeException("Inconsistent property type!");
+ }
+ }
+
protected void writePrimitiveValue(final EdmProperty edmProperty, final Object primitiveValue, JsonGenerator json)
throws EdmPrimitiveTypeException, IOException {
final EdmPrimitiveType type = (EdmPrimitiveType) edmProperty.getType();
@@ -209,10 +209,9 @@ public class ODataJsonSerializer implements ODataSerializer {
}
}
- private void writeLinkedComplexValue(final EdmProperty edmProperty, final LinkedComplexValue linkedComplexValue,
- JsonGenerator json) throws IOException, EdmPrimitiveTypeException {
+ private void writeComplexValue(final EdmProperty edmProperty, final List<Property> properties,
+ JsonGenerator json) throws IOException, EdmPrimitiveTypeException {
final EdmComplexType type = (EdmComplexType) edmProperty.getType();
- final List<Property> properties = linkedComplexValue.getValue();
json.writeStartObject();
for (final String propertyName : type.getPropertyNames()) {
final Property property = findProperty(propertyName, properties);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/71bdaed3/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 1008c5f..e7563b0 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
@@ -18,15 +18,10 @@
*/
package org.apache.olingo.server.core.serializer.json;
-import org.apache.olingo.commons.api.ODataRuntimeException;
import org.apache.olingo.commons.api.data.ContextURL;
import org.apache.olingo.commons.api.data.Entity;
import org.apache.olingo.commons.api.data.ValueType;
-import org.apache.olingo.commons.api.edm.EdmEntitySet;
-import org.apache.olingo.commons.api.edm.EdmEntityType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.EdmProperty;
-import org.apache.olingo.commons.api.edm.EdmType;
+import org.apache.olingo.commons.api.edm.*;
import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
import org.apache.olingo.commons.core.data.EntityImpl;
import org.apache.olingo.commons.core.data.EntitySetImpl;
@@ -36,17 +31,11 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.List;
-import java.util.UUID;
+import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -65,11 +54,14 @@ public class ODataJsonSerializerTest {
public static class TecComplexProperty implements TechProperty {
- final String name;
final String typeName;
- public TecComplexProperty(String typeName, String name) {
- this.name = name;
+ final String name;
+ final List<EdmProperty> properties;
+
+ public TecComplexProperty(String typeName, String name, List<EdmProperty> propertyNames) {
this.typeName = typeName;
+ this.name = name;
+ this.properties = new ArrayList<EdmProperty>(propertyNames);
}
@Override
public String getName() {
@@ -83,6 +75,9 @@ public class ODataJsonSerializerTest {
public EdmPrimitiveTypeKind getType() {
return null;
}
+ public List<EdmProperty> getProperties() {
+ return properties;
+ }
}
enum TecSimpleProperty implements TechProperty {
@@ -181,7 +176,7 @@ public class ODataJsonSerializerTest {
Mockito.when(edmETCompAllPrim.getName()).thenReturn(ETCompAllPrim);
List<EdmProperty> capProperties = Arrays.asList(
mockProperty(TecSimpleProperty.Int16, false),
- mockProperty(new TecComplexProperty(CTAllPrim_Type, CTAllPrim), false, true)
+ mockProperty(new TecComplexProperty(CTAllPrim_Type, CTAllPrim, properties), false)
);
List<String> capPropertyNames = new ArrayList<String>();
@@ -193,22 +188,27 @@ public class ODataJsonSerializerTest {
}
private EdmProperty mockProperty(TechProperty name) {
- return mockProperty(name, true, false);
+ return mockProperty(name, true);
}
- private EdmProperty mockProperty(TechProperty name, boolean nullable) {
- return mockProperty(name, nullable, false);
- }
-
- private EdmProperty mockProperty(TechProperty tecProperty, boolean nullable, boolean complex) {
+ private EdmProperty mockProperty(TechProperty tecProperty, boolean nullable) {
EdmProperty edmElement = Mockito.mock(EdmProperty.class);
Mockito.when(edmElement.getName()).thenReturn(tecProperty.getName());
- if(complex) {
+ if (tecProperty instanceof TecComplexProperty) {
+ TecComplexProperty complexProperty = (TecComplexProperty) tecProperty;
Mockito.when(edmElement.isPrimitive()).thenReturn(false);
- EdmType type = Mockito.mock(EdmType.class);
+ EdmComplexType type = Mockito.mock(EdmComplexType.class);
Mockito.when(type.getKind()).thenReturn(EdmTypeKind.COMPLEX);
Mockito.when(type.getName()).thenReturn(tecProperty.getTypeName());
Mockito.when(edmElement.getType()).thenReturn(type);
+
+ List<String> propertyNames = new ArrayList<String>();
+ List<EdmProperty> properties = complexProperty.getProperties();
+ for (EdmProperty property : properties) {
+ propertyNames.add(property.getName());
+ Mockito.when(type.getProperty(property.getName())).thenReturn(property);
+ }
+ Mockito.when(type.getPropertyNames()).thenReturn(propertyNames);
} else {
Mockito.when(edmElement.isPrimitive()).thenReturn(true);
// TODO: set default values
@@ -287,20 +287,23 @@ public class ODataJsonSerializerTest {
Assert.assertEquals(100, count);
}
- @Test(expected = ODataRuntimeException.class)
+ @Test
public void entityETCompAllPrim() throws Exception {
Entity complexCtAllPrim = createETAllPrim();
Entity entity = new EntityImpl();
entity.addProperty(new PropertyImpl("Edm.Int16", TecSimpleProperty.Int16.name, ValueType.PRIMITIVE, 4711));
- entity.addProperty(createProperty(new TecComplexProperty(CTAllPrim_Type, CTAllPrim),
- ValueType.COMPLEX, complexCtAllPrim));
+ entity.addProperty(createProperty(
+ new TecComplexProperty(CTAllPrim_Type, CTAllPrim, Collections.<EdmProperty>emptyList()),
+ ValueType.COMPLEX, complexCtAllPrim.getProperties()));
InputStream result = serializer.entity(edmETCompAllPrim, entity, contextUrl);
String resultString = streamToString(result);
String expectedResult = "{" +
"\"@odata.context\":\"http://localhost:8080/test.svc\"," +
"\"PropertyInt16\":4711," +
+ "\"CTAllPrim\":{" +
+ "\"PropertyInt16\":4711," +
"\"PropertyString\":\"StringValue\"," +
"\"PropertyBoolean\":true," +
"\"PropertyByte\":19," +
@@ -316,7 +319,7 @@ public class ODataJsonSerializerTest {
"\"PropertyDuration\":\"P16148383DT8H0S\"," +
"\"PropertyGuid\":\"0000aaaa-00bb-00cc-00dd-000000ffffff\"," +
"\"PropertyTimeOfDay\":\"10:12:00\"" +
- "}";
+ "}}";
Assert.assertEquals(expectedResult, resultString);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/71bdaed3/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 8cf00e9..cf40489 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
@@ -19,6 +19,8 @@
package org.apache.olingo.server.tecsvc.processor;
import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
import java.util.UUID;
import org.apache.olingo.commons.api.data.ContextURL;
@@ -27,7 +29,10 @@ import org.apache.olingo.commons.api.data.EntitySet;
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.data.ValueType;
import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
+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.http.HttpStatusCode;
@@ -41,6 +46,7 @@ import org.apache.olingo.server.api.processor.EntityProcessor;
import org.apache.olingo.server.api.processor.EntitySetProcessor;
import org.apache.olingo.server.api.serializer.ODataSerializer;
import org.apache.olingo.server.api.uri.UriInfo;
+import org.apache.olingo.server.api.uri.UriResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -60,16 +66,13 @@ public class SampleJsonProcessor implements EntitySetProcessor, EntityProcessor
public void readEntitySet(ODataRequest request, ODataResponse response, UriInfo uriInfo, String format) {
long time = System.nanoTime();
- EntitySet entitySet = createEntitySet();
-
LOG.info((System.nanoTime() - time) / 1000 + " microseconds");
time = System.nanoTime();
ODataSerializer serializer = odata.createSerializer(ODataFormat.JSON);
- response.setContent(serializer.entitySet(
- edm.getEntityContainer(new FullQualifiedName("com.sap.odata.test1", "Container"))
- .getEntitySet("ESAllPrim"),
- entitySet,
- ContextURL.getInstance(URI.create("dummyContextURL"))));
+ EdmEntitySet edmEntitySet = getEntitySet(uriInfo);
+ EntitySet entitySet = createEntitySet(edmEntitySet.getEntityType());
+ response.setContent(serializer.entitySet(edmEntitySet, entitySet,
+ getContextUrl(request, edmEntitySet.getEntityType())));
LOG.info("Finished in " + (System.nanoTime() - time) / 1000 + " microseconds");
response.setStatusCode(HttpStatusCode.OK.getStatusCode());
@@ -79,23 +82,45 @@ public class SampleJsonProcessor implements EntitySetProcessor, EntityProcessor
@Override
public void readEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, String format) {
long time = System.nanoTime();
- Entity entity = createEntity();
LOG.info((System.nanoTime() - time) / 1000 + " microseconds");
time = System.nanoTime();
ODataSerializer serializer = odata.createSerializer(ODataFormat.JSON);
- response.setContent(serializer.entity(
- edm.getEntityContainer(new FullQualifiedName("com.sap.odata.test1", "Container"))
- .getEntitySet("ESAllPrim").getEntityType(),
- entity,
- ContextURL.getInstance(URI.create("dummyContextURL"))));
+ EdmEntityType entityType = getEntityType(uriInfo);
+ Entity entity = createEntity(entityType);
+
+ response.setContent(serializer.entity(entityType, entity,
+ getContextUrl(request, entityType)));
LOG.info("Finished in " + (System.nanoTime() - time) / 1000 + " microseconds");
response.setStatusCode(HttpStatusCode.OK.getStatusCode());
response.setHeader("Content-Type", ContentType.APPLICATION_JSON.toContentTypeString());
}
- protected Entity createEntity() {
+ private ContextURL getContextUrl(ODataRequest request, EdmEntityType entityType) {
+ return ContextURL.getInstance(URI.create(request.getRawBaseUri() + "/" + entityType.getName()));
+ }
+
+ public EdmEntityType getEntityType(UriInfo uriInfo) {
+ return getEntitySet(uriInfo).getEntityType();
+ }
+
+ public EdmEntitySet getEntitySet(UriInfo uriInfo) {
+ List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
+ if(resourcePaths.isEmpty()) {
+ throw new RuntimeException("Invalid resource path.");
+ }
+ String entitySetName = resourcePaths.get(resourcePaths.size()-1).toString();
+ return edm.getEntityContainer(new FullQualifiedName("com.sap.odata.test1", "Container"))
+ .getEntitySet(entitySetName);
+ }
+
+ protected Entity createEntity(EdmEntityType entityType) {
+ boolean complex = (entityType.getName().contains("Comp"));
+ return createEntity(complex);
+ }
+
+ protected Entity createEntity(boolean complex) {
Entity entity = new EntityImpl();
Property property = new PropertyImpl();
property.setName("PropertyString");
@@ -109,15 +134,40 @@ public class SampleJsonProcessor implements EntitySetProcessor, EntityProcessor
propertyGuid.setName("PropertyGuid");
propertyGuid.setValue(ValueType.PRIMITIVE, UUID.randomUUID());
entity.getProperties().add(propertyGuid);
+
+ if(complex) {
+ entity.addProperty(createComplexProperty());
+ }
+
return entity;
}
- protected EntitySet createEntitySet() {
+ protected Property createComplexProperty() {
+ List<Property> properties = new ArrayList<Property>();
+ Property property = new PropertyImpl();
+ property.setName("PropertyString");
+ property.setValue(ValueType.PRIMITIVE, "dummyValue");
+ properties.add(property);
+ Property propertyInt = new PropertyImpl();
+ propertyInt.setName("PropertyInt16");
+ propertyInt.setValue(ValueType.PRIMITIVE, 42);
+ properties.add(propertyInt);
+ Property propertyGuid = new PropertyImpl();
+ propertyGuid.setName("PropertyGuid");
+ propertyGuid.setValue(ValueType.PRIMITIVE, UUID.randomUUID());
+ properties.add(propertyGuid);
+
+ return new PropertyImpl("com.sap.odata.test1.ETCompAllPrim", "PropertyComplex", ValueType.COMPLEX,
+ properties);
+ }
+
+
+ protected EntitySet createEntitySet(EdmEntityType edmEntityType) {
EntitySet entitySet = new EntitySetImpl();
entitySet.setCount(4242);
entitySet.setNext(URI.create("nextLinkURI"));
for (int i = 0; i < 1000; i++) {
- entitySet.getEntities().add(createEntity());
+ entitySet.getEntities().add(createEntity(edmEntityType));
}
return entitySet;
}
[17/18] git commit: [OLINGO-337] merger origin/master
Posted by sk...@apache.org.
[OLINGO-337] merger origin/master
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/811fff54
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/811fff54
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/811fff54
Branch: refs/heads/olingo337
Commit: 811fff545c64364d66af0d8f4ba6e57f585479d3
Parents: aff42fc d860717
Author: Stephan Klevenz <st...@sap.com>
Authored: Tue Jul 8 10:10:31 2014 +0200
Committer: Stephan Klevenz <st...@sap.com>
Committed: Tue Jul 8 10:10:36 2014 +0200
----------------------------------------------------------------------
.../olingo/commons/core/data/PropertyImpl.java | 4 +-
.../serializer/json/ODataJsonSerializer.java | 120 ++---
.../json/ODataJsonSerializerTest.java | 523 +++++++++++++++++--
.../tecsvc/processor/SampleJsonProcessor.java | 157 +++++-
4 files changed, 681 insertions(+), 123 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/811fff54/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
----------------------------------------------------------------------
diff --cc lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
index b3dc02d,e34fd42..ffb8d7f
--- 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
@@@ -95,10 -91,36 +92,36 @@@ public class SampleJsonProcessor implem
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() {
+ private ContextURL getContextUrl(ODataRequest request, EdmEntityType entityType) {
+ return ContextURL.getInstance(URI.create(request.getRawBaseUri() + "/" + entityType.getName()));
+ }
+
+ public EdmEntityType getEntityType(UriInfo uriInfo) {
+ return getEntitySet(uriInfo).getEntityType();
+ }
+
+ public EdmEntitySet getEntitySet(UriInfo uriInfo) {
+ List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
+ if(resourcePaths.isEmpty()) {
+ throw new RuntimeException("Invalid resource path.");
+ }
+ String entitySetName = resourcePaths.get(resourcePaths.size()-1).toString();
+ return edm.getEntityContainer(new FullQualifiedName("com.sap.odata.test1", "Container"))
+ .getEntitySet(entitySetName);
+ }
+
+ protected Entity createEntity(EdmEntityType entityType) {
+ boolean complex = (entityType.getName().contains("Comp"));
+ if(entityType.getName().contains("Coll")) {
+ return createEntityWithCollection(complex);
+ }
+ return createEntity(complex);
+ }
+
+ protected Entity createEntity(boolean complex) {
Entity entity = new EntityImpl();
Property property = new PropertyImpl();
property.setName("PropertyString");
[14/18] git commit: [OLINGO-317] Fix problem with Timezone in test
Posted by sk...@apache.org.
[OLINGO-317] Fix problem with Timezone in test
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/eb2e3b78
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/eb2e3b78
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/eb2e3b78
Branch: refs/heads/olingo337
Commit: eb2e3b78aa339bb83924acc2d33b3092e88958d3
Parents: 95e2d8d
Author: Michael Bolz <mi...@sap.com>
Authored: Mon Jul 7 08:43:59 2014 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Mon Jul 7 08:43:59 2014 +0200
----------------------------------------------------------------------
.../json/ODataJsonSerializerTest.java | 22 ++++++++++++--------
1 file changed, 13 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/eb2e3b78/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 91e49b9..61b6954 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
@@ -337,8 +337,8 @@ public class ODataJsonSerializerTest {
"\"PropertyDecimal\":4711.1174," +
"\"PropertyBinary\":\"BAcBAQ==\"," +
"\"PropertyDate\":\"2014-03-19\"," +
- "\"PropertyDateTimeOffset\":\"2014-03-19T10:12:00+01:00\"," +
- "\"PropertyDuration\":\"P16148383DT8H0S\"," +
+ "\"PropertyDateTimeOffset\":\"2014-03-19T11:12:00+01:00\"," +
+ "\"PropertyDuration\":\"P16148425DT0S\"," +
"\"PropertyGuid\":\"0000aaaa-00bb-00cc-00dd-000000ffffff\"," +
"\"PropertyTimeOfDay\":\"10:12:00\"" +
"}";
@@ -396,8 +396,8 @@ public class ODataJsonSerializerTest {
"\"CollPropertyDecimal\":[4711.1174,1174.4711]," +
"\"CollPropertyBinary\":[\"BAcBAQ==\",\"dGVzdA==\"]," +
"\"CollPropertyDate\":[\"2014-03-19\",\"2014-07-02\"]," +
- "\"CollPropertyDateTimeOffset\":[\"2014-03-19T10:12:00+01:00\",\"2014-07-02T13:30:00+02:00\"]," +
- "\"CollPropertyDuration\":[\"P16148383DT8H0S\",\"P16253479DT4H0S\"]," +
+ "\"CollPropertyDateTimeOffset\":[\"2014-03-19T11:12:00+01:00\",\"2014-07-02T15:30:00+02:00\"]," +
+ "\"CollPropertyDuration\":[\"P16148425DT0S\",\"P16253562DT12H0S\"]," +
"\"CollPropertyGuid\":[\"0000aaaa-00bb-00cc-00dd-000000ffffff\",\"0000ffff-00dd-00cc-00bb-000000aaaaaa\"]," +
"\"CollPropertyTimeOfDay\":[\"10:12:00\",\"13:30:00\"]" +
"}";
@@ -433,8 +433,8 @@ public class ODataJsonSerializerTest {
"\"PropertyDecimal\":4711.1174," +
"\"PropertyBinary\":\"BAcBAQ==\"," +
"\"PropertyDate\":\"2014-03-19\"," +
- "\"PropertyDateTimeOffset\":\"2014-03-19T10:12:00+01:00\"," +
- "\"PropertyDuration\":\"P16148383DT8H0S\"," +
+ "\"PropertyDateTimeOffset\":\"2014-03-19T11:12:00+01:00\"," +
+ "\"PropertyDuration\":\"P16148425DT0S\"," +
"\"PropertyGuid\":\"0000aaaa-00bb-00cc-00dd-000000ffffff\"," +
"\"PropertyTimeOfDay\":\"10:12:00\"" +
"}}";
@@ -455,10 +455,10 @@ public class ODataJsonSerializerTest {
private Entity createETCollAllPrim(int id) {
Entity entity = new EntityImpl();
- Calendar date = Calendar.getInstance();
+ Calendar date = createCalendarInstance();
date.set(2014, Calendar.MARCH, 19, 10, 12, 0);
date.set(Calendar.MILLISECOND, 0);
- Calendar date2 = Calendar.getInstance();
+ Calendar date2 = createCalendarInstance();
date2.set(2014, Calendar.JULY, 2, 13, 30, 0);
date2.set(Calendar.MILLISECOND, 0);
//
@@ -503,7 +503,7 @@ public class ODataJsonSerializerTest {
private Entity createETAllPrim(int id) {
Entity entity = new EntityImpl();
- Calendar date = Calendar.getInstance();
+ Calendar date = createCalendarInstance();
date.set(2014, Calendar.MARCH, 19, 10, 12, 0);
date.set(Calendar.MILLISECOND, 0);
entity.addProperty(createProperty("Edm.Int16", TecSvcSimpleProperty.Int16, ValueType.PRIMITIVE, id));
@@ -531,6 +531,10 @@ public class ODataJsonSerializerTest {
return entity;
}
+ private Calendar createCalendarInstance() {
+ return Calendar.getInstance(TimeZone.getTimeZone("GMT"), Locale.ENGLISH);
+ }
+
private String streamToString(InputStream result) throws IOException {
byte[] buffer = new byte[8192];
StringBuilder sb = new StringBuilder();
[04/18] git commit: [OLINGO-317] Minor code clean up in test
Posted by sk...@apache.org.
[OLINGO-317] Minor code clean up in test
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/876655fd
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/876655fd
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/876655fd
Branch: refs/heads/olingo337
Commit: 876655fd26d1fc1bfe45347b921a8c63889398b9
Parents: da8cf72
Author: Michael Bolz <mi...@sap.com>
Authored: Thu Jul 3 07:21:06 2014 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Thu Jul 3 07:32:25 2014 +0200
----------------------------------------------------------------------
.../serializer/json/ODataJsonSerializer.java | 3 +-
.../json/ODataJsonSerializerTest.java | 202 ++++++++++---------
2 files changed, 111 insertions(+), 94 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/876655fd/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 1c61cc0..536ead1 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
@@ -238,8 +238,7 @@ public class ODataJsonSerializer implements ODataSerializer {
JsonGenerator json = new JsonFactory().createGenerator(buffer.getOutputStream());
json.writeStartObject();
if (contextURL != null) {
- String context = "$metadata#" + edmEntitySet.getName();
- json.writeStringField(Constants.JSON_CONTEXT, context);
+ json.writeStringField(Constants.JSON_CONTEXT, contextURL.getURI().toASCIIString());
}
if (entitySet.getCount() != null) {
json.writeNumberField("@odata.count", entitySet.getCount());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/876655fd/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 b791cc6..91e49b9 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
@@ -35,6 +35,7 @@ import org.mockito.Mockito;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
+import java.net.URISyntaxException;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -47,29 +48,29 @@ public class ODataJsonSerializerTest {
private static final String CTAllPrim = "CTAllPrim";
private static final String CTAllPrim_Type = "com.sap.odata.test1.CTAllPrim";
- interface TechProperty {
+ interface TecSvcProperty {
String getName();
String getTypeName();
EdmPrimitiveTypeKind getType();
boolean isCollection();
}
- public static class TecComplexProperty implements TechProperty {
+ public static class TecSvcComplexProperty implements TecSvcProperty {
final String typeName;
final String name;
final List<EdmProperty> properties = new ArrayList<EdmProperty>();
boolean collection = false;
- public TecComplexProperty(String typeName, String name) {
+ public TecSvcComplexProperty(String typeName, String name) {
this.typeName = typeName;
this.name = name;
}
- TechProperty addProperties(List<EdmProperty> properties) {
+ TecSvcProperty addProperties(List<EdmProperty> properties) {
this.properties.addAll(properties);
return this;
}
- TechProperty asCollection() {
+ TecSvcProperty asCollection() {
this.collection = true;
return this;
}
@@ -94,7 +95,7 @@ public class ODataJsonSerializerTest {
}
}
- enum TecSimpleProperty implements TechProperty {
+ enum TecSvcSimpleProperty implements TecSvcProperty {
Int16("PropertyInt16", EdmPrimitiveTypeKind.Int16),
String("PropertyString", EdmPrimitiveTypeKind.String),
Boolean("PropertyBoolean", EdmPrimitiveTypeKind.Boolean),
@@ -136,10 +137,10 @@ public class ODataJsonSerializerTest {
final EdmPrimitiveTypeKind type;
final boolean isCollection;
- TecSimpleProperty(String name, EdmPrimitiveTypeKind type) {
+ TecSvcSimpleProperty(String name, EdmPrimitiveTypeKind type) {
this(name, type, false);
}
- TecSimpleProperty(String name, EdmPrimitiveTypeKind type, boolean collection) {
+ TecSvcSimpleProperty(String name, EdmPrimitiveTypeKind type, boolean collection) {
this.name = name;
this.type = type;
this.isCollection = collection;
@@ -162,7 +163,6 @@ public class ODataJsonSerializerTest {
}
}
- private ContextURL contextUrl;
private EdmEntitySet edmESAllPrim;
private EdmEntitySet edmESCompAllPrim;
private EdmEntitySet edmESCollAllPrim;
@@ -174,28 +174,26 @@ public class ODataJsonSerializerTest {
@Before
public void prepare() throws Exception {
- contextUrl = ContextURL.getInstance(new URI("http://localhost:8080/test.svc"));
-
// entity all primitive
edmETAllPrim = Mockito.mock(EdmEntityType.class);
Mockito.when(edmETAllPrim.getName()).thenReturn(ETAllPrim);
List<EdmProperty> properties = Arrays.asList(
- mockProperty(TecSimpleProperty.Int16, false),
- mockProperty(TecSimpleProperty.String),
- mockProperty(TecSimpleProperty.Boolean),
- mockProperty(TecSimpleProperty.Byte),
- mockProperty(TecSimpleProperty.SByte),
- mockProperty(TecSimpleProperty.Int32),
- mockProperty(TecSimpleProperty.Int64),
- mockProperty(TecSimpleProperty.Single),
- mockProperty(TecSimpleProperty.Double),
- mockProperty(TecSimpleProperty.Decimal),
- mockProperty(TecSimpleProperty.Binary),
- mockProperty(TecSimpleProperty.Date),
- mockProperty(TecSimpleProperty.DateTimeOffset),
- mockProperty(TecSimpleProperty.Duration),
- mockProperty(TecSimpleProperty.Guid),
- mockProperty(TecSimpleProperty.TimeOfDay)
+ mockProperty(TecSvcSimpleProperty.Int16, false),
+ mockProperty(TecSvcSimpleProperty.String),
+ mockProperty(TecSvcSimpleProperty.Boolean),
+ mockProperty(TecSvcSimpleProperty.Byte),
+ mockProperty(TecSvcSimpleProperty.SByte),
+ mockProperty(TecSvcSimpleProperty.Int32),
+ mockProperty(TecSvcSimpleProperty.Int64),
+ mockProperty(TecSvcSimpleProperty.Single),
+ mockProperty(TecSvcSimpleProperty.Double),
+ mockProperty(TecSvcSimpleProperty.Decimal),
+ mockProperty(TecSvcSimpleProperty.Binary),
+ mockProperty(TecSvcSimpleProperty.Date),
+ mockProperty(TecSvcSimpleProperty.DateTimeOffset),
+ mockProperty(TecSvcSimpleProperty.Duration),
+ mockProperty(TecSvcSimpleProperty.Guid),
+ mockProperty(TecSvcSimpleProperty.TimeOfDay)
// mockProperty(NavPropertyETTwoPrimOne, false),
// mockProperty(NavPropertyETTwoPrimMany, false)
);
@@ -211,13 +209,21 @@ public class ODataJsonSerializerTest {
edmESAllPrim = Mockito.mock(EdmEntitySet.class);
Mockito.when(edmESAllPrim.getName()).thenReturn("ESAllPrim");
Mockito.when(edmESAllPrim.getEntityType()).thenReturn(edmETAllPrim);
+ // Entity Set All Primitive
+ edmESCompAllPrim = Mockito.mock(EdmEntitySet.class);
+ Mockito.when(edmESCompAllPrim.getName()).thenReturn("ESCompAllPrim");
+ Mockito.when(edmESCompAllPrim.getEntityType()).thenReturn(edmETCompAllPrim);
+ // Entity Set All Primitive
+ edmESCollAllPrim = Mockito.mock(EdmEntitySet.class);
+ Mockito.when(edmESCollAllPrim.getName()).thenReturn("ESCollAllPrim");
+ Mockito.when(edmESCollAllPrim.getEntityType()).thenReturn(edmETCollAllPrim);
// Entity Type Complex All Primitive
edmETCompAllPrim = Mockito.mock(EdmEntityType.class);
Mockito.when(edmETCompAllPrim.getName()).thenReturn(ETCompAllPrim);
List<EdmProperty> capProperties = Arrays.asList(
- mockProperty(TecSimpleProperty.Int16, false),
- mockProperty(new TecComplexProperty(CTAllPrim_Type, CTAllPrim).addProperties(properties), false)
+ mockProperty(TecSvcSimpleProperty.Int16, false),
+ mockProperty(new TecSvcComplexProperty(CTAllPrim_Type, CTAllPrim).addProperties(properties), false)
);
List<String> capPropertyNames = new ArrayList<String>();
@@ -232,22 +238,22 @@ public class ODataJsonSerializerTest {
edmETCollAllPrim = Mockito.mock(EdmEntityType.class);
Mockito.when(edmETCollAllPrim.getName()).thenReturn(ETCollAllPrim);
List<EdmProperty> allCollProperties = Arrays.asList(
- mockProperty(TecSimpleProperty.Int16, false),
- mockProperty(TecSimpleProperty.Collection_String),
- mockProperty(TecSimpleProperty.Collection_Boolean),
- mockProperty(TecSimpleProperty.Collection_Byte),
- mockProperty(TecSimpleProperty.Collection_SByte),
- mockProperty(TecSimpleProperty.Collection_Int32),
- mockProperty(TecSimpleProperty.Collection_Int64),
- mockProperty(TecSimpleProperty.Collection_Single),
- mockProperty(TecSimpleProperty.Collection_Double),
- mockProperty(TecSimpleProperty.Collection_Decimal),
- mockProperty(TecSimpleProperty.Collection_Binary),
- mockProperty(TecSimpleProperty.Collection_Date),
- mockProperty(TecSimpleProperty.Collection_DateTimeOffset),
- mockProperty(TecSimpleProperty.Collection_Duration),
- mockProperty(TecSimpleProperty.Collection_Guid),
- mockProperty(TecSimpleProperty.Collection_TimeOfDay)
+ mockProperty(TecSvcSimpleProperty.Int16, false),
+ mockProperty(TecSvcSimpleProperty.Collection_String),
+ mockProperty(TecSvcSimpleProperty.Collection_Boolean),
+ mockProperty(TecSvcSimpleProperty.Collection_Byte),
+ mockProperty(TecSvcSimpleProperty.Collection_SByte),
+ mockProperty(TecSvcSimpleProperty.Collection_Int32),
+ mockProperty(TecSvcSimpleProperty.Collection_Int64),
+ mockProperty(TecSvcSimpleProperty.Collection_Single),
+ mockProperty(TecSvcSimpleProperty.Collection_Double),
+ mockProperty(TecSvcSimpleProperty.Collection_Decimal),
+ mockProperty(TecSvcSimpleProperty.Collection_Binary),
+ mockProperty(TecSvcSimpleProperty.Collection_Date),
+ mockProperty(TecSvcSimpleProperty.Collection_DateTimeOffset),
+ mockProperty(TecSvcSimpleProperty.Collection_Duration),
+ mockProperty(TecSvcSimpleProperty.Collection_Guid),
+ mockProperty(TecSvcSimpleProperty.Collection_TimeOfDay)
);
List<String> etCollAllPrimPropertyNames = new ArrayList<String>();
@@ -260,15 +266,15 @@ public class ODataJsonSerializerTest {
// Entity Set all primitive collection
}
- private EdmProperty mockProperty(TechProperty name) {
+ private EdmProperty mockProperty(TecSvcProperty name) {
return mockProperty(name, true);
}
- private EdmProperty mockProperty(TechProperty tecProperty, boolean nullable) {
+ private EdmProperty mockProperty(TecSvcProperty tecProperty, boolean nullable) {
EdmProperty edmElement = Mockito.mock(EdmProperty.class);
Mockito.when(edmElement.getName()).thenReturn(tecProperty.getName());
- if (tecProperty instanceof TecComplexProperty) {
- TecComplexProperty complexProperty = (TecComplexProperty) tecProperty;
+ if (tecProperty instanceof TecSvcComplexProperty) {
+ TecSvcComplexProperty complexProperty = (TecSvcComplexProperty) tecProperty;
Mockito.when(edmElement.isPrimitive()).thenReturn(false);
EdmComplexType type = Mockito.mock(EdmComplexType.class);
Mockito.when(type.getKind()).thenReturn(EdmTypeKind.COMPLEX);
@@ -295,11 +301,11 @@ public class ODataJsonSerializerTest {
return edmElement;
}
- private PropertyImpl createProperty(TechProperty property, ValueType vType, Object value) {
+ private PropertyImpl createProperty(TecSvcProperty property, ValueType vType, Object value) {
return new PropertyImpl(property.getTypeName(), property.getName(), vType, value);
}
- private PropertyImpl createProperty(String type, TecSimpleProperty property, ValueType vType, Object ... value) {
+ private PropertyImpl createProperty(String type, TecSvcSimpleProperty property, ValueType vType, Object ... value) {
final Object propValue;
if(value == null || value.length ==0) {
propValue = null;
@@ -315,10 +321,10 @@ public class ODataJsonSerializerTest {
public void entitySimple() throws Exception {
Entity entity = createETAllPrim();
- InputStream result = serializer.entity(edmETAllPrim, entity, contextUrl);
+ InputStream result = serializer.entity(edmETAllPrim, entity, createContextURL(edmESAllPrim, true));
String resultString = streamToString(result);
String expectedResult = "{" +
- "\"@odata.context\":\"http://localhost:8080/test.svc\"," +
+ "\"@odata.context\":\"$metadata#ESAllPrim/$entity\"," +
"\"PropertyInt16\":4711," +
"\"PropertyString\":\"StringValue\"," +
"\"PropertyBoolean\":true," +
@@ -347,16 +353,17 @@ public class ODataJsonSerializerTest {
entitySet.getEntities().add(createETAllPrim(i));
}
entitySet.setCount(entitySet.getEntities().size());
+ ContextURL contextUrl = createContextURL(edmESAllPrim, false);
entitySet.setNext(URI.create(contextUrl.getURI().toASCIIString() + "/next"));
InputStream result = serializer.entitySet(edmEntitySet, entitySet, contextUrl);
String resultString = streamToString(result);
Assert.assertTrue(resultString.matches("\\{" +
- "\"@odata\\.context\":\"http://localhost:8080/test.svc\"," +
+ "\"@odata\\.context\":\"\\$metadata#ESAllPrim\"," +
"\"@odata\\.count\":100," +
"\"value\":\\[.*\\]," +
- "\"@odata\\.nextLink\":\"http://localhost:8080/test.svc/next\"" +
+ "\"@odata\\.nextLink\":\"\\$metadata#ESAllPrim/next\"" +
"\\}"));
Matcher matcher = Pattern.compile("(\\{[a-z0-9:\\=\"\\-,\\.\\+]*\\})",
@@ -372,10 +379,11 @@ public class ODataJsonSerializerTest {
public void entityCollAllPrim() throws Exception {
Entity entity = createETCollAllPrim(4711);
+ ContextURL contextUrl = createContextURL(edmESCollAllPrim, true);
InputStream result = serializer.entity(edmETCollAllPrim, entity, contextUrl);
String resultString = streamToString(result);
String expectedResult = "{" +
- "\"@odata.context\":\"http://localhost:8080/test.svc\"," +
+ "\"@odata.context\":\"$metadata#ESCollAllPrim/$entity\"," +
"\"PropertyInt16\":4711," +
"\"CollPropertyString\":[\"StringValue_1\",\"StringValue_2\"]," +
"\"CollPropertyBoolean\":[true,false]," +
@@ -401,15 +409,16 @@ public class ODataJsonSerializerTest {
Entity complexCtAllPrim = createETAllPrim();
Entity entity = new EntityImpl();
- entity.addProperty(new PropertyImpl("Edm.Int16", TecSimpleProperty.Int16.name, ValueType.PRIMITIVE, 4711));
+ entity.addProperty(new PropertyImpl("Edm.Int16", TecSvcSimpleProperty.Int16.name, ValueType.PRIMITIVE, 4711));
entity.addProperty(createProperty(
- new TecComplexProperty(CTAllPrim_Type, CTAllPrim),
+ new TecSvcComplexProperty(CTAllPrim_Type, CTAllPrim),
ValueType.COMPLEX, complexCtAllPrim.getProperties()));
+ ContextURL contextUrl = createContextURL(edmESCompAllPrim, true);
InputStream result = serializer.entity(edmETCompAllPrim, entity, contextUrl);
String resultString = streamToString(result);
String expectedResult = "{" +
- "\"@odata.context\":\"http://localhost:8080/test.svc\"," +
+ "\"@odata.context\":\"$metadata#ESCompAllPrim/$entity\"," +
"\"PropertyInt16\":4711," +
"\"CTAllPrim\":{" +
"\"PropertyInt16\":4711," +
@@ -432,6 +441,13 @@ public class ODataJsonSerializerTest {
Assert.assertEquals(expectedResult, resultString);
}
+ private ContextURL createContextURL(EdmEntitySet entitySet, boolean isEntity) throws URISyntaxException {
+ StringBuilder sb = new StringBuilder("$metadata#" + entitySet.getName());
+ if(isEntity) {
+ sb.append("/$entity");
+ }
+ return ContextURL.getInstance(new URI(sb.toString()));
+ }
private Entity createETAllPrim() {
return createETAllPrim(4711);
@@ -446,41 +462,41 @@ public class ODataJsonSerializerTest {
date2.set(2014, Calendar.JULY, 2, 13, 30, 0);
date2.set(Calendar.MILLISECOND, 0);
//
- entity.addProperty(createProperty("Edm.Int16", TecSimpleProperty.Int16, ValueType.PRIMITIVE, id));
+ entity.addProperty(createProperty("Edm.Int16", TecSvcSimpleProperty.Int16, ValueType.PRIMITIVE, id));
//
- entity.addProperty(createProperty("Collection(Edm.Int16)", TecSimpleProperty.Collection_Int16,
+ entity.addProperty(createProperty("Collection(Edm.Int16)", TecSvcSimpleProperty.Collection_Int16,
ValueType.COLLECTION_PRIMITIVE, id));
- entity.addProperty(createProperty("Collection(Edm.String)", TecSimpleProperty.Collection_String,
+ entity.addProperty(createProperty("Collection(Edm.String)", TecSvcSimpleProperty.Collection_String,
ValueType.COLLECTION_PRIMITIVE, "StringValue_1", "StringValue_2"));
- entity.addProperty(createProperty("Collection(Edm.Boolean)", TecSimpleProperty.Collection_Boolean,
+ entity.addProperty(createProperty("Collection(Edm.Boolean)", TecSvcSimpleProperty.Collection_Boolean,
ValueType.COLLECTION_PRIMITIVE, Boolean.TRUE, Boolean.FALSE));
- entity.addProperty(createProperty("Collection(Edm.Byte)", TecSimpleProperty.Collection_Byte,
+ entity.addProperty(createProperty("Collection(Edm.Byte)", TecSvcSimpleProperty.Collection_Byte,
ValueType.COLLECTION_PRIMITIVE, Byte.valueOf("19"), Byte.valueOf("42")));
- entity.addProperty(createProperty("Collection(Edm.SByte)", TecSimpleProperty.Collection_SByte,
+ entity.addProperty(createProperty("Collection(Edm.SByte)", TecSvcSimpleProperty.Collection_SByte,
ValueType.COLLECTION_PRIMITIVE, Short.valueOf("1"), Short.valueOf("2")));
- entity.addProperty(createProperty("Collection(Edm.Int32)", TecSimpleProperty.Collection_Int32,
+ entity.addProperty(createProperty("Collection(Edm.Int32)", TecSvcSimpleProperty.Collection_Int32,
ValueType.COLLECTION_PRIMITIVE, Integer.MAX_VALUE, Integer.MIN_VALUE));
- entity.addProperty(createProperty("Collection(Edm.Int64)", TecSimpleProperty.Collection_Int64,
+ entity.addProperty(createProperty("Collection(Edm.Int64)", TecSvcSimpleProperty.Collection_Int64,
ValueType.COLLECTION_PRIMITIVE, Long.MAX_VALUE, Long.MIN_VALUE));
- entity.addProperty(createProperty("Collection(Edm.Single)", TecSimpleProperty.Collection_Single,
+ entity.addProperty(createProperty("Collection(Edm.Single)", TecSvcSimpleProperty.Collection_Single,
ValueType.COLLECTION_PRIMITIVE, 47.11, 11.47));
- entity.addProperty(createProperty("Collection(Edm.Double)", TecSimpleProperty.Collection_Double,
+ entity.addProperty(createProperty("Collection(Edm.Double)", TecSvcSimpleProperty.Collection_Double,
ValueType.COLLECTION_PRIMITIVE, 4.711, 711.4));
- entity.addProperty(createProperty("Collection(Edm.Decimal)", TecSimpleProperty.Collection_Decimal,
+ entity.addProperty(createProperty("Collection(Edm.Decimal)", TecSvcSimpleProperty.Collection_Decimal,
ValueType.COLLECTION_PRIMITIVE, 4711.1174, 1174.4711));
- entity.addProperty(createProperty("Collection(Edm.Binary)", TecSimpleProperty.Collection_Binary,
+ entity.addProperty(createProperty("Collection(Edm.Binary)", TecSvcSimpleProperty.Collection_Binary,
ValueType.COLLECTION_PRIMITIVE, new byte[]{0x04, 0x07, 0x01, 0x01}, "test".getBytes()));
- entity.addProperty(createProperty("Collection(Edm.Date)", TecSimpleProperty.Collection_Date,
+ entity.addProperty(createProperty("Collection(Edm.Date)", TecSvcSimpleProperty.Collection_Date,
ValueType.COLLECTION_PRIMITIVE, date, date2));
- entity.addProperty(createProperty("Collection(Edm.DateTimeOffset)", TecSimpleProperty.Collection_DateTimeOffset,
+ entity.addProperty(createProperty("Collection(Edm.DateTimeOffset)", TecSvcSimpleProperty.Collection_DateTimeOffset,
ValueType.COLLECTION_PRIMITIVE, date.getTime(), date2.getTime()));
- entity.addProperty(createProperty("Collection(Edm.Duration)", TecSimpleProperty.Collection_Duration,
+ entity.addProperty(createProperty("Collection(Edm.Duration)", TecSvcSimpleProperty.Collection_Duration,
ValueType.COLLECTION_PRIMITIVE, date.getTimeInMillis(), date2.getTimeInMillis()));
- entity.addProperty(createProperty("Collection(Edm.Guid)", TecSimpleProperty.Collection_Guid,
+ entity.addProperty(createProperty("Collection(Edm.Guid)", TecSvcSimpleProperty.Collection_Guid,
ValueType.COLLECTION_PRIMITIVE,
UUID.fromString("AAAA-BB-CC-DD-FFFFFF"),
UUID.fromString("FFFF-DD-CC-BB-AAAAAA")));
- entity.addProperty(createProperty("Collection(Edm.TimeOfDay)", TecSimpleProperty.Collection_TimeOfDay,
+ entity.addProperty(createProperty("Collection(Edm.TimeOfDay)", TecSvcSimpleProperty.Collection_TimeOfDay,
ValueType.COLLECTION_PRIMITIVE, date, date2));
return entity;
}
@@ -490,26 +506,28 @@ public class ODataJsonSerializerTest {
Calendar date = Calendar.getInstance();
date.set(2014, Calendar.MARCH, 19, 10, 12, 0);
date.set(Calendar.MILLISECOND, 0);
- entity.addProperty(createProperty("Edm.Int16", TecSimpleProperty.Int16, ValueType.PRIMITIVE, id));
- entity.addProperty(createProperty("Edm.String", TecSimpleProperty.String, ValueType.PRIMITIVE, "StringValue"));
- entity.addProperty(createProperty("Edm.Boolean", TecSimpleProperty.Boolean, ValueType.PRIMITIVE, Boolean.TRUE));
- entity.addProperty(createProperty("Edm.Byte", TecSimpleProperty.Byte, ValueType.PRIMITIVE, Byte.valueOf("19")));
- entity.addProperty(createProperty("Edm.SByte", TecSimpleProperty.SByte, ValueType.PRIMITIVE, Short.valueOf("1")));
- entity.addProperty(createProperty("Edm.Int32", TecSimpleProperty.Int32, ValueType.PRIMITIVE, Integer.MAX_VALUE));
- entity.addProperty(createProperty("Edm.Int64", TecSimpleProperty.Int64, ValueType.PRIMITIVE, Long.MAX_VALUE));
- entity.addProperty(createProperty("Edm.Single", TecSimpleProperty.Single, ValueType.PRIMITIVE, 47.11));
- entity.addProperty(createProperty("Edm.Double", TecSimpleProperty.Double, ValueType.PRIMITIVE, 4.711));
- entity.addProperty(createProperty("Edm.Decimal", TecSimpleProperty.Decimal, ValueType.PRIMITIVE, 4711.1174));
- entity.addProperty(createProperty("Edm.Binary", TecSimpleProperty.Binary, ValueType.PRIMITIVE,
+ entity.addProperty(createProperty("Edm.Int16", TecSvcSimpleProperty.Int16, ValueType.PRIMITIVE, id));
+ entity.addProperty(createProperty("Edm.String", TecSvcSimpleProperty.String, ValueType.PRIMITIVE, "StringValue"));
+ entity.addProperty(createProperty("Edm.Boolean", TecSvcSimpleProperty.Boolean, ValueType.PRIMITIVE, Boolean.TRUE));
+ entity.addProperty(createProperty("Edm.Byte", TecSvcSimpleProperty.Byte, ValueType.PRIMITIVE, Byte.valueOf("19")));
+ entity.addProperty(createProperty("Edm.SByte",
+ TecSvcSimpleProperty.SByte, ValueType.PRIMITIVE, Short.valueOf("1")));
+ entity.addProperty(createProperty("Edm.Int32",
+ TecSvcSimpleProperty.Int32, ValueType.PRIMITIVE, Integer.MAX_VALUE));
+ entity.addProperty(createProperty("Edm.Int64", TecSvcSimpleProperty.Int64, ValueType.PRIMITIVE, Long.MAX_VALUE));
+ entity.addProperty(createProperty("Edm.Single", TecSvcSimpleProperty.Single, ValueType.PRIMITIVE, 47.11));
+ entity.addProperty(createProperty("Edm.Double", TecSvcSimpleProperty.Double, ValueType.PRIMITIVE, 4.711));
+ entity.addProperty(createProperty("Edm.Decimal", TecSvcSimpleProperty.Decimal, ValueType.PRIMITIVE, 4711.1174));
+ entity.addProperty(createProperty("Edm.Binary", TecSvcSimpleProperty.Binary, ValueType.PRIMITIVE,
new byte[]{0x04, 0x07, 0x01, 0x01}));
- entity.addProperty(createProperty("Edm.Date", TecSimpleProperty.Date, ValueType.PRIMITIVE, date));
- entity.addProperty(createProperty("Edm.DateTimeOffset", TecSimpleProperty.DateTimeOffset, ValueType.PRIMITIVE,
+ entity.addProperty(createProperty("Edm.Date", TecSvcSimpleProperty.Date, ValueType.PRIMITIVE, date));
+ entity.addProperty(createProperty("Edm.DateTimeOffset", TecSvcSimpleProperty.DateTimeOffset, ValueType.PRIMITIVE,
date.getTime()));
- entity.addProperty(createProperty("Edm.Duration", TecSimpleProperty.Duration, ValueType.PRIMITIVE,
+ entity.addProperty(createProperty("Edm.Duration", TecSvcSimpleProperty.Duration, ValueType.PRIMITIVE,
date.getTimeInMillis()));
- entity.addProperty(createProperty("Edm.Guid", TecSimpleProperty.Guid, ValueType.PRIMITIVE,
+ entity.addProperty(createProperty("Edm.Guid", TecSvcSimpleProperty.Guid, ValueType.PRIMITIVE,
UUID.fromString("AAAA-BB-CC-DD-FFFFFF")));
- entity.addProperty(createProperty("Edm.TimeOfDay", TecSimpleProperty.TimeOfDay, ValueType.PRIMITIVE, date));
+ entity.addProperty(createProperty("Edm.TimeOfDay", TecSvcSimpleProperty.TimeOfDay, ValueType.PRIMITIVE, date));
return entity;
}
[15/18] git commit: [OLINGO-317] Fix problem with DataTimeOffset in
test
Posted by sk...@apache.org.
[OLINGO-317] Fix problem with DataTimeOffset in test
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/d860717e
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/d860717e
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/d860717e
Branch: refs/heads/olingo337
Commit: d860717ed50a2698d0ade13796d9a39989581292
Parents: eb2e3b7
Author: mibo <mi...@mirb.de>
Authored: Mon Jul 7 13:41:34 2014 +0200
Committer: mibo <mi...@mirb.de>
Committed: Mon Jul 7 13:41:34 2014 +0200
----------------------------------------------------------------------
.../core/serializer/json/ODataJsonSerializerTest.java | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d860717e/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 61b6954..ec2619b 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
@@ -337,7 +337,7 @@ public class ODataJsonSerializerTest {
"\"PropertyDecimal\":4711.1174," +
"\"PropertyBinary\":\"BAcBAQ==\"," +
"\"PropertyDate\":\"2014-03-19\"," +
- "\"PropertyDateTimeOffset\":\"2014-03-19T11:12:00+01:00\"," +
+ "\"PropertyDateTimeOffset\":\"2014-03-19T10:12:00Z\"," +
"\"PropertyDuration\":\"P16148425DT0S\"," +
"\"PropertyGuid\":\"0000aaaa-00bb-00cc-00dd-000000ffffff\"," +
"\"PropertyTimeOfDay\":\"10:12:00\"" +
@@ -396,7 +396,7 @@ public class ODataJsonSerializerTest {
"\"CollPropertyDecimal\":[4711.1174,1174.4711]," +
"\"CollPropertyBinary\":[\"BAcBAQ==\",\"dGVzdA==\"]," +
"\"CollPropertyDate\":[\"2014-03-19\",\"2014-07-02\"]," +
- "\"CollPropertyDateTimeOffset\":[\"2014-03-19T11:12:00+01:00\",\"2014-07-02T15:30:00+02:00\"]," +
+ "\"CollPropertyDateTimeOffset\":[\"2014-03-19T10:12:00Z\",\"2014-07-02T13:30:00Z\"]," +
"\"CollPropertyDuration\":[\"P16148425DT0S\",\"P16253562DT12H0S\"]," +
"\"CollPropertyGuid\":[\"0000aaaa-00bb-00cc-00dd-000000ffffff\",\"0000ffff-00dd-00cc-00bb-000000aaaaaa\"]," +
"\"CollPropertyTimeOfDay\":[\"10:12:00\",\"13:30:00\"]" +
@@ -433,7 +433,7 @@ public class ODataJsonSerializerTest {
"\"PropertyDecimal\":4711.1174," +
"\"PropertyBinary\":\"BAcBAQ==\"," +
"\"PropertyDate\":\"2014-03-19\"," +
- "\"PropertyDateTimeOffset\":\"2014-03-19T11:12:00+01:00\"," +
+ "\"PropertyDateTimeOffset\":\"2014-03-19T10:12:00Z\"," +
"\"PropertyDuration\":\"P16148425DT0S\"," +
"\"PropertyGuid\":\"0000aaaa-00bb-00cc-00dd-000000ffffff\"," +
"\"PropertyTimeOfDay\":\"10:12:00\"" +
@@ -489,7 +489,7 @@ public class ODataJsonSerializerTest {
entity.addProperty(createProperty("Collection(Edm.Date)", TecSvcSimpleProperty.Collection_Date,
ValueType.COLLECTION_PRIMITIVE, date, date2));
entity.addProperty(createProperty("Collection(Edm.DateTimeOffset)", TecSvcSimpleProperty.Collection_DateTimeOffset,
- ValueType.COLLECTION_PRIMITIVE, date.getTime(), date2.getTime()));
+ ValueType.COLLECTION_PRIMITIVE, date, date2));
entity.addProperty(createProperty("Collection(Edm.Duration)", TecSvcSimpleProperty.Collection_Duration,
ValueType.COLLECTION_PRIMITIVE, date.getTimeInMillis(), date2.getTimeInMillis()));
entity.addProperty(createProperty("Collection(Edm.Guid)", TecSvcSimpleProperty.Collection_Guid,
@@ -522,7 +522,7 @@ public class ODataJsonSerializerTest {
new byte[]{0x04, 0x07, 0x01, 0x01}));
entity.addProperty(createProperty("Edm.Date", TecSvcSimpleProperty.Date, ValueType.PRIMITIVE, date));
entity.addProperty(createProperty("Edm.DateTimeOffset", TecSvcSimpleProperty.DateTimeOffset, ValueType.PRIMITIVE,
- date.getTime()));
+ date));
entity.addProperty(createProperty("Edm.Duration", TecSvcSimpleProperty.Duration, ValueType.PRIMITIVE,
date.getTimeInMillis()));
entity.addProperty(createProperty("Edm.Guid", TecSvcSimpleProperty.Guid, ValueType.PRIMITIVE,
@@ -532,7 +532,9 @@ public class ODataJsonSerializerTest {
}
private Calendar createCalendarInstance() {
- return Calendar.getInstance(TimeZone.getTimeZone("GMT"), Locale.ENGLISH);
+ Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"), Locale.ENGLISH);
+ cal.set(Calendar.ZONE_OFFSET, 0);
+ return cal;
}
private String streamToString(InputStream result) throws IOException {
[08/18] 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/434246ab
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/434246ab
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/434246ab
Branch: refs/heads/olingo337
Commit: 434246abe960da7dff6556fbd21a095e5daa62e7
Parents: d049864
Author: Stephan Klevenz <st...@sap.com>
Authored: Thu Jul 3 10:45:37 2014 +0200
Committer: Stephan Klevenz <st...@sap.com>
Committed: Fri Jul 4 12:18:24 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/434246ab/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/434246ab/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/434246ab/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/434246ab/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/434246ab/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/434246ab/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/434246ab/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/434246ab/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/434246ab/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/434246ab/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/434246ab/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/434246ab/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/434246ab/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/434246ab/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/434246ab/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;
[03/18] git commit: [OLINGO-317] Added collection type handling
Posted by sk...@apache.org.
[OLINGO-317] Added collection type handling
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/da8cf726
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/da8cf726
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/da8cf726
Branch: refs/heads/olingo337
Commit: da8cf726bfb9eb63e8198b40ea600121e6d2697e
Parents: 71bdaed
Author: Michael Bolz <mi...@sap.com>
Authored: Wed Jul 2 09:28:26 2014 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Wed Jul 2 12:39:47 2014 +0200
----------------------------------------------------------------------
.../serializer/json/ODataJsonSerializer.java | 24 +--
.../json/ODataJsonSerializerTest.java | 180 +++++++++++++++++--
.../tecsvc/processor/SampleJsonProcessor.java | 145 ++++++++++-----
3 files changed, 283 insertions(+), 66 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/da8cf726/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 c3fe720..1c61cc0 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
@@ -135,18 +135,16 @@ public class ODataJsonSerializer implements ODataSerializer {
json.writeNull();
}
} else {
- if (edmProperty.isPrimitive()) {
- handlePrimitive(edmProperty, property, json);
- } else if (edmProperty.isCollection()) {
+ if (edmProperty.isCollection()) {
handleCollection(edmProperty, property, json);
+ } else if (edmProperty.isPrimitive()) {
+ handlePrimitive(edmProperty, property, json);
+ } else if (property.isLinkedComplex()) {
+ writeComplexValue(edmProperty, property.asLinkedComplex().getValue(), json);
+ } else if(property.isComplex()) {
+ writeComplexValue(edmProperty, property.asComplex(), json);
} else {
- if (property.isLinkedComplex()) {
- writeComplexValue(edmProperty, property.asLinkedComplex().getValue(), json);
- } else if(property.isComplex()) {
- writeComplexValue(edmProperty, property.asComplex(), json);
- } else {
- throw new ODataRuntimeException("Property type not yet supported!");
- }
+ throw new ODataRuntimeException("Property type not yet supported!");
}
}
}
@@ -167,6 +165,9 @@ public class ODataJsonSerializer implements ODataSerializer {
case COLLECTION_LINKED_COMPLEX:
writeComplexValue(edmProperty, ((LinkedComplexValue) value).getValue(), json);
break;
+ case COLLECTION_COMPLEX:
+ writeComplexValue(edmProperty, property.asComplex(), json);
+ break;
default:
throw new ODataRuntimeException("Property type not yet supported!");
}
@@ -237,7 +238,8 @@ public class ODataJsonSerializer implements ODataSerializer {
JsonGenerator json = new JsonFactory().createGenerator(buffer.getOutputStream());
json.writeStartObject();
if (contextURL != null) {
- json.writeStringField(Constants.JSON_CONTEXT, contextURL.getURI().toASCIIString());
+ String context = "$metadata#" + edmEntitySet.getName();
+ json.writeStringField(Constants.JSON_CONTEXT, context);
}
if (entitySet.getCount() != null) {
json.writeNumberField("@odata.count", entitySet.getCount());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/da8cf726/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 e7563b0..b791cc6 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
@@ -43,6 +43,7 @@ public class ODataJsonSerializerTest {
private static final String ETAllPrim = "ETAllPrim";
private static final String ETCompAllPrim = "ETCompAllPrim";
+ private static final String ETCollAllPrim = "ETCollAllPrim";
private static final String CTAllPrim = "CTAllPrim";
private static final String CTAllPrim_Type = "com.sap.odata.test1.CTAllPrim";
@@ -50,18 +51,31 @@ public class ODataJsonSerializerTest {
String getName();
String getTypeName();
EdmPrimitiveTypeKind getType();
+ boolean isCollection();
}
public static class TecComplexProperty implements TechProperty {
final String typeName;
final String name;
- final List<EdmProperty> properties;
+ final List<EdmProperty> properties = new ArrayList<EdmProperty>();
+ boolean collection = false;
- public TecComplexProperty(String typeName, String name, List<EdmProperty> propertyNames) {
+ public TecComplexProperty(String typeName, String name) {
this.typeName = typeName;
this.name = name;
- this.properties = new ArrayList<EdmProperty>(propertyNames);
+ }
+ TechProperty addProperties(List<EdmProperty> properties) {
+ this.properties.addAll(properties);
+ return this;
+ }
+ TechProperty asCollection() {
+ this.collection = true;
+ return this;
+ }
+ @Override
+ public boolean isCollection() {
+ return collection;
}
@Override
public String getName() {
@@ -96,25 +110,44 @@ public class ODataJsonSerializerTest {
DateTimeOffset("PropertyDateTimeOffset", EdmPrimitiveTypeKind.DateTimeOffset),
Duration("PropertyDuration", EdmPrimitiveTypeKind.Duration),
Guid("PropertyGuid", EdmPrimitiveTypeKind.Guid),
- TimeOfDay("PropertyTimeOfDay", EdmPrimitiveTypeKind.TimeOfDay);
+ TimeOfDay("PropertyTimeOfDay", EdmPrimitiveTypeKind.TimeOfDay),
// <NavigationProperty Name="NavPropertyETTwoPrimOne" Type="test1.ETTwoPrim" Nullable="false"/>
// NavETTwoPrimOne = "NavPropertyETTwoPrimOne", EdmPrimitiveTypeKind.),
// <NavigationProperty Name="NavPropertyETTwoPrimMany" Type="Collection(test1.ETTwoPrim)" Nullable="false"/>
// NavETTwoPrimMany("NavPropertyETTwoPrimMany", EdmCom.);
+ Collection_Int16("CollPropertyInt16", EdmPrimitiveTypeKind.Int16, true),
+ Collection_String("CollPropertyString", EdmPrimitiveTypeKind.String, true),
+ Collection_Boolean("CollPropertyBoolean", EdmPrimitiveTypeKind.Boolean, true),
+ Collection_Byte("CollPropertyByte", EdmPrimitiveTypeKind.Byte, true),
+ Collection_SByte("CollPropertySByte", EdmPrimitiveTypeKind.SByte, true),
+ Collection_Int32("CollPropertyInt32", EdmPrimitiveTypeKind.Int32, true),
+ Collection_Int64("CollPropertyInt64", EdmPrimitiveTypeKind.Int64, true),
+ Collection_Single("CollPropertySingle", EdmPrimitiveTypeKind.Single, true),
+ Collection_Double("CollPropertyDouble", EdmPrimitiveTypeKind.Double, true),
+ Collection_Decimal("CollPropertyDecimal", EdmPrimitiveTypeKind.Decimal, true),
+ Collection_Binary("CollPropertyBinary", EdmPrimitiveTypeKind.Binary, true),
+ Collection_Date("CollPropertyDate", EdmPrimitiveTypeKind.Date, true),
+ Collection_DateTimeOffset("CollPropertyDateTimeOffset", EdmPrimitiveTypeKind.DateTimeOffset, true),
+ Collection_Duration("CollPropertyDuration", EdmPrimitiveTypeKind.Duration, true),
+ Collection_Guid("CollPropertyGuid", EdmPrimitiveTypeKind.Guid, true),
+ Collection_TimeOfDay("CollPropertyTimeOfDay", EdmPrimitiveTypeKind.TimeOfDay, true);
final String name;
final EdmPrimitiveTypeKind type;
+ final boolean isCollection;
TecSimpleProperty(String name, EdmPrimitiveTypeKind type) {
+ this(name, type, false);
+ }
+ TecSimpleProperty(String name, EdmPrimitiveTypeKind type, boolean collection) {
this.name = name;
this.type = type;
+ this.isCollection = collection;
}
-
@Override
public String getTypeName() {
return type.name();
}
-
@Override
public EdmPrimitiveTypeKind getType() {
return type;
@@ -123,12 +156,19 @@ public class ODataJsonSerializerTest {
public String getName() {
return name;
}
+ @Override
+ public boolean isCollection() {
+ return isCollection;
+ }
}
private ContextURL contextUrl;
private EdmEntitySet edmESAllPrim;
+ private EdmEntitySet edmESCompAllPrim;
+ private EdmEntitySet edmESCollAllPrim;
private EdmEntityType edmETAllPrim;
private EdmEntityType edmETCompAllPrim;
+ private EdmEntityType edmETCollAllPrim;
private ODataJsonSerializer serializer = new ODataJsonSerializer();
@@ -136,6 +176,7 @@ public class ODataJsonSerializerTest {
public void prepare() throws Exception {
contextUrl = ContextURL.getInstance(new URI("http://localhost:8080/test.svc"));
+ // entity all primitive
edmETAllPrim = Mockito.mock(EdmEntityType.class);
Mockito.when(edmETAllPrim.getName()).thenReturn(ETAllPrim);
List<EdmProperty> properties = Arrays.asList(
@@ -176,7 +217,7 @@ public class ODataJsonSerializerTest {
Mockito.when(edmETCompAllPrim.getName()).thenReturn(ETCompAllPrim);
List<EdmProperty> capProperties = Arrays.asList(
mockProperty(TecSimpleProperty.Int16, false),
- mockProperty(new TecComplexProperty(CTAllPrim_Type, CTAllPrim, properties), false)
+ mockProperty(new TecComplexProperty(CTAllPrim_Type, CTAllPrim).addProperties(properties), false)
);
List<String> capPropertyNames = new ArrayList<String>();
@@ -185,6 +226,38 @@ public class ODataJsonSerializerTest {
Mockito.when(edmETCompAllPrim.getProperty(property.getName())).thenReturn(property);
}
Mockito.when(edmETCompAllPrim.getPropertyNames()).thenReturn(capPropertyNames);
+
+ // entity type all primitive collections
+ //
+ edmETCollAllPrim = Mockito.mock(EdmEntityType.class);
+ Mockito.when(edmETCollAllPrim.getName()).thenReturn(ETCollAllPrim);
+ List<EdmProperty> allCollProperties = Arrays.asList(
+ mockProperty(TecSimpleProperty.Int16, false),
+ mockProperty(TecSimpleProperty.Collection_String),
+ mockProperty(TecSimpleProperty.Collection_Boolean),
+ mockProperty(TecSimpleProperty.Collection_Byte),
+ mockProperty(TecSimpleProperty.Collection_SByte),
+ mockProperty(TecSimpleProperty.Collection_Int32),
+ mockProperty(TecSimpleProperty.Collection_Int64),
+ mockProperty(TecSimpleProperty.Collection_Single),
+ mockProperty(TecSimpleProperty.Collection_Double),
+ mockProperty(TecSimpleProperty.Collection_Decimal),
+ mockProperty(TecSimpleProperty.Collection_Binary),
+ mockProperty(TecSimpleProperty.Collection_Date),
+ mockProperty(TecSimpleProperty.Collection_DateTimeOffset),
+ mockProperty(TecSimpleProperty.Collection_Duration),
+ mockProperty(TecSimpleProperty.Collection_Guid),
+ mockProperty(TecSimpleProperty.Collection_TimeOfDay)
+ );
+ List<String> etCollAllPrimPropertyNames = new ArrayList<String>();
+
+ for (EdmProperty property : allCollProperties) {
+ etCollAllPrimPropertyNames.add(property.getName());
+ Mockito.when(edmETCollAllPrim.getProperty(property.getName())).thenReturn(property);
+ }
+ Mockito.when(edmETCollAllPrim.getPropertyNames()).thenReturn(etCollAllPrimPropertyNames);
+
+ // Entity Set all primitive collection
}
private EdmProperty mockProperty(TechProperty name) {
@@ -217,6 +290,7 @@ public class ODataJsonSerializerTest {
Mockito.when(edmElement.getScale()).thenReturn(10);
Mockito.when(edmElement.getType()).thenReturn(EdmPrimitiveTypeFactory.getInstance(tecProperty.getType()));
}
+ Mockito.when(edmElement.isCollection()).thenReturn(tecProperty.isCollection());
Mockito.when(edmElement.isNullable()).thenReturn(nullable);
return edmElement;
}
@@ -225,8 +299,16 @@ public class ODataJsonSerializerTest {
return new PropertyImpl(property.getTypeName(), property.getName(), vType, value);
}
- private PropertyImpl createProperty(String type, TecSimpleProperty property, ValueType vType, Object value) {
- return new PropertyImpl(type, property.name, vType, value);
+ private PropertyImpl createProperty(String type, TecSimpleProperty property, ValueType vType, Object ... value) {
+ final Object propValue;
+ if(value == null || value.length ==0) {
+ propValue = null;
+ } else if(property.isCollection()) {
+ propValue = Arrays.asList(value);
+ } else {
+ propValue = value[0];
+ }
+ return new PropertyImpl(type, property.name, vType, propValue);
}
@Test
@@ -257,7 +339,6 @@ public class ODataJsonSerializerTest {
Assert.assertEquals(expectedResult, resultString);
}
-
@Test
public void entitySetETAllPrim() throws Exception {
EdmEntitySet edmEntitySet = edmESAllPrim;
@@ -288,13 +369,41 @@ public class ODataJsonSerializerTest {
}
@Test
+ public void entityCollAllPrim() throws Exception {
+ Entity entity = createETCollAllPrim(4711);
+
+ InputStream result = serializer.entity(edmETCollAllPrim, entity, contextUrl);
+ String resultString = streamToString(result);
+ String expectedResult = "{" +
+ "\"@odata.context\":\"http://localhost:8080/test.svc\"," +
+ "\"PropertyInt16\":4711," +
+ "\"CollPropertyString\":[\"StringValue_1\",\"StringValue_2\"]," +
+ "\"CollPropertyBoolean\":[true,false]," +
+ "\"CollPropertyByte\":[19,42]," +
+ "\"CollPropertySByte\":[1,2]," +
+ "\"CollPropertyInt32\":[2147483647,-2147483648]," +
+ "\"CollPropertyInt64\":[9223372036854775807,-9223372036854775808]," +
+ "\"CollPropertySingle\":[47.11,11.47]," +
+ "\"CollPropertyDouble\":[4.711,711.4]," +
+ "\"CollPropertyDecimal\":[4711.1174,1174.4711]," +
+ "\"CollPropertyBinary\":[\"BAcBAQ==\",\"dGVzdA==\"]," +
+ "\"CollPropertyDate\":[\"2014-03-19\",\"2014-07-02\"]," +
+ "\"CollPropertyDateTimeOffset\":[\"2014-03-19T10:12:00+01:00\",\"2014-07-02T13:30:00+02:00\"]," +
+ "\"CollPropertyDuration\":[\"P16148383DT8H0S\",\"P16253479DT4H0S\"]," +
+ "\"CollPropertyGuid\":[\"0000aaaa-00bb-00cc-00dd-000000ffffff\",\"0000ffff-00dd-00cc-00bb-000000aaaaaa\"]," +
+ "\"CollPropertyTimeOfDay\":[\"10:12:00\",\"13:30:00\"]" +
+ "}";
+ Assert.assertEquals(expectedResult, resultString);
+ }
+
+ @Test
public void entityETCompAllPrim() throws Exception {
Entity complexCtAllPrim = createETAllPrim();
Entity entity = new EntityImpl();
entity.addProperty(new PropertyImpl("Edm.Int16", TecSimpleProperty.Int16.name, ValueType.PRIMITIVE, 4711));
entity.addProperty(createProperty(
- new TecComplexProperty(CTAllPrim_Type, CTAllPrim, Collections.<EdmProperty>emptyList()),
+ new TecComplexProperty(CTAllPrim_Type, CTAllPrim),
ValueType.COMPLEX, complexCtAllPrim.getProperties()));
InputStream result = serializer.entity(edmETCompAllPrim, entity, contextUrl);
@@ -323,10 +432,59 @@ public class ODataJsonSerializerTest {
Assert.assertEquals(expectedResult, resultString);
}
+
private Entity createETAllPrim() {
return createETAllPrim(4711);
}
+ private Entity createETCollAllPrim(int id) {
+ Entity entity = new EntityImpl();
+ Calendar date = Calendar.getInstance();
+ date.set(2014, Calendar.MARCH, 19, 10, 12, 0);
+ date.set(Calendar.MILLISECOND, 0);
+ Calendar date2 = Calendar.getInstance();
+ date2.set(2014, Calendar.JULY, 2, 13, 30, 0);
+ date2.set(Calendar.MILLISECOND, 0);
+ //
+ entity.addProperty(createProperty("Edm.Int16", TecSimpleProperty.Int16, ValueType.PRIMITIVE, id));
+ //
+ entity.addProperty(createProperty("Collection(Edm.Int16)", TecSimpleProperty.Collection_Int16,
+ ValueType.COLLECTION_PRIMITIVE, id));
+ entity.addProperty(createProperty("Collection(Edm.String)", TecSimpleProperty.Collection_String,
+ ValueType.COLLECTION_PRIMITIVE, "StringValue_1", "StringValue_2"));
+ entity.addProperty(createProperty("Collection(Edm.Boolean)", TecSimpleProperty.Collection_Boolean,
+ ValueType.COLLECTION_PRIMITIVE, Boolean.TRUE, Boolean.FALSE));
+ entity.addProperty(createProperty("Collection(Edm.Byte)", TecSimpleProperty.Collection_Byte,
+ ValueType.COLLECTION_PRIMITIVE, Byte.valueOf("19"), Byte.valueOf("42")));
+ entity.addProperty(createProperty("Collection(Edm.SByte)", TecSimpleProperty.Collection_SByte,
+ ValueType.COLLECTION_PRIMITIVE, Short.valueOf("1"), Short.valueOf("2")));
+ entity.addProperty(createProperty("Collection(Edm.Int32)", TecSimpleProperty.Collection_Int32,
+ ValueType.COLLECTION_PRIMITIVE, Integer.MAX_VALUE, Integer.MIN_VALUE));
+ entity.addProperty(createProperty("Collection(Edm.Int64)", TecSimpleProperty.Collection_Int64,
+ ValueType.COLLECTION_PRIMITIVE, Long.MAX_VALUE, Long.MIN_VALUE));
+ entity.addProperty(createProperty("Collection(Edm.Single)", TecSimpleProperty.Collection_Single,
+ ValueType.COLLECTION_PRIMITIVE, 47.11, 11.47));
+ entity.addProperty(createProperty("Collection(Edm.Double)", TecSimpleProperty.Collection_Double,
+ ValueType.COLLECTION_PRIMITIVE, 4.711, 711.4));
+ entity.addProperty(createProperty("Collection(Edm.Decimal)", TecSimpleProperty.Collection_Decimal,
+ ValueType.COLLECTION_PRIMITIVE, 4711.1174, 1174.4711));
+ entity.addProperty(createProperty("Collection(Edm.Binary)", TecSimpleProperty.Collection_Binary,
+ ValueType.COLLECTION_PRIMITIVE, new byte[]{0x04, 0x07, 0x01, 0x01}, "test".getBytes()));
+ entity.addProperty(createProperty("Collection(Edm.Date)", TecSimpleProperty.Collection_Date,
+ ValueType.COLLECTION_PRIMITIVE, date, date2));
+ entity.addProperty(createProperty("Collection(Edm.DateTimeOffset)", TecSimpleProperty.Collection_DateTimeOffset,
+ ValueType.COLLECTION_PRIMITIVE, date.getTime(), date2.getTime()));
+ entity.addProperty(createProperty("Collection(Edm.Duration)", TecSimpleProperty.Collection_Duration,
+ ValueType.COLLECTION_PRIMITIVE, date.getTimeInMillis(), date2.getTimeInMillis()));
+ entity.addProperty(createProperty("Collection(Edm.Guid)", TecSimpleProperty.Collection_Guid,
+ ValueType.COLLECTION_PRIMITIVE,
+ UUID.fromString("AAAA-BB-CC-DD-FFFFFF"),
+ UUID.fromString("FFFF-DD-CC-BB-AAAAAA")));
+ entity.addProperty(createProperty("Collection(Edm.TimeOfDay)", TecSimpleProperty.Collection_TimeOfDay,
+ ValueType.COLLECTION_PRIMITIVE, date, date2));
+ return entity;
+ }
+
private Entity createETAllPrim(int id) {
Entity entity = new EntityImpl();
Calendar date = Calendar.getInstance();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/da8cf726/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 cf40489..bfdede8 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
@@ -19,9 +19,7 @@
package org.apache.olingo.server.tecsvc.processor;
import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
+import java.util.*;
import org.apache.olingo.commons.api.data.ContextURL;
import org.apache.olingo.commons.api.data.Entity;
@@ -70,9 +68,9 @@ public class SampleJsonProcessor implements EntitySetProcessor, EntityProcessor
time = System.nanoTime();
ODataSerializer serializer = odata.createSerializer(ODataFormat.JSON);
EdmEntitySet edmEntitySet = getEntitySet(uriInfo);
- EntitySet entitySet = createEntitySet(edmEntitySet.getEntityType());
- response.setContent(serializer.entitySet(edmEntitySet, entitySet,
- getContextUrl(request, edmEntitySet.getEntityType())));
+ ContextURL contextUrl = getContextUrl(request, edmEntitySet.getEntityType());
+ EntitySet entitySet = createEntitySet(edmEntitySet.getEntityType(), contextUrl.getURI().toASCIIString());
+ response.setContent(serializer.entitySet(edmEntitySet, entitySet, contextUrl));
LOG.info("Finished in " + (System.nanoTime() - time) / 1000 + " microseconds");
response.setStatusCode(HttpStatusCode.OK.getStatusCode());
@@ -106,42 +104,67 @@ public class SampleJsonProcessor implements EntitySetProcessor, EntityProcessor
}
public EdmEntitySet getEntitySet(UriInfo uriInfo) {
- List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
- if(resourcePaths.isEmpty()) {
- throw new RuntimeException("Invalid resource path.");
- }
- String entitySetName = resourcePaths.get(resourcePaths.size()-1).toString();
- return edm.getEntityContainer(new FullQualifiedName("com.sap.odata.test1", "Container"))
- .getEntitySet(entitySetName);
+ List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
+ if(resourcePaths.isEmpty()) {
+ throw new RuntimeException("Invalid resource path.");
}
+ String entitySetName = resourcePaths.get(resourcePaths.size()-1).toString();
+ return edm.getEntityContainer(new FullQualifiedName("com.sap.odata.test1", "Container"))
+ .getEntitySet(entitySetName);
+ }
- protected Entity createEntity(EdmEntityType entityType) {
- boolean complex = (entityType.getName().contains("Comp"));
- return createEntity(complex);
+ protected Entity createEntity(EdmEntityType entityType) {
+ boolean complex = (entityType.getName().contains("Comp"));
+ if(entityType.getName().contains("Coll")) {
+ return createEntityWithCollection(complex);
}
+ return createEntity(complex);
+ }
+
+ protected Entity createEntity(boolean complex) {
+ Entity entity = new EntityImpl();
+ Property property = new PropertyImpl();
+ property.setName("PropertyString");
+ property.setValue(ValueType.PRIMITIVE, "dummyValue");
+ entity.getProperties().add(property);
+ Property propertyInt = new PropertyImpl();
+ propertyInt.setName("PropertyInt16");
+ propertyInt.setValue(ValueType.PRIMITIVE, 42);
+ entity.getProperties().add(propertyInt);
+ Property propertyGuid = new PropertyImpl();
+ propertyGuid.setName("PropertyGuid");
+ propertyGuid.setValue(ValueType.PRIMITIVE, UUID.randomUUID());
+ entity.getProperties().add(propertyGuid);
+
+ if(complex) {
+ entity.addProperty(createComplexProperty());
+ }
+
+ return entity;
+ }
+
+ protected Entity createEntityWithCollection(boolean complex) {
+ Entity entity = new EntityImpl();
+ Property propertyInt = new PropertyImpl();
+ propertyInt.setName("PropertyInt16");
+ propertyInt.setValue(ValueType.PRIMITIVE, 42);
+ Property property = new PropertyImpl();
+ property.setName("CollPropertyString");
+ property.setValue(ValueType.COLLECTION_PRIMITIVE, Arrays.asList("dummyValue", "dummyValue_2"));
+ entity.getProperties().add(property);
+ entity.getProperties().add(propertyInt);
+ Property propertyGuid = new PropertyImpl();
+ propertyGuid.setName("CollPropertyGuid");
+ propertyGuid.setValue(ValueType.COLLECTION_PRIMITIVE, Arrays.asList(UUID.randomUUID(), UUID.randomUUID()));
+ entity.getProperties().add(propertyGuid);
- protected Entity createEntity(boolean complex) {
- Entity entity = new EntityImpl();
- Property property = new PropertyImpl();
- property.setName("PropertyString");
- property.setValue(ValueType.PRIMITIVE, "dummyValue");
- entity.getProperties().add(property);
- Property propertyInt = new PropertyImpl();
- propertyInt.setName("PropertyInt16");
- propertyInt.setValue(ValueType.PRIMITIVE, 42);
- entity.getProperties().add(propertyInt);
- Property propertyGuid = new PropertyImpl();
- propertyGuid.setName("PropertyGuid");
- propertyGuid.setValue(ValueType.PRIMITIVE, UUID.randomUUID());
- entity.getProperties().add(propertyGuid);
-
- if(complex) {
- entity.addProperty(createComplexProperty());
- }
-
- return entity;
+ if(complex) {
+ entity.addProperty(createCollectionOfComplexProperty());
}
+ return entity;
+ }
+
protected Property createComplexProperty() {
List<Property> properties = new ArrayList<Property>();
Property property = new PropertyImpl();
@@ -161,14 +184,48 @@ public class SampleJsonProcessor implements EntitySetProcessor, EntityProcessor
properties);
}
+ protected Property createCollectionOfComplexProperty() {
+ List<Property> properties = new ArrayList<Property>();
+ Property property = new PropertyImpl();
+ property.setName("PropertyString");
+ property.setValue(ValueType.PRIMITIVE, "dummyValue");
+ properties.add(property);
+ Property propertyInt = new PropertyImpl();
+ propertyInt.setName("PropertyInt16");
+ propertyInt.setValue(ValueType.PRIMITIVE, 42);
+ properties.add(propertyInt);
+ Property propertyGuid = new PropertyImpl();
+ propertyGuid.setName("PropertyGuid");
+ propertyGuid.setValue(ValueType.PRIMITIVE, UUID.randomUUID());
+ properties.add(propertyGuid);
+
+ List<Property> properties2 = new ArrayList<Property>();
+ Property property2 = new PropertyImpl();
+ property2.setName("PropertyString");
+ property2.setValue(ValueType.PRIMITIVE, "dummyValue2");
+ properties2.add(property2);
+ Property property2Int = new PropertyImpl();
+ property2Int.setName("PropertyInt16");
+ property2Int.setValue(ValueType.PRIMITIVE, 44);
+ properties2.add(property2Int);
+ Property property2Guid = new PropertyImpl();
+ property2Guid.setName("PropertyGuid");
+ property2Guid.setValue(ValueType.PRIMITIVE, UUID.randomUUID());
+ properties2.add(property2Guid);
+
+ return new PropertyImpl("com.sap.odata.test1.ETCompAllPrim", "PropertyComplex", ValueType.COMPLEX,
+ Arrays.asList(properties, properties2));
+ }
+
- protected EntitySet createEntitySet(EdmEntityType edmEntityType) {
- EntitySet entitySet = new EntitySetImpl();
- entitySet.setCount(4242);
- entitySet.setNext(URI.create("nextLinkURI"));
- for (int i = 0; i < 1000; i++) {
- entitySet.getEntities().add(createEntity(edmEntityType));
- }
- return entitySet;
+ protected EntitySet createEntitySet(EdmEntityType edmEntityType, String baseUri) {
+ EntitySet entitySet = new EntitySetImpl();
+ int count = (int) ((Math.random() * 50) + 1);
+ entitySet.setCount(count);
+ entitySet.setNext(URI.create(baseUri + "nextLink"));
+ for (int i = 0; i < count; i++) {
+ entitySet.getEntities().add(createEntity(edmEntityType));
}
+ return entitySet;
}
+}
[07/18] git commit: [OLINGO-341] Fix
Posted by sk...@apache.org.
[OLINGO-341] Fix
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/098ed145
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/098ed145
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/098ed145
Branch: refs/heads/olingo337
Commit: 098ed145dbafa2bd59d35448ec37fcf0b01bcb98
Parents: 15f7de8
Author: Francesco Chicchiriccò <--global>
Authored: Fri Jul 4 11:23:36 2014 +0200
Committer: Francesco Chicchiriccò <--global>
Committed: Fri Jul 4 11:23:36 2014 +0200
----------------------------------------------------------------------
.../apache/olingo/fit/tecsvc/BasicITCase.java | 14 ++++++++++--
.../retrieve/AbstractODataRetrieveRequest.java | 6 +----
.../retrieve/EdmMetadataRequestImpl.java | 10 ++++++++
.../retrieve/v4/XMLMetadataRequestImpl.java | 24 ++++++++++++--------
4 files changed, 37 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/098ed145/fit/src/test/java/org/apache/olingo/fit/tecsvc/BasicITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/BasicITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/BasicITCase.java
index 136d513..8c5650f 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/BasicITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/BasicITCase.java
@@ -18,14 +18,17 @@
*/
package org.apache.olingo.fit.tecsvc;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.apache.olingo.client.api.communication.request.retrieve.EdmMetadataRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataServiceDocumentRequest;
+import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.api.v4.ODataClient;
import org.apache.olingo.client.core.ODataClientFactory;
import org.apache.olingo.commons.api.domain.ODataServiceDocument;
import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.junit.Before;
import org.junit.Test;
@@ -43,7 +46,7 @@ public class BasicITCase {
@Test
public void readServiceDocument() {
ODataServiceDocumentRequest request =
- odata.getRetrieveRequestFactory().getServiceDocumentRequest(REF_SERVICE);
+ odata.getRetrieveRequestFactory().getServiceDocumentRequest(REF_SERVICE);
request.setAccept("application/json;odata.metadata=minimal");
assertNotNull(request);
ODataServiceDocument serviceDocument = request.execute().getBody();
@@ -54,7 +57,14 @@ public class BasicITCase {
public void readMetadata() {
EdmMetadataRequest request = odata.getRetrieveRequestFactory().getMetadataRequest(REF_SERVICE);
assertNotNull(request);
- Edm edm = request.execute().getBody();
+
+ ODataRetrieveResponse<Edm> response = request.execute();
+ assertEquals(200, response.getStatusCode());
+
+ Edm edm = response.getBody();
assertNotNull(edm);
+ assertEquals("com.sap.odata.test1", edm.getSchema("com.sap.odata.test1").getNamespace());
+ assertEquals("Namespace1_Alias", edm.getSchema("com.sap.odata.test1").getAlias());
+ assertNotNull(edm.getTerm(new FullQualifiedName("Core.Description")));
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/098ed145/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractODataRetrieveRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractODataRetrieveRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractODataRetrieveRequest.java
index 1a28a14..c42832c 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractODataRetrieveRequest.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractODataRetrieveRequest.java
@@ -62,7 +62,7 @@ public abstract class AbstractODataRetrieveRequest<T>
* Response abstract class about an ODataRetrieveRequest.
*/
protected abstract class AbstractODataRetrieveResponse
- extends AbstractODataResponse implements ODataRetrieveResponse<T> {
+ extends AbstractODataResponse implements ODataRetrieveResponse<T> {
/**
* Constructor.
@@ -83,10 +83,6 @@ public abstract class AbstractODataRetrieveRequest<T>
super(client, res);
}
- protected HttpResponse getHttpResponse() {
- return res;
- }
-
@Override
public abstract T getBody();
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/098ed145/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/EdmMetadataRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/EdmMetadataRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/EdmMetadataRequestImpl.java
index 5a02a19..64486ff 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/EdmMetadataRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/EdmMetadataRequestImpl.java
@@ -58,6 +58,16 @@ class EdmMetadataRequestImpl extends AbstractMetadataRequestImpl<Edm> implements
}
@Override
+ public int getStatusCode() {
+ return xmlMetadataResponse.getStatusCode();
+ }
+
+ @Override
+ public String getStatusMessage() {
+ return xmlMetadataResponse.getStatusMessage();
+ }
+
+ @Override
public Edm getBody() {
if (metadata == null) {
try {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/098ed145/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/XMLMetadataRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/XMLMetadataRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/XMLMetadataRequestImpl.java
index 88fb07a..4645d86 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/XMLMetadataRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/XMLMetadataRequestImpl.java
@@ -23,6 +23,8 @@ import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
import org.apache.olingo.client.api.communication.request.retrieve.XMLMetadataRequest;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.api.edm.xml.Schema;
@@ -50,7 +52,7 @@ public class XMLMetadataRequestImpl extends AbstractMetadataRequestImpl<Map<Stri
final SingleXMLMetadatRequestImpl rootReq = new SingleXMLMetadatRequestImpl((ODataClient) odataClient, uri);
final ODataRetrieveResponse<XMLMetadata> rootRes = rootReq.execute();
- final XMLMetadataResponseImpl response = new XMLMetadataResponseImpl();
+ final XMLMetadataResponseImpl response = new XMLMetadataResponseImpl(httpClient, rootReq.getHttpResponse());
final XMLMetadata rootMetadata = rootRes.getBody();
for (Schema schema : rootMetadata.getSchemas()) {
@@ -87,7 +89,7 @@ public class XMLMetadataRequestImpl extends AbstractMetadataRequestImpl<Map<Stri
// process all edm:Annotations in each schema of the included document
for (Annotations annotationGroup : ((SchemaImpl) schema).getAnnotationGroups()) {
- // take into account only when (TargetNamespace was either not provided or matches) and
+ // take into account only when (TargetNamespace was either not provided or matches) and
// (Qualifier was either not provided or matches)
if ((StringUtils.isBlank(include.getTargetNamespace())
|| include.getTargetNamespace().equals(
@@ -123,13 +125,20 @@ public class XMLMetadataRequestImpl extends AbstractMetadataRequestImpl<Map<Stri
private class SingleXMLMetadatRequestImpl extends AbstractMetadataRequestImpl<XMLMetadata> {
+ private HttpResponse httpResponse;
+
public SingleXMLMetadatRequestImpl(final ODataClient odataClient, final URI uri) {
super(odataClient, uri);
}
+ public HttpResponse getHttpResponse() {
+ return httpResponse;
+ }
+
@Override
public ODataRetrieveResponse<XMLMetadata> execute() {
- return new AbstractODataRetrieveResponse(httpClient, doExecute()) {
+ httpResponse = doExecute();
+ return new AbstractODataRetrieveResponse(httpClient, httpResponse) {
@Override
public XMLMetadata getBody() {
@@ -147,13 +156,8 @@ public class XMLMetadataRequestImpl extends AbstractMetadataRequestImpl<Map<Stri
private final Map<String, Schema> schemas = new HashMap<String, Schema>();
- /**
- * Constructor.
- * <br/>
- * Just to create response templates to be initialized from batch.
- */
- private XMLMetadataResponseImpl() {
- super();
+ private XMLMetadataResponseImpl(final HttpClient client, final HttpResponse res) {
+ super(client, res);
}
@Override
[11/18] git commit: Fixing checkstyle errors
Posted by sk...@apache.org.
Fixing checkstyle errors
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/6383ab0b
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/6383ab0b
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/6383ab0b
Branch: refs/heads/olingo337
Commit: 6383ab0b12ccc6a7caca0382d92980c8a524946c
Parents: 32c113d
Author: Francesco Chicchiriccò <--global>
Authored: Fri Jul 4 09:11:52 2014 +0200
Committer: Stephan Klevenz <st...@sap.com>
Committed: Fri Jul 4 12:21:01 2014 +0200
----------------------------------------------------------------------
.../apache/olingo/commons/api/format/AcceptType.java | 1 -
.../apache/olingo/commons/api/format/ContentType.java | 12 ++++++++----
2 files changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6383ab0b/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 39bdf75..736b747 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
@@ -24,7 +24,6 @@ import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
-import java.util.regex.Pattern;
/**
* Internally used {@link AcceptType} for OData library.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6383ab0b/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 3506ffb..a686880 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
@@ -52,10 +52,12 @@ public class ContentType {
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,
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 =
+ create(APPLICATION_ATOM_XML,TypeUtil. PARAMETER_TYPE, "entry");
public static final ContentType APPLICATION_ATOM_XML_ENTRY_CS_UTF_8 = create(APPLICATION_ATOM_XML_ENTRY,
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 =
+ create(APPLICATION_ATOM_XML,TypeUtil. PARAMETER_TYPE, "feed");
public static final ContentType APPLICATION_ATOM_XML_FEED_CS_UTF_8 = create(APPLICATION_ATOM_XML_FEED,
TypeUtil. PARAMETER_CHARSET,TypeUtil.CHARSET_UTF_8);
public static final ContentType APPLICATION_ATOM_SVC = create("application", "atomsvc+xml");
@@ -66,7 +68,8 @@ public class ContentType {
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, TypeUtil.PARAMETER_CHARSET,TypeUtil. 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");
@@ -205,7 +208,8 @@ public class ContentType {
typeSubtype.add(tokens[1]);
}
} else {
- throw new IllegalArgumentException("Too many '" +TypeUtil.TYPE_SUBTYPE_SEPARATOR + "' in format '" + format + "'.");
+ throw new IllegalArgumentException(
+ "Too many '" +TypeUtil.TYPE_SUBTYPE_SEPARATOR + "' in format '" + format + "'.");
}
} else {
throw new IllegalArgumentException("No separator '" +TypeUtil.TYPE_SUBTYPE_SEPARATOR
[09/18] git commit: [OLINGO-337] refactor requestedContentType
Posted by sk...@apache.org.
[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/d049864e
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/d049864e
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/d049864e
Branch: refs/heads/olingo337
Commit: d049864ea4657fc95114e1e6bd72fd85f4f4f671
Parents: 098ed14
Author: Stephan Klevenz <st...@sap.com>
Authored: Thu Jul 3 09:09:22 2014 +0200
Committer: Stephan Klevenz <st...@sap.com>
Committed: Fri Jul 4 12:18:24 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/d049864e/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/d049864e/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/d049864e/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/d049864e/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/d049864e/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/d049864e/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/d049864e/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/d049864e/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/d049864e/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());
}
}
[05/18] git commit: [OLINGO-317] Merge with current master
Posted by sk...@apache.org.
[OLINGO-317] Merge with current master
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/66f26e5b
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/66f26e5b
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/66f26e5b
Branch: refs/heads/olingo337
Commit: 66f26e5b6ac3e2e3dd9c69bb6f2fbbe69baee87d
Parents: 876655f 2bd0662
Author: Michael Bolz <mi...@sap.com>
Authored: Thu Jul 3 09:04:49 2014 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Thu Jul 3 09:04:49 2014 +0200
----------------------------------------------------------------------
fit/pom.xml | 2 +-
.../org/apache/olingo/fit/AbstractServices.java | 735 +++++------
.../fit/UnsupportedMediaTypeException.java | 21 +-
.../apache/olingo/fit/V3ActionOverloading.java | 72 +-
.../org/apache/olingo/fit/V3KeyAsSegment.java | 132 +-
.../java/org/apache/olingo/fit/V3OpenType.java | 64 +-
.../org/apache/olingo/fit/V3PrimitiveKeys.java | 19 +-
.../java/org/apache/olingo/fit/V3Services.java | 200 +--
.../main/java/org/apache/olingo/fit/V4Demo.java | 104 +-
.../org/apache/olingo/fit/V4KeyAsSegment.java | 90 +-
.../java/org/apache/olingo/fit/V4NorthWind.java | 17 +-
.../org/apache/olingo/fit/V4NorthWindExt.java | 19 +-
.../java/org/apache/olingo/fit/V4OpenType.java | 60 +-
.../java/org/apache/olingo/fit/V4Services.java | 266 ++--
.../org/apache/olingo/fit/V4Vocabularies.java | 41 +-
.../fit/metadata/AbstractMetadataElement.java | 14 +-
.../apache/olingo/fit/metadata/Association.java | 14 +-
.../olingo/fit/metadata/AssociationSet.java | 14 +-
.../apache/olingo/fit/metadata/Container.java | 14 +-
.../apache/olingo/fit/metadata/EntitySet.java | 23 +-
.../apache/olingo/fit/metadata/EntityType.java | 18 +-
.../apache/olingo/fit/metadata/Metadata.java | 62 +-
.../olingo/fit/metadata/NavigationProperty.java | 24 +-
.../apache/olingo/fit/metadata/Property.java | 20 +-
.../org/apache/olingo/fit/metadata/Schema.java | 18 +-
.../org/apache/olingo/fit/methods/MERGE.java | 20 +-
.../org/apache/olingo/fit/methods/PATCH.java | 20 +-
.../apache/olingo/fit/rproxy/LinkRewrite.java | 17 +-
.../olingo/fit/rproxy/LinkRewriteRenderer.java | 23 +-
.../fit/serializer/FITAtomDeserializer.java | 14 +-
.../olingo/fit/utils/AbstractUtilities.java | 39 +-
.../org/apache/olingo/fit/utils/Accept.java | 25 +-
.../org/apache/olingo/fit/utils/Commons.java | 108 +-
.../apache/olingo/fit/utils/ConstantKey.java | 14 +-
.../org/apache/olingo/fit/utils/Constants.java | 25 +-
.../org/apache/olingo/fit/utils/FSManager.java | 14 +-
.../fit/utils/InjectableSerializerProvider.java | 18 +-
.../apache/olingo/fit/utils/JSONUtilities.java | 80 +-
.../org/apache/olingo/fit/utils/LinkInfo.java | 16 +-
.../olingo/fit/utils/MetadataLinkInfo.java | 35 +-
.../olingo/fit/utils/NavigationLinks.java | 27 +-
.../utils/ResolvingReferencesInterceptor.java | 20 +-
.../fit/utils/XHTTPMethodInterceptor.java | 17 +-
.../org/apache/olingo/fit/utils/XMLElement.java | 18 +-
.../olingo/fit/utils/XMLEventReaderWrapper.java | 42 +-
.../apache/olingo/fit/utils/XMLUtilities.java | 268 ++--
.../olingo/fit/AbstractBaseTestITCase.java | 14 +-
.../olingo/fit/proxy/v3/AbstractTestITCase.java | 56 +-
.../proxy/v3/ActionOverloadingTestITCase.java | 50 +-
.../olingo/fit/proxy/v3/AsyncTestITCase.java | 71 +-
.../olingo/fit/proxy/v3/ContextTestITCase.java | 127 +-
.../fit/proxy/v3/EntityCreateTestITCase.java | 34 +-
.../fit/proxy/v3/EntityRetrieveTestITCase.java | 94 +-
.../fit/proxy/v3/EntitySetTestITCase.java | 15 +-
.../fit/proxy/v3/EntityUpdateTestITCase.java | 154 ++-
.../olingo/fit/proxy/v3/FilterTestITCase.java | 41 +-
.../olingo/fit/proxy/v3/InvokeTestITCase.java | 34 +-
.../fit/proxy/v3/MediaEntityTestITCase.java | 19 +-
.../olingo/fit/proxy/v3/OpenTypeTestITCase.java | 25 +-
.../fit/proxy/v3/PrimitiveKeysTestITCase.java | 27 +-
.../olingo/fit/proxy/v3/PropertyTestITCase.java | 50 +-
.../AllGeoCollectionTypesSet.java | 56 +-
.../astoriadefaultservice/AllGeoTypesSet.java | 50 +-
.../services/astoriadefaultservice/Car.java | 50 +-
.../astoriadefaultservice/Computer.java | 50 +-
.../astoriadefaultservice/ComputerDetail.java | 50 +-
.../astoriadefaultservice/Customer.java | 50 +-
.../astoriadefaultservice/CustomerInfo.java | 50 +-
.../astoriadefaultservice/DefaultContainer.java | 211 ++--
.../services/astoriadefaultservice/Driver.java | 50 +-
.../astoriadefaultservice/LastLogin.java | 50 +-
.../services/astoriadefaultservice/License.java | 50 +-
.../services/astoriadefaultservice/Login.java | 50 +-
.../astoriadefaultservice/MappedEntityType.java | 50 +-
.../services/astoriadefaultservice/Message.java | 51 +-
.../MessageAttachment.java | 50 +-
.../services/astoriadefaultservice/Order.java | 50 +-
.../astoriadefaultservice/OrderLine.java | 69 +-
.../astoriadefaultservice/PageView.java | 56 +-
.../services/astoriadefaultservice/Person.java | 76 +-
.../astoriadefaultservice/PersonMetadata.java | 50 +-
.../services/astoriadefaultservice/Product.java | 56 +-
.../astoriadefaultservice/ProductDetail.java | 50 +-
.../astoriadefaultservice/ProductPhoto.java | 51 +-
.../astoriadefaultservice/ProductReview.java | 51 +-
.../astoriadefaultservice/RSAToken.java | 50 +-
.../astoriadefaultservice/package-info.java | 16 +-
.../astoriadefaultservice/types/Aliases.java | 62 +-
.../types/AllSpatialCollectionTypes.java | 139 +--
.../AllSpatialCollectionTypesCollection.java | 44 +-
.../types/AllSpatialCollectionTypes_Simple.java | 470 ++++---
...SpatialCollectionTypes_SimpleCollection.java | 44 +-
.../types/AllSpatialTypes.java | 985 +++++++--------
.../types/AllSpatialTypesCollection.java | 44 +-
.../astoriadefaultservice/types/AuditInfo.java | 89 +-
.../types/BackOrderLine.java | 457 +++----
.../types/BackOrderLine2.java | 457 +++----
.../types/BackOrderLine2Collection.java | 44 +-
.../types/BackOrderLineCollection.java | 44 +-
.../astoriadefaultservice/types/Car.java | 305 ++---
.../types/CarCollection.java | 44 +-
.../types/ComplexToCategory.java | 77 +-
.../astoriadefaultservice/types/Computer.java | 222 ++--
.../types/ComputerCollection.java | 44 +-
.../types/ComputerDetail.java | 500 ++++----
.../types/ComputerDetailCollection.java | 44 +-
.../types/ConcurrencyInfo.java | 70 +-
.../types/ContactDetails.java | 147 +--
.../astoriadefaultservice/types/Contractor.java | 477 ++++---
.../types/ContractorCollection.java | 44 +-
.../astoriadefaultservice/types/Customer.java | 648 +++++-----
.../types/CustomerCollection.java | 44 +-
.../types/CustomerInfo.java | 199 ++-
.../types/CustomerInfoCollection.java | 44 +-
.../astoriadefaultservice/types/Dimensions.java | 77 +-
.../types/DiscontinuedProduct.java | 901 +++++++-------
.../types/DiscontinuedProductCollection.java | 44 +-
.../astoriadefaultservice/types/Driver.java | 222 ++--
.../types/DriverCollection.java | 44 +-
.../astoriadefaultservice/types/Employee.java | 470 ++++---
.../types/EmployeeCollection.java | 58 +-
.../astoriadefaultservice/types/LastLogin.java | 328 +++--
.../types/LastLoginCollection.java | 44 +-
.../astoriadefaultservice/types/License.java | 381 +++---
.../types/LicenseCollection.java | 44 +-
.../astoriadefaultservice/types/Login.java | 346 +++---
.../types/LoginCollection.java | 44 +-
.../types/MappedEntityType.java | 1173 +++++++++---------
.../types/MappedEntityTypeCollection.java | 44 +-
.../astoriadefaultservice/types/Message.java | 548 ++++----
.../types/MessageAttachment.java | 192 ++-
.../types/MessageAttachmentCollection.java | 44 +-
.../types/MessageCollection.java | 44 +-
.../astoriadefaultservice/types/MessageKey.java | 76 +-
.../astoriadefaultservice/types/Order.java | 319 +++--
.../types/OrderCollection.java | 44 +-
.../astoriadefaultservice/types/OrderLine.java | 435 +++----
.../types/OrderLineCollection.java | 44 +-
.../types/OrderLineKey.java | 76 +-
.../astoriadefaultservice/types/PageView.java | 381 +++---
.../types/PageViewCollection.java | 44 +-
.../astoriadefaultservice/types/Person.java | 242 ++--
.../types/PersonCollection.java | 44 +-
.../types/PersonMetadata.java | 328 +++--
.../types/PersonMetadataCollection.java | 44 +-
.../astoriadefaultservice/types/Phone.java | 69 +-
.../astoriadefaultservice/types/Product.java | 639 +++++-----
.../types/ProductCollection.java | 44 +-
.../types/ProductDetail.java | 222 ++--
.../types/ProductDetailCollection.java | 44 +-
.../types/ProductPageView.java | 514 ++++----
.../types/ProductPageViewCollection.java | 44 +-
.../types/ProductPhoto.java | 244 ++--
.../types/ProductPhotoCollection.java | 44 +-
.../types/ProductPhotoKey.java | 76 +-
.../types/ProductReview.java | 328 +++--
.../types/ProductReviewCollection.java | 44 +-
.../types/ProductReviewKey.java | 92 +-
.../astoriadefaultservice/types/RSAToken.java | 222 ++--
.../types/RSATokenCollection.java | 44 +-
.../types/SpecialEmployee.java | 669 +++++-----
.../types/SpecialEmployeeCollection.java | 58 +-
.../types/package-info.java | 16 +-
.../opentypesservicev3/DefaultContainer.java | 66 +-
.../odata/services/opentypesservicev3/Row.java | 55 +-
.../services/opentypesservicev3/RowIndex.java | 49 +-
.../opentypesservicev3/package-info.java | 16 +-
.../types/ContactDetails.java | 151 +--
.../opentypesservicev3/types/IndexedRow.java | 149 +--
.../types/IndexedRowCollection.java | 44 +-
.../services/opentypesservicev3/types/Row.java | 140 +--
.../opentypesservicev3/types/RowCollection.java | 44 +-
.../opentypesservicev3/types/RowIndex.java | 170 ++-
.../types/RowIndexCollection.java | 44 +-
.../opentypesservicev3/types/package-info.java | 16 +-
.../primitivekeysservice/EdmBinarySet.java | 50 +-
.../primitivekeysservice/EdmBooleanSet.java | 50 +-
.../primitivekeysservice/EdmByteSet.java | 50 +-
.../EdmDateTimeOffsetSet.java | 50 +-
.../primitivekeysservice/EdmDateTimeSet.java | 50 +-
.../primitivekeysservice/EdmDecimalSet.java | 50 +-
.../primitivekeysservice/EdmDoubleSet.java | 50 +-
.../primitivekeysservice/EdmGuidSet.java | 50 +-
.../primitivekeysservice/EdmInt16Set.java | 50 +-
.../primitivekeysservice/EdmInt32Set.java | 50 +-
.../primitivekeysservice/EdmInt64Set.java | 50 +-
.../primitivekeysservice/EdmSingleSet.java | 50 +-
.../primitivekeysservice/EdmStringSet.java | 50 +-
.../primitivekeysservice/EdmTimeSet.java | 50 +-
.../services/primitivekeysservice/Folders.java | 50 +-
.../primitivekeysservice/TestContext.java | 88 +-
.../primitivekeysservice/package-info.java | 16 +-
.../primitivekeysservice/types/EdmBinary.java | 139 +--
.../types/EdmBinaryCollection.java | 44 +-
.../primitivekeysservice/types/EdmBoolean.java | 139 +--
.../types/EdmBooleanCollection.java | 44 +-
.../primitivekeysservice/types/EdmByte.java | 139 +--
.../types/EdmByteCollection.java | 44 +-
.../primitivekeysservice/types/EdmDateTime.java | 139 +--
.../types/EdmDateTimeCollection.java | 44 +-
.../types/EdmDateTimeOffset.java | 139 +--
.../types/EdmDateTimeOffsetCollection.java | 44 +-
.../primitivekeysservice/types/EdmDecimal.java | 139 +--
.../types/EdmDecimalCollection.java | 44 +-
.../primitivekeysservice/types/EdmDouble.java | 139 +--
.../types/EdmDoubleCollection.java | 44 +-
.../primitivekeysservice/types/EdmGuid.java | 139 +--
.../types/EdmGuidCollection.java | 44 +-
.../primitivekeysservice/types/EdmInt16.java | 139 +--
.../types/EdmInt16Collection.java | 44 +-
.../primitivekeysservice/types/EdmInt32.java | 139 +--
.../types/EdmInt32Collection.java | 44 +-
.../primitivekeysservice/types/EdmInt64.java | 139 +--
.../types/EdmInt64Collection.java | 44 +-
.../primitivekeysservice/types/EdmSingle.java | 139 +--
.../types/EdmSingleCollection.java | 44 +-
.../primitivekeysservice/types/EdmString.java | 139 +--
.../types/EdmStringCollection.java | 44 +-
.../primitivekeysservice/types/EdmTime.java | 139 +--
.../types/EdmTimeCollection.java | 44 +-
.../primitivekeysservice/types/Folder.java | 222 ++--
.../types/FolderCollection.java | 44 +-
.../types/package-info.java | 16 +-
.../AllGeoCollectionTypesSet.java | 56 +-
.../astoriadefaultservice/AllGeoTypesSet.java | 50 +-
.../services/astoriadefaultservice/Car.java | 49 +-
.../astoriadefaultservice/Computer.java | 50 +-
.../astoriadefaultservice/ComputerDetail.java | 50 +-
.../astoriadefaultservice/Customer.java | 50 +-
.../astoriadefaultservice/CustomerInfo.java | 50 +-
.../astoriadefaultservice/DefaultContainer.java | 299 ++---
.../services/astoriadefaultservice/Driver.java | 50 +-
.../astoriadefaultservice/LastLogin.java | 50 +-
.../services/astoriadefaultservice/License.java | 50 +-
.../services/astoriadefaultservice/Login.java | 50 +-
.../astoriadefaultservice/MappedEntityType.java | 50 +-
.../services/astoriadefaultservice/Message.java | 51 +-
.../MessageAttachment.java | 50 +-
.../services/astoriadefaultservice/Order.java | 50 +-
.../astoriadefaultservice/OrderLine.java | 69 +-
.../astoriadefaultservice/PageView.java | 56 +-
.../services/astoriadefaultservice/Person.java | 76 +-
.../astoriadefaultservice/PersonMetadata.java | 50 +-
.../services/astoriadefaultservice/Product.java | 56 +-
.../astoriadefaultservice/ProductDetail.java | 50 +-
.../astoriadefaultservice/ProductPhoto.java | 51 +-
.../astoriadefaultservice/ProductReview.java | 51 +-
.../astoriadefaultservice/RSAToken.java | 50 +-
.../astoriadefaultservice/package-info.java | 16 +-
.../astoriadefaultservice/types/Aliases.java | 62 +-
.../types/AllSpatialCollectionTypes.java | 139 +--
.../AllSpatialCollectionTypesCollection.java | 44 +-
.../types/AllSpatialCollectionTypes_Simple.java | 470 ++++---
...SpatialCollectionTypes_SimpleCollection.java | 44 +-
.../types/AllSpatialTypes.java | 985 +++++++--------
.../types/AllSpatialTypesCollection.java | 44 +-
.../astoriadefaultservice/types/AuditInfo.java | 89 +-
.../types/BackOrderLine.java | 441 ++++---
.../types/BackOrderLine2.java | 442 +++----
.../types/BackOrderLine2Collection.java | 44 +-
.../types/BackOrderLineCollection.java | 44 +-
.../astoriadefaultservice/types/Car.java | 305 ++---
.../types/CarCollection.java | 44 +-
.../types/ComplexToCategory.java | 77 +-
.../types/ComplexWithAllPrimitiveTypes.java | 167 +--
.../astoriadefaultservice/types/Computer.java | 245 ++--
.../types/ComputerCollection.java | 44 +-
.../types/ComputerDetail.java | 526 ++++----
.../types/ComputerDetailCollection.java | 44 +-
.../types/ConcurrencyInfo.java | 70 +-
.../types/ContactDetails.java | 147 +--
.../astoriadefaultservice/types/Contractor.java | 452 ++++---
.../types/ContractorCollection.java | 44 +-
.../astoriadefaultservice/types/Customer.java | 648 +++++-----
.../types/CustomerCollection.java | 44 +-
.../types/CustomerInfo.java | 199 ++-
.../types/CustomerInfoCollection.java | 44 +-
.../astoriadefaultservice/types/Dimensions.java | 77 +-
.../types/DiscontinuedProduct.java | 901 +++++++-------
.../types/DiscontinuedProductCollection.java | 44 +-
.../astoriadefaultservice/types/Driver.java | 222 ++--
.../types/DriverCollection.java | 44 +-
.../astoriadefaultservice/types/Employee.java | 450 ++++---
.../types/EmployeeCollection.java | 58 +-
.../astoriadefaultservice/types/LastLogin.java | 328 +++--
.../types/LastLoginCollection.java | 44 +-
.../astoriadefaultservice/types/License.java | 381 +++---
.../types/LicenseCollection.java | 44 +-
.../astoriadefaultservice/types/Login.java | 346 +++---
.../types/LoginCollection.java | 44 +-
.../types/MappedEntityType.java | 1173 +++++++++---------
.../types/MappedEntityTypeCollection.java | 44 +-
.../astoriadefaultservice/types/Message.java | 548 ++++----
.../types/MessageAttachment.java | 192 ++-
.../types/MessageAttachmentCollection.java | 44 +-
.../types/MessageCollection.java | 44 +-
.../astoriadefaultservice/types/MessageKey.java | 76 +-
.../astoriadefaultservice/types/Order.java | 319 +++--
.../types/OrderCollection.java | 44 +-
.../astoriadefaultservice/types/OrderLine.java | 411 +++---
.../types/OrderLineCollection.java | 44 +-
.../types/OrderLineKey.java | 76 +-
.../astoriadefaultservice/types/PageView.java | 381 +++---
.../types/PageViewCollection.java | 44 +-
.../astoriadefaultservice/types/Person.java | 222 ++--
.../types/PersonCollection.java | 44 +-
.../types/PersonMetadata.java | 328 +++--
.../types/PersonMetadataCollection.java | 44 +-
.../astoriadefaultservice/types/Phone.java | 69 +-
.../astoriadefaultservice/types/Product.java | 642 +++++-----
.../types/ProductCollection.java | 44 +-
.../types/ProductDetail.java | 222 ++--
.../types/ProductDetailCollection.java | 44 +-
.../types/ProductPageView.java | 514 ++++----
.../types/ProductPageViewCollection.java | 44 +-
.../types/ProductPhoto.java | 244 ++--
.../types/ProductPhotoCollection.java | 44 +-
.../types/ProductPhotoKey.java | 76 +-
.../types/ProductReview.java | 328 +++--
.../types/ProductReviewCollection.java | 44 +-
.../types/ProductReviewKey.java | 92 +-
.../astoriadefaultservice/types/RSAToken.java | 222 ++--
.../types/RSATokenCollection.java | 44 +-
.../types/SpecialEmployee.java | 645 +++++-----
.../types/SpecialEmployeeCollection.java | 44 +-
.../types/package-info.java | 16 +-
.../olingo/fit/proxy/v4/AbstractTestITCase.java | 25 +-
.../olingo/fit/proxy/v4/AsyncTestITCase.java | 34 +-
.../proxy/v4/AuthEntityCreateTestITCase.java | 22 +-
.../proxy/v4/AuthEntityRetrieveTestITCase.java | 17 +-
.../v4/BoundOperationInvokeTestITCase.java | 28 +-
.../fit/proxy/v4/DerivedTypeTestITCase.java | 32 +-
.../fit/proxy/v4/EntityCreateTestITCase.java | 44 +-
.../fit/proxy/v4/EntityRetrieveTestITCase.java | 29 +-
.../fit/proxy/v4/EntitySetTestITCase.java | 14 +-
.../fit/proxy/v4/EntityUpdateTestITCase.java | 39 +-
.../olingo/fit/proxy/v4/FilterTestITCase.java | 28 +-
.../fit/proxy/v4/KeyAsSegmentTestITCase.java | 14 +-
.../fit/proxy/v4/MediaEntityTestITCase.java | 15 +-
...TransactionalAuthEntityCreateTestITCase.java | 22 +-
.../NonTransactionalEntityCreateTestITCase.java | 17 +-
.../NonTransactionalEntityUpdateTestITCase.java | 17 +-
.../NonTransactionalMediaEntityTestITCase.java | 14 +-
.../olingo/fit/proxy/v4/OpenTypeTestITCase.java | 27 +-
.../v4/OperationImportInvokeTestITCase.java | 22 +-
.../olingo/fit/proxy/v4/PropertyTestITCase.java | 14 +-
.../fit/proxy/v4/SingletonTestITCase.java | 14 +-
.../v4/UnauthorizedEntityCreateTestITCase.java | 19 +-
.../proxy/v4/demo/odatademo/Advertisements.java | 48 +-
.../fit/proxy/v4/demo/odatademo/Categories.java | 48 +-
.../proxy/v4/demo/odatademo/DemoService.java | 97 +-
.../proxy/v4/demo/odatademo/PersonDetails.java | 48 +-
.../fit/proxy/v4/demo/odatademo/Persons.java | 62 +-
.../proxy/v4/demo/odatademo/ProductDetails.java | 48 +-
.../fit/proxy/v4/demo/odatademo/Products.java | 52 +-
.../fit/proxy/v4/demo/odatademo/Suppliers.java | 48 +-
.../proxy/v4/demo/odatademo/package-info.java | 16 +-
.../proxy/v4/demo/odatademo/types/Address.java | 272 ++--
.../v4/demo/odatademo/types/Advertisement.java | 279 ++---
.../types/AdvertisementCollection.java | 43 +-
.../proxy/v4/demo/odatademo/types/Category.java | 220 ++--
.../odatademo/types/CategoryCollection.java | 43 +-
.../proxy/v4/demo/odatademo/types/Customer.java | 285 ++---
.../odatademo/types/CustomerCollection.java | 43 +-
.../proxy/v4/demo/odatademo/types/Employee.java | 391 +++---
.../odatademo/types/EmployeeCollection.java | 43 +-
.../demo/odatademo/types/FeaturedProduct.java | 615 +++++----
.../types/FeaturedProductCollection.java | 43 +-
.../proxy/v4/demo/odatademo/types/Person.java | 219 ++--
.../demo/odatademo/types/PersonCollection.java | 43 +-
.../v4/demo/odatademo/types/PersonDetail.java | 440 +++----
.../odatademo/types/PersonDetailCollection.java | 43 +-
.../proxy/v4/demo/odatademo/types/Product.java | 566 ++++-----
.../demo/odatademo/types/ProductCollection.java | 43 +-
.../v4/demo/odatademo/types/ProductDetail.java | 219 ++--
.../types/ProductDetailCollection.java | 43 +-
.../proxy/v4/demo/odatademo/types/Supplier.java | 387 +++---
.../odatademo/types/SupplierCollection.java | 43 +-
.../v4/demo/odatademo/types/package-info.java | 16 +-
.../opentypesservicev4/DefaultContainer.java | 72 +-
.../odata/services/opentypesservicev4/Row.java | 55 +-
.../services/opentypesservicev4/RowIndex.java | 49 +-
.../opentypesservicev4/package-info.java | 16 +-
.../opentypesservicev4/types/AccountInfo.java | 155 +--
.../opentypesservicev4/types/Color.java | 45 +-
.../types/ContactDetails.java | 552 ++++-----
.../opentypesservicev4/types/IndexedRow.java | 149 +--
.../types/IndexedRowCollection.java | 44 +-
.../services/opentypesservicev4/types/Row.java | 140 +--
.../opentypesservicev4/types/RowCollection.java | 44 +-
.../opentypesservicev4/types/RowIndex.java | 168 +--
.../types/RowIndexCollection.java | 44 +-
.../opentypesservicev4/types/package-info.java | 16 +-
.../services/odatawcfservice/Accounts.java | 49 +-
.../odata/services/odatawcfservice/Boss.java | 44 +-
.../odata/services/odatawcfservice/Company.java | 44 +-
.../services/odatawcfservice/Customers.java | 50 +-
.../odatawcfservice/DefaultStoredPI.java | 44 +-
.../services/odatawcfservice/Departments.java | 50 +-
.../services/odatawcfservice/Employees.java | 50 +-
.../odatawcfservice/InMemoryEntities.java | 294 ++---
.../services/odatawcfservice/LabourUnion.java | 44 +-
.../services/odatawcfservice/OrderDetails.java | 51 +-
.../odata/services/odatawcfservice/Orders.java | 49 +-
.../odata/services/odatawcfservice/People.java | 67 +-
.../odatawcfservice/ProductDetails.java | 51 +-
.../odatawcfservice/ProductReviews.java | 51 +-
.../services/odatawcfservice/Products.java | 49 +-
.../services/odatawcfservice/PublicCompany.java | 44 +-
.../services/odatawcfservice/StoredPIs.java | 50 +-
.../odatawcfservice/SubscriptionTemplates.java | 50 +-
.../services/odatawcfservice/VipCustomer.java | 44 +-
.../services/odatawcfservice/package-info.java | 16 +-
.../odatawcfservice/types/AccessLevel.java | 49 +-
.../services/odatawcfservice/types/Account.java | 488 ++++----
.../types/AccountCollection.java | 44 +-
.../odatawcfservice/types/AccountInfo.java | 155 +--
.../services/odatawcfservice/types/Address.java | 192 ++-
.../services/odatawcfservice/types/Asset.java | 245 ++--
.../odatawcfservice/types/AssetCollection.java | 44 +-
.../services/odatawcfservice/types/Club.java | 192 ++-
.../odatawcfservice/types/ClubCollection.java | 44 +-
.../services/odatawcfservice/types/Color.java | 45 +-
.../services/odatawcfservice/types/Company.java | 528 ++++----
.../odatawcfservice/types/CompanyAddress.java | 254 ++--
.../odatawcfservice/types/CompanyCategory.java | 47 +-
.../types/CompanyCollection.java | 44 +-
.../odatawcfservice/types/CreditCardPI.java | 658 +++++-----
.../types/CreditCardPICollection.java | 44 +-
.../odatawcfservice/types/CreditRecord.java | 298 ++---
.../types/CreditRecordCollection.java | 44 +-
.../odatawcfservice/types/Customer.java | 823 ++++++------
.../types/CustomerCollection.java | 44 +-
.../odatawcfservice/types/Department.java | 274 ++--
.../types/DepartmentCollection.java | 44 +-
.../odatawcfservice/types/Employee.java | 739 +++++------
.../types/EmployeeCollection.java | 44 +-
.../odatawcfservice/types/GiftCard.java | 377 +++---
.../types/GiftCardCollection.java | 44 +-
.../odatawcfservice/types/HomeAddress.java | 254 ++--
.../services/odatawcfservice/types/IsBoss.java | 25 +-
.../odatawcfservice/types/LabourUnion.java | 192 ++-
.../types/LabourUnionCollection.java | 44 +-
.../services/odatawcfservice/types/Order.java | 390 +++---
.../odatawcfservice/types/OrderCollection.java | 44 +-
.../odatawcfservice/types/OrderDetail.java | 411 +++---
.../types/OrderDetailCollection.java | 44 +-
.../odatawcfservice/types/OrderDetailKey.java | 76 +-
.../types/PaymentInstrument.java | 359 +++---
.../types/PaymentInstrumentCollection.java | 44 +-
.../services/odatawcfservice/types/Person.java | 594 +++++----
.../odatawcfservice/types/PersonCollection.java | 44 +-
.../services/odatawcfservice/types/Product.java | 644 +++++-----
.../types/ProductCollection.java | 61 +-
.../odatawcfservice/types/ProductDetail.java | 384 +++---
.../types/ProductDetailCollection.java | 44 +-
.../odatawcfservice/types/ProductDetailKey.java | 76 +-
.../odatawcfservice/types/ProductReview.java | 405 +++---
.../types/ProductReviewCollection.java | 44 +-
.../odatawcfservice/types/ProductReviewKey.java | 108 +-
.../odatawcfservice/types/PublicCompany.java | 700 ++++++-----
.../types/PublicCompanyCollection.java | 44 +-
.../odatawcfservice/types/Statement.java | 298 ++---
.../types/StatementCollection.java | 44 +-
.../odatawcfservice/types/StoredPI.java | 298 ++---
.../types/StoredPICollection.java | 44 +-
.../odatawcfservice/types/Subscription.java | 351 +++---
.../types/SubscriptionCollection.java | 44 +-
.../odatawcfservice/types/package-info.java | 16 +-
.../apache/olingo/fit/tecsvc/BasicITCase.java | 8 +-
.../apache/olingo/fit/tecsvc/PingITCase.java | 15 +-
.../apache/olingo/fit/tecsvc/TecSvcConst.java | 25 +
.../olingo/fit/v3/AbstractTestITCase.java | 128 +-
.../fit/v3/ActionOverloadingTestITCase.java | 57 +-
.../apache/olingo/fit/v3/AsyncTestITCase.java | 33 +-
.../fit/v3/AuthEntityRetrieveTestITCase.java | 14 +-
.../apache/olingo/fit/v3/BatchTestITCase.java | 115 +-
.../apache/olingo/fit/v3/CountTestITCase.java | 18 +-
.../olingo/fit/v3/EntityCreateTestITCase.java | 120 +-
.../olingo/fit/v3/EntityRetrieveTestITCase.java | 30 +-
.../olingo/fit/v3/EntitySetTestITCase.java | 18 +-
.../olingo/fit/v3/EntityUpdateTestITCase.java | 60 +-
.../apache/olingo/fit/v3/ErrorTestITCase.java | 18 +-
.../olingo/fit/v3/FilterFactoryTestITCase.java | 70 +-
.../apache/olingo/fit/v3/FilterTestITCase.java | 18 +-
.../apache/olingo/fit/v3/InvokeTestITCase.java | 73 +-
.../olingo/fit/v3/KeyAsSegmentTestITCase.java | 20 +-
.../apache/olingo/fit/v3/LinkTestITCase.java | 37 +-
.../olingo/fit/v3/MediaEntityTestITCase.java | 30 +-
.../olingo/fit/v3/MetadataTestITCase.java | 19 +-
.../olingo/fit/v3/OpenTypeTestITCase.java | 96 +-
.../olingo/fit/v3/PrimitiveKeysTestITCase.java | 16 +-
.../fit/v3/PropertyRetrieveTestITCase.java | 124 +-
.../olingo/fit/v3/PropertyTestITCase.java | 68 +-
.../olingo/fit/v3/PropertyValueTestITCase.java | 44 +-
.../olingo/fit/v3/QueryOptionsTestITCase.java | 32 +-
.../fit/v3/ServiceDocumentTestITCase.java | 19 +-
.../v3/XHTTPMethodEntityUpdateTestITCase.java | 14 +-
.../v3/XHTTPMethodPropertyUpdateTestITCase.java | 14 +-
.../olingo/fit/v4/AbstractTestITCase.java | 38 +-
.../apache/olingo/fit/v4/AsyncTestITCase.java | 44 +-
.../olingo/fit/v4/AuthBatchTestITCase.java | 16 +-
.../apache/olingo/fit/v4/BatchTestITCase.java | 112 +-
.../fit/v4/BoundOperationInvokeTestITCase.java | 232 ++--
.../olingo/fit/v4/ConformanceTestITCase.java | 106 +-
.../apache/olingo/fit/v4/DeltaTestITCase.java | 18 +-
.../olingo/fit/v4/DerivedTypeTestITCase.java | 66 +-
.../olingo/fit/v4/EntityCreateTestITCase.java | 76 +-
.../olingo/fit/v4/EntityRetrieveTestITCase.java | 60 +-
.../olingo/fit/v4/EntitySetTestITCase.java | 22 +-
.../olingo/fit/v4/EntityUpdateTestITCase.java | 50 +-
.../olingo/fit/v4/ErrorResponseTestITCase.java | 22 +-
.../olingo/fit/v4/FilterFactoryTestITCase.java | 20 +-
.../fit/v4/JSONFormatConformanceTestITCase.java | 164 +--
.../olingo/fit/v4/KeyAsSegmentTestITCase.java | 24 +-
.../olingo/fit/v4/MediaEntityTestITCase.java | 40 +-
.../olingo/fit/v4/MetadataTestITCase.java | 34 +-
.../olingo/fit/v4/OpenTypeTestITCase.java | 98 +-
.../fit/v4/OperationImportInvokeTestITCase.java | 128 +-
.../olingo/fit/v4/PropertyTestITCase.java | 55 +-
.../olingo/fit/v4/PropertyValueTestITCase.java | 38 +-
.../olingo/fit/v4/QueryOptionsTestITCase.java | 54 +-
.../fit/v4/ServiceDocumentTestITCase.java | 23 +-
.../olingo/fit/v4/SingletonTestITCase.java | 36 +-
.../apache/olingo/commons/api/Constants.java | 14 +-
.../commons/api/ODataApplicationException.java | 16 +-
.../olingo/commons/api/ODataException.java | 16 +-
.../api/ODataNotImplementedException.java | 16 +-
.../commons/api/ODataRuntimeException.java | 6 +-
.../olingo/commons/api/data/Annotatable.java | 14 +-
.../olingo/commons/api/data/Annotation.java | 14 +-
.../olingo/commons/api/data/ContextURL.java | 25 +-
.../olingo/commons/api/data/DeletedEntity.java | 14 +-
.../apache/olingo/commons/api/data/Delta.java | 14 +-
.../olingo/commons/api/data/DeltaLink.java | 14 +-
.../apache/olingo/commons/api/data/Entity.java | 61 +-
.../olingo/commons/api/data/EntitySet.java | 32 +-
.../olingo/commons/api/data/GeoUtils.java | 70 +-
.../apache/olingo/commons/api/data/Link.java | 42 +-
.../apache/olingo/commons/api/data/Linked.java | 22 +-
.../commons/api/data/LinkedComplexValue.java | 14 +-
.../olingo/commons/api/data/Property.java | 14 +-
.../apache/olingo/commons/api/data/ResWrap.java | 22 +-
.../olingo/commons/api/data/Valuable.java | 27 +-
.../olingo/commons/api/data/ValueType.java | 16 +-
.../commons/api/data/v3/LinkCollection.java | 22 +-
.../api/domain/AbstractODataPayload.java | 16 +-
.../commons/api/domain/AbstractODataValue.java | 26 +-
.../commons/api/domain/CommonODataEntity.java | 53 +-
.../api/domain/CommonODataEntitySet.java | 22 +-
.../api/domain/CommonODataObjectFactory.java | 37 +-
.../commons/api/domain/CommonODataProperty.java | 28 +-
.../api/domain/ODataCollectionValue.java | 24 +-
.../commons/api/domain/ODataComplexValue.java | 24 +-
.../olingo/commons/api/domain/ODataError.java | 24 +-
.../commons/api/domain/ODataErrorDetail.java | 20 +-
.../commons/api/domain/ODataInlineEntity.java | 25 +-
.../api/domain/ODataInlineEntitySet.java | 25 +-
.../commons/api/domain/ODataInvokeResult.java | 19 +-
.../olingo/commons/api/domain/ODataItem.java | 19 +-
.../olingo/commons/api/domain/ODataLink.java | 60 +-
.../commons/api/domain/ODataLinkType.java | 20 +-
.../olingo/commons/api/domain/ODataLinked.java | 26 +-
.../commons/api/domain/ODataOperation.java | 26 +-
.../commons/api/domain/ODataPrimitiveValue.java | 21 +-
.../commons/api/domain/ODataPropertyType.java | 14 +-
.../api/domain/ODataServiceDocument.java | 38 +-
.../olingo/commons/api/domain/ODataValue.java | 28 +-
.../commons/api/domain/v3/ODataEntity.java | 15 +-
.../commons/api/domain/v3/ODataEntitySet.java | 15 +-
.../api/domain/v3/ODataObjectFactory.java | 17 +-
.../commons/api/domain/v3/ODataProperty.java | 18 +-
.../commons/api/domain/v4/ODataAnnotatable.java | 14 +-
.../commons/api/domain/v4/ODataAnnotation.java | 16 +-
.../api/domain/v4/ODataDeletedEntity.java | 14 +-
.../commons/api/domain/v4/ODataDelta.java | 14 +-
.../commons/api/domain/v4/ODataDeltaLink.java | 14 +-
.../commons/api/domain/v4/ODataEntity.java | 17 +-
.../commons/api/domain/v4/ODataEntitySet.java | 19 +-
.../commons/api/domain/v4/ODataEnumValue.java | 14 +-
.../olingo/commons/api/domain/v4/ODataLink.java | 15 +-
.../api/domain/v4/ODataLinkedComplexValue.java | 16 +-
.../api/domain/v4/ODataObjectFactory.java | 17 +-
.../commons/api/domain/v4/ODataProperty.java | 17 +-
.../commons/api/domain/v4/ODataSingleton.java | 17 +-
.../commons/api/domain/v4/ODataValuable.java | 36 +-
.../commons/api/domain/v4/ODataValue.java | 22 +-
.../org/apache/olingo/commons/api/edm/Edm.java | 54 +-
.../olingo/commons/api/edm/EdmAction.java | 16 +-
.../olingo/commons/api/edm/EdmActionImport.java | 18 +-
.../commons/api/edm/EdmActionImportInfo.java | 18 +-
.../olingo/commons/api/edm/EdmAnnotatable.java | 16 +-
.../olingo/commons/api/edm/EdmAnnotation.java | 14 +-
.../olingo/commons/api/edm/EdmAnnotations.java | 16 +-
.../commons/api/edm/EdmAnnotationsTarget.java | 18 +-
.../commons/api/edm/EdmBindingTarget.java | 22 +-
.../olingo/commons/api/edm/EdmComplexType.java | 16 +-
.../olingo/commons/api/edm/EdmElement.java | 16 +-
.../commons/api/edm/EdmEntityContainer.java | 20 +-
.../olingo/commons/api/edm/EdmEntitySet.java | 16 +-
.../commons/api/edm/EdmEntitySetInfo.java | 18 +-
.../olingo/commons/api/edm/EdmEntityType.java | 26 +-
.../olingo/commons/api/edm/EdmEnumType.java | 16 +-
.../olingo/commons/api/edm/EdmException.java | 16 +-
.../olingo/commons/api/edm/EdmFunction.java | 16 +-
.../commons/api/edm/EdmFunctionImport.java | 20 +-
.../commons/api/edm/EdmFunctionImportInfo.java | 18 +-
.../commons/api/edm/EdmKeyPropertyRef.java | 16 +-
.../olingo/commons/api/edm/EdmMappable.java | 18 +-
.../olingo/commons/api/edm/EdmMapping.java | 24 +-
.../olingo/commons/api/edm/EdmMember.java | 16 +-
.../apache/olingo/commons/api/edm/EdmNamed.java | 16 +-
.../api/edm/EdmNavigationPropertyBinding.java | 8 +-
.../olingo/commons/api/edm/EdmOperation.java | 24 +-
.../commons/api/edm/EdmOperationImport.java | 16 +-
.../commons/api/edm/EdmOperationImportInfo.java | 16 +-
.../olingo/commons/api/edm/EdmParameter.java | 16 +-
.../commons/api/edm/EdmPrimitiveType.java | 40 +-
.../api/edm/EdmPrimitiveTypeException.java | 16 +-
.../commons/api/edm/EdmPrimitiveTypeKind.java | 39 +-
.../olingo/commons/api/edm/EdmProperty.java | 20 +-
.../olingo/commons/api/edm/EdmReturnType.java | 16 +-
.../olingo/commons/api/edm/EdmSchema.java | 20 +-
.../commons/api/edm/EdmServiceMetadata.java | 17 +-
.../olingo/commons/api/edm/EdmSingleton.java | 16 +-
.../commons/api/edm/EdmSingletonInfo.java | 18 +-
.../commons/api/edm/EdmStructuredType.java | 36 +-
.../apache/olingo/commons/api/edm/EdmTerm.java | 19 +-
.../apache/olingo/commons/api/edm/EdmType.java | 18 +-
.../commons/api/edm/EdmTypeDefinition.java | 16 +-
.../apache/olingo/commons/api/edm/EdmTyped.java | 18 +-
.../commons/api/edm/FullQualifiedName.java | 10 +-
.../apache/olingo/commons/api/edm/Target.java | 4 +-
.../commons/api/edm/annotation/EdmAnd.java | 14 +-
.../edm/annotation/EdmAnnotationExpression.java | 14 +-
.../api/edm/annotation/EdmAnnotationPath.java | 14 +-
.../commons/api/edm/annotation/EdmApply.java | 17 +-
.../commons/api/edm/annotation/EdmCast.java | 14 +-
.../api/edm/annotation/EdmCollection.java | 14 +-
.../EdmConstantAnnotationExpression.java | 14 +-
.../EdmDynamicAnnotationExpression.java | 14 +-
.../commons/api/edm/annotation/EdmEq.java | 14 +-
.../commons/api/edm/annotation/EdmGe.java | 14 +-
.../commons/api/edm/annotation/EdmGt.java | 14 +-
.../commons/api/edm/annotation/EdmIf.java | 14 +-
.../commons/api/edm/annotation/EdmIsOf.java | 14 +-
.../api/edm/annotation/EdmLabeledElement.java | 14 +-
.../annotation/EdmLabeledElementReference.java | 14 +-
.../commons/api/edm/annotation/EdmLe.java | 14 +-
.../commons/api/edm/annotation/EdmLt.java | 14 +-
.../annotation/EdmNavigationPropertyPath.java | 14 +-
.../commons/api/edm/annotation/EdmNe.java | 14 +-
.../commons/api/edm/annotation/EdmNot.java | 14 +-
.../commons/api/edm/annotation/EdmNull.java | 14 +-
.../commons/api/edm/annotation/EdmOr.java | 14 +-
.../commons/api/edm/annotation/EdmPath.java | 14 +-
.../api/edm/annotation/EdmPropertyPath.java | 14 +-
.../api/edm/annotation/EdmPropertyValue.java | 14 +-
.../commons/api/edm/annotation/EdmRecord.java | 15 +-
...mTwoParamsOpDynamicAnnotationExpression.java | 14 +-
.../commons/api/edm/annotation/EdmUrlRef.java | 14 +-
.../api/edm/constants/EdmContentKind.java | 14 +-
.../commons/api/edm/constants/EdmOnDelete.java | 16 +-
.../commons/api/edm/constants/EdmTypeKind.java | 16 +-
.../api/edm/constants/ODataServiceVersion.java | 35 +-
.../commons/api/edm/geo/ComposedGeospatial.java | 18 +-
.../olingo/commons/api/edm/geo/Geospatial.java | 26 +-
.../api/edm/geo/GeospatialCollection.java | 19 +-
.../olingo/commons/api/edm/geo/LineString.java | 19 +-
.../commons/api/edm/geo/MultiLineString.java | 19 +-
.../olingo/commons/api/edm/geo/MultiPoint.java | 19 +-
.../commons/api/edm/geo/MultiPolygon.java | 19 +-
.../olingo/commons/api/edm/geo/Point.java | 24 +-
.../olingo/commons/api/edm/geo/Polygon.java | 29 +-
.../apache/olingo/commons/api/edm/geo/SRID.java | 24 +-
.../olingo/commons/api/edm/package-info.java | 17 +-
.../olingo/commons/api/format/AcceptType.java | 42 +-
.../olingo/commons/api/format/ContentType.java | 55 +-
.../olingo/commons/api/format/ODataFormat.java | 46 +-
.../olingo/commons/api/http/HttpHeader.java | 2 +-
.../olingo/commons/api/http/HttpMethod.java | 14 +-
.../api/serialization/ODataDeserializer.java | 22 +-
.../ODataDeserializerException.java | 14 +-
.../api/serialization/ODataSerializer.java | 14 +-
.../serialization/ODataSerializerException.java | 14 +-
.../olingo/commons/api/data/ContextURLTest.java | 37 +-
.../commons/api/format/AcceptTypeTest.java | 60 +
.../core/data/AbstractAnnotatedObject.java | 14 +-
.../commons/core/data/AbstractODataObject.java | 18 +-
.../commons/core/data/AbstractValuable.java | 16 +-
.../commons/core/data/AnnotationImpl.java | 14 +-
.../commons/core/data/DeletedEntityImpl.java | 15 +-
.../olingo/commons/core/data/DeltaLinkImpl.java | 15 +-
.../olingo/commons/core/data/EntityImpl.java | 25 +-
.../olingo/commons/core/data/EntitySetImpl.java | 15 +-
.../olingo/commons/core/data/LinkImpl.java | 14 +-
.../core/data/LinkedComplexValueImpl.java | 14 +-
.../commons/core/data/ODataErrorDetailImpl.java | 14 +-
.../commons/core/data/ODataErrorImpl.java | 16 +-
.../olingo/commons/core/data/PropertyImpl.java | 21 +-
.../core/data/v3/LinkCollectionImpl.java | 21 +-
.../olingo/commons/core/data/v4/DeltaImpl.java | 15 +-
.../domain/AbstractODataCollectionValue.java | 31 +-
.../core/domain/AbstractODataComplexValue.java | 31 +-
.../core/domain/AbstractODataEntity.java | 49 +-
.../core/domain/AbstractODataEntitySet.java | 17 +-
.../core/domain/AbstractODataObjectFactory.java | 20 +-
.../domain/AbstractODataPrimitiveValue.java | 22 +-
.../core/domain/AbstractODataProperty.java | 42 +-
.../domain/v3/ODataCollectionValueImpl.java | 14 +-
.../core/domain/v3/ODataComplexValueImpl.java | 14 +-
.../commons/core/domain/v3/ODataEntityImpl.java | 15 +-
.../core/domain/v3/ODataEntitySetImpl.java | 18 +-
.../core/domain/v3/ODataObjectFactoryImpl.java | 29 +-
.../core/domain/v3/ODataPrimitiveValueImpl.java | 16 +-
.../core/domain/v3/ODataPropertyImpl.java | 18 +-
.../core/domain/v4/ODataAnnotationImpl.java | 22 +-
.../domain/v4/ODataCollectionValueImpl.java | 17 +-
.../core/domain/v4/ODataComplexValueImpl.java | 37 +-
.../core/domain/v4/ODataDeletedEntityImpl.java | 15 +-
.../commons/core/domain/v4/ODataDeltaImpl.java | 17 +-
.../core/domain/v4/ODataDeltaLinkImpl.java | 15 +-
.../commons/core/domain/v4/ODataEntityImpl.java | 15 +-
.../core/domain/v4/ODataEntitySetImpl.java | 15 +-
.../core/domain/v4/ODataEnumValueImpl.java | 16 +-
.../core/domain/v4/ODataObjectFactoryImpl.java | 33 +-
.../core/domain/v4/ODataPrimitiveValueImpl.java | 18 +-
.../core/domain/v4/ODataPropertyImpl.java | 25 +-
.../core/domain/v4/ODataValuableImpl.java | 40 +-
.../olingo/commons/core/edm/AbstractEdm.java | 42 +-
.../core/edm/AbstractEdmBindingTarget.java | 23 +-
.../core/edm/AbstractEdmComplexType.java | 8 +-
.../core/edm/AbstractEdmEntityContainer.java | 2 +-
.../commons/core/edm/AbstractEdmEntityType.java | 23 +-
.../commons/core/edm/AbstractEdmEnumType.java | 40 +-
.../core/edm/AbstractEdmKeyPropertyRef.java | 22 +-
.../commons/core/edm/AbstractEdmMember.java | 16 +-
.../core/edm/AbstractEdmNavigationProperty.java | 2 +-
.../commons/core/edm/AbstractEdmOperation.java | 22 +-
.../core/edm/AbstractEdmOperationImport.java | 24 +-
.../commons/core/edm/AbstractEdmParameter.java | 16 +-
.../commons/core/edm/AbstractEdmProperty.java | 14 +-
.../commons/core/edm/AbstractEdmReturnType.java | 16 +-
.../commons/core/edm/AbstractEdmSchema.java | 24 +-
.../core/edm/AbstractEdmStructuredType.java | 10 +-
.../core/edm/AbstractEdmTypeDefinition.java | 30 +-
.../olingo/commons/core/edm/ActionMapKey.java | 24 +-
.../core/edm/EdmActionImportInfoImpl.java | 16 +-
.../commons/core/edm/EdmAnnotationHelper.java | 17 +-
.../olingo/commons/core/edm/EdmElementImpl.java | 16 +-
.../commons/core/edm/EdmEntitySetInfoImpl.java | 16 +-
.../core/edm/EdmFunctionImportInfoImpl.java | 16 +-
.../olingo/commons/core/edm/EdmNamedImpl.java | 14 +-
.../edm/EdmNavigationPropertyBindingImpl.java | 4 +-
.../core/edm/EdmOperationImportInfoImpl.java | 16 +-
.../commons/core/edm/EdmSingletonInfoImpl.java | 16 +-
.../core/edm/EdmStructuredTypeHelper.java | 14 +-
.../olingo/commons/core/edm/EdmTypeInfo.java | 73 +-
.../olingo/commons/core/edm/FunctionMapKey.java | 34 +-
...mAnnotatableDynamicAnnotationExpression.java | 17 +-
.../AbstractEdmAnnotationEspression.java | 14 +-
.../AbstractEdmDynamicAnnotationExpression.java | 16 +-
.../AbstractEdmElementOrAttributeNotation.java | 14 +-
...mTwoParamsOpDynamicAnnotationExpression.java | 18 +-
.../commons/core/edm/annotation/EdmAndImpl.java | 14 +-
.../edm/annotation/EdmAnnotationPathImpl.java | 14 +-
.../core/edm/annotation/EdmApplyImpl.java | 15 +-
.../core/edm/annotation/EdmCollectionImpl.java | 15 +-
.../commons/core/edm/annotation/EdmEqImpl.java | 14 +-
.../commons/core/edm/annotation/EdmGeImpl.java | 14 +-
.../commons/core/edm/annotation/EdmGtImpl.java | 14 +-
.../commons/core/edm/annotation/EdmIfImpl.java | 16 +-
.../edm/annotation/EdmLabeledElementImpl.java | 16 +-
.../EdmLabeledElementReferenceImpl.java | 16 +-
.../commons/core/edm/annotation/EdmLeImpl.java | 14 +-
.../commons/core/edm/annotation/EdmLtImpl.java | 14 +-
.../EdmNavigationPropertyPathImpl.java | 16 +-
.../commons/core/edm/annotation/EdmNeImpl.java | 14 +-
.../commons/core/edm/annotation/EdmNotImpl.java | 14 +-
.../core/edm/annotation/EdmNullImpl.java | 14 +-
.../commons/core/edm/annotation/EdmOrImpl.java | 14 +-
.../core/edm/annotation/EdmPathImpl.java | 14 +-
.../edm/annotation/EdmPropertyPathImpl.java | 14 +-
.../edm/annotation/EdmPropertyValueImpl.java | 16 +-
.../core/edm/annotation/EdmUrlRefImpl.java | 14 +-
.../primitivetype/AbstractGeospatialType.java | 345 +++---
.../primitivetype/AbstractPrimitiveType.java | 44 +-
.../core/edm/primitivetype/EdmBinary.java | 42 +-
.../core/edm/primitivetype/EdmBoolean.java | 34 +-
.../commons/core/edm/primitivetype/EdmByte.java | 40 +-
.../commons/core/edm/primitivetype/EdmDate.java | 34 +-
.../core/edm/primitivetype/EdmDateTime.java | 34 +-
.../edm/primitivetype/EdmDateTimeOffset.java | 76 +-
.../core/edm/primitivetype/EdmDecimal.java | 74 +-
.../core/edm/primitivetype/EdmDouble.java | 54 +-
.../core/edm/primitivetype/EdmDuration.java | 52 +-
.../core/edm/primitivetype/EdmGeography.java | 24 +-
.../primitivetype/EdmGeographyCollection.java | 26 +-
.../primitivetype/EdmGeographyLineString.java | 24 +-
.../EdmGeographyMultiLineString.java | 26 +-
.../primitivetype/EdmGeographyMultiPoint.java | 24 +-
.../primitivetype/EdmGeographyMultiPolygon.java | 24 +-
.../edm/primitivetype/EdmGeographyPoint.java | 24 +-
.../edm/primitivetype/EdmGeographyPolygon.java | 24 +-
.../core/edm/primitivetype/EdmGeometry.java | 24 +-
.../primitivetype/EdmGeometryCollection.java | 26 +-
.../primitivetype/EdmGeometryLineString.java | 24 +-
.../EdmGeometryMultiLineString.java | 26 +-
.../primitivetype/EdmGeometryMultiPoint.java | 24 +-
.../primitivetype/EdmGeometryMultiPolygon.java | 26 +-
.../edm/primitivetype/EdmGeometryPoint.java | 24 +-
.../edm/primitivetype/EdmGeometryPolygon.java | 24 +-
.../commons/core/edm/primitivetype/EdmGuid.java | 36 +-
.../core/edm/primitivetype/EdmInt16.java | 42 +-
.../core/edm/primitivetype/EdmInt32.java | 42 +-
.../core/edm/primitivetype/EdmInt64.java | 48 +-
.../primitivetype/EdmPrimitiveTypeFactory.java | 160 +--
.../core/edm/primitivetype/EdmSByte.java | 36 +-
.../core/edm/primitivetype/EdmSingle.java | 48 +-
.../core/edm/primitivetype/EdmStream.java | 31 +-
.../core/edm/primitivetype/EdmString.java | 31 +-
.../commons/core/edm/primitivetype/EdmTime.java | 16 +-
.../core/edm/primitivetype/EdmTimeOfDay.java | 34 +-
.../primitivetype/SingletonPrimitiveType.java | 16 +-
.../commons/core/edm/primitivetype/Uint7.java | 28 +-
.../core/serialization/AbstractAtomDealer.java | 105 +-
.../core/serialization/AtomDeserializer.java | 34 +-
.../serialization/AtomGeoValueDeserializer.java | 114 +-
.../serialization/AtomGeoValueSerializer.java | 164 +--
.../core/serialization/AtomSerializer.java | 32 +-
.../serialization/JsonDeltaDeserializer.java | 21 +-
.../core/serialization/JsonDeserializer.java | 26 +-
.../serialization/JsonEntityDeserializer.java | 14 +-
.../serialization/JsonEntitySerializer.java | 14 +-
.../JsonEntitySetDeserializer.java | 18 +-
.../serialization/JsonEntitySetSerializer.java | 14 +-
.../serialization/JsonGeoValueDeserializer.java | 122 +-
.../serialization/JsonGeoValueSerializer.java | 140 +--
.../JsonLinkCollectionDeserializer.java | 16 +-
.../JsonODataErrorDeserializer.java | 18 +-
.../JsonODataErrorDetailDeserializer.java | 14 +-
.../serialization/JsonPropertyDeserializer.java | 16 +-
.../serialization/JsonPropertySerializer.java | 26 +-
.../core/serialization/JsonSerializer.java | 22 +-
.../apache/olingo/commons/core/EncoderTest.java | 2 +-
.../commons/core/edm/ActionMapKeyTest.java | 19 +-
.../commons/core/edm/EdmImplCachingTest.java | 24 +-
.../commons/core/edm/EdmImplCallCreateTest.java | 24 +-
.../commons/core/edm/FunctionMapKeyTest.java | 17 +-
.../primitivetype/CommonPrimitiveTypeTest.java | 40 +-
.../core/edm/primitivetype/EdmBinaryTest.java | 42 +-
.../core/edm/primitivetype/EdmBooleanTest.java | 16 +-
.../core/edm/primitivetype/EdmByteTest.java | 16 +-
.../core/edm/primitivetype/EdmDateTest.java | 16 +-
.../primitivetype/EdmDateTimeOffsetTest.java | 26 +-
.../core/edm/primitivetype/EdmDecimalTest.java | 16 +-
.../core/edm/primitivetype/EdmDoubleTest.java | 16 +-
.../core/edm/primitivetype/EdmDurationTest.java | 16 +-
.../core/edm/primitivetype/EdmGeoTest.java | 49 +-
.../core/edm/primitivetype/EdmGuidTest.java | 16 +-
.../core/edm/primitivetype/EdmInt16Test.java | 16 +-
.../core/edm/primitivetype/EdmInt32Test.java | 16 +-
.../core/edm/primitivetype/EdmInt64Test.java | 16 +-
.../core/edm/primitivetype/EdmNullTest.java | 16 +-
.../core/edm/primitivetype/EdmSByteTest.java | 16 +-
.../core/edm/primitivetype/EdmSingleTest.java | 28 +-
.../core/edm/primitivetype/EdmStringTest.java | 16 +-
.../edm/primitivetype/EdmTimeOfDayTest.java | 18 +-
.../primitivetype/PrimitiveTypeBaseTest.java | 54 +-
.../core/edm/primitivetype/UInt7Test.java | 20 +-
lib/server-api/pom.xml | 4 +
.../apache/olingo/server/api/ODataRequest.java | 37 +-
.../api/processor/CollectionProcessor.java | 29 +
.../api/processor/CustomContentTypeSupport.java | 28 +
.../server/api/processor/DefaultProcessor.java | 10 +-
.../api/processor/EntitySetProcessor.java | 29 -
.../api/processor/FormatContentTypeMapping.java | 53 +
.../server/api/processor/MetadataProcessor.java | 2 +-
.../olingo/server/api/ODataRequestTest.java | 66 +
.../olingo/server/core/ContentNegotiator.java | 158 +++
.../server/core/DefaultRedirectProcessor.java | 16 +-
.../apache/olingo/server/core/ODataHandler.java | 86 +-
.../server/core/ODataHttpHandlerImpl.java | 12 +-
.../apache/olingo/server/core/ODataImpl.java | 2 +-
.../core/serializer/ODataXmlSerializerImpl.java | 5 +-
.../serializer/json/ODataJsonSerializer.java | 9 +-
.../json/ServiceDocumentJsonSerializer.java | 2 +-
.../xml/MetadataDocumentXmlSerializer.java | 3 +-
.../server/core/ContentNegotiatorTest.java | 233 ++++
.../server/core/edm/provider/EdmEnumTest.java | 2 +-
.../core/edm/provider/EdmMemberImplTest.java | 6 +-
lib/server-tecsvc/pom.xml | 34 -
.../olingo/server/tecsvc/TechnicalServlet.java | 48 +-
.../server/tecsvc/data/model/EtAllPrim.java | 36 +-
.../server/tecsvc/data/model/EtTwoPrim.java | 8 +-
.../tecsvc/processor/SampleJsonProcessor.java | 82 +-
.../tecsvc/processor/TechnicalProcessor.java | 23 +-
.../tecsvc/provider/ContainerProvider.java | 4 +-
.../src/main/webapp/META-INF/MANIFEST.MF | 8 +-
.../olingo/server/api/ODataRequestTest.java | 45 -
.../olingo/server/core/ODataHandlerTest.java | 22 +-
.../core/uri/testutil/ResourceValidator.java | 2 +-
.../core/uri/validator/UriValidatorTest.java | 7 +-
903 files changed, 34701 insertions(+), 41979 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/66f26e5b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/66f26e5b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
----------------------------------------------------------------------
diff --cc lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
index 536ead1,21304b6..2ea5b9e
--- 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
@@@ -135,60 -147,48 +135,61 @@@ public class ODataJsonSerializer implem
json.writeNull();
}
} else {
- if (edmProperty.isPrimitive()) {
- if (property.isPrimitive()) {
- writePrimitiveValue(edmProperty, property.asPrimitive(), json);
- } else if (property.isGeospatial()) {
- throw new ODataRuntimeException("Property type not yet supported!");
- } else if (property.isEnum()) {
- json.writeString(property.asEnum().toString());
- } else {
- throw new ODataRuntimeException("Inconsistent property type!");
- }
- } else if (edmProperty.isCollection()) {
- json.writeStartArray();
- for (Object value : property.asCollection()) {
- switch (property.getValueType()) {
- case COLLECTION_PRIMITIVE:
- writePrimitiveValue(edmProperty, value, json);
- break;
- case COLLECTION_GEOSPATIAL:
- throw new ODataRuntimeException("Property type not yet supported!");
- case COLLECTION_ENUM:
- json.writeString(value.toString());
- break;
- case COLLECTION_LINKED_COMPLEX:
- writeLinkedComplexValue(edmProperty, (LinkedComplexValue) value, json);
- break;
- default:
- throw new ODataRuntimeException("Property type not yet supported!");
- }
- }
- json.writeEndArray();
+ if (edmProperty.isCollection()) {
+ handleCollection(edmProperty, property, json);
+ } else if (edmProperty.isPrimitive()) {
+ handlePrimitive(edmProperty, property, json);
+ } else if (property.isLinkedComplex()) {
+ writeComplexValue(edmProperty, property.asLinkedComplex().getValue(), json);
+ } else if(property.isComplex()) {
+ writeComplexValue(edmProperty, property.asComplex(), json);
} else {
- if (property.isLinkedComplex()) {
- writeLinkedComplexValue(edmProperty, property.asLinkedComplex(), json);
- } else {
- throw new ODataRuntimeException("Property type not yet supported!");
- }
+ throw new ODataRuntimeException("Property type not yet supported!");
+ }
+ }
+ }
+
+ private void handleCollection(EdmProperty edmProperty, Property property, JsonGenerator json)
+ throws IOException, EdmPrimitiveTypeException {
+ json.writeStartArray();
+ for (Object value : property.asCollection()) {
+ switch (property.getValueType()) {
+ case COLLECTION_PRIMITIVE:
+ writePrimitiveValue(edmProperty, value, json);
+ break;
+ case COLLECTION_GEOSPATIAL:
+ throw new ODataRuntimeException("Property type not yet supported!");
+ case COLLECTION_ENUM:
+ json.writeString(value.toString());
+ break;
+ case COLLECTION_LINKED_COMPLEX:
+ writeComplexValue(edmProperty, ((LinkedComplexValue) value).getValue(), json);
+ break;
+ case COLLECTION_COMPLEX:
+ writeComplexValue(edmProperty, property.asComplex(), json);
+ break;
+ default:
+ throw new ODataRuntimeException("Property type not yet supported!");
}
}
+ json.writeEndArray();
+ }
+
+ private void handlePrimitive(EdmProperty edmProperty, Property property, JsonGenerator json)
+ throws EdmPrimitiveTypeException, IOException {
+ if (property.isPrimitive()) {
+ writePrimitiveValue(edmProperty, property.asPrimitive(), json);
+ } else if (property.isGeospatial()) {
+ throw new ODataRuntimeException("Property type not yet supported!");
+ } else if (property.isEnum()) {
+ json.writeString(property.asEnum().toString());
+ } else {
+ throw new ODataRuntimeException("Inconsistent property type!");
+ }
}
- protected void writePrimitiveValue(final EdmProperty edmProperty, final Object primitiveValue, JsonGenerator json)
+ protected void writePrimitiveValue(final EdmProperty edmProperty, final Object primitiveValue,
+ final JsonGenerator json)
throws EdmPrimitiveTypeException, IOException {
final EdmPrimitiveType type = (EdmPrimitiveType) edmProperty.getType();
final String value = type.valueToString(primitiveValue,
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/66f26e5b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
----------------------------------------------------------------------
diff --cc lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
index bfdede8,e7d6717..e34fd42
--- 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
@@@ -27,10 -27,7 +27,9 @@@ import org.apache.olingo.commons.api.da
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.data.ValueType;
import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
- 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.http.HttpStatusCode;
@@@ -40,88 -37,67 +39,88 @@@ import org.apache.olingo.commons.core.d
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.EntityProcessor;
- import org.apache.olingo.server.api.processor.EntitySetProcessor;
import org.apache.olingo.server.api.serializer.ODataSerializer;
import org.apache.olingo.server.api.uri.UriInfo;
+import org.apache.olingo.server.api.uri.UriResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
- public class SampleJsonProcessor implements EntitySetProcessor, EntityProcessor {
- private static final Logger LOG = LoggerFactory.getLogger(SampleJsonProcessor.class);
+ public class SampleJsonProcessor implements CollectionProcessor, EntityProcessor {
+ private static final Logger LOG = LoggerFactory.getLogger(SampleJsonProcessor.class);
- private OData odata;
- private Edm edm;
+ private OData odata;
+ private Edm edm;
- @Override
- public void init(OData odata, Edm edm) {
- this.odata = odata;
- this.edm = edm;
- }
+ @Override
- public void init(final OData odata, final Edm edm) {
++ public void init(OData odata, Edm edm) {
+ this.odata = odata;
+ this.edm = edm;
+ }
- @Override
- public void readEntitySet(ODataRequest request, ODataResponse response, UriInfo uriInfo, String format) {
- long time = System.nanoTime();
-
- LOG.info((System.nanoTime() - time) / 1000 + " microseconds");
- time = System.nanoTime();
- ODataSerializer serializer = odata.createSerializer(ODataFormat.JSON);
- EdmEntitySet edmEntitySet = getEntitySet(uriInfo);
- ContextURL contextUrl = getContextUrl(request, edmEntitySet.getEntityType());
- EntitySet entitySet = createEntitySet(edmEntitySet.getEntityType(), contextUrl.getURI().toASCIIString());
- response.setContent(serializer.entitySet(edmEntitySet, entitySet, contextUrl));
- LOG.info("Finished in " + (System.nanoTime() - time) / 1000 + " microseconds");
-
- response.setStatusCode(HttpStatusCode.OK.getStatusCode());
- response.setHeader("Content-Type", ContentType.APPLICATION_JSON.toContentTypeString());
- }
+ @Override
- public void readCollection(final ODataRequest request, final ODataResponse response, final UriInfo uriInfo,
- final String format) {
++ public void readCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo, String format) {
+ long time = System.nanoTime();
+
- EntitySet entitySet = createEntitySet();
-
+ LOG.info((System.nanoTime() - time) / 1000 + " microseconds");
+ time = System.nanoTime();
+ ODataSerializer serializer = odata.createSerializer(ODataFormat.JSON);
- response.setContent(serializer.entitySet(
- edm.getEntityContainer(new FullQualifiedName("com.sap.odata.test1", "Container"))
- .getEntitySet("ESAllPrim"),
- entitySet,
- ContextURL.getInstance(URI.create("dummyContextURL"))));
++ EdmEntitySet edmEntitySet = getEntitySet(uriInfo);
++ ContextURL contextUrl = getContextUrl(request, edmEntitySet.getEntityType());
++ EntitySet entitySet = createEntitySet(edmEntitySet.getEntityType(), contextUrl.getURI().toASCIIString());
++ response.setContent(serializer.entitySet(edmEntitySet, entitySet, contextUrl));
+ LOG.info("Finished in " + (System.nanoTime() - time) / 1000 + " microseconds");
+
+ response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+ response.setHeader("Content-Type", ContentType.APPLICATION_JSON.toContentTypeString());
+ }
- @Override
- public void readEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, String format) {
- long time = System.nanoTime();
+ @Override
- public void readEntity(final ODataRequest request, final ODataResponse response, final UriInfo uriInfo,
- final String format) {
++ public void readEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, String format) {
+ long time = System.nanoTime();
- Entity entity = createEntity();
- LOG.info((System.nanoTime() - time) / 1000 + " microseconds");
- time = System.nanoTime();
- ODataSerializer serializer = odata.createSerializer(ODataFormat.JSON);
- EdmEntityType entityType = getEntityType(uriInfo);
- Entity entity = createEntity(entityType);
+ LOG.info((System.nanoTime() - time) / 1000 + " microseconds");
+ time = System.nanoTime();
+ ODataSerializer serializer = odata.createSerializer(ODataFormat.JSON);
- response.setContent(serializer.entity(
- edm.getEntityContainer(new FullQualifiedName("com.sap.odata.test1", "Container"))
- .getEntitySet("ESAllPrim").getEntityType(),
- entity,
- ContextURL.getInstance(URI.create("dummyContextURL"))));
++ EdmEntityType entityType = getEntityType(uriInfo);
++ Entity entity = createEntity(entityType);
+
- response.setContent(serializer.entity(entityType, entity,
- getContextUrl(request, entityType)));
- LOG.info("Finished in " + (System.nanoTime() - time) / 1000 + " microseconds");
++ response.setContent(serializer.entity(entityType, entity,
++ getContextUrl(request, entityType)));
+ LOG.info("Finished in " + (System.nanoTime() - time) / 1000 + " microseconds");
- response.setStatusCode(HttpStatusCode.OK.getStatusCode());
- response.setHeader("Content-Type", ContentType.APPLICATION_JSON.toContentTypeString());
- }
+ response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+ response.setHeader("Content-Type", ContentType.APPLICATION_JSON.toContentTypeString());
+ }
- protected Entity createEntity() {
+ private ContextURL getContextUrl(ODataRequest request, EdmEntityType entityType) {
+ return ContextURL.getInstance(URI.create(request.getRawBaseUri() + "/" + entityType.getName()));
+ }
+
+ public EdmEntityType getEntityType(UriInfo uriInfo) {
+ return getEntitySet(uriInfo).getEntityType();
+ }
+
+ public EdmEntitySet getEntitySet(UriInfo uriInfo) {
+ List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
+ if(resourcePaths.isEmpty()) {
+ throw new RuntimeException("Invalid resource path.");
+ }
+ String entitySetName = resourcePaths.get(resourcePaths.size()-1).toString();
+ return edm.getEntityContainer(new FullQualifiedName("com.sap.odata.test1", "Container"))
+ .getEntitySet(entitySetName);
+ }
+
+ protected Entity createEntity(EdmEntityType entityType) {
+ boolean complex = (entityType.getName().contains("Comp"));
+ if(entityType.getName().contains("Coll")) {
+ return createEntityWithCollection(complex);
+ }
+ return createEntity(complex);
+ }
+
+ protected Entity createEntity(boolean complex) {
Entity entity = new EntityImpl();
Property property = new PropertyImpl();
property.setName("PropertyString");
@@@ -143,88 -114,12 +142,87 @@@
return entity;
}
- protected EntitySet createEntitySet() {
+ protected Entity createEntityWithCollection(boolean complex) {
+ Entity entity = new EntityImpl();
+ Property propertyInt = new PropertyImpl();
+ propertyInt.setName("PropertyInt16");
+ propertyInt.setValue(ValueType.PRIMITIVE, 42);
+ Property property = new PropertyImpl();
+ property.setName("CollPropertyString");
+ property.setValue(ValueType.COLLECTION_PRIMITIVE, Arrays.asList("dummyValue", "dummyValue_2"));
+ entity.getProperties().add(property);
+ entity.getProperties().add(propertyInt);
+ Property propertyGuid = new PropertyImpl();
+ propertyGuid.setName("CollPropertyGuid");
+ propertyGuid.setValue(ValueType.COLLECTION_PRIMITIVE, Arrays.asList(UUID.randomUUID(), UUID.randomUUID()));
+ entity.getProperties().add(propertyGuid);
+
+ if(complex) {
+ entity.addProperty(createCollectionOfComplexProperty());
+ }
+
+ return entity;
+ }
+
+ protected Property createComplexProperty() {
+ List<Property> properties = new ArrayList<Property>();
+ Property property = new PropertyImpl();
+ property.setName("PropertyString");
+ property.setValue(ValueType.PRIMITIVE, "dummyValue");
+ properties.add(property);
+ Property propertyInt = new PropertyImpl();
+ propertyInt.setName("PropertyInt16");
+ propertyInt.setValue(ValueType.PRIMITIVE, 42);
+ properties.add(propertyInt);
+ Property propertyGuid = new PropertyImpl();
+ propertyGuid.setName("PropertyGuid");
+ propertyGuid.setValue(ValueType.PRIMITIVE, UUID.randomUUID());
+ properties.add(propertyGuid);
+
+ return new PropertyImpl("com.sap.odata.test1.ETCompAllPrim", "PropertyComplex", ValueType.COMPLEX,
+ properties);
+ }
+
+ protected Property createCollectionOfComplexProperty() {
+ List<Property> properties = new ArrayList<Property>();
+ Property property = new PropertyImpl();
+ property.setName("PropertyString");
+ property.setValue(ValueType.PRIMITIVE, "dummyValue");
+ properties.add(property);
+ Property propertyInt = new PropertyImpl();
+ propertyInt.setName("PropertyInt16");
+ propertyInt.setValue(ValueType.PRIMITIVE, 42);
+ properties.add(propertyInt);
+ Property propertyGuid = new PropertyImpl();
+ propertyGuid.setName("PropertyGuid");
+ propertyGuid.setValue(ValueType.PRIMITIVE, UUID.randomUUID());
+ properties.add(propertyGuid);
+
+ List<Property> properties2 = new ArrayList<Property>();
+ Property property2 = new PropertyImpl();
+ property2.setName("PropertyString");
+ property2.setValue(ValueType.PRIMITIVE, "dummyValue2");
+ properties2.add(property2);
+ Property property2Int = new PropertyImpl();
+ property2Int.setName("PropertyInt16");
+ property2Int.setValue(ValueType.PRIMITIVE, 44);
+ properties2.add(property2Int);
+ Property property2Guid = new PropertyImpl();
+ property2Guid.setName("PropertyGuid");
+ property2Guid.setValue(ValueType.PRIMITIVE, UUID.randomUUID());
+ properties2.add(property2Guid);
+
+ return new PropertyImpl("com.sap.odata.test1.ETCompAllPrim", "PropertyComplex", ValueType.COMPLEX,
+ Arrays.asList(properties, properties2));
+ }
+
-
+ protected EntitySet createEntitySet(EdmEntityType edmEntityType, String baseUri) {
EntitySet entitySet = new EntitySetImpl();
- entitySet.setCount(4242);
- entitySet.setNext(URI.create("nextLinkURI"));
- for (int i = 0; i < 1000; i++) {
- entitySet.getEntities().add(createEntity());
+ int count = (int) ((Math.random() * 50) + 1);
+ entitySet.setCount(count);
+ entitySet.setNext(URI.create(baseUri + "nextLink"));
+ for (int i = 0; i < count; i++) {
+ entitySet.getEntities().add(createEntity(edmEntityType));
}
return entitySet;
}
[18/18] git commit: [OLINGO-337] merge origin/master
Posted by sk...@apache.org.
[OLINGO-337] merge origin/master
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/233651a8
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/233651a8
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/233651a8
Branch: refs/heads/olingo337
Commit: 233651a8bf9512592a1904f74c05d4b6071af0ba
Parents: 811fff5 f117154
Author: Stephan Klevenz <st...@sap.com>
Authored: Tue Jul 8 10:16:48 2014 +0200
Committer: Stephan Klevenz <st...@sap.com>
Committed: Tue Jul 8 10:16:48 2014 +0200
----------------------------------------------------------------------
.../olingo/commons/api/format/AcceptType.java | 3 +++
.../tecsvc/processor/SampleJsonProcessor.java | 28 +++++++++++---------
2 files changed, 18 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/233651a8/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/AcceptType.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/233651a8/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
----------------------------------------------------------------------
diff --cc lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
index ffb8d7f,b3dc02d..8d43276
--- 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
@@@ -61,9 -58,12 +61,10 @@@ public class SampleJsonProcessor implem
}
@Override
- public void readCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo, String format) {
+ public void readCollection(final ODataRequest request, final ODataResponse response, final UriInfo uriInfo,
+ final ContentType requestedContentType) {
long time = System.nanoTime();
- EntitySet entitySet = createEntitySet();
-
LOG.info((System.nanoTime() - time) / 1000 + " microseconds");
time = System.nanoTime();
ODataSerializer serializer = odata.createSerializer(ODataFormat.JSON);
@@@ -78,50 -79,26 +79,51 @@@
}
@Override
- public void readEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, String format) {
+ public void readEntity(final ODataRequest request, final ODataResponse response, final UriInfo uriInfo,
+ final ContentType requestedContentType) {
long time = System.nanoTime();
- Entity entity = createEntity();
LOG.info((System.nanoTime() - time) / 1000 + " microseconds");
time = System.nanoTime();
ODataSerializer serializer = odata.createSerializer(ODataFormat.JSON);
- response.setContent(serializer.entity(
- edm.getEntityContainer(new FullQualifiedName("com.sap.odata.test1", "Container"))
- .getEntitySet("ESAllPrim").getEntityType(),
- entity,
- ContextURL.getInstance(URI.create("dummyContextURL"))));
+ EdmEntityType entityType = getEntityType(uriInfo);
+ Entity entity = createEntity(entityType);
+
+ response.setContent(serializer.entity(entityType, entity,
- getContextUrl(request, entityType)));
++ getContextUrl(request, entityType)));
LOG.info("Finished in " + (System.nanoTime() - time) / 1000 + " microseconds");
response.setStatusCode(HttpStatusCode.OK.getStatusCode());
response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString());
}
- protected Entity createEntity() {
+ private ContextURL getContextUrl(ODataRequest request, EdmEntityType entityType) {
+ return ContextURL.getInstance(URI.create(request.getRawBaseUri() + "/" + entityType.getName()));
+ }
+
+ public EdmEntityType getEntityType(UriInfo uriInfo) {
+ return getEntitySet(uriInfo).getEntityType();
+ }
+
+ public EdmEntitySet getEntitySet(UriInfo uriInfo) {
+ List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
- if(resourcePaths.isEmpty()) {
++ if (resourcePaths.isEmpty()) {
+ throw new RuntimeException("Invalid resource path.");
+ }
- String entitySetName = resourcePaths.get(resourcePaths.size()-1).toString();
++ String entitySetName = resourcePaths.get(resourcePaths.size() - 1).toString();
+ return edm.getEntityContainer(new FullQualifiedName("com.sap.odata.test1", "Container"))
- .getEntitySet(entitySetName);
++ .getEntitySet(entitySetName);
+ }
+
+ protected Entity createEntity(EdmEntityType entityType) {
+ boolean complex = (entityType.getName().contains("Comp"));
- if(entityType.getName().contains("Coll")) {
++ if (entityType.getName().contains("Coll")) {
+ return createEntityWithCollection(complex);
+ }
+ return createEntity(complex);
+ }
+
+ protected Entity createEntity(boolean complex) {
Entity entity = new EntityImpl();
Property property = new PropertyImpl();
property.setName("PropertyString");
@@@ -135,95 -112,15 +137,95 @@@
propertyGuid.setName("PropertyGuid");
propertyGuid.setValue(ValueType.PRIMITIVE, UUID.randomUUID());
entity.getProperties().add(propertyGuid);
+
- if(complex) {
++ if (complex) {
+ entity.addProperty(createComplexProperty());
+ }
+
return entity;
}
- protected EntitySet createEntitySet() {
+ protected Entity createEntityWithCollection(boolean complex) {
+ Entity entity = new EntityImpl();
+ Property propertyInt = new PropertyImpl();
+ propertyInt.setName("PropertyInt16");
+ propertyInt.setValue(ValueType.PRIMITIVE, 42);
+ Property property = new PropertyImpl();
+ property.setName("CollPropertyString");
+ property.setValue(ValueType.COLLECTION_PRIMITIVE, Arrays.asList("dummyValue", "dummyValue_2"));
+ entity.getProperties().add(property);
+ entity.getProperties().add(propertyInt);
+ Property propertyGuid = new PropertyImpl();
+ propertyGuid.setName("CollPropertyGuid");
+ propertyGuid.setValue(ValueType.COLLECTION_PRIMITIVE, Arrays.asList(UUID.randomUUID(), UUID.randomUUID()));
+ entity.getProperties().add(propertyGuid);
+
- if(complex) {
++ if (complex) {
+ entity.addProperty(createCollectionOfComplexProperty());
+ }
+
+ return entity;
+ }
+
+ protected Property createComplexProperty() {
+ List<Property> properties = new ArrayList<Property>();
+ Property property = new PropertyImpl();
+ property.setName("PropertyString");
+ property.setValue(ValueType.PRIMITIVE, "dummyValue");
+ properties.add(property);
+ Property propertyInt = new PropertyImpl();
+ propertyInt.setName("PropertyInt16");
+ propertyInt.setValue(ValueType.PRIMITIVE, 42);
+ properties.add(propertyInt);
+ Property propertyGuid = new PropertyImpl();
+ propertyGuid.setName("PropertyGuid");
+ propertyGuid.setValue(ValueType.PRIMITIVE, UUID.randomUUID());
+ properties.add(propertyGuid);
+
+ return new PropertyImpl("com.sap.odata.test1.ETCompAllPrim", "PropertyComplex", ValueType.COMPLEX,
- properties);
++ properties);
+ }
+
+ protected Property createCollectionOfComplexProperty() {
+ List<Property> properties = new ArrayList<Property>();
+ Property property = new PropertyImpl();
+ property.setName("PropertyString");
+ property.setValue(ValueType.PRIMITIVE, "dummyValue");
+ properties.add(property);
+ Property propertyInt = new PropertyImpl();
+ propertyInt.setName("PropertyInt16");
+ propertyInt.setValue(ValueType.PRIMITIVE, 42);
+ properties.add(propertyInt);
+ Property propertyGuid = new PropertyImpl();
+ propertyGuid.setName("PropertyGuid");
+ propertyGuid.setValue(ValueType.PRIMITIVE, UUID.randomUUID());
+ properties.add(propertyGuid);
+
+ List<Property> properties2 = new ArrayList<Property>();
+ Property property2 = new PropertyImpl();
+ property2.setName("PropertyString");
+ property2.setValue(ValueType.PRIMITIVE, "dummyValue2");
+ properties2.add(property2);
+ Property property2Int = new PropertyImpl();
+ property2Int.setName("PropertyInt16");
+ property2Int.setValue(ValueType.PRIMITIVE, 44);
+ properties2.add(property2Int);
+ Property property2Guid = new PropertyImpl();
+ property2Guid.setName("PropertyGuid");
+ property2Guid.setValue(ValueType.PRIMITIVE, UUID.randomUUID());
+ properties2.add(property2Guid);
+
+ return new PropertyImpl("com.sap.odata.test1.ETCompAllPrim", "PropertyComplex", ValueType.COMPLEX,
- Arrays.asList(properties, properties2));
++ Arrays.asList(properties, properties2));
+ }
+
+ protected EntitySet createEntitySet(EdmEntityType edmEntityType, String baseUri) {
EntitySet entitySet = new EntitySetImpl();
- entitySet.setCount(4242);
- entitySet.setNext(URI.create("nextLinkURI"));
- for (int i = 0; i < 1000; i++) {
- entitySet.getEntities().add(createEntity());
+ int count = (int) ((Math.random() * 50) + 1);
+ entitySet.setCount(count);
+ entitySet.setNext(URI.create(baseUri + "nextLink"));
+ for (int i = 0; i < count; i++) {
+ entitySet.getEntities().add(createEntity(edmEntityType));
}
return entitySet;
}
[06/18] git commit: [OLINGO-340] Fix
Posted by sk...@apache.org.
[OLINGO-340] Fix
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/15f7de8f
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/15f7de8f
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/15f7de8f
Branch: refs/heads/olingo337
Commit: 15f7de8f6c75f3dd179a9e68037983fa2fa57b84
Parents: 263e428
Author: Francesco Chicchiriccò <--global>
Authored: Fri Jul 4 11:09:42 2014 +0200
Committer: Francesco Chicchiriccò <--global>
Committed: Fri Jul 4 11:09:42 2014 +0200
----------------------------------------------------------------------
.../org/apache/olingo/client/core/edm/EdmEnumTypeImpl.java | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/15f7de8f/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEnumTypeImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEnumTypeImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEnumTypeImpl.java
index 4a76953..cc29e06 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEnumTypeImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEnumTypeImpl.java
@@ -62,11 +62,12 @@ public class EdmEnumTypeImpl extends AbstractEdmEnumType implements EdmEnumType
if (xmlEnumType.getUnderlyingType() == null) {
this.underlyingType = EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Int32);
} else {
- this.underlyingType = EdmPrimitiveTypeFactory.getInstance(
- EdmPrimitiveTypeKind.valueOfFQN(version, xmlEnumType.getUnderlyingType()));
- if (!ArrayUtils.contains(VALID_UNDERLYING_TYPES, this.underlyingType.getKind())) {
- throw new EdmException("Not allowed as underlying type: " + this.underlyingType.getKind());
+ final EdmPrimitiveTypeKind underlyingTipeKind =
+ EdmPrimitiveTypeKind.valueOfFQN(version, xmlEnumType.getUnderlyingType());
+ if (!ArrayUtils.contains(VALID_UNDERLYING_TYPES, underlyingTipeKind)) {
+ throw new EdmException("Not allowed as underlying type: " + underlyingTipeKind);
}
+ this.underlyingType = EdmPrimitiveTypeFactory.getInstance(underlyingTipeKind);
}
final List<? extends Member> xmlMembers = xmlEnumType.getMembers();
[12/18] git commit: [OLINGO-337] BasicITCase
Posted by sk...@apache.org.
[OLINGO-337] BasicITCase
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/32c113df
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/32c113df
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/32c113df
Branch: refs/heads/olingo337
Commit: 32c113df0b88069f130c6ebb4d40cb8f54149579
Parents: f464091
Author: Stephan Klevenz <st...@sap.com>
Authored: Fri Jul 4 08:38:08 2014 +0200
Committer: Stephan Klevenz <st...@sap.com>
Committed: Fri Jul 4 12:21:01 2014 +0200
----------------------------------------------------------------------
.../org/apache/olingo/fit/tecsvc/BasicITCase.java | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/32c113df/fit/src/test/java/org/apache/olingo/fit/tecsvc/BasicITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/BasicITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/BasicITCase.java
index 8c5650f..c188568 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/BasicITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/BasicITCase.java
@@ -20,6 +20,7 @@ package org.apache.olingo.fit.tecsvc;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import org.apache.olingo.client.api.communication.request.retrieve.EdmMetadataRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataServiceDocumentRequest;
@@ -41,6 +42,7 @@ public class BasicITCase {
@Before
public void before() {
odata = ODataClientFactory.getV4();
+ odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
}
@Test
@@ -49,8 +51,17 @@ public class BasicITCase {
odata.getRetrieveRequestFactory().getServiceDocumentRequest(REF_SERVICE);
request.setAccept("application/json;odata.metadata=minimal");
assertNotNull(request);
- ODataServiceDocument serviceDocument = request.execute().getBody();
+
+ ODataRetrieveResponse<ODataServiceDocument> response = request.execute();
+
+ assertEquals(200, response.getStatusCode());
+
+ ODataServiceDocument serviceDocument = response.getBody();
assertNotNull(serviceDocument);
+
+ assertTrue(serviceDocument.getEntitySetNames().contains("ESAllPrim"));
+ assertTrue(serviceDocument.getFunctionImportNames().contains("FICRTCollCTTwoPrim"));
+ assertTrue(serviceDocument.getSingletonNames().contains("SIMedia"));
}
@Test
@@ -66,5 +77,6 @@ public class BasicITCase {
assertEquals("com.sap.odata.test1", edm.getSchema("com.sap.odata.test1").getNamespace());
assertEquals("Namespace1_Alias", edm.getSchema("com.sap.odata.test1").getAlias());
assertNotNull(edm.getTerm(new FullQualifiedName("Core.Description")));
+ assertEquals(2, edm.getSchemas().size());
}
}
[10/18] 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/f4640911
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/f4640911
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/f4640911
Branch: refs/heads/olingo337
Commit: f4640911af9846b9fcf24b116c086a3dc4768069
Parents: 434246a
Author: Stephan Klevenz <st...@sap.com>
Authored: Thu Jul 3 12:54:07 2014 +0200
Committer: Stephan Klevenz <st...@sap.com>
Committed: Fri Jul 4 12:18:25 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/f4640911/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/f4640911/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/f4640911/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/f4640911/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/f4640911/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/f4640911/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 {
+
+}
[13/18] git commit: [OLINGO-317] Merge with current master
Posted by sk...@apache.org.
[OLINGO-317] Merge with current master
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/95e2d8d3
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/95e2d8d3
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/95e2d8d3
Branch: refs/heads/olingo337
Commit: 95e2d8d33911872b606bd1da12c0fcf8271b6bb2
Parents: 66f26e5 098ed14
Author: Michael Bolz <mi...@sap.com>
Authored: Mon Jul 7 07:42:22 2014 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Mon Jul 7 07:42:22 2014 +0200
----------------------------------------------------------------------
.../apache/olingo/fit/tecsvc/BasicITCase.java | 14 ++++++--
.../retrieve/AbstractODataRetrieveRequest.java | 6 +---
.../retrieve/EdmMetadataRequestImpl.java | 10 ++++++
.../retrieve/v4/XMLMetadataRequestImpl.java | 24 ++++++++------
.../olingo/client/core/edm/EdmEnumTypeImpl.java | 9 +++---
lib/server-tecsvc/pom.xml | 34 ++++++++++++++++++++
6 files changed, 76 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
[16/18] git commit: [OLINGO-337] more tests and fixes
Posted by sk...@apache.org.
[OLINGO-337] more tests and fixes
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/aff42fce
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/aff42fce
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/aff42fce
Branch: refs/heads/olingo337
Commit: aff42fcee5e189d5cc506ff1cdc05421528fbeb5
Parents: 6383ab0
Author: Stephan Klevenz <st...@sap.com>
Authored: Tue Jul 8 10:07:16 2014 +0200
Committer: Stephan Klevenz <st...@sap.com>
Committed: Tue Jul 8 10:07:16 2014 +0200
----------------------------------------------------------------------
.../apache/olingo/fit/tecsvc/BasicITCase.java | 3 ++-
.../olingo/commons/api/format/AcceptType.java | 8 +++---
.../olingo/commons/api/format/ContentType.java | 27 ++++++++++----------
.../commons/api/format/AcceptTypeTest.java | 23 +++++++++++++++--
.../server/core/ContentNegotiatorTest.java | 2 +-
5 files changed, 40 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/aff42fce/fit/src/test/java/org/apache/olingo/fit/tecsvc/BasicITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/BasicITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/BasicITCase.java
index c188568..da2f711 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/BasicITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/BasicITCase.java
@@ -30,6 +30,7 @@ import org.apache.olingo.client.core.ODataClientFactory;
import org.apache.olingo.commons.api.domain.ODataServiceDocument;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Before;
import org.junit.Test;
@@ -49,7 +50,6 @@ public class BasicITCase {
public void readServiceDocument() {
ODataServiceDocumentRequest request =
odata.getRetrieveRequestFactory().getServiceDocumentRequest(REF_SERVICE);
- request.setAccept("application/json;odata.metadata=minimal");
assertNotNull(request);
ODataRetrieveResponse<ODataServiceDocument> response = request.execute();
@@ -73,6 +73,7 @@ public class BasicITCase {
assertEquals(200, response.getStatusCode());
Edm edm = response.getBody();
+
assertNotNull(edm);
assertEquals("com.sap.odata.test1", edm.getSchema("com.sap.odata.test1").getNamespace());
assertEquals("Namespace1_Alias", edm.getSchema("com.sap.odata.test1").getAlias());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/aff42fce/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 736b747..12ebf9a 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
@@ -193,9 +193,6 @@ public class AcceptType {
for (final String key : parameters.keySet()) {
result.append(';').append(key).append('=').append(parameters.get(key));
}
- if (quality < 1F) {
- result.append(';').append(TypeUtil.PARAMETER_Q).append('=').append(quality);
- }
return result.toString();
}
@@ -225,8 +222,9 @@ public class AcceptType {
}
Map<String, String> compareParameters = contentType.getParameters();
for (final String key : parameters.keySet()) {
- if (compareParameters.containsKey(key)) {
- if (!parameters.get(key).equalsIgnoreCase(compareParameters.get(key))) {
+ if (compareParameters.containsKey(key) || TypeUtil.PARAMETER_Q.equalsIgnoreCase(key)) {
+ if (!parameters.get(key).equalsIgnoreCase(compareParameters.get(key))
+ && !TypeUtil.PARAMETER_Q.equalsIgnoreCase(key)) {
return false;
}
} else {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/aff42fce/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 a686880..4aee30e 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
@@ -45,31 +45,30 @@ import java.util.TreeMap;
*/
public class ContentType {
-
public static final ContentType APPLICATION_XML = create("application", "xml");
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,
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 =
+ create(APPLICATION_ATOM_XML, TypeUtil.PARAMETER_TYPE, "entry");
public static final ContentType APPLICATION_ATOM_XML_ENTRY_CS_UTF_8 = create(APPLICATION_ATOM_XML_ENTRY,
- TypeUtil. PARAMETER_CHARSET, TypeUtil.CHARSET_UTF_8);
- public static final ContentType APPLICATION_ATOM_XML_FEED =
- create(APPLICATION_ATOM_XML,TypeUtil. 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,
- TypeUtil. PARAMETER_CHARSET,TypeUtil.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,
- TypeUtil. PARAMETER_CHARSET, TypeUtil.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,
- TypeUtil. PARAMETER_CHARSET,TypeUtil. 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, TypeUtil.PARAMETER_CHARSET,TypeUtil. 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");
@@ -209,10 +208,10 @@ public class ContentType {
}
} else {
throw new IllegalArgumentException(
- "Too many '" +TypeUtil.TYPE_SUBTYPE_SEPARATOR + "' in format '" + format + "'.");
+ "Too many '" + TypeUtil.TYPE_SUBTYPE_SEPARATOR + "' in format '" + format + "'.");
}
} else {
- throw new IllegalArgumentException("No separator '" +TypeUtil.TYPE_SUBTYPE_SEPARATOR
+ throw new IllegalArgumentException("No separator '" + TypeUtil.TYPE_SUBTYPE_SEPARATOR
+ "' was found in format '" + format + "'.");
}
@@ -305,7 +304,7 @@ public class ContentType {
}
return compatible.booleanValue();
}
-
+
/**
* Check equal without parameters.
* It is possible that no decision about <code>equal/none equal</code> can be determined a <code>NULL</code> is
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/aff42fce/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 4427bf0..935b001 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
@@ -20,6 +20,7 @@ package org.apache.olingo.commons.api.format;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import java.util.List;
@@ -45,15 +46,33 @@ public class AcceptTypeTest {
assertEquals("a/a", atl.get(0).toString());
}
+ @Test
+ public void testWithQParameter() {
+ List<AcceptType> atl = AcceptType.create("application/json;q=0.2");
+
+ assertEquals(1, atl.size());
+ assertEquals("application", atl.get(0).getType());
+ assertEquals("json", atl.get(0).getSubtype());
+ assertEquals("0.2", atl.get(0).getParameters().get("q"));
+ assertEquals("application/json;q=0.2", atl.get(0).toString());
+ }
+
+ @Test
+ public void testMatchWithQParameter() {
+ List<AcceptType> atl = AcceptType.create("application/json;q=0.2");
+ assertEquals(1, atl.size());
+ assertTrue(atl.get(0).matches(ContentType.APPLICATION_JSON));
+ }
+
@Test(expected = IllegalArgumentException.class)
public void testWrongQParameter() {
AcceptType.create(" a/a;q=z ");
}
-
+
@Test
public void testWildcard() {
List<AcceptType> atl = AcceptType.create("*; q=.2");
-
+
assertNotNull(atl);
assertEquals(1, atl.size());
assertEquals("*", atl.get(0).getType());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/aff42fce/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 88896da..6c1d67f 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
@@ -104,7 +104,7 @@ public class ContentNegotiatorTest {
@Test
public void testServiceDocumentSingleCase() {
- String[] useCase = { ACCEPT_CASE_FULL, null, ACCEPT_CASE_FULL, "dummy", ACCEPT_CASE_FULL };
+ String[] useCase = { "application/json", null, ACCEPT_CASE_JSON, null, null };
testContentNegotiation(useCase, ServiceDocumentProcessor.class);
}