You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by il...@apache.org on 2014/03/28 17:09:39 UTC
[1/3] [OLINGO-200] V4 Atom and JSON parsers on their way - still to
refine, but most features are in, and specific tests were added
Repository: olingo-odata4
Updated Branches:
refs/heads/olingo200 bc398d3da -> 3c4d7d176
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomPropertyDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomPropertyDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomPropertyDeserializer.java
index fd466ea..1e60a3c 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomPropertyDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomPropertyDeserializer.java
@@ -18,8 +18,6 @@
*/
package org.apache.olingo.commons.core.data;
-import java.net.URI;
-import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.Attribute;
@@ -28,7 +26,6 @@ import javax.xml.stream.events.XMLEvent;
import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.commons.api.Constants;
import org.apache.olingo.commons.api.data.CollectionValue;
-import org.apache.olingo.commons.api.data.ComplexValue;
import org.apache.olingo.commons.api.data.Value;
import org.apache.olingo.commons.api.domain.ODataPropertyType;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
@@ -73,17 +70,24 @@ class AtomPropertyDeserializer extends AbstractAtomDealer {
return value;
}
- private ComplexValue fromComplex(final XMLEventReader reader, final StartElement start)
+ private Value fromComplexOrEnum(final XMLEventReader reader, final StartElement start)
throws XMLStreamException {
- final ComplexValue value = new ComplexValueImpl();
+ Value value = null;
boolean foundEndProperty = false;
while (reader.hasNext() && !foundEndProperty) {
final XMLEvent event = reader.nextEvent();
if (event.isStartElement()) {
- value.get().add(deserialize(reader, event.asStartElement()));
+ if (value == null) {
+ value = new ComplexValueImpl();
+ }
+ value.asComplex().get().add(deserialize(reader, event.asStartElement()));
+ }
+
+ if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
+ value = new EnumValueImpl(event.asCharacters().getData());
}
if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
@@ -108,9 +112,10 @@ class AtomPropertyDeserializer extends AbstractAtomDealer {
final XMLEvent event = reader.nextEvent();
if (event.isStartElement()) {
- switch (guessPropertyType(reader)) {
+ switch (guessPropertyType(reader, typeInfo)) {
case COMPLEX:
- value.get().add(fromComplex(reader, event.asStartElement()));
+ case ENUM:
+ value.get().add(fromComplexOrEnum(reader, event.asStartElement()));
break;
case PRIMITIVE:
@@ -130,7 +135,9 @@ class AtomPropertyDeserializer extends AbstractAtomDealer {
return value;
}
- private ODataPropertyType guessPropertyType(final XMLEventReader reader) throws XMLStreamException {
+ private ODataPropertyType guessPropertyType(final XMLEventReader reader, final EdmTypeInfo typeInfo)
+ throws XMLStreamException {
+
XMLEvent child = null;
while (reader.hasNext() && child == null) {
final XMLEvent event = reader.peek();
@@ -143,7 +150,9 @@ class AtomPropertyDeserializer extends AbstractAtomDealer {
final ODataPropertyType type;
if (child == null) {
- type = ODataPropertyType.PRIMITIVE;
+ type = typeInfo == null || typeInfo.isPrimitiveType()
+ ? ODataPropertyType.PRIMITIVE
+ : ODataPropertyType.ENUM;
} else {
if (child.isStartElement()) {
if (Constants.NS_GML.equals(child.asStartElement().getName().getNamespaceURI())) {
@@ -154,7 +163,9 @@ class AtomPropertyDeserializer extends AbstractAtomDealer {
type = ODataPropertyType.COMPLEX;
}
} else if (child.isCharacters()) {
- type = ODataPropertyType.PRIMITIVE;
+ type = typeInfo == null || typeInfo.isPrimitiveType()
+ ? ODataPropertyType.PRIMITIVE
+ : ODataPropertyType.ENUM;
} else {
type = ODataPropertyType.EMPTY;
}
@@ -165,20 +176,17 @@ class AtomPropertyDeserializer extends AbstractAtomDealer {
public AtomPropertyImpl deserialize(final XMLEventReader reader, final StartElement start)
throws XMLStreamException {
- final AtomPropertyImpl property = new AtomPropertyImpl();
-
- final Attribute context = start.getAttributeByName(contextQName);
- property.setContextURL(context == null ? null : URI.create(context.getValue()));
-
- final QName name = start.getName();
+ final AtomPropertyImpl property = new AtomPropertyImpl();
- if (ODataServiceVersion.V40 == version && v4PropertyValueQName.equals(name)) {
+ if (ODataServiceVersion.V40 == version && v4PropertyValueQName.equals(start.getName())) {
// retrieve name from context
- final String contextURL = property.getContextURL().toASCIIString();
- property.setName(contextURL.substring(contextURL.lastIndexOf("/") + 1));
+ final Attribute context = start.getAttributeByName(contextQName);
+ if (context != null) {
+ property.setName(StringUtils.substringAfterLast(context.getValue(), "/"));
+ }
} else {
- property.setName(name.getLocalPart());
+ property.setName(start.getName().getLocalPart());
}
final Attribute nullAttr = start.getAttributeByName(this.nullQName);
@@ -197,7 +205,7 @@ class AtomPropertyDeserializer extends AbstractAtomDealer {
}
final ODataPropertyType propType = typeInfo == null
- ? guessPropertyType(reader)
+ ? guessPropertyType(reader, typeInfo)
: typeInfo.isCollection()
? ODataPropertyType.COLLECTION
: typeInfo.isPrimitiveType()
@@ -210,7 +218,7 @@ class AtomPropertyDeserializer extends AbstractAtomDealer {
break;
case COMPLEX:
- value = fromComplex(reader, start);
+ value = fromComplexOrEnum(reader, start);
break;
case PRIMITIVE:
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomPropertySerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomPropertySerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomPropertySerializer.java
index 412a127..0461ad2 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomPropertySerializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomPropertySerializer.java
@@ -26,6 +26,7 @@ import org.apache.olingo.commons.api.data.CollectionValue;
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.data.Value;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.core.edm.EdmTypeInfo;
class AtomPropertySerializer extends AbstractAtomDealer {
@@ -38,16 +39,23 @@ class AtomPropertySerializer extends AbstractAtomDealer {
private void collection(final XMLStreamWriter writer, final CollectionValue value) throws XMLStreamException {
for (Value item : value.get()) {
- writer.writeStartElement(Constants.PREFIX_DATASERVICES, Constants.ELEM_ELEMENT,
- version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES));
+ if (version == ODataServiceVersion.V30) {
+ writer.writeStartElement(Constants.PREFIX_DATASERVICES, Constants.ELEM_ELEMENT,
+ version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES));
+ } else {
+ writer.writeStartElement(Constants.PREFIX_METADATA, Constants.ELEM_ELEMENT,
+ version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA));
+ }
value(writer, item);
writer.writeEndElement();
}
}
private void value(final XMLStreamWriter writer, final Value value) throws XMLStreamException {
- if (value.isSimple()) {
- writer.writeCharacters(value.asSimple().get());
+ if (value.isPrimitive()) {
+ writer.writeCharacters(value.asPrimitive().get());
+ } else if (value.isEnum()) {
+ writer.writeCharacters(value.asEnum().get());
} else if (value.isGeospatial()) {
this.geoSerializer.serialize(writer, value.asGeospatial().get());
} else if (value.isCollection()) {
@@ -62,22 +70,34 @@ class AtomPropertySerializer extends AbstractAtomDealer {
public void property(final XMLStreamWriter writer, final Property property, final boolean standalone)
throws XMLStreamException {
- writer.writeStartElement(Constants.PREFIX_DATASERVICES, property.getName(),
- version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES));
-
- if (version == ODataServiceVersion.V40 && property.getContextURL() != null) {
- writer.writeAttribute(
- version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA),
- Constants.CONTEXT,
- property.getContextURL().toASCIIString());
+ if (version == ODataServiceVersion.V40 && standalone) {
+ writer.writeStartElement(Constants.PREFIX_METADATA, Constants.VALUE,
+ version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES));
+ } else {
+ writer.writeStartElement(Constants.PREFIX_DATASERVICES, property.getName(),
+ version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES));
}
if (standalone) {
namespaces(writer);
}
+
if (StringUtils.isNotBlank(property.getType())) {
+ String type = property.getType();
+ if (version == ODataServiceVersion.V40) {
+ final EdmTypeInfo typeInfo = new EdmTypeInfo.Builder().setTypeExpression(property.getType()).build();
+ if (typeInfo.isPrimitiveType()) {
+ if (typeInfo.isCollection()) {
+ type = "#Collection(" + typeInfo.getFullQualifiedName().getName() + ")";
+ } else {
+ type = typeInfo.getFullQualifiedName().getName();
+ }
+ } else {
+ type = "#" + property.getType();
+ }
+ }
writer.writeAttribute(Constants.PREFIX_METADATA, version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA),
- Constants.ATTR_TYPE, property.getType());
+ Constants.ATTR_TYPE, type);
}
if (property.getValue().isNull()) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomSerializer.java
index 4bcd3bf..c3be420 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomSerializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomSerializer.java
@@ -127,13 +127,6 @@ public class AtomSerializer extends AbstractAtomDealer {
}
private void entry(final XMLStreamWriter writer, final Entry entry) throws XMLStreamException {
- if (version == ODataServiceVersion.V40 && entry.getContextURL() != null) {
- writer.writeAttribute(
- version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA),
- Constants.CONTEXT,
- entry.getContextURL().toASCIIString());
- }
-
if (entry.getBaseURI() != null) {
writer.writeAttribute(XMLConstants.XML_NS_URI, Constants.ATTR_XML_BASE, entry.getBaseURI().toASCIIString());
}
@@ -191,13 +184,6 @@ public class AtomSerializer extends AbstractAtomDealer {
}
private void feed(final XMLStreamWriter writer, final Feed feed) throws XMLStreamException {
- if (version == ODataServiceVersion.V40 && feed.getContextURL() != null) {
- writer.writeAttribute(
- version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA),
- Constants.CONTEXT,
- feed.getContextURL().toASCIIString());
- }
-
if (feed.getBaseURI() != null) {
writer.writeAttribute(XMLConstants.XML_NS_URI, Constants.ATTR_XML_BASE, feed.getBaseURI().toASCIIString());
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EnumValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EnumValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EnumValueImpl.java
new file mode 100644
index 0000000..5d79d22
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EnumValueImpl.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.commons.core.data;
+
+import org.apache.olingo.commons.api.data.EnumValue;
+
+public class EnumValueImpl extends AbstractValue implements EnumValue {
+
+ private final String value;
+
+ public EnumValueImpl(final String value) {
+ this.value = value;
+ }
+
+ @Override
+ public boolean isEnum() {
+ return true;
+ }
+
+ @Override
+ public String get() {
+ return value;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntryDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntryDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntryDeserializer.java
index e87daa0..eaaa653 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntryDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntryDeserializer.java
@@ -88,13 +88,17 @@ public class JSONEntryDeserializer extends AbstractJsonDeserializer<JSONEntryImp
final JSONEntryImpl entry = new JSONEntryImpl();
+ String contextURL = null;
if (tree.hasNonNull(Constants.JSON_CONTEXT)) {
- entry.setContextURL(URI.create(tree.get(Constants.JSON_CONTEXT).textValue()));
+ contextURL = tree.get(Constants.JSON_CONTEXT).textValue();
tree.remove(Constants.JSON_CONTEXT);
} else if (tree.hasNonNull(Constants.JSON_METADATA)) {
- entry.setContextURL(URI.create(tree.get(Constants.JSON_METADATA).textValue()));
+ contextURL = tree.get(Constants.JSON_METADATA).textValue();
tree.remove(Constants.JSON_METADATA);
}
+ if (contextURL != null) {
+ entry.setBaseURI(contextURL.substring(0, contextURL.indexOf(Constants.METADATA)));
+ }
if (tree.hasNonNull(Constants.JSON_MEDIA_ETAG)) {
entry.setMediaETag(tree.get(Constants.JSON_MEDIA_ETAG).textValue());
@@ -106,40 +110,40 @@ public class JSONEntryDeserializer extends AbstractJsonDeserializer<JSONEntryImp
tree.remove(Constants.JSON_ETAG);
}
- if (tree.hasNonNull(Constants.JSON_TYPE)) {
- entry.setType(tree.get(Constants.JSON_TYPE).textValue());
- tree.remove(Constants.JSON_TYPE);
+ if (tree.hasNonNull(jsonType)) {
+ entry.setType(tree.get(jsonType).textValue());
+ tree.remove(jsonType);
}
- if (tree.hasNonNull(Constants.JSON_ID)) {
- entry.setId(tree.get(Constants.JSON_ID).textValue());
- tree.remove(Constants.JSON_ID);
+ if (tree.hasNonNull(jsonId)) {
+ entry.setId(tree.get(jsonId).textValue());
+ tree.remove(jsonId);
}
- if (tree.hasNonNull(Constants.JSON_READ_LINK)) {
+ if (tree.hasNonNull(jsonReadLink)) {
final LinkImpl link = new LinkImpl();
link.setRel(Constants.SELF_LINK_REL);
- link.setHref(tree.get(Constants.JSON_READ_LINK).textValue());
+ link.setHref(tree.get(jsonReadLink).textValue());
entry.setSelfLink(link);
- tree.remove(Constants.JSON_READ_LINK);
+ tree.remove(jsonReadLink);
}
- if (tree.hasNonNull(Constants.JSON_EDIT_LINK)) {
+ if (tree.hasNonNull(jsonEditLink)) {
final LinkImpl link = new LinkImpl();
link.setRel(Constants.EDIT_LINK_REL);
- link.setHref(tree.get(Constants.JSON_EDIT_LINK).textValue());
+ link.setHref(tree.get(jsonEditLink).textValue());
entry.setEditLink(link);
- tree.remove(Constants.JSON_EDIT_LINK);
+ tree.remove(jsonEditLink);
}
- if (tree.hasNonNull(Constants.JSON_MEDIAREAD_LINK)) {
- entry.setMediaContentSource(tree.get(Constants.JSON_MEDIAREAD_LINK).textValue());
- tree.remove(Constants.JSON_MEDIAREAD_LINK);
+ if (tree.hasNonNull(jsonMediaReadLink)) {
+ entry.setMediaContentSource(tree.get(jsonMediaReadLink).textValue());
+ tree.remove(jsonMediaReadLink);
}
- if (tree.hasNonNull(Constants.JSON_MEDIAEDIT_LINK)) {
- tree.remove(Constants.JSON_MEDIAEDIT_LINK);
+ if (tree.hasNonNull(jsonMediaEditLink)) {
+ tree.remove(jsonMediaEditLink);
}
if (tree.hasNonNull(Constants.JSON_MEDIA_CONTENT_TYPE)) {
entry.setMediaContentType(tree.get(Constants.JSON_MEDIA_CONTENT_TYPE).textValue());
@@ -150,7 +154,7 @@ public class JSONEntryDeserializer extends AbstractJsonDeserializer<JSONEntryImp
for (final Iterator<Map.Entry<String, JsonNode>> itor = tree.fields(); itor.hasNext();) {
final Map.Entry<String, JsonNode> field = itor.next();
- if (field.getKey().endsWith(Constants.JSON_NAVIGATION_LINK_SUFFIX)) {
+ if (field.getKey().endsWith(jsonNavigationLink)) {
final LinkImpl link = new LinkImpl();
link.setTitle(getTitle(field));
link.setRel(version.getNamespaceMap().get(ODataServiceVersion.NAVIGATION_LINK_REL) + getTitle(field));
@@ -168,8 +172,8 @@ public class JSONEntryDeserializer extends AbstractJsonDeserializer<JSONEntryImp
entry.getNavigationLinks().add(link);
toRemove.add(field.getKey());
- toRemove.add(setInline(field.getKey(), Constants.JSON_NAVIGATION_LINK_SUFFIX, tree, parser.getCodec(), link));
- } else if (field.getKey().endsWith(Constants.JSON_ASSOCIATION_LINK_SUFFIX)) {
+ toRemove.add(setInline(field.getKey(), jsonNavigationLink, tree, parser.getCodec(), link));
+ } else if (field.getKey().endsWith(jsonAssociationLink)) {
final LinkImpl link = new LinkImpl();
link.setTitle(getTitle(field));
link.setRel(version.getNamespaceMap().get(ODataServiceVersion.ASSOCIATION_LINK_REL) + getTitle(field));
@@ -178,7 +182,7 @@ public class JSONEntryDeserializer extends AbstractJsonDeserializer<JSONEntryImp
entry.getAssociationLinks().add(link);
toRemove.add(field.getKey());
- } else if (field.getKey().endsWith(Constants.JSON_MEDIAEDIT_LINK_SUFFIX)) {
+ } else if (field.getKey().endsWith(getJSONAnnotation(jsonMediaEditLink))) {
final LinkImpl link = new LinkImpl();
link.setTitle(getTitle(field));
link.setRel(version.getNamespaceMap().get(ODataServiceVersion.MEDIA_EDIT_LINK_REL) + getTitle(field));
@@ -192,7 +196,7 @@ public class JSONEntryDeserializer extends AbstractJsonDeserializer<JSONEntryImp
}
toRemove.add(field.getKey());
- toRemove.add(setInline(field.getKey(), Constants.JSON_MEDIAEDIT_LINK_SUFFIX, tree, parser.getCodec(), link));
+ toRemove.add(setInline(field.getKey(), getJSONAnnotation(jsonMediaEditLink), tree, parser.getCodec(), link));
} else if (field.getKey().endsWith(Constants.JSON_MEDIA_CONTENT_TYPE)) {
final String linkTitle = getTitle(field);
for (Link link : entry.getMediaEditLinks()) {
@@ -220,7 +224,7 @@ public class JSONEntryDeserializer extends AbstractJsonDeserializer<JSONEntryImp
for (final Iterator<Map.Entry<String, JsonNode>> itor = tree.fields(); itor.hasNext();) {
final Map.Entry<String, JsonNode> field = itor.next();
- if (type == null && field.getKey().endsWith(Constants.JSON_TYPE_SUFFIX)) {
+ if (type == null && field.getKey().endsWith(getJSONAnnotation(jsonType))) {
type = field.getValue().asText();
} else {
final JSONPropertyImpl property = new JSONPropertyImpl();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntryImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntryImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntryImpl.java
index 10123d4..a83332a 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntryImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntryImpl.java
@@ -20,8 +20,6 @@ package org.apache.olingo.commons.core.data;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import java.net.URI;
-import org.apache.olingo.commons.api.Constants;
/**
* A single entry, represented via JSON.
@@ -34,17 +32,6 @@ public class JSONEntryImpl extends AbstractEntry {
private String mediaETag;
- @Override
- public URI getBaseURI() {
- URI baseURI = null;
- if (getContextURL() != null) {
- final String metadataURI = getContextURL().toASCIIString();
- baseURI = URI.create(metadataURI.substring(0, metadataURI.indexOf(Constants.METADATA)));
- }
-
- return baseURI;
- }
-
/**
* The odata.mediaEtag annotation MAY be included; its value MUST be the ETag of the binary stream represented by this
* media entity or named stream property.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntrySerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntrySerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntrySerializer.java
index bd5a145..eb51362 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntrySerializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntrySerializer.java
@@ -45,14 +45,8 @@ public class JSONEntrySerializer extends AbstractJsonSerializer<JSONEntryImpl> {
jgen.writeStartObject();
- if (entry.getContextURL() != null) {
- jgen.writeStringField(
- version == ODataServiceVersion.V40 ? Constants.JSON_CONTEXT : Constants.JSON_METADATA,
- entry.getContextURL().toASCIIString());
- }
-
if (entry.getId() != null) {
- jgen.writeStringField(Constants.JSON_ID, entry.getId());
+ jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_ID), entry.getId());
}
final Map<String, List<String>> entitySetLinks = new HashMap<String, List<String>>();
@@ -100,7 +94,7 @@ public class JSONEntrySerializer extends AbstractJsonSerializer<JSONEntryImpl> {
for (Link link : entry.getMediaEditLinks()) {
if (link.getTitle() == null) {
- jgen.writeStringField(Constants.JSON_MEDIAEDIT_LINK, link.getHref());
+ jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK), link.getHref());
}
if (link.getInlineEntry() != null) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONFeedImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONFeedImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONFeedImpl.java
index e89bb1f..8994e88 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONFeedImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONFeedImpl.java
@@ -51,22 +51,14 @@ public class JSONFeedImpl extends AbstractPayloadObject implements Feed {
@Override
public URI getBaseURI() {
URI baseURI = null;
- if (getContextURL() != null) {
- final String metadataURI = getContextURL().toASCIIString();
+ if (contextURL != null) {
+ final String metadataURI = contextURL.toASCIIString();
baseURI = URI.create(metadataURI.substring(0, metadataURI.indexOf(Constants.METADATA)));
}
return baseURI;
}
- /**
- * {@inheritDoc}
- */
- @Override
- public URI getContextURL() {
- return contextURL;
- }
-
public void setContextURL(final URI context) {
this.contextURL = context;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONFeedSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONFeedSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONFeedSerializer.java
index df359b8..649bc99 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONFeedSerializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONFeedSerializer.java
@@ -34,13 +34,8 @@ public class JSONFeedSerializer extends AbstractJsonSerializer<JSONFeedImpl> {
jgen.writeStartObject();
- if (feed.getContextURL() != null) {
- jgen.writeStringField(
- version == ODataServiceVersion.V40 ? Constants.JSON_CONTEXT : Constants.JSON_METADATA,
- feed.getContextURL().toASCIIString());
- }
if (feed.getId() != null) {
- jgen.writeStringField(Constants.JSON_ID, feed.getId());
+ jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_ID), feed.getId());
}
if (feed.getCount() != null) {
jgen.writeNumberField(Constants.JSON_COUNT, feed.getCount());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertyDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertyDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertyDeserializer.java
index 8af23e1..1215c5d 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertyDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertyDeserializer.java
@@ -23,7 +23,6 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.io.IOException;
-import java.net.URI;
import org.apache.olingo.commons.api.Constants;
/**
@@ -41,24 +40,24 @@ public class JSONPropertyDeserializer extends AbstractJsonDeserializer<JSONPrope
final JSONPropertyImpl property = new JSONPropertyImpl();
+ String contextURL = null;
if (tree.hasNonNull(Constants.JSON_CONTEXT)) {
- property.setContextURL(URI.create(tree.get(Constants.JSON_CONTEXT).textValue()));
+ contextURL = tree.get(Constants.JSON_CONTEXT).textValue();
tree.remove(Constants.JSON_CONTEXT);
} else if (tree.hasNonNull(Constants.JSON_METADATA)) {
- property.setContextURL(URI.create(tree.get(Constants.JSON_METADATA).textValue()));
+ contextURL = tree.get(Constants.JSON_METADATA).textValue();
tree.remove(Constants.JSON_METADATA);
}
- if (property.getContextURL() != null) {
- final String contextURL = property.getContextURL().toASCIIString();
+ if (contextURL != null) {
final int dashIdx = contextURL.lastIndexOf('#');
if (dashIdx != -1) {
property.setType(contextURL.substring(dashIdx + 1));
}
}
- if (tree.has(Constants.JSON_TYPE) && property.getType() == null) {
- property.setType(tree.get(Constants.JSON_TYPE).asText());
+ if (tree.has(jsonType) && property.getType() == null) {
+ property.setType(tree.get(jsonType).asText());
}
if (tree.has(Constants.JSON_NULL) && tree.get(Constants.JSON_NULL).asBoolean()) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertySerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertySerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertySerializer.java
index ce5f891..d1804eb 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertySerializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertySerializer.java
@@ -24,7 +24,6 @@ import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.IOException;
import org.apache.olingo.commons.api.Constants;
import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
/**
* Writes out JSON string from <tt>JSONPropertyImpl</tt>.
@@ -39,16 +38,12 @@ public class JSONPropertySerializer extends AbstractJsonSerializer<JSONPropertyI
jgen.writeStartObject();
- if (property.getContextURL() != null) {
- jgen.writeStringField(
- version == ODataServiceVersion.V40 ? Constants.JSON_CONTEXT : Constants.JSON_METADATA,
- property.getContextURL().toASCIIString());
- }
-
if (property.getValue().isNull()) {
jgen.writeBooleanField(Constants.JSON_NULL, true);
- } else if (property.getValue().isSimple()) {
- jgen.writeStringField(Constants.VALUE, property.getValue().asSimple().get());
+ } else if (property.getValue().isPrimitive()) {
+ jgen.writeStringField(Constants.VALUE, property.getValue().asPrimitive().get());
+ } else if (property.getValue().isEnum()) {
+ jgen.writeStringField(Constants.VALUE, property.getValue().asEnum().get());
} else if (property.getValue().isGeospatial() || property.getValue().isCollection()) {
property(jgen, property, Constants.VALUE);
} else if (property.getValue().isComplex()) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataJacksonDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataJacksonDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataJacksonDeserializer.java
index e882be2..baf418d 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataJacksonDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataJacksonDeserializer.java
@@ -30,14 +30,44 @@ public abstract class ODataJacksonDeserializer<T> extends JsonDeserializer<T> {
protected ODataServiceVersion version;
+ protected String jsonType;
+
+ protected String jsonId;
+
+ protected String jsonReadLink;
+
+ protected String jsonEditLink;
+
+ protected String jsonMediaEditLink;
+
+ protected String jsonMediaReadLink;
+
+ protected String jsonAssociationLink;
+
+ protected String jsonNavigationLink;
+
protected abstract T doDeserialize(JsonParser jp, DeserializationContext ctxt)
throws IOException, JsonProcessingException;
+ protected String getJSONAnnotation(final String string) {
+ return string.startsWith("@") ? string : "@" + string;
+ }
+
@Override
public T deserialize(final JsonParser jp, final DeserializationContext ctxt)
throws IOException, JsonProcessingException {
version = (ODataServiceVersion) ctxt.findInjectableValue(ODataServiceVersion.class.getName(), null, null);
+
+ jsonType = version.getJSONMap().get(ODataServiceVersion.JSON_TYPE);
+ jsonId = version.getJSONMap().get(ODataServiceVersion.JSON_ID);
+ jsonReadLink = version.getJSONMap().get(ODataServiceVersion.JSON_READ_LINK);
+ jsonEditLink = version.getJSONMap().get(ODataServiceVersion.JSON_EDIT_LINK);
+ jsonMediaReadLink = version.getJSONMap().get(ODataServiceVersion.JSON_MEDIAREAD_LINK);
+ jsonMediaEditLink = version.getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK);
+ jsonAssociationLink = version.getJSONMap().get(ODataServiceVersion.JSON_ASSOCIATION_LINK);
+ jsonNavigationLink = version.getJSONMap().get(ODataServiceVersion.JSON_NAVIGATION_LINK);
+
return doDeserialize(jp, ctxt);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PrimitiveValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PrimitiveValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PrimitiveValueImpl.java
index 2d0a6bc..b3334ae 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PrimitiveValueImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PrimitiveValueImpl.java
@@ -29,7 +29,7 @@ public class PrimitiveValueImpl extends AbstractValue implements PrimitiveValue
}
@Override
- public boolean isSimple() {
+ public boolean isPrimitive() {
return true;
}
[3/3] git commit: Merge branch 'olingo200' of
https://git-wip-us.apache.org/repos/asf/olingo-odata4 into olingo200
Posted by il...@apache.org.
Merge branch 'olingo200' of https://git-wip-us.apache.org/repos/asf/olingo-odata4 into olingo200
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/3c4d7d17
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/3c4d7d17
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/3c4d7d17
Branch: refs/heads/olingo200
Commit: 3c4d7d17674d785bfddf3d5dfd17f8118131eb96
Parents: ce18b8e bc398d3
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Fri Mar 28 17:07:46 2014 +0100
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Fri Mar 28 17:07:46 2014 +0100
----------------------------------------------------------------------
fit/pom.xml | 12 ++
fit/src/main/resources/v4/services.full.json | 126 +++++++++++++++++++
fit/src/main/resources/v4/services.xml | 102 +++++++++++++++
.../retrieve/ODataEntityRequestImpl.java | 4 +-
.../retrieve/ODataEntitySetRequestImpl.java | 4 +-
.../ODataServiceDocumentRequestImpl.java | 6 +-
.../v4/ServiceDocumentRetrieveTestITCase.java | 74 +++++++++++
.../core/it/v4/ServiceDocumentTestITCase.java | 60 +++++++++
8 files changed, 383 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
[2/3] git commit: [OLINGO-200] V4 Atom and JSON parsers on their way
- still to refine, but most features are in, and specific tests were added
Posted by il...@apache.org.
[OLINGO-200] V4 Atom and JSON parsers on their way - still to refine, but most features are in, and specific tests were added
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/ce18b8e0
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/ce18b8e0
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/ce18b8e0
Branch: refs/heads/olingo200
Commit: ce18b8e056754a6f203535813d0672f2dd7e9c07
Parents: e4bf213
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Fri Mar 28 17:07:20 2014 +0100
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Fri Mar 28 17:07:20 2014 +0100
----------------------------------------------------------------------
.../client/core/op/AbstractODataBinder.java | 9 +-
.../apache/olingo/client/core/v3/AtomTest.java | 2 +-
.../apache/olingo/client/core/v3/JSONTest.java | 39 +++--
.../apache/olingo/client/core/v4/AtomTest.java | 74 +++++++++
.../apache/olingo/client/core/v4/JSONTest.java | 152 +++++++++++++++++++
.../apache/olingo/client/core/atom_cleanup.xsl | 48 ------
.../olingo/client/core/v3/atom_cleanup.xsl | 48 ++++++
.../olingo/client/core/v4/Products_5.json | 1 +
.../apache/olingo/client/core/v4/Products_5.xml | 49 ++++++
.../client/core/v4/Products_5_SkinColor.json | 5 +
.../client/core/v4/Products_5_SkinColor.xml | 27 ++++
.../olingo/client/core/v4/VipCustomer.json | 50 ++++++
.../olingo/client/core/v4/VipCustomer.xml | 67 ++++++++
.../olingo/client/core/v4/atom_cleanup.xsl | 48 ++++++
.../olingo/client/core/v4/complexProperty.json | 8 -
.../core/v4/entity.collection.complex.json | 14 ++
.../core/v4/entity.collection.primitive.json | 7 +
.../olingo/client/core/v4/entity.complex.json | 12 ++
.../olingo/client/core/v4/entity.full.json | 22 +++
.../olingo/client/core/v4/entity.minimal.json | 15 ++
.../olingo/client/core/v4/entity.primitive.json | 22 +++
.../olingo/client/core/v4/fullEntity.json | 22 ---
.../olingo/client/core/v4/fullEntitySet.json | 29 ----
.../core/v4/fullEntitySetWithTwoEntities.json | 49 ------
...fullEntityWithCollectionOfComplexValues.json | 28 ----
.../client/core/v4/primitiveNullValue.json | 3 -
.../client/core/v4/setOfComplexProperties.json | 13 --
.../core/v4/setOfPrimitiveProperties.json | 8 -
.../apache/olingo/commons/api/Constants.java | 24 +--
.../apache/olingo/commons/api/data/Entry.java | 15 --
.../olingo/commons/api/data/EnumValue.java | 25 +++
.../apache/olingo/commons/api/data/Feed.java | 15 --
.../olingo/commons/api/data/Property.java | 10 --
.../apache/olingo/commons/api/data/Value.java | 8 +-
.../commons/api/domain/ODataPropertyType.java | 8 +-
.../api/edm/constants/ODataServiceVersion.java | 56 +++++++
.../commons/core/data/AbstractAtomDealer.java | 5 +-
.../core/data/AbstractJsonDeserializer.java | 25 ++-
.../core/data/AbstractJsonSerializer.java | 16 +-
.../commons/core/data/AbstractODataObject.java | 16 --
.../commons/core/data/AbstractPropertyImpl.java | 18 ---
.../olingo/commons/core/data/AbstractValue.java | 17 ++-
.../commons/core/data/AtomDeserializer.java | 1 +
.../core/data/AtomPropertyDeserializer.java | 54 ++++---
.../core/data/AtomPropertySerializer.java | 46 ++++--
.../commons/core/data/AtomSerializer.java | 14 --
.../olingo/commons/core/data/EnumValueImpl.java | 41 +++++
.../core/data/JSONEntryDeserializer.java | 54 ++++---
.../olingo/commons/core/data/JSONEntryImpl.java | 13 --
.../commons/core/data/JSONEntrySerializer.java | 10 +-
.../olingo/commons/core/data/JSONFeedImpl.java | 12 +-
.../commons/core/data/JSONFeedSerializer.java | 7 +-
.../core/data/JSONPropertyDeserializer.java | 13 +-
.../core/data/JSONPropertySerializer.java | 13 +-
.../core/data/ODataJacksonDeserializer.java | 30 ++++
.../commons/core/data/PrimitiveValueImpl.java | 2 +-
56 files changed, 959 insertions(+), 480 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
index a678834..36ff32b 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
@@ -91,7 +91,6 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
public Feed getFeed(final ODataEntitySet entitySet, final Class<? extends Feed> reference) {
final Feed feed = ResourceFactory.newFeed(reference);
- feed.setContextURL(entitySet.getContextURL());
feed.setCount(entitySet.getCount());
final URI next = entitySet.getNext();
@@ -115,7 +114,6 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
public Entry getEntry(final ODataEntity entity, final Class<? extends Entry> reference, final boolean setType) {
final Entry entry = ResourceFactory.newEntry(reference);
- entry.setContextURL(entity.getContextURL());
entry.setId(entity.getReference());
entry.setType(entity.getName());
@@ -281,8 +279,6 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
? client.getObjectFactory().newEntitySet()
: client.getObjectFactory().newEntitySet(URIUtils.getURI(base, next.toASCIIString()));
- entitySet.setContextURL(resource.getContextURL());
-
if (resource.getCount() != null) {
entitySet.setCount(resource.getCount());
}
@@ -315,7 +311,6 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
: client.getObjectFactory().newEntity(resource.getType(),
URIUtils.getURI(base, resource.getSelfLink().getHref()));
- entity.setContextURL(resource.getContextURL());
entity.setReference(resource.getId());
if (StringUtils.isNotBlank(resource.getETag())) {
@@ -380,9 +375,9 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
private ODataValue getODataValue(final Property resource) {
ODataValue value = null;
- if (resource.getValue().isSimple()) {
+ if (resource.getValue().isPrimitive()) {
value = client.getPrimitiveValueBuilder().
- setText(resource.getValue().asSimple().get()).
+ setText(resource.getValue().asPrimitive().get()).
setType(resource.getType() == null
? null
: EdmPrimitiveTypeKind.valueOfFQN(client.getServiceVersion(), resource.getType())).build();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/AtomTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/AtomTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/AtomTest.java
index 1be265b..ce2ef71 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/AtomTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/AtomTest.java
@@ -53,7 +53,7 @@ public class AtomTest extends AbstractTest {
private String cleanup(final String input) throws Exception {
final TransformerFactory factory = TransformerFactory.newInstance();
- final Source xslt = new StreamSource(getClass().getResourceAsStream("../atom_cleanup.xsl"));
+ final Source xslt = new StreamSource(getClass().getResourceAsStream("atom_cleanup.xsl"));
final Transformer transformer = factory.newTransformer(xslt);
final StringWriter result = new StringWriter();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/JSONTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/JSONTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/JSONTest.java
index c3b1552..bae0bdd 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/JSONTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/JSONTest.java
@@ -30,6 +30,7 @@ import java.util.List;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.format.ODataPubFormat;
@@ -48,20 +49,23 @@ public class JSONTest extends AtomTest {
}
private void cleanup(final ObjectNode node) {
- if (node.has(Constants.JSON_TYPE)) {
- node.remove(Constants.JSON_TYPE);
+ if (node.has(Constants.JSON_METADATA)) {
+ node.remove(Constants.JSON_METADATA);
}
- if (node.has(Constants.JSON_EDIT_LINK)) {
- node.remove(Constants.JSON_EDIT_LINK);
+ if (node.has(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_TYPE))) {
+ node.remove(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_TYPE));
}
- if (node.has(Constants.JSON_READ_LINK)) {
- node.remove(Constants.JSON_READ_LINK);
+ if (node.has(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_EDIT_LINK))) {
+ node.remove(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_EDIT_LINK));
}
- if (node.has(Constants.JSON_MEDIAEDIT_LINK)) {
- node.remove(Constants.JSON_MEDIAEDIT_LINK);
+ if (node.has(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_READ_LINK))) {
+ node.remove(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_READ_LINK));
}
- if (node.has(Constants.JSON_MEDIAREAD_LINK)) {
- node.remove(Constants.JSON_MEDIAREAD_LINK);
+ if (node.has(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK))) {
+ node.remove(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK));
+ }
+ if (node.has(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIAREAD_LINK))) {
+ node.remove(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIAREAD_LINK));
}
if (node.has(Constants.JSON_MEDIA_CONTENT_TYPE)) {
node.remove(Constants.JSON_MEDIA_CONTENT_TYPE);
@@ -71,10 +75,13 @@ public class JSONTest extends AtomTest {
final Map.Entry<String, JsonNode> field = itor.next();
if (field.getKey().charAt(0) == '#'
- || field.getKey().endsWith(Constants.JSON_TYPE_SUFFIX)
- || field.getKey().endsWith(Constants.JSON_MEDIAEDIT_LINK_SUFFIX)
+ || field.getKey().endsWith(
+ getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_TYPE))
+ || field.getKey().endsWith(
+ getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK))
|| field.getKey().endsWith(Constants.JSON_MEDIA_CONTENT_TYPE_SUFFIX)
- || field.getKey().endsWith(Constants.JSON_ASSOCIATION_LINK_SUFFIX)
+ || field.getKey().endsWith(
+ getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_ASSOCIATION_LINK))
|| field.getKey().endsWith(Constants.JSON_MEDIA_ETAG_SUFFIX)) {
toRemove.add(field.getKey());
@@ -95,10 +102,12 @@ public class JSONTest extends AtomTest {
@Override
protected void assertSimilar(final String filename, final String actual) throws Exception {
final JsonNode orig = OBJECT_MAPPER.readTree(IOUtils.toString(getClass().getResourceAsStream(filename)).
- replace("Categories" + Constants.JSON_NAVIGATION_LINK_SUFFIX,
+ replace("Categories" + getClient().getServiceVersion().getJSONMap().
+ get(ODataServiceVersion.JSON_NAVIGATION_LINK),
"Categories" + Constants.JSON_BIND_LINK_SUFFIX).
replace("\"Products(0)/Categories\"", "[\"Products(0)/Categories\"]").
- replace(Constants.JSON_NAVIGATION_LINK_SUFFIX, Constants.JSON_BIND_LINK_SUFFIX));
+ replace(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_NAVIGATION_LINK),
+ Constants.JSON_BIND_LINK_SUFFIX));
cleanup((ObjectNode) orig);
assertEquals(orig, OBJECT_MAPPER.readTree(new ByteArrayInputStream(actual.getBytes())));
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/AtomTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/AtomTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/AtomTest.java
new file mode 100644
index 0000000..ed6b8c0
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/AtomTest.java
@@ -0,0 +1,74 @@
+/*
+ * 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.client.core.v4;
+
+import java.io.ByteArrayInputStream;
+import java.io.StringWriter;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import org.apache.commons.io.IOUtils;
+import org.apache.olingo.client.api.v4.ODataClient;
+import org.apache.olingo.client.core.AtomLinksQualifier;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.custommonkey.xmlunit.Diff;
+import static org.junit.Assert.assertTrue;
+
+public class AtomTest extends JSONTest {
+
+ @Override
+ protected ODataClient getClient() {
+ return v4Client;
+ }
+
+ @Override
+ protected ODataPubFormat getODataPubFormat() {
+ return ODataPubFormat.ATOM;
+ }
+
+ @Override
+ protected ODataFormat getODataFormat() {
+ return ODataFormat.XML;
+ }
+
+ private String cleanup(final String input) throws Exception {
+ final TransformerFactory factory = TransformerFactory.newInstance();
+ final Source xslt = new StreamSource(getClass().getResourceAsStream("atom_cleanup.xsl"));
+ final Transformer transformer = factory.newTransformer(xslt);
+
+ final StringWriter result = new StringWriter();
+ transformer.transform(new StreamSource(new ByteArrayInputStream(input.getBytes())), new StreamResult(result));
+ return result.toString();
+ }
+
+ protected void assertSimilar(final String filename, final String actual) throws Exception {
+ final Diff diff = new Diff(cleanup(IOUtils.toString(getClass().getResourceAsStream(filename))), actual);
+ diff.overrideElementQualifier(new AtomLinksQualifier());
+ assertTrue(diff.similar());
+ }
+
+ @Override
+ public void additionalEntries() throws Exception {
+ // no test
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java
new file mode 100644
index 0000000..272ab13
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java
@@ -0,0 +1,152 @@
+/*
+ * 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.client.core.v4;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import java.io.ByteArrayInputStream;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.io.IOUtils;
+import org.apache.olingo.client.api.v4.ODataClient;
+import org.apache.olingo.client.core.AbstractTest;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.format.ODataPubFormat;
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
+public class JSONTest extends AbstractTest {
+
+ private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+
+ @Override
+ protected ODataClient getClient() {
+ return v4Client;
+ }
+
+ protected ODataPubFormat getODataPubFormat() {
+ return ODataPubFormat.JSON;
+ }
+
+ protected ODataFormat getODataFormat() {
+ return ODataFormat.JSON;
+ }
+
+ private void cleanup(final ObjectNode node) {
+ if (node.has(Constants.JSON_CONTEXT)) {
+ node.remove(Constants.JSON_CONTEXT);
+ }
+ if (node.has(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_TYPE))) {
+ node.remove(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_TYPE));
+ }
+ if (node.has(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_EDIT_LINK))) {
+ node.remove(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_EDIT_LINK));
+ }
+ if (node.has(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_READ_LINK))) {
+ node.remove(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_READ_LINK));
+ }
+ if (node.has(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK))) {
+ node.remove(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK));
+ }
+ if (node.has(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIAREAD_LINK))) {
+ node.remove(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIAREAD_LINK));
+ }
+ if (node.has(Constants.JSON_MEDIA_CONTENT_TYPE)) {
+ node.remove(Constants.JSON_MEDIA_CONTENT_TYPE);
+ }
+ final List<String> toRemove = new ArrayList<String>();
+ for (final Iterator<Map.Entry<String, JsonNode>> itor = node.fields(); itor.hasNext();) {
+ final Map.Entry<String, JsonNode> field = itor.next();
+
+ if (field.getKey().charAt(0) == '#'
+ || field.getKey().endsWith(
+ getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_TYPE))
+ || field.getKey().endsWith(
+ getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK))
+ || field.getKey().endsWith(Constants.JSON_MEDIA_CONTENT_TYPE_SUFFIX)
+ || field.getKey().endsWith(
+ getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_ASSOCIATION_LINK))
+ || field.getKey().endsWith(Constants.JSON_MEDIA_ETAG_SUFFIX)) {
+
+ toRemove.add(field.getKey());
+ } else if (field.getValue().isObject()) {
+ cleanup((ObjectNode) field.getValue());
+ } else if (field.getValue().isArray()) {
+ for (final Iterator<JsonNode> arrayItems = field.getValue().elements(); arrayItems.hasNext();) {
+ final JsonNode arrayItem = arrayItems.next();
+ if (arrayItem.isObject()) {
+ cleanup((ObjectNode) arrayItem);
+ }
+ }
+ }
+ }
+ node.remove(toRemove);
+ }
+
+ protected void assertSimilar(final String filename, final String actual) throws Exception {
+ final JsonNode orig = OBJECT_MAPPER.readTree(IOUtils.toString(getClass().getResourceAsStream(filename)).
+ replace(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_NAVIGATION_LINK),
+ Constants.JSON_BIND_LINK_SUFFIX));
+ cleanup((ObjectNode) orig);
+ assertEquals(orig, OBJECT_MAPPER.readTree(new ByteArrayInputStream(actual.getBytes())));
+ }
+
+ protected void entry(final String filename, final ODataPubFormat format) throws Exception {
+ final StringWriter writer = new StringWriter();
+ getClient().getSerializer().entry(getClient().getDeserializer().toEntry(
+ getClass().getResourceAsStream(filename + "." + getSuffix(format)), format).getObject(), writer);
+
+ assertSimilar(filename + "." + getSuffix(format), writer.toString());
+ }
+
+ @Test
+ public void additionalEntries() throws Exception {
+ entry("entity.minimal", getODataPubFormat());
+// entry("entity.full", getODataPubFormat());
+ entry("entity.primitive", getODataPubFormat());
+ entry("entity.complex", getODataPubFormat());
+ entry("entity.collection.primitive", getODataPubFormat());
+ entry("entity.collection.complex", getODataPubFormat());
+ }
+
+ @Test
+ public void entries() throws Exception {
+ entry("Products_5", getODataPubFormat());
+ entry("VipCustomer", getODataPubFormat());
+ }
+
+ protected void property(final String filename, final ODataFormat format) throws Exception {
+ final StringWriter writer = new StringWriter();
+ getClient().getSerializer().property(getClient().getDeserializer().
+ toProperty(getClass().getResourceAsStream(filename + "." + getSuffix(format)), format).getObject(), writer);
+
+ assertSimilar(filename + "." + getSuffix(format), writer.toString());
+ }
+
+ @Test
+ public void properties() throws Exception {
+ property("Products_5_SkinColor", getODataFormat());
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/client-core/src/test/resources/org/apache/olingo/client/core/atom_cleanup.xsl
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/atom_cleanup.xsl b/lib/client-core/src/test/resources/org/apache/olingo/client/core/atom_cleanup.xsl
deleted file mode 100644
index a518fcb..0000000
--- a/lib/client-core/src/test/resources/org/apache/olingo/client/core/atom_cleanup.xsl
+++ /dev/null
@@ -1,48 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns="http://www.w3.org/2005/Atom"
- xmlns:atom="http://www.w3.org/2005/Atom"
- xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
- version="1.0">
-
- <xsl:template match="atom:updated"/>
- <xsl:template match="atom:author"/>
- <xsl:template match="atom:title">
- <xsl:if test="string-length(.) > 0">
- <title type="{@type}">
- <xsl:apply-templates/>
- </title>
- </xsl:if>
- </xsl:template>
- <xsl:template match="atom:link[@rel = 'self' or @rel = 'edit' or @rel = 'edit-media']"/>
-
- <xsl:template match="m:action"/>
-
- <xsl:template match="@*[name() = 'm:etag']"/>
-
- <xsl:template match="node()|@*">
- <xsl:copy>
- <xsl:apply-templates select="@*|node()"/>
- </xsl:copy>
- </xsl:template>
-</xsl:stylesheet>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/client-core/src/test/resources/org/apache/olingo/client/core/v3/atom_cleanup.xsl
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v3/atom_cleanup.xsl b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v3/atom_cleanup.xsl
new file mode 100644
index 0000000..a518fcb
--- /dev/null
+++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v3/atom_cleanup.xsl
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns="http://www.w3.org/2005/Atom"
+ xmlns:atom="http://www.w3.org/2005/Atom"
+ xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
+ version="1.0">
+
+ <xsl:template match="atom:updated"/>
+ <xsl:template match="atom:author"/>
+ <xsl:template match="atom:title">
+ <xsl:if test="string-length(.) > 0">
+ <title type="{@type}">
+ <xsl:apply-templates/>
+ </title>
+ </xsl:if>
+ </xsl:template>
+ <xsl:template match="atom:link[@rel = 'self' or @rel = 'edit' or @rel = 'edit-media']"/>
+
+ <xsl:template match="m:action"/>
+
+ <xsl:template match="@*[name() = 'm:etag']"/>
+
+ <xsl:template match="node()|@*">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+</xsl:stylesheet>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/Products_5.json
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/Products_5.json b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/Products_5.json
new file mode 100644
index 0000000..22c8473
--- /dev/null
+++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/Products_5.json
@@ -0,0 +1 @@
+{"@odata.context":"http://odatae2etest.azurewebsites.net/javatest/DefaultService/$metadata#Products/$entity","@odata.type":"#Microsoft.Test.OData.Services.ODataWCFService.Product","@odata.id":"http://odatae2etest.azurewebsites.net/javatest/DefaultService/Products(5)","@odata.editLink":"http://odatae2etest.azurewebsites.net/javatest/DefaultService/Products(5)","ProductID":5,"Name":"Cheetos","QuantityPerUnit":"100g Bag","UnitPrice@odata.type":"#Single","UnitPrice":3.24,"QuantityInStock":100,"Discontinued":true,"UserAccess@odata.type":"#Microsoft.Test.OData.Services.ODataWCFService.AccessLevel","UserAccess":"None","SkinColor@odata.type":"#Microsoft.Test.OData.Services.ODataWCFService.Color","SkinColor":"Red","CoverColors@odata.type":"#Collection(Microsoft.Test.OData.Services.ODataWCFService.Color)","CoverColors":["Green","Blue","Blue"],"Details@odata.associationLink":"http://odatae2etest.azurewebsites.net/javatest/DefaultService/Products(5)/Details/$ref","Details@odata.navigationLink":
"http://odatae2etest.azurewebsites.net/javatest/DefaultService/Products(5)/Details","#Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight":{"title":"Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight","target":"http://odatae2etest.azurewebsites.net/javatest/DefaultService/Products(5)/Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight"},"#Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails":{"title":"Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails","target":"http://odatae2etest.azurewebsites.net/javatest/DefaultService/Products(5)/Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails"}}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/Products_5.xml
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/Products_5.xml b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/Products_5.xml
new file mode 100644
index 0000000..9109f2d
--- /dev/null
+++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/Products_5.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+ 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.
+
+-->
+<entry xml:base="http://odatae2etest.azurewebsites.net/javatest/DefaultService/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://docs.oasis-open.org/odata/ns/data" xmlns:m="http://docs.oasis-open.org/odata/ns/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml" m:context="http://odatae2etest.azurewebsites.net/javatest/DefaultService/$metadata#Products/$entity">
+ <id>http://odatae2etest.azurewebsites.net/javatest/DefaultService/Products(5)</id>
+ <category term="#Microsoft.Test.OData.Services.ODataWCFService.Product" scheme="http://docs.oasis-open.org/odata/ns/scheme" />
+ <link rel="edit" href="http://odatae2etest.azurewebsites.net/javatest/DefaultService/Products(5)" />
+ <link rel="http://docs.oasis-open.org/odata/ns/related/Details" type="application/atom+xml;type=feed" title="Details" href="http://odatae2etest.azurewebsites.net/javatest/DefaultService/Products(5)/Details" />
+ <title />
+ <updated>2014-03-28T11:24:49Z</updated>
+ <author>
+ <name />
+ </author>
+ <content type="application/xml">
+ <m:properties>
+ <d:ProductID m:type="Int32">5</d:ProductID>
+ <d:Name>Cheetos</d:Name>
+ <d:QuantityPerUnit>100g Bag</d:QuantityPerUnit>
+ <d:UnitPrice m:type="Single">3.24</d:UnitPrice>
+ <d:QuantityInStock m:type="Int32">100</d:QuantityInStock>
+ <d:Discontinued m:type="Boolean">true</d:Discontinued>
+ <d:UserAccess m:type="#Microsoft.Test.OData.Services.ODataWCFService.AccessLevel">None</d:UserAccess>
+ <d:SkinColor m:type="#Microsoft.Test.OData.Services.ODataWCFService.Color">Red</d:SkinColor>
+ <d:CoverColors m:type="#Collection(Microsoft.Test.OData.Services.ODataWCFService.Color)">
+ <m:element>Green</m:element>
+ <m:element>Blue</m:element>
+ <m:element>Blue</m:element>
+ </d:CoverColors>
+ </m:properties>
+ </content>
+</entry>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/Products_5_SkinColor.json
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/Products_5_SkinColor.json b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/Products_5_SkinColor.json
new file mode 100644
index 0000000..b5e26da
--- /dev/null
+++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/Products_5_SkinColor.json
@@ -0,0 +1,5 @@
+{
+ "@odata.context": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/$metadata#Products(5)/SkinColor",
+ "@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.Color",
+ "value": "Red"
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/Products_5_SkinColor.xml
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/Products_5_SkinColor.xml b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/Products_5_SkinColor.xml
new file mode 100644
index 0000000..be392fd
--- /dev/null
+++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/Products_5_SkinColor.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+ 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.
+
+-->
+<m:value xmlns:d="http://docs.oasis-open.org/odata/ns/data"
+ xmlns:georss="http://www.georss.org/georss"
+ xmlns:gml="http://www.opengis.net/gml"
+ m:context="http://odatae2etest.azurewebsites.net/javatest/DefaultService/$metadata#Products(5)/SkinColor"
+ m:type="#Microsoft.Test.OData.Services.ODataWCFService.Color"
+ xmlns:m="http://docs.oasis-open.org/odata/ns/metadata">Red</m:value>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/VipCustomer.json
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/VipCustomer.json b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/VipCustomer.json
new file mode 100644
index 0000000..5f3f697
--- /dev/null
+++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/VipCustomer.json
@@ -0,0 +1,50 @@
+{
+ "@odata.context": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/$metadata#VipCustomer",
+ "@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.Customer",
+ "@odata.id": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer",
+ "@odata.editLink": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer",
+ "PersonID": 1,
+ "FirstName": "Bob",
+ "LastName": "Cat",
+ "MiddleName": "Vat",
+ "HomeAddress": {
+ "@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.Address",
+ "Street": "1 Microsoft Way",
+ "City": "London",
+ "PostalCode": "98052"
+ },
+ "Home@odata.type": "#GeographyPoint",
+ "Home": {
+ "type": "Point",
+ "coordinates": [23.1, 32.1],
+ "crs": {
+ "type": "name",
+ "properties": {
+ "name": "EPSG:4326"
+ }
+ }
+ },
+ "Numbers@odata.type": "#Collection(String)",
+ "Numbers": ["111-111-1111"],
+ "Emails@odata.type": "#Collection(String)",
+ "Emails": ["abc@abc.com"],
+ "City": "London",
+ "Birthday@odata.type": "#DateTimeOffset",
+ "Birthday": "1957-04-03T00:00:00Z",
+ "TimeBetweenLastTwoOrders@odata.type": "#Duration",
+ "TimeBetweenLastTwoOrders": "PT0.0000001S",
+ "Parent@odata.associationLink": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer/Parent/$ref",
+ "Parent@odata.navigationLink": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer/Parent",
+ "Orders@odata.associationLink": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer/Orders/$ref",
+ "Orders@odata.navigationLink": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer/Orders",
+ "Company@odata.associationLink": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer/Company/$ref",
+ "Company@odata.navigationLink": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer/Company",
+ "#Microsoft.Test.OData.Services.ODataWCFService.ResetAddress": {
+ "title": "Microsoft.Test.OData.Services.ODataWCFService.ResetAddress",
+ "target": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer/Microsoft.Test.OData.Services.ODataWCFService.ResetAddress"
+ },
+ "#Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress": {
+ "title": "Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress",
+ "target": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer/Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress"
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/VipCustomer.xml
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/VipCustomer.xml b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/VipCustomer.xml
new file mode 100644
index 0000000..001c1a9
--- /dev/null
+++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/VipCustomer.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+ 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.
+
+-->
+<entry xml:base="http://odatae2etest.azurewebsites.net/javatest/DefaultService/"
+ xmlns="http://www.w3.org/2005/Atom"
+ xmlns:d="http://docs.oasis-open.org/odata/ns/data"
+ xmlns:m="http://docs.oasis-open.org/odata/ns/metadata"
+ xmlns:georss="http://www.georss.org/georss"
+ xmlns:gml="http://www.opengis.net/gml"
+ m:context="http://odatae2etest.azurewebsites.net/javatest/DefaultService/$metadata#VipCustomer">
+ <id>http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer</id>
+ <category term="#Microsoft.Test.OData.Services.ODataWCFService.Customer" scheme="http://docs.oasis-open.org/odata/ns/scheme" />
+ <link rel="edit" href="http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer" />
+ <link rel="http://docs.oasis-open.org/odata/ns/related/Parent" type="application/atom+xml;type=entry" title="Parent" href="http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer/Parent" />
+ <link rel="http://docs.oasis-open.org/odata/ns/related/Orders" type="application/atom+xml;type=feed" title="Orders" href="http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer/Orders" />
+ <link rel="http://docs.oasis-open.org/odata/ns/related/Company" type="application/atom+xml;type=entry" title="Company" href="http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer/Company" />
+ <title />
+ <updated>2014-03-28T13:03:32Z</updated>
+ <author>
+ <name />
+ </author>
+ <content type="application/xml">
+ <m:properties>
+ <d:PersonID m:type="Int32">1</d:PersonID>
+ <d:FirstName>Bob</d:FirstName>
+ <d:LastName>Cat</d:LastName>
+ <d:MiddleName>Vat</d:MiddleName>
+ <d:HomeAddress m:type="#Microsoft.Test.OData.Services.ODataWCFService.Address">
+ <d:Street>1 Microsoft Way</d:Street>
+ <d:City>London</d:City>
+ <d:PostalCode>98052</d:PostalCode>
+ </d:HomeAddress>
+ <d:Home m:type="GeographyPoint">
+ <gml:Point gml:srsName="http://www.opengis.net/def/crs/EPSG/0/4326">
+ <gml:pos>32.1 23.1</gml:pos>
+ </gml:Point>
+ </d:Home>
+ <d:Numbers m:type="#Collection(String)">
+ <m:element>111-111-1111</m:element>
+ </d:Numbers>
+ <d:Emails m:type="#Collection(String)">
+ <m:element>abc@abc.com</m:element>
+ </d:Emails>
+ <d:City>London</d:City>
+ <d:Birthday m:type="DateTimeOffset">1957-04-03T00:00:00Z</d:Birthday>
+ <d:TimeBetweenLastTwoOrders m:type="Duration">PT0.0000001S</d:TimeBetweenLastTwoOrders>
+ </m:properties>
+ </content>
+</entry>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/atom_cleanup.xsl
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/atom_cleanup.xsl b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/atom_cleanup.xsl
new file mode 100644
index 0000000..ed30201
--- /dev/null
+++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/atom_cleanup.xsl
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns="http://www.w3.org/2005/Atom"
+ xmlns:atom="http://www.w3.org/2005/Atom"
+ xmlns:m="http://docs.oasis-open.org/odata/ns/metadata"
+ version="1.0">
+
+ <xsl:template match="atom:updated"/>
+ <xsl:template match="atom:author"/>
+ <xsl:template match="atom:title">
+ <xsl:if test="string-length(.) > 0">
+ <title type="{@type}">
+ <xsl:apply-templates/>
+ </title>
+ </xsl:if>
+ </xsl:template>
+ <xsl:template match="atom:link[@rel = 'self' or @rel = 'edit' or @rel = 'edit-media']"/>
+
+ <xsl:template match="m:action"/>
+
+ <xsl:template match="@*[name() = 'm:etag' or name() = 'm:context']"/>
+
+ <xsl:template match="node()|@*">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+</xsl:stylesheet>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/complexProperty.json
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/complexProperty.json b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/complexProperty.json
deleted file mode 100644
index 53af94c..0000000
--- a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/complexProperty.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "Address": {
- "Street": "Obere Str. 57",
- "City": "Berlin",
- "Region": null,
- "PostalCode": "D-12209"
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.collection.complex.json
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.collection.complex.json b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.collection.complex.json
new file mode 100644
index 0000000..0bf131e
--- /dev/null
+++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.collection.complex.json
@@ -0,0 +1,14 @@
+{
+ "PhoneNumbers": [
+ {
+ "Number": "425-555-1212",
+ "Type": "Home"
+ },
+ {
+ "@odata.type": "#Model.CellPhoneNumber",
+ "Number": "425-555-0178",
+ "Type": "Cell",
+ "Carrier": "Sprint"
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.collection.primitive.json
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.collection.primitive.json b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.collection.primitive.json
new file mode 100644
index 0000000..dc811b4
--- /dev/null
+++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.collection.primitive.json
@@ -0,0 +1,7 @@
+{
+ "@odata.context": "http://host/service/$metadata#Customers/$entity",
+ "EmailAddresses": [
+ "Julie@Swansworth.com",
+ "Julie.Swansworth@work.com"
+ ]
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.complex.json
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.complex.json b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.complex.json
new file mode 100644
index 0000000..189613f
--- /dev/null
+++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.complex.json
@@ -0,0 +1,12 @@
+{
+ "CompanyID": 0,
+ "CompanyCategory": "IT",
+ "Revenue": 100000,
+ "Name": "MS",
+ "Address": {
+ "Street": "1 Microsoft Way",
+ "City": "Redmond",
+ "PostalCode": "98052",
+ "CompanyName": "Microsoft"
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.full.json
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.full.json b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.full.json
new file mode 100644
index 0000000..bcd1dba
--- /dev/null
+++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.full.json
@@ -0,0 +1,22 @@
+{
+ "@odata.context": "http://host/service/$metadata#Customers/$entity",
+ "@odata.id": "Customers('ALFKI')",
+ "@odata.etag": "W/\"MjAxMy0wNS0yN1QxMTo1OFo=\"",
+ "@odata.editLink": "Customers('ALFKI')",
+ "ID": "ALFKI",
+ "CompanyName": "Alfreds Futterkiste",
+ "ContactName": "Maria Anders",
+ "ContactTitle": "Sales Representative",
+ "Phone": "030-0074321",
+ "Fax": "030-0076545",
+ "Address": {
+ "Street": "Obere Str. 57",
+ "City": "Berlin",
+ "Region": null,
+ "PostalCode": "D-12209",
+ "Country@odata.associationLink": "Customers('ALFKI')/Address/Country/$ref",
+ "Country@odata.navigationLink": "Customers('ALFKI')/Address/Country"
+ },
+ "Orders@odata.associationLink": "Customers('ALFKI')/Orders/$ref",
+ "Orders@odata.navigationLink": "Customers('ALFKI')/Orders"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.minimal.json
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.minimal.json b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.minimal.json
new file mode 100644
index 0000000..de0a50b
--- /dev/null
+++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.minimal.json
@@ -0,0 +1,15 @@
+{
+ "@odata.context": "http://host/service/$metadata#Customers/$entity",
+ "ID": "ALFKI",
+ "CompanyName": "Alfreds Futterkiste",
+ "ContactName": "Maria Anders",
+ "ContactTitle": "Sales Representative",
+ "Phone": "030-0074321",
+ "Fax": "030-0076545",
+ "Address": {
+ "Street": "Obere Str. 57",
+ "City": "Berlin",
+ "Region": null,
+ "PostalCode": "D-12209"
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.primitive.json
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.primitive.json b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.primitive.json
new file mode 100644
index 0000000..db12081
--- /dev/null
+++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.primitive.json
@@ -0,0 +1,22 @@
+{
+ "NullValue": null,
+ "TrueValue": true,
+ "FalseValue": false,
+ "BinaryValue": "T0RhdGE",
+ "IntegerValue": -128,
+ "DoubleValue": 3.1415926535897931,
+ "SingleValue": "INF",
+ "DecimalValue": 34.95,
+ "StringValue": "Say \"Hello\",\nthen go",
+ "DateValue": "2012-12-03",
+ "DateTimeOffsetValue": "2012-12-03T07:16:23Z",
+ "DurationValue": "P12DT23H59M59.999999999999S",
+ "TimeOfDayValue": "07:59:59.999",
+ "GuidValue": "01234567-89ab-cdef-0123-456789abcdef",
+ "Int64Value": 0,
+ "ColorEnumValue": "Yellow",
+ "GeographyPoint": {
+ "type": "point",
+ "coordinates": [142.1, 64.1]
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/fullEntity.json
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/fullEntity.json b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/fullEntity.json
deleted file mode 100644
index 4d84995..0000000
--- a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/fullEntity.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "odata.context": "http://host/service/$metadata#Customers/$entity",
- "odata.id": "Customers('ALFKI')",
- "odata.etag": "W/\"MjAxMy0wNS0yN1QxMTo1OFo=\"",
- "odata.editLink": "Customers('ALFKI')",
- "Orders@odata.navigationLink": "Customers('ALFKI')/Orders",
- "Orders@odata.associationLink": "Customers('ALFKI')/Orders/$ref",
- "ID": "ALFKI",
- "CompanyName": "Alfreds Futterkiste",
- "ContactName": "Maria Anders",
- "ContactTitle": "Sales Representative",
- "Phone": "030-0074321",
- "Fax": "030-0076545",
- "Address": {
- "Street": "Obere Str. 57",
- "City": "Berlin",
- "Region": null,
- "PostalCode": "D-12209",
- "Country@odata.navigationLink": "Customers('ALFKI')/Address/Country",
- "Country@odata.associationLink":"Customers('ALFKI')/Address/Country/$ref"
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/fullEntitySet.json
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/fullEntitySet.json b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/fullEntitySet.json
deleted file mode 100644
index b3ddf63..0000000
--- a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/fullEntitySet.json
+++ /dev/null
@@ -1,29 +0,0 @@
-{
-"odata.context": "http://host/service/$metadata#Customers/$entity",
-"odata.count": 1,
-"value": [
-{
-"odata.context": "http://host/service/$metadata#Customers/$entity",
-"odata.id": "Customers('ALFKI')",
-"odata.etag": "W/\"MjAxMy0wNS0yN1QxMTo1OFo=\"",
-"odata.editLink": "Customers('ALFKI')",
-"Orders@odata.navigationLink": "Customers('ALFKI')/Orders",
-"Orders@odata.associationLink": "Customers('ALFKI')/Orders/$ref",
-"ID": "ALFKI",
-"CompanyName": "Alfreds Futterkiste",
-"ContactName": "Maria Anders",
-"ContactTitle": "Sales Representative",
-"Phone": "030-0074321",
-"Fax": "030-0076545",
-"Address": {
- "Street": "Obere Str. 57",
- "City": "Berlin",
- "Region": null,
- "PostalCode": "D-12209",
- "Country@odata.navigationLink": "Customers('ALFKI')/Address/Country",
- "Country@odata.associationLink":"Customers('ALFKI')/Address/Country/$ref"
- }
-}
-],
-"odata.nextLink": "http://host/service/EntitySet?$skiptoken=342r89"
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/fullEntitySetWithTwoEntities.json
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/fullEntitySetWithTwoEntities.json b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/fullEntitySetWithTwoEntities.json
deleted file mode 100644
index 96854ac..0000000
--- a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/fullEntitySetWithTwoEntities.json
+++ /dev/null
@@ -1,49 +0,0 @@
-{
-"odata.context": "http://host/service/$metadata#Customers/$entity",
-"odata.count": 1,
-"value": [
- {
- "odata.context": "http://host/service/$metadata#Customers/$entity",
- "odata.id": "Customers('ALFKI')",
- "odata.etag": "W/\"MjAxMy0wNS0yN1QxMTo1OFo=\"",
- "odata.editLink": "Customers('ALFKI')",
- "Orders@odata.navigationLink": "Customers('ALFKI')/Orders",
- "Orders@odata.associationLink": "Customers('ALFKI')/Orders/$ref",
- "ID": "ALFKI",
- "CompanyName": "Alfreds Futterkiste",
- "ContactName": "Maria Anders",
- "ContactTitle": "Sales Representative",
- "Phone": "030-0074321",
- "Fax": "030-0076545",
- "Address": {
- "Street": "Obere Str. 57",
- "City": "Berlin",
- "Region": null,
- "PostalCode": "D-12209",
- "Country@odata.navigationLink": "Customers('ALFKI')/Address/Country",
- "Country@odata.associationLink":"Customers('ALFKI')/Address/Country/$ref"
- }
- },
- {
- "odata.context": "http://host/service/$metadata#Customers/$entity",
- "odata.id": "Customers('MUSKI')",
- "odata.etag": "W/\"MjAxMy0wNS0yN1QxMTo1OFo=\"",
- "odata.editLink": "Customers('MUSKI')",
- "Orders@odata.navigationLink": "Customers('MUSKI')/Orders",
- "Orders@odata.associationLink": "Customers('MUSKI')/Orders/$ref",
- "ID": "MUSKI",
- "CompanyName": "Mustermanns Futterkiste",
- "ContactName": "Mustermann Max",
- "ContactTitle": "Some Guy",
- "Phone": "030-002222",
- "Fax": "030-004444",
- "Address": {
- "Street": "Musterstrasse 42",
- "City": "Musterstadt",
- "Region": "SomeRegion",
- "PostalCode": "D-42042"
- }
- }
-],
-"odata.nextLink": "http://host/service/EntitySet?$skiptoken=342r89"
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/fullEntityWithCollectionOfComplexValues.json
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/fullEntityWithCollectionOfComplexValues.json b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/fullEntityWithCollectionOfComplexValues.json
deleted file mode 100644
index cbdfd1c..0000000
--- a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/fullEntityWithCollectionOfComplexValues.json
+++ /dev/null
@@ -1,28 +0,0 @@
-{
- "odata.context": "http://host/service/$metadata#Customers/$entity",
- "odata.id": "Customers('ALFKI')",
- "odata.etag": "W/\"MjAxMy0wNS0yN1QxMTo1OFo=\"",
- "odata.editLink": "Customers('ALFKI')",
- "Orders@odata.navigationLink": "Customers('ALFKI')/Orders",
- "Orders@odata.associationLink": "Customers('ALFKI')/Orders/$ref",
- "ID": "ALFKI",
- "CompanyName": "Alfreds Futterkiste",
- "ContactName": "Maria Anders",
- "ContactTitle": "Sales Representative",
- "Phone": "030-0074321",
- "Fax": "030-0076545",
- "Address": [ {
- "Street": "Obere Str. 57",
- "City": "Berlin",
- "Region": null,
- "PostalCode": "D-12209",
- "Country@odata.navigationLink": "Customers('ALFKI')/Address/Country",
- "Country@odata.associationLink":"Customers('ALFKI')/Address/Country/$ref"
- }, {
- "Street": "Musterstrasse 42",
- "City": "Musterstadt",
- "Region": "SomeRegion",
- "PostalCode": "D-42042"
- }
- ]
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/primitiveNullValue.json
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/primitiveNullValue.json b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/primitiveNullValue.json
deleted file mode 100644
index 5774413..0000000
--- a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/primitiveNullValue.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "NullValue" : null
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/setOfComplexProperties.json
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/setOfComplexProperties.json b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/setOfComplexProperties.json
deleted file mode 100644
index 24ec160..0000000
--- a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/setOfComplexProperties.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "PhoneNumbers": [
- {
- "Number": "425-555-1212",
- "Type": "Home"
- }, {
- "odata.type": "#Model.CellPhoneNumber",
- "Number": "425-555-0178",
- "Type": "Cell",
- "Carrier": "Sprint"
- }
- ]
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/setOfPrimitiveProperties.json
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/setOfPrimitiveProperties.json b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/setOfPrimitiveProperties.json
deleted file mode 100644
index 61b3d2c..0000000
--- a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/setOfPrimitiveProperties.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "odata.context": "http://host/service/$metadata#Customers/$entity",
-
- "EmailAddresses": [
- "Julie@Swansworth.com",
- "Julie.Swansworth@work.com"
- ]
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/Constants.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/Constants.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/Constants.java
index 39d9614..0a8bafb 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/Constants.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/Constants.java
@@ -137,15 +137,11 @@ public interface Constants {
public static final String ELEM_URI = "uri";
// JSON stuff
- public final static String JSON_CONTEXT = "@odata.context";
-
public final static String JSON_METADATA = "odata.metadata";
- public final static String JSON_METADATA_ETAG = "@odata.metadataEtag";
-
- public final static String JSON_TYPE = "odata.type";
+ public final static String JSON_CONTEXT = "@odata.context";
- public final static String JSON_TYPE_SUFFIX = "@" + JSON_TYPE;
+ public final static String JSON_METADATA_ETAG = "@odata.metadataEtag";
public final static String JSON_ETAG = "odata.etag";
@@ -153,28 +149,12 @@ public interface Constants {
public final static String JSON_MEDIA_ETAG_SUFFIX = "@" + JSON_MEDIA_ETAG;
- public final static String JSON_ID = "odata.id";
-
- public final static String JSON_READ_LINK = "odata.readLink";
-
- public final static String JSON_EDIT_LINK = "odata.editLink";
-
- public final static String JSON_MEDIAREAD_LINK = "odata.mediaReadLink";
-
- public final static String JSON_MEDIAEDIT_LINK = "odata.mediaEditLink";
-
- public final static String JSON_MEDIAEDIT_LINK_SUFFIX = "@" + JSON_MEDIAEDIT_LINK;
-
public final static String JSON_MEDIA_CONTENT_TYPE = "odata.mediaContentType";
public final static String JSON_MEDIA_CONTENT_TYPE_SUFFIX = "@" + JSON_MEDIA_CONTENT_TYPE;
- public final static String JSON_NAVIGATION_LINK_SUFFIX = "@odata.navigationLinkUrl";
-
public final static String JSON_BIND_LINK_SUFFIX = "@odata.bind";
- public final static String JSON_ASSOCIATION_LINK_SUFFIX = "@odata.associationLinkUrl";
-
public final static String JSON_NULL = "odata.null";
public final static String VALUE = "value";
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Entry.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Entry.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Entry.java
index 5ac0dbd..c064216 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Entry.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Entry.java
@@ -39,21 +39,6 @@ public interface Entry {
URI getBaseURI();
/**
- * The context URL describes the content of the payload. It consists of the canonical metadata document URL and a
- * fragment identifying the relevant portion of the metadata document.
- *
- * @return context URL.
- */
- URI getContextURL();
-
- /**
- * Set context URL.
- *
- * @param contextURL context URL.
- */
- void setContextURL(final URI contextURL);
-
- /**
* Gets entry type.
*
* @return entry type.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EnumValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EnumValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EnumValue.java
new file mode 100644
index 0000000..2f13fa7
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EnumValue.java
@@ -0,0 +1,25 @@
+/*
+ * 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.data;
+
+public interface EnumValue extends Value {
+
+ @Override
+ String get();
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Feed.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Feed.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Feed.java
index 45b28d9..4f6a542 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Feed.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Feed.java
@@ -31,21 +31,6 @@ public interface Feed {
URI getBaseURI();
/**
- * The context URL describes the content of the payload. It consists of the canonical metadata document URL and a
- * fragment identifying the relevant portion of the metadata document.
- *
- * @return context URL.
- */
- URI getContextURL();
-
- /**
- * Set context URL.
- *
- * @param contextURL context URL.
- */
- void setContextURL(final URI contextURL);
-
- /**
* Sets number of entries.
*
* @param count number of entries
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Property.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Property.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Property.java
index da34c16..feb8f71 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Property.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Property.java
@@ -18,18 +18,8 @@
*/
package org.apache.olingo.commons.api.data;
-import java.net.URI;
-
public interface Property {
- /**
- * The context URL describes the content of the payload. It consists of the canonical metadata document URL and a
- * fragment identifying the relevant portion of the metadata document.
- *
- * @return context URL.
- */
- URI getContextURL();
-
String getName();
void setName(String name);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Value.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Value.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Value.java
index 045751d..b02f1ba 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Value.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Value.java
@@ -22,10 +22,12 @@ public interface Value {
boolean isNull();
- boolean isSimple();
+ boolean isPrimitive();
boolean isGeospatial();
+ boolean isEnum();
+
boolean isComplex();
boolean isCollection();
@@ -34,7 +36,9 @@ public interface Value {
NullValue asNull();
- PrimitiveValue asSimple();
+ PrimitiveValue asPrimitive();
+
+ EnumValue asEnum();
GeospatialValue asGeospatial();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataPropertyType.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataPropertyType.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataPropertyType.java
index d173e50..99126f7 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataPropertyType.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataPropertyType.java
@@ -21,11 +21,15 @@ package org.apache.olingo.commons.api.domain;
public enum ODataPropertyType {
/**
- * Primitive (including geospatial and enum).
+ * Primitive (including geospatial).
*/
PRIMITIVE,
/**
- * Collection
+ * Enum.
+ */
+ ENUM,
+ /**
+ * Collection.
*/
COLLECTION,
/**
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/constants/ODataServiceVersion.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/constants/ODataServiceVersion.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/constants/ODataServiceVersion.java
index d637814..96d9937 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/constants/ODataServiceVersion.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/constants/ODataServiceVersion.java
@@ -48,6 +48,22 @@ public enum ODataServiceVersion {
public static final String MEDIA_EDIT_LINK_REL = "mediaEditLinkRel";
+ public static final String JSON_TYPE = "jsonType";
+
+ public static final String JSON_ID = "jsonId";
+
+ public static final String JSON_READ_LINK = "jsonReadLink";
+
+ public static final String JSON_EDIT_LINK = "jsonEditLink";
+
+ public static final String JSON_MEDIAREAD_LINK = "jsonMediaReadLink";
+
+ public static final String JSON_MEDIAEDIT_LINK = "jsonMediaEditLink";
+
+ public static final String JSON_ASSOCIATION_LINK = "jsonAssociationLink";
+
+ public static final String JSON_NAVIGATION_LINK = "jsonNavigationLink";
+
private static final Map<String, String> V30_NAMESPACES = Collections.unmodifiableMap(new HashMap<String, String>() {
private static final long serialVersionUID = 3109256773218160485L;
@@ -62,6 +78,22 @@ public enum ODataServiceVersion {
}
});
+ private static final Map<String, String> V30_JSON = Collections.unmodifiableMap(new HashMap<String, String>() {
+
+ private static final long serialVersionUID = 3109256773218160485L;
+
+ {
+ put(JSON_TYPE, "odata.type");
+ put(JSON_ID, "odata.id");
+ put(JSON_READ_LINK, "odata.readLink");
+ put(JSON_EDIT_LINK, "odata.editLink");
+ put(JSON_MEDIAREAD_LINK, "odata.mediaReadLink");
+ put(JSON_MEDIAEDIT_LINK, "odata.mediaEditLink");
+ put(JSON_ASSOCIATION_LINK, "@odata.associationLinkUrl");
+ put(JSON_NAVIGATION_LINK, "@odata.navigationLinkUrl");
+ }
+ });
+
private static final Map<String, String> V40_NAMESPACES = Collections.unmodifiableMap(new HashMap<String, String>() {
private static final long serialVersionUID = 3109256773218160485L;
@@ -76,6 +108,22 @@ public enum ODataServiceVersion {
}
});
+ private static final Map<String, String> V40_JSON = Collections.unmodifiableMap(new HashMap<String, String>() {
+
+ private static final long serialVersionUID = 3109256773218160485L;
+
+ {
+ put(JSON_TYPE, "@odata.type");
+ put(JSON_ID, "@odata.id");
+ put(JSON_READ_LINK, "@odata.readLink");
+ put(JSON_EDIT_LINK, "@odata.editLink");
+ put(JSON_MEDIAREAD_LINK, "@odata.mediaReadLink");
+ put(JSON_MEDIAEDIT_LINK, "@odata.mediaEditLink");
+ put(JSON_ASSOCIATION_LINK, "@odata.associationLink");
+ put(JSON_NAVIGATION_LINK, "@odata.navigationLink");
+ }
+ });
+
/**
* Validates format and range of a data service version string.
*
@@ -135,6 +183,14 @@ public enum ODataServiceVersion {
: V40_NAMESPACES;
}
+ public Map<String, String> getJSONMap() {
+ return this == V10 || this == V20
+ ? Collections.<String, String>emptyMap()
+ : this == V30
+ ? V30_JSON
+ : V40_JSON;
+ }
+
@Override
public String toString() {
return version;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractAtomDealer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractAtomDealer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractAtomDealer.java
index e258219..656207c 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractAtomDealer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractAtomDealer.java
@@ -75,8 +75,9 @@ abstract class AbstractAtomDealer {
new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.PROPERTIES);
this.typeQName = new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATTR_TYPE);
this.nullQName = new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATTR_NULL);
- this.elementQName =
- new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES), Constants.ELEM_ELEMENT);
+ this.elementQName = version == ODataServiceVersion.V30
+ ? new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES), Constants.ELEM_ELEMENT)
+ : new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ELEM_ELEMENT);
this.countQName =
new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ELEM_COUNT);
this.uriQName =
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonDeserializer.java
index 4c92ae6..4ba9671 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonDeserializer.java
@@ -23,7 +23,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
import java.util.Iterator;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.Constants;
import org.apache.olingo.commons.api.data.CollectionValue;
import org.apache.olingo.commons.api.data.ComplexValue;
import org.apache.olingo.commons.api.data.Value;
@@ -95,7 +94,7 @@ abstract class AbstractJsonDeserializer<T> extends ODataJacksonDeserializer<T> {
for (final Iterator<Map.Entry<String, JsonNode>> itor = node.fields(); itor.hasNext();) {
final Map.Entry<String, JsonNode> field = itor.next();
- if (type == null && field.getKey().endsWith(Constants.JSON_TYPE_SUFFIX)) {
+ if (type == null && field.getKey().endsWith(getJSONAnnotation(jsonType))) {
type = field.getValue().asText();
} else {
final JSONPropertyImpl property = new JSONPropertyImpl();
@@ -122,10 +121,14 @@ abstract class AbstractJsonDeserializer<T> extends ODataJacksonDeserializer<T> {
final JsonNode child = nodeItor.next();
if (child.isValueNode()) {
- value.get().add(fromPrimitive(child, type));
+ if (typeInfo == null || typeInfo.isPrimitiveType()) {
+ value.get().add(fromPrimitive(child, type));
+ } else {
+ value.get().add(new EnumValueImpl(child.asText()));
+ }
} else if (child.isContainerNode()) {
- if (child.has(Constants.JSON_TYPE)) {
- ((ObjectNode) child).remove(Constants.JSON_TYPE);
+ if (child.has(jsonType)) {
+ ((ObjectNode) child).remove(jsonType);
}
value.get().add(fromComplex(child));
}
@@ -145,6 +148,8 @@ abstract class AbstractJsonDeserializer<T> extends ODataJacksonDeserializer<T> {
? ODataPropertyType.COLLECTION
: typeInfo.isPrimitiveType()
? ODataPropertyType.PRIMITIVE
+ : node.isValueNode()
+ ? ODataPropertyType.ENUM
: ODataPropertyType.COMPLEX;
switch (propType) {
@@ -153,13 +158,17 @@ abstract class AbstractJsonDeserializer<T> extends ODataJacksonDeserializer<T> {
break;
case COMPLEX:
- if (node.has(Constants.JSON_TYPE)) {
- property.setType(node.get(Constants.JSON_TYPE).asText());
- ((ObjectNode) node).remove(Constants.JSON_TYPE);
+ if (node.has(jsonType)) {
+ property.setType(node.get(jsonType).asText());
+ ((ObjectNode) node).remove(jsonType);
}
property.setValue(fromComplex(node));
break;
+ case ENUM:
+ property.setValue(new EnumValueImpl(node.asText()));
+ break;
+
case PRIMITIVE:
if (property.getType() == null) {
property.setType(getPrimitiveType(node).getFullQualifiedName().toString());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonSerializer.java
index 1380dd5..dede6aa 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonSerializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonSerializer.java
@@ -56,22 +56,24 @@ abstract class AbstractJsonSerializer<T> extends ODataJacksonSerializer<T> {
if (value.isNull()) {
jgen.writeNull();
- } else if (value.isSimple()) {
+ } else if (value.isPrimitive()) {
final boolean isNumber = typeInfo == null
- ? NumberUtils.isNumber(value.asSimple().get())
+ ? NumberUtils.isNumber(value.asPrimitive().get())
: ArrayUtils.contains(NUMBER_TYPES, typeInfo.getPrimitiveTypeKind());
final boolean isBoolean = typeInfo == null
- ? (value.asSimple().get().equalsIgnoreCase(Boolean.TRUE.toString())
- || value.asSimple().get().equalsIgnoreCase(Boolean.FALSE.toString()))
+ ? (value.asPrimitive().get().equalsIgnoreCase(Boolean.TRUE.toString())
+ || value.asPrimitive().get().equalsIgnoreCase(Boolean.FALSE.toString()))
: typeInfo.getPrimitiveTypeKind() == EdmPrimitiveTypeKind.Boolean;
if (isNumber) {
- jgen.writeNumber(value.asSimple().get());
+ jgen.writeNumber(value.asPrimitive().get());
} else if (isBoolean) {
- jgen.writeBoolean(BooleanUtils.toBoolean(value.asSimple().get()));
+ jgen.writeBoolean(BooleanUtils.toBoolean(value.asPrimitive().get()));
} else {
- jgen.writeString(value.asSimple().get());
+ jgen.writeString(value.asPrimitive().get());
}
+ } else if (value.isEnum()) {
+ jgen.writeString(value.asEnum().get());
} else if (value.isGeospatial()) {
jgen.writeStartObject();
geoSerializer.serialize(jgen, value.asGeospatial().get());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractODataObject.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractODataObject.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractODataObject.java
index 3bcef74..6dd86a2 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractODataObject.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractODataObject.java
@@ -31,8 +31,6 @@ abstract class AbstractODataObject extends AbstractPayloadObject {
private URI baseURI;
- private URI contextURL;
-
private String id;
private String title;
@@ -49,20 +47,6 @@ abstract class AbstractODataObject extends AbstractPayloadObject {
this.baseURI = URI.create(baseURI);
}
- /**
- * The context URL describes the content of the payload. It consists of the canonical metadata document URL and a
- * fragment identifying the relevant portion of the metadata document.
- *
- * @return context URL.
- */
- public URI getContextURL() {
- return contextURL;
- }
-
- public void setContextURL(final URI contextURL) {
- this.contextURL = contextURL;
- }
-
public String getId() {
return id;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractPropertyImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractPropertyImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractPropertyImpl.java
index b3ca459..e005f98 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractPropertyImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractPropertyImpl.java
@@ -18,7 +18,6 @@
*/
package org.apache.olingo.commons.core.data;
-import java.net.URI;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
@@ -28,29 +27,12 @@ import org.apache.olingo.commons.api.data.Value;
public abstract class AbstractPropertyImpl implements Property {
- private URI contextURL;
-
private String name;
private String type;
private Value value;
- /**
- * The context URL describes the content of the payload. It consists of the canonical metadata document URL and a
- * fragment identifying the relevant portion of the metadata document.
- *
- * @return context URL.
- */
- @Override
- public URI getContextURL() {
- return contextURL;
- }
-
- public void setContextURL(final URI contextURL) {
- this.contextURL = contextURL;
- }
-
@Override
public String getName() {
return name;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValue.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValue.java
index 31629e2..629592f 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValue.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValue.java
@@ -24,6 +24,7 @@ import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.apache.olingo.commons.api.data.CollectionValue;
import org.apache.olingo.commons.api.data.ComplexValue;
+import org.apache.olingo.commons.api.data.EnumValue;
import org.apache.olingo.commons.api.data.GeospatialValue;
import org.apache.olingo.commons.api.data.NullValue;
import org.apache.olingo.commons.api.data.PrimitiveValue;
@@ -37,7 +38,7 @@ public abstract class AbstractValue implements Value {
}
@Override
- public boolean isSimple() {
+ public boolean isPrimitive() {
return false;
}
@@ -47,6 +48,11 @@ public abstract class AbstractValue implements Value {
}
@Override
+ public boolean isEnum() {
+ return false;
+ }
+
+ @Override
public boolean isComplex() {
return false;
}
@@ -62,8 +68,8 @@ public abstract class AbstractValue implements Value {
}
@Override
- public PrimitiveValue asSimple() {
- return isSimple() ? (PrimitiveValue) this : null;
+ public PrimitiveValue asPrimitive() {
+ return isPrimitive() ? (PrimitiveValue) this : null;
}
@Override
@@ -72,6 +78,11 @@ public abstract class AbstractValue implements Value {
}
@Override
+ public EnumValue asEnum() {
+ return isEnum() ? (EnumValue) this : null;
+ }
+
+ @Override
public ComplexValue asComplex() {
return isComplex() ? (ComplexValue) this : null;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce18b8e0/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomDeserializer.java
index d863eb6..a16d4ed 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomDeserializer.java
@@ -384,6 +384,7 @@ public class AtomDeserializer extends AbstractAtomDealer {
@SuppressWarnings("unchecked")
public <T, V extends T> Container<T> read(final InputStream input, final Class<V> reference)
throws XMLStreamException {
+
if (AtomFeedImpl.class.equals(reference)) {
return (Container<T>) feed(input);
} else if (AtomEntryImpl.class.equals(reference)) {