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/04/28 17:00:40 UTC
[1/5] [OLINGO-259] Delta response content parsing (including new
domain objects)
Repository: olingo-odata4
Updated Branches:
refs/heads/master 0b05798cd -> 118b779bc
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/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
deleted file mode 100644
index edf4366..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntryImpl.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.data;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
-/**
- * A single entry, represented via JSON.
- */
-@JsonSerialize(using = JSONEntrySerializer.class)
-@JsonDeserialize(using = JSONEntryDeserializer.class)
-public class JSONEntryImpl extends AbstractEntry {
-
- private static final long serialVersionUID = -5275365545400797758L;
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/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
deleted file mode 100644
index a5c2c33..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntrySerializer.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.data;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import java.io.IOException;
-import java.net.URI;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.data.Entry;
-import org.apache.olingo.commons.api.data.Link;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.domain.ODataOperation;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.core.edm.EdmTypeInfo;
-
-/**
- * Writes out JSON string from an entry.
- */
-public class JSONEntrySerializer extends AbstractJsonSerializer<JSONEntryImpl> {
-
- @Override
- protected void doSerialize(final JSONEntryImpl entry, final JsonGenerator jgen, final SerializerProvider provider)
- throws IOException, JsonProcessingException {
-
- doContainerSerialize(new ResWrap<JSONEntryImpl>((URI) null, null, entry), jgen, provider);
- }
-
- @Override
- protected void doContainerSerialize(
- final ResWrap<JSONEntryImpl> container, final JsonGenerator jgen, final SerializerProvider provider)
- throws IOException, JsonProcessingException {
-
- final Entry entry = container.getPayload();
-
- jgen.writeStartObject();
-
- if (serverMode) {
- if (container.getContextURL() != null) {
- jgen.writeStringField(version.compareTo(ODataServiceVersion.V40) >= 0
- ? Constants.JSON_CONTEXT : Constants.JSON_METADATA,
- container.getContextURL().getURI().toASCIIString());
- }
- if (version.compareTo(ODataServiceVersion.V40) >= 0 && StringUtils.isNotBlank(container.getMetadataETag())) {
- jgen.writeStringField(Constants.JSON_METADATA_ETAG, container.getMetadataETag());
- }
-
- if (StringUtils.isNotBlank(entry.getETag())) {
- jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_ETAG), entry.getETag());
- }
- }
-
- if (StringUtils.isNotBlank(entry.getType())) {
- jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_TYPE),
- new EdmTypeInfo.Builder().setTypeExpression(entry.getType()).build().external(version));
- }
-
- if (entry.getId() != null) {
- jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_ID), entry.getId());
- }
-
- for (Property property : entry.getProperties()) {
- property(jgen, property, property.getName());
- }
-
- if (serverMode && entry.getEditLink() != null && StringUtils.isNotBlank(entry.getEditLink().getHref())) {
- final URI link = URI.create(entry.getEditLink().getHref());
- final String editLink = link.isAbsolute() ? link.toASCIIString()
- : URI.create(entry.getBaseURI() + "/" + link.toASCIIString()).normalize().toASCIIString();
-
- jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_EDIT_LINK), editLink);
- }
-
- links(entry, jgen);
-
- for (Link link : entry.getMediaEditLinks()) {
- if (link.getTitle() == null) {
- jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK), link.getHref());
- }
-
- if (link.getInlineEntry() != null) {
- jgen.writeObjectField(link.getTitle(), link.getInlineEntry());
- }
- if (link.getInlineFeed() != null) {
- jgen.writeArrayFieldStart(link.getTitle());
- for (Entry subEntry : link.getInlineFeed().getEntries()) {
- jgen.writeObject(subEntry);
- }
- jgen.writeEndArray();
- }
- }
-
- if (serverMode) {
- for (ODataOperation operation : entry.getOperations()) {
- jgen.writeObjectFieldStart("#" + StringUtils.substringAfterLast(operation.getMetadataAnchor(), "#"));
- jgen.writeStringField(Constants.ATTR_TITLE, operation.getTitle());
- jgen.writeStringField(Constants.ATTR_TARGET, operation.getTarget().toASCIIString());
- jgen.writeEndObject();
- }
- }
-
- jgen.writeEndObject();
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONFeedDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONFeedDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONFeedDeserializer.java
deleted file mode 100644
index a9f80c4..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONFeedDeserializer.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.data;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import java.io.IOException;
-import java.net.URI;
-import java.util.Iterator;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.ResWrap;
-
-/**
- * Reads JSON string into a feed.
- * <br/>
- * If metadata information is available, the corresponding entry fields and content will be populated.
- */
-public class JSONFeedDeserializer extends AbstractJsonDeserializer<JSONFeedImpl> {
-
- @Override
- protected ResWrap<JSONFeedImpl> doDeserialize(final JsonParser parser, final DeserializationContext ctxt)
- throws IOException, JsonProcessingException {
-
- final ObjectNode tree = (ObjectNode) parser.getCodec().readTree(parser);
-
- if (!tree.has(Constants.VALUE)) {
- return null;
- }
-
- final JSONFeedImpl feed = new JSONFeedImpl();
-
- final URI contextURL;
- if (tree.hasNonNull(Constants.JSON_CONTEXT)) {
- contextURL = URI.create(tree.get(Constants.JSON_CONTEXT).textValue());
- tree.remove(Constants.JSON_CONTEXT);
- } else if (tree.hasNonNull(Constants.JSON_METADATA)) {
- contextURL = URI.create(tree.get(Constants.JSON_METADATA).textValue());
- tree.remove(Constants.JSON_METADATA);
- } else {
- contextURL = null;
- }
- feed.setMetadataContextURL(contextURL);
-
- final String metadataETag;
- if (tree.hasNonNull(Constants.JSON_METADATA_ETAG)) {
- metadataETag = tree.get(Constants.JSON_METADATA_ETAG).textValue();
- tree.remove(Constants.JSON_METADATA_ETAG);
- } else {
- metadataETag = null;
- }
-
- if (tree.hasNonNull(Constants.JSON_COUNT)) {
- feed.setCount(tree.get(Constants.JSON_COUNT).asInt());
- }
- if (tree.hasNonNull(Constants.JSON_NEXT_LINK)) {
- feed.setNext(URI.create(tree.get(Constants.JSON_NEXT_LINK).textValue()));
- }
-
- if (tree.hasNonNull(Constants.VALUE)) {
- for (final Iterator<JsonNode> itor = tree.get(Constants.VALUE).iterator(); itor.hasNext();) {
- feed.getEntries().add(
- itor.next().traverse(parser.getCodec()).<ResWrap<JSONEntryImpl>>readValueAs(
- new TypeReference<JSONEntryImpl>() {
- }).getPayload());
- }
- }
-
- return new ResWrap<JSONFeedImpl>(contextURL, metadataETag, feed);
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/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
deleted file mode 100644
index 02ce871..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONFeedImpl.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.data;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.olingo.commons.api.data.Entry;
-import org.apache.olingo.commons.api.data.Feed;
-import org.apache.olingo.commons.api.Constants;
-
-/**
- * List of entries, represented via JSON.
- *
- * @see JSONEntry
- */
-@JsonDeserialize(using = JSONFeedDeserializer.class)
-@JsonSerialize(using = JSONFeedSerializer.class)
-public class JSONFeedImpl extends AbstractPayloadObject implements Feed {
-
- private static final long serialVersionUID = -3576372289800799417L;
-
- private URI metadataContextURL;
-
- private String id;
-
- private Integer count;
-
- private final List<Entry> entries = new ArrayList<Entry>();
-
- private String next;
-
- @Override
- public URI getBaseURI() {
- URI baseURI = null;
- if (metadataContextURL != null) {
- final String metadataURI = metadataContextURL.toASCIIString();
- baseURI = URI.create(metadataURI.substring(0, metadataURI.indexOf(Constants.METADATA)));
- }
-
- return baseURI;
- }
-
- public void setMetadataContextURL(final URI metadataContextURL) {
- this.metadataContextURL = metadataContextURL;
- }
-
- @Override
- public String getId() {
- return id;
- }
-
- public void setId(final String id) {
- this.id = id;
- }
-
- @Override
- public Integer getCount() {
- return count;
- }
-
- @Override
- public void setCount(final Integer count) {
- this.count = count;
- }
-
- @Override
- public List<Entry> getEntries() {
- return entries;
- }
-
- @Override
- public void setNext(final URI next) {
- this.next = next == null ? null : next.toASCIIString();
- }
-
- @Override
- public URI getNext() {
- return next == null ? null : URI.create(next);
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/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
deleted file mode 100644
index 457b34c..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONFeedSerializer.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.data;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import java.io.IOException;
-import java.net.URI;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.data.Entry;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-
-public class JSONFeedSerializer extends AbstractJsonSerializer<JSONFeedImpl> {
-
- @Override
- protected void doSerialize(
- final JSONFeedImpl feed, final JsonGenerator jgen, final SerializerProvider provider)
- throws IOException, JsonProcessingException {
-
- doContainerSerialize(new ResWrap<JSONFeedImpl>((URI) null, null, feed), jgen, provider);
- }
-
- @Override
- protected void doContainerSerialize(
- final ResWrap<JSONFeedImpl> container, final JsonGenerator jgen, final SerializerProvider provider)
- throws IOException, JsonProcessingException {
-
- final JSONFeedImpl feed = container.getPayload();
-
- jgen.writeStartObject();
-
- if (serverMode) {
- if (container.getContextURL() != null) {
- jgen.writeStringField(version.compareTo(ODataServiceVersion.V40) >= 0
- ? Constants.JSON_CONTEXT : Constants.JSON_METADATA,
- container.getContextURL().getURI().toASCIIString());
- }
-
- if (version.compareTo(ODataServiceVersion.V40) >= 0 && StringUtils.isNotBlank(container.getMetadataETag())) {
- jgen.writeStringField(
- Constants.JSON_METADATA_ETAG,
- container.getMetadataETag());
- }
- }
-
- if (feed.getId() != null) {
- jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_ID), feed.getId());
- }
- if (feed.getCount() != null) {
- jgen.writeNumberField(Constants.JSON_COUNT, feed.getCount());
- }
- if (feed.getNext() != null) {
- jgen.writeStringField(Constants.JSON_NEXT_LINK, feed.getNext().toASCIIString());
- }
-
- jgen.writeArrayFieldStart(Constants.VALUE);
- for (Entry entry : feed.getEntries()) {
- jgen.writeObject(entry);
- }
-
- jgen.writeEndArray();
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/LinkImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/LinkImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/LinkImpl.java
index 85fabdc..bb865d1 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/LinkImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/LinkImpl.java
@@ -18,8 +18,8 @@
*/
package org.apache.olingo.commons.core.data;
-import org.apache.olingo.commons.api.data.Entry;
-import org.apache.olingo.commons.api.data.Feed;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
import org.apache.olingo.commons.api.data.Link;
public class LinkImpl extends AbstractPayloadObject implements Link {
@@ -36,9 +36,9 @@ public class LinkImpl extends AbstractPayloadObject implements Link {
private String mediaETag;
- private Entry entry;
+ private Entity entity;
- private Feed feed;
+ private EntitySet entitySet;
@Override
public String getTitle() {
@@ -91,22 +91,22 @@ public class LinkImpl extends AbstractPayloadObject implements Link {
}
@Override
- public Entry getInlineEntry() {
- return entry;
+ public Entity getInlineEntity() {
+ return entity;
}
@Override
- public void setInlineEntry(final Entry entry) {
- this.entry = entry;
+ public void setInlineEntity(final Entity entity) {
+ this.entity = entity;
}
@Override
- public Feed getInlineFeed() {
- return feed;
+ public EntitySet getInlineEntitySet() {
+ return entitySet;
}
@Override
- public void setInlineFeed(final Feed feed) {
- this.feed = feed;
+ public void setInlineEntitySet(final EntitySet entitySet) {
+ this.entitySet = entitySet;
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/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 8651b4b..a6a75b8 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
@@ -55,6 +55,12 @@ public abstract class ODataJacksonDeserializer<T> extends JsonDeserializer<T> {
protected String jsonNavigationLink;
+ protected String jsonCount;
+
+ protected String jsonNextLink;
+
+ protected String jsonDeltaLink;
+
protected String jsonError;
protected abstract T doDeserialize(JsonParser jp, DeserializationContext ctxt)
@@ -82,6 +88,9 @@ public abstract class ODataJacksonDeserializer<T> extends JsonDeserializer<T> {
jsonMediaETag = version.getJSONMap().get(ODataServiceVersion.JSON_MEDIA_ETAG);
jsonAssociationLink = version.getJSONMap().get(ODataServiceVersion.JSON_ASSOCIATION_LINK);
jsonNavigationLink = version.getJSONMap().get(ODataServiceVersion.JSON_NAVIGATION_LINK);
+ jsonCount = version.getJSONMap().get(ODataServiceVersion.JSON_COUNT);
+ jsonNextLink = version.getJSONMap().get(ODataServiceVersion.JSON_NEXT_LINK);
+ jsonDeltaLink = version.getJSONMap().get(ODataServiceVersion.JSON_DELTA_LINK);
jsonError = version.getJSONMap().get(ODataServiceVersion.JSON_ERROR);
return doDeserialize(jp, ctxt);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/JSONLinkCollectionImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/JSONLinkCollectionImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/JSONLinkCollectionImpl.java
index b0bd6e0..edf871b 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/JSONLinkCollectionImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/JSONLinkCollectionImpl.java
@@ -27,7 +27,7 @@ import org.apache.olingo.commons.api.data.v3.LinkCollection;
import org.apache.olingo.commons.core.data.AbstractPayloadObject;
/**
- * Link from an entry, represented via JSON.
+ * Link from an entity, represented via JSON.
*/
public class JSONLinkCollectionImpl extends AbstractPayloadObject implements LinkCollection {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataEntity.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataEntity.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataEntity.java
index 253b1a1..3152b3d 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataEntity.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataEntity.java
@@ -69,7 +69,7 @@ public abstract class AbstractODataEntity extends AbstractODataPayload implement
private URI editLink;
/**
- * Navigation links (might contain in-line entities or feeds).
+ * Navigation links (might contain in-line entities or entity sets).
*/
private final List<ODataLink> navigationLinks = new ArrayList<ODataLink>();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataEntitySet.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataEntitySet.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataEntitySet.java
index b2f7dc8..1396bce 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataEntitySet.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataEntitySet.java
@@ -32,8 +32,9 @@ public abstract class AbstractODataEntitySet extends AbstractODataPayload implem
private URI next;
/**
- * Number of ODataEntities contained in this feed. If <tt>$inlinecount</tt> was requested, this value comes from
- * there.
+ * Number of ODataEntities contained in this entity set.
+ * <br/>
+ * If <tt>$inlinecount</tt> was requested, this value comes from there.
*/
private Integer count;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataComplexValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataComplexValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataComplexValueImpl.java
index 9eed8c5..07ae0da 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataComplexValueImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataComplexValueImpl.java
@@ -34,7 +34,7 @@ public class ODataComplexValueImpl extends AbstractODataComplexValue<ODataProper
private static final long serialVersionUID = 1143925901934898802L;
/**
- * Navigation links (might contain in-line entities or feeds).
+ * Navigation links (might contain in-line entities or entity sets).
*/
private final List<ODataLink> navigationLinks = new ArrayList<ODataLink>();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmNavigationProperty.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmNavigationProperty.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmNavigationProperty.java
index e14879e..2e398f5 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmNavigationProperty.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmNavigationProperty.java
@@ -23,7 +23,6 @@ import org.apache.olingo.commons.api.edm.EdmEntityType;
import org.apache.olingo.commons.api.edm.EdmException;
import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
import org.apache.olingo.commons.api.edm.EdmStructuredType;
-import org.apache.olingo.commons.api.edm.EdmType;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
public abstract class AbstractEdmNavigationProperty extends EdmElementImpl implements EdmNavigationProperty {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/AbstractODataDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/AbstractODataDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/AbstractODataDeserializer.java
index 29eed4a..f584868 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/AbstractODataDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/AbstractODataDeserializer.java
@@ -22,9 +22,9 @@ import com.fasterxml.jackson.core.type.TypeReference;
import java.io.InputStream;
import java.lang.reflect.Type;
import java.net.URI;
-import org.apache.olingo.commons.api.data.Entry;
+import org.apache.olingo.commons.api.data.Entity;
import org.apache.olingo.commons.api.domain.ODataError;
-import org.apache.olingo.commons.api.data.Feed;
+import org.apache.olingo.commons.api.data.EntitySet;
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.format.ODataPubFormat;
@@ -32,11 +32,11 @@ import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.commons.api.op.CommonODataDeserializer;
import org.apache.olingo.commons.core.data.AtomDeserializer;
import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.core.data.AtomEntryImpl;
-import org.apache.olingo.commons.core.data.AtomFeedImpl;
+import org.apache.olingo.commons.core.data.AtomEntityImpl;
+import org.apache.olingo.commons.core.data.AtomEntitySetImpl;
import org.apache.olingo.commons.core.data.AtomPropertyImpl;
-import org.apache.olingo.commons.core.data.JSONEntryImpl;
-import org.apache.olingo.commons.core.data.JSONFeedImpl;
+import org.apache.olingo.commons.core.data.JSONEntityImpl;
+import org.apache.olingo.commons.core.data.JSONEntitySetImpl;
import org.apache.olingo.commons.core.data.JSONODataErrorImpl;
import org.apache.olingo.commons.core.data.JSONPropertyImpl;
import org.apache.olingo.commons.core.data.XMLODataErrorImpl;
@@ -54,17 +54,17 @@ public abstract class AbstractODataDeserializer extends AbstractJacksonTool impl
}
@Override
- public ResWrap<Feed> toFeed(final InputStream input, final ODataPubFormat format) {
+ public ResWrap<EntitySet> toEntitySet(final InputStream input, final ODataPubFormat format) {
return format == ODataPubFormat.ATOM
- ? this.<Feed, AtomFeedImpl>atom(input, AtomFeedImpl.class)
- : this.<Feed, JSONFeedImpl>json(input, JSONFeedImpl.class);
+ ? this.<EntitySet, AtomEntitySetImpl>atom(input, AtomEntitySetImpl.class)
+ : this.<EntitySet, JSONEntitySetImpl>json(input, JSONEntitySetImpl.class);
}
@Override
- public ResWrap<Entry> toEntry(final InputStream input, final ODataPubFormat format) {
+ public ResWrap<Entity> toEntity(final InputStream input, final ODataPubFormat format) {
return format == ODataPubFormat.ATOM
- ? this.<Entry, AtomEntryImpl>atom(input, AtomEntryImpl.class)
- : this.<Entry, JSONEntryImpl>json(input, JSONEntryImpl.class);
+ ? this.<Entity, AtomEntityImpl>atom(input, AtomEntityImpl.class)
+ : this.<Entity, JSONEntityImpl>json(input, JSONEntityImpl.class);
}
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/AbstractODataSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/AbstractODataSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/AbstractODataSerializer.java
index 6ce1fbf..32b9e99 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/AbstractODataSerializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/AbstractODataSerializer.java
@@ -25,19 +25,19 @@ import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.Entry;
-import org.apache.olingo.commons.api.data.Feed;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
import org.apache.olingo.commons.api.data.Link;
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.commons.api.op.ODataSerializer;
-import org.apache.olingo.commons.core.data.AtomEntryImpl;
-import org.apache.olingo.commons.core.data.AtomFeedImpl;
+import org.apache.olingo.commons.core.data.AtomEntityImpl;
+import org.apache.olingo.commons.core.data.AtomEntitySetImpl;
import org.apache.olingo.commons.core.data.AtomPropertyImpl;
import org.apache.olingo.commons.core.data.AtomSerializer;
-import org.apache.olingo.commons.core.data.JSONEntryImpl;
-import org.apache.olingo.commons.core.data.JSONFeedImpl;
+import org.apache.olingo.commons.core.data.JSONEntityImpl;
+import org.apache.olingo.commons.core.data.JSONEntitySetImpl;
import org.apache.olingo.commons.core.data.JSONPropertyImpl;
public abstract class AbstractODataSerializer extends AbstractJacksonTool implements ODataSerializer {
@@ -53,30 +53,30 @@ public abstract class AbstractODataSerializer extends AbstractJacksonTool implem
}
@Override
- public void feed(final Feed obj, final OutputStream out) {
- feed(obj, new OutputStreamWriter(out));
+ public void entitySet(final EntitySet obj, final OutputStream out) {
+ entitySet(obj, new OutputStreamWriter(out));
}
@Override
- public void feed(final Feed obj, final Writer writer) {
- if (obj instanceof AtomFeedImpl) {
- atom((AtomFeedImpl) obj, writer);
+ public void entitySet(final EntitySet obj, final Writer writer) {
+ if (obj instanceof AtomEntitySetImpl) {
+ atom((AtomEntitySetImpl) obj, writer);
} else {
- json((JSONFeedImpl) obj, writer);
+ json((JSONEntitySetImpl) obj, writer);
}
}
@Override
- public void entry(final Entry obj, final OutputStream out) {
- entry(obj, new OutputStreamWriter(out));
+ public void entity(final Entity obj, final OutputStream out) {
+ entity(obj, new OutputStreamWriter(out));
}
@Override
- public void entry(final Entry obj, final Writer writer) {
- if (obj instanceof AtomEntryImpl) {
- atom((AtomEntryImpl) obj, writer);
+ public void entity(final Entity obj, final Writer writer) {
+ if (obj instanceof AtomEntityImpl) {
+ atom((AtomEntityImpl) obj, writer);
} else {
- json((JSONEntryImpl) obj, writer);
+ json((JSONEntityImpl) obj, writer);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/ResourceFactory.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/ResourceFactory.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/ResourceFactory.java
index e585b2d..a2efe34 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/ResourceFactory.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/ResourceFactory.java
@@ -18,62 +18,62 @@
*/
package org.apache.olingo.commons.core.op;
-import org.apache.olingo.commons.api.data.Entry;
-import org.apache.olingo.commons.api.data.Feed;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.core.data.AtomEntryImpl;
-import org.apache.olingo.commons.core.data.AtomFeedImpl;
+import org.apache.olingo.commons.core.data.AtomEntityImpl;
+import org.apache.olingo.commons.core.data.AtomEntitySetImpl;
import org.apache.olingo.commons.core.data.AtomPropertyImpl;
-import org.apache.olingo.commons.core.data.JSONEntryImpl;
-import org.apache.olingo.commons.core.data.JSONFeedImpl;
+import org.apache.olingo.commons.core.data.JSONEntityImpl;
+import org.apache.olingo.commons.core.data.JSONEntitySetImpl;
import org.apache.olingo.commons.core.data.JSONPropertyImpl;
public class ResourceFactory {
/**
- * Gets a new instance of <tt>Feed</tt>.
+ * Gets a new instance of <tt>EntitySet</tt>.
*
* @param resourceClass reference class.
- * @return <tt>Feed</tt> object.
+ * @return {@link EntitySet} object.
*/
- public static Feed newFeed(final Class<? extends Feed> resourceClass) {
- Feed result = null;
+ public static EntitySet newEntitySet(final Class<? extends EntitySet> resourceClass) {
+ EntitySet result = null;
- if (AtomFeedImpl.class.equals(resourceClass)) {
- result = new AtomFeedImpl();
+ if (AtomEntitySetImpl.class.equals(resourceClass)) {
+ result = new AtomEntitySetImpl();
}
- if (JSONFeedImpl.class.equals(resourceClass)) {
- result = new JSONFeedImpl();
+ if (JSONEntitySetImpl.class.equals(resourceClass)) {
+ result = new JSONEntitySetImpl();
}
return result;
}
/**
- * Gets a new instance of <tt>Entry</tt>.
+ * Gets a new instance of <tt>Entity</tt>.
*
* @param resourceClass reference class.
- * @return <tt>Entry</tt> object.
+ * @return {@link Entity} object.
*/
- public static Entry newEntry(final Class<? extends Entry> resourceClass) {
- Entry result = null;
- if (AtomEntryImpl.class.equals(resourceClass)) {
- result = new AtomEntryImpl();
+ public static Entity newEntity(final Class<? extends Entity> resourceClass) {
+ Entity result = null;
+ if (AtomEntityImpl.class.equals(resourceClass)) {
+ result = new AtomEntityImpl();
}
- if (JSONEntryImpl.class.equals(resourceClass)) {
- result = new JSONEntryImpl();
+ if (JSONEntityImpl.class.equals(resourceClass)) {
+ result = new JSONEntityImpl();
}
return result;
}
- public static Property newProperty(final Class<? extends Entry> resourceClass) {
+ public static Property newProperty(final Class<? extends Entity> resourceClass) {
Property result = null;
- if (AtomEntryImpl.class.equals(resourceClass)) {
+ if (AtomEntityImpl.class.equals(resourceClass)) {
result = new AtomPropertyImpl();
}
- if (JSONEntryImpl.class.equals(resourceClass)) {
+ if (JSONEntityImpl.class.equals(resourceClass)) {
result = new JSONPropertyImpl();
}
@@ -81,45 +81,45 @@ public class ResourceFactory {
}
/**
- * Gets feed reference class from the given format.
+ * Gets entity set reference class from the given format.
*
* @param isXML whether it is JSON or XML / Atom
* @return resource reference class.
*/
- public static Class<? extends Feed> feedClassForFormat(final boolean isXML) {
- return isXML ? AtomFeedImpl.class : JSONFeedImpl.class;
+ public static Class<? extends EntitySet> entitySetClassForFormat(final boolean isXML) {
+ return isXML ? AtomEntitySetImpl.class : JSONEntitySetImpl.class;
}
/**
- * Gets entry reference class from the given format.
+ * Gets entity reference class from the given format.
*
* @param isXML whether it is JSON or XML / Atom
* @return resource reference class.
*/
- public static Class<? extends Entry> entryClassForFormat(final boolean isXML) {
- return isXML ? AtomEntryImpl.class : JSONEntryImpl.class;
+ public static Class<? extends Entity> entityClassForFormat(final boolean isXML) {
+ return isXML ? AtomEntityImpl.class : JSONEntityImpl.class;
}
/**
- * Gets <tt>Entry</tt> object from feed resource.
+ * Gets <tt>Entity</tt> object from entity set resource.
*
- * @param resourceClass feed reference class.
- * @return <tt>Entry</tt> object.
+ * @param resourceClass entity set reference class.
+ * @return {@link Entity} object.
*/
- public static Class<? extends Entry> entryClassForFeed(final Class<? extends Feed> resourceClass) {
- Class<? extends Entry> result = null;
+ public static Class<? extends Entity> entityClassForEntitySet(final Class<? extends EntitySet> resourceClass) {
+ Class<? extends Entity> result = null;
- if (AtomFeedImpl.class.equals(resourceClass)) {
- result = AtomEntryImpl.class;
+ if (AtomEntitySetImpl.class.equals(resourceClass)) {
+ result = AtomEntityImpl.class;
}
- if (JSONFeedImpl.class.equals(resourceClass)) {
- result = JSONEntryImpl.class;
+ if (JSONEntitySetImpl.class.equals(resourceClass)) {
+ result = JSONEntityImpl.class;
}
return result;
}
- public static ODataPubFormat formatForEntryClass(final Class<? extends Entry> reference) {
- return reference.equals(AtomEntryImpl.class) ? ODataPubFormat.ATOM : ODataPubFormat.JSON;
+ public static ODataPubFormat formatForEntityClass(final Class<? extends Entity> reference) {
+ return reference.equals(AtomEntityImpl.class) ? ODataPubFormat.ATOM : ODataPubFormat.JSON;
}
}
[2/5] [OLINGO-259] Delta response content parsing (including new
domain objects)
Posted by il...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/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 72d8d76..080b4aa 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
@@ -18,7 +18,6 @@
*/
package org.apache.olingo.commons.core.data;
-import org.apache.olingo.commons.api.data.ResWrap;
import java.io.InputStream;
import java.net.URI;
import java.text.ParseException;
@@ -32,6 +31,8 @@ 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.EntitySet;
+import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.data.Value;
import org.apache.olingo.commons.api.domain.ODataOperation;
import org.apache.olingo.commons.api.domain.ODataPropertyType;
@@ -228,7 +229,7 @@ public class AtomDeserializer extends AbstractAtomDealer {
final AtomPropertyImpl property = new AtomPropertyImpl();
- if (ODataServiceVersion.V40 == version && v4PropertyValueQName.equals(start.getName())) {
+ if (ODataServiceVersion.V40 == version && propertyValueQName.equals(start.getName())) {
// retrieve name from context
final Attribute context = start.getAttributeByName(contextQName);
if (context != null) {
@@ -352,10 +353,10 @@ public class AtomDeserializer extends AbstractAtomDealer {
}
if (inline != null) {
if (Constants.QNAME_ATOM_ELEM_ENTRY.equals(inline.getName())) {
- link.setInlineEntry(entry(reader, inline));
+ link.setInlineEntity(entity(reader, inline));
}
if (Constants.QNAME_ATOM_ELEM_FEED.equals(inline.getName())) {
- link.setInlineFeed(feed(reader, inline));
+ link.setInlineEntitySet(entitySet(reader, inline));
}
}
}
@@ -366,6 +367,102 @@ public class AtomDeserializer extends AbstractAtomDealer {
}
}
+ private ResWrap<AtomDeltaImpl> delta(final InputStream input) throws XMLStreamException {
+ final XMLEventReader reader = getReader(input);
+ final StartElement start = skipBeforeFirstStartElement(reader);
+ return getContainer(start, delta(reader, start));
+ }
+
+ private AtomDeltaImpl delta(final XMLEventReader reader, final StartElement start) throws XMLStreamException {
+ if (!Constants.QNAME_ATOM_ELEM_FEED.equals(start.getName())) {
+ return null;
+ }
+ final AtomDeltaImpl delta = new AtomDeltaImpl();
+ final Attribute xmlBase = start.getAttributeByName(Constants.QNAME_ATTR_XML_BASE);
+ if (xmlBase != null) {
+ delta.setBaseURI(xmlBase.getValue());
+ }
+
+ boolean foundEndFeed = false;
+ while (reader.hasNext() && !foundEndFeed) {
+ final XMLEvent event = reader.nextEvent();
+ if (event.isStartElement()) {
+ if (countQName.equals(event.asStartElement().getName())) {
+ count(reader, event.asStartElement(), delta);
+ } else if (Constants.QNAME_ATOM_ELEM_ID.equals(event.asStartElement().getName())) {
+ common(reader, event.asStartElement(), delta, "id");
+ } else if (Constants.QNAME_ATOM_ELEM_TITLE.equals(event.asStartElement().getName())) {
+ common(reader, event.asStartElement(), delta, "title");
+ } else if (Constants.QNAME_ATOM_ELEM_SUMMARY.equals(event.asStartElement().getName())) {
+ common(reader, event.asStartElement(), delta, "summary");
+ } else if (Constants.QNAME_ATOM_ELEM_UPDATED.equals(event.asStartElement().getName())) {
+ common(reader, event.asStartElement(), delta, "updated");
+ } else if (Constants.QNAME_ATOM_ELEM_LINK.equals(event.asStartElement().getName())) {
+ final Attribute rel = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REL));
+ if (rel != null) {
+ if (Constants.NEXT_LINK_REL.equals(rel.getValue())) {
+ final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
+ if (href != null) {
+ delta.setNext(URI.create(href.getValue()));
+ }
+ }
+ if (Constants.DELTA_LINK_REL.equals(rel.getValue())) {
+ final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
+ if (href != null) {
+ delta.setDeltaLink(URI.create(href.getValue()));
+ }
+ }
+ }
+ } else if (Constants.QNAME_ATOM_ELEM_ENTRY.equals(event.asStartElement().getName())) {
+ delta.getEntities().add(entity(reader, event.asStartElement()));
+ } else if (deletedEntryQName.equals(event.asStartElement().getName())) {
+ final DeletedEntityImpl deletedEntity = new DeletedEntityImpl();
+
+ final Attribute ref = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REF));
+ if (ref != null) {
+ deletedEntity.setId(ref.getValue());
+ }
+ final Attribute reason = event.asStartElement().getAttributeByName(reasonQName);
+ if (reason != null) {
+ deletedEntity.setReason(reason.getValue());
+ }
+
+ delta.getDeletedEntities().add(deletedEntity);
+ } else if (linkQName.equals(event.asStartElement().getName())
+ || deletedLinkQName.equals(event.asStartElement().getName())) {
+
+ final DeltaLinkImpl link = new DeltaLinkImpl();
+
+ final Attribute source = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_SOURCE));
+ if (source != null) {
+ link.setSource(URI.create(source.getValue()));
+ }
+ final Attribute relationship =
+ event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_RELATIONSHIP));
+ if (relationship != null) {
+ link.setRelationship(relationship.getValue());
+ }
+ final Attribute target = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TARGET));
+ if (target != null) {
+ link.setTarget(URI.create(target.getValue()));
+ }
+
+ if (linkQName.equals(event.asStartElement().getName())) {
+ delta.getAddedLinks().add(link);
+ } else {
+ delta.getDeletedLinks().add(link);
+ }
+ }
+ }
+
+ if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
+ foundEndFeed = true;
+ }
+ }
+
+ return delta;
+ }
+
private ResWrap<XMLLinkCollectionImpl> linkCollection(final InputStream input) throws XMLStreamException {
final XMLEventReader reader = getReader(input);
final StartElement start = skipBeforeFirstStartElement(reader);
@@ -400,14 +497,14 @@ public class AtomDeserializer extends AbstractAtomDealer {
return linkCollection;
}
- private void properties(final XMLEventReader reader, final StartElement start, final AtomEntryImpl entry)
+ private void properties(final XMLEventReader reader, final StartElement start, final AtomEntityImpl entity)
throws XMLStreamException {
boolean foundEndProperties = false;
while (reader.hasNext() && !foundEndProperties) {
final XMLEvent event = reader.nextEvent();
if (event.isStartElement()) {
- entry.getProperties().add(property(reader, event.asStartElement()));
+ entity.getProperties().add(property(reader, event.asStartElement()));
}
if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
@@ -416,31 +513,31 @@ public class AtomDeserializer extends AbstractAtomDealer {
}
}
- private AtomEntryImpl entryRef(final StartElement start) throws XMLStreamException {
- final AtomEntryImpl entry = new AtomEntryImpl();
+ private AtomEntityImpl entityRef(final StartElement start) throws XMLStreamException {
+ final AtomEntityImpl entity = new AtomEntityImpl();
- final Attribute entryRefId = start.getAttributeByName(Constants.QNAME_ATOM_ATTR_ID);
- if (entryRefId != null) {
- entry.setId(entryRefId.getValue());
+ final Attribute entityRefId = start.getAttributeByName(Constants.QNAME_ATOM_ATTR_ID);
+ if (entityRefId != null) {
+ entity.setId(entityRefId.getValue());
}
- return entry;
+ return entity;
}
- private AtomEntryImpl entry(final XMLEventReader reader, final StartElement start) throws XMLStreamException {
- final AtomEntryImpl entry;
+ private AtomEntityImpl entity(final XMLEventReader reader, final StartElement start) throws XMLStreamException {
+ final AtomEntityImpl entity;
if (entryRefQName.equals(start.getName())) {
- entry = entryRef(start);
+ entity = entityRef(start);
} else if (Constants.QNAME_ATOM_ELEM_ENTRY.equals(start.getName())) {
- entry = new AtomEntryImpl();
+ entity = new AtomEntityImpl();
final Attribute xmlBase = start.getAttributeByName(Constants.QNAME_ATTR_XML_BASE);
if (xmlBase != null) {
- entry.setBaseURI(xmlBase.getValue());
+ entity.setBaseURI(xmlBase.getValue());
}
final Attribute etag = start.getAttributeByName(etagQName);
if (etag != null) {
- entry.setETag(etag.getValue());
+ entity.setETag(etag.getValue());
}
boolean foundEndEntry = false;
@@ -449,17 +546,17 @@ public class AtomDeserializer extends AbstractAtomDealer {
if (event.isStartElement()) {
if (Constants.QNAME_ATOM_ELEM_ID.equals(event.asStartElement().getName())) {
- common(reader, event.asStartElement(), entry, "id");
+ common(reader, event.asStartElement(), entity, "id");
} else if (Constants.QNAME_ATOM_ELEM_TITLE.equals(event.asStartElement().getName())) {
- common(reader, event.asStartElement(), entry, "title");
+ common(reader, event.asStartElement(), entity, "title");
} else if (Constants.QNAME_ATOM_ELEM_SUMMARY.equals(event.asStartElement().getName())) {
- common(reader, event.asStartElement(), entry, "summary");
+ common(reader, event.asStartElement(), entity, "summary");
} else if (Constants.QNAME_ATOM_ELEM_UPDATED.equals(event.asStartElement().getName())) {
- common(reader, event.asStartElement(), entry, "updated");
+ common(reader, event.asStartElement(), entity, "updated");
} else if (Constants.QNAME_ATOM_ELEM_CATEGORY.equals(event.asStartElement().getName())) {
final Attribute term = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATOM_ATTR_TERM));
if (term != null) {
- entry.setType(new EdmTypeInfo.Builder().setTypeExpression(term.getValue()).build().internal());
+ entity.setType(new EdmTypeInfo.Builder().setTypeExpression(term.getValue()).build().internal());
}
} else if (Constants.QNAME_ATOM_ELEM_LINK.equals(event.asStartElement().getName())) {
final LinkImpl link = new LinkImpl();
@@ -481,22 +578,22 @@ public class AtomDeserializer extends AbstractAtomDealer {
}
if (Constants.SELF_LINK_REL.equals(link.getRel())) {
- entry.setSelfLink(link);
+ entity.setSelfLink(link);
} else if (Constants.EDIT_LINK_REL.equals(link.getRel())) {
- entry.setEditLink(link);
+ entity.setEditLink(link);
} else if (Constants.EDITMEDIA_LINK_REL.equals(link.getRel())) {
final Attribute mediaETag = event.asStartElement().getAttributeByName(etagQName);
if (mediaETag != null) {
- entry.setMediaETag(mediaETag.getValue());
+ entity.setMediaETag(mediaETag.getValue());
}
} else if (link.getRel().startsWith(
version.getNamespaceMap().get(ODataServiceVersion.NAVIGATION_LINK_REL))) {
- entry.getNavigationLinks().add(link);
+ entity.getNavigationLinks().add(link);
inline(reader, event.asStartElement(), link);
} else if (link.getRel().startsWith(
version.getNamespaceMap().get(ODataServiceVersion.ASSOCIATION_LINK_REL))) {
- entry.getAssociationLinks().add(link);
+ entity.getAssociationLinks().add(link);
} else if (link.getRel().startsWith(
version.getNamespaceMap().get(ODataServiceVersion.MEDIA_EDIT_LINK_REL))) {
@@ -504,7 +601,7 @@ public class AtomDeserializer extends AbstractAtomDealer {
if (metag != null) {
link.setMediaETag(metag.getValue());
}
- entry.getMediaEditLinks().add(link);
+ entity.getMediaEditLinks().add(link);
}
} else if (actionQName.equals(event.asStartElement().getName())) {
final ODataOperation operation = new ODataOperation();
@@ -522,20 +619,20 @@ public class AtomDeserializer extends AbstractAtomDealer {
operation.setTarget(URI.create(target.getValue()));
}
- entry.getOperations().add(operation);
+ entity.getOperations().add(operation);
} else if (Constants.QNAME_ATOM_ELEM_CONTENT.equals(event.asStartElement().getName())) {
final Attribute type = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TYPE));
if (type == null || ContentType.APPLICATION_XML.equals(type.getValue())) {
- properties(reader, skipBeforeFirstStartElement(reader), entry);
+ properties(reader, skipBeforeFirstStartElement(reader), entity);
} else {
- entry.setMediaContentType(type.getValue());
+ entity.setMediaContentType(type.getValue());
final Attribute src = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATOM_ATTR_SRC));
if (src != null) {
- entry.setMediaContentSource(src.getValue());
+ entity.setMediaContentSource(src.getValue());
}
}
} else if (propertiesQName.equals(event.asStartElement().getName())) {
- properties(reader, event.asStartElement(), entry);
+ properties(reader, event.asStartElement(), entity);
}
}
@@ -544,21 +641,21 @@ public class AtomDeserializer extends AbstractAtomDealer {
}
}
- return entry;
+ return entity;
} else {
- entry = null;
+ entity = null;
}
- return entry;
+ return entity;
}
- private ResWrap<AtomEntryImpl> entry(final InputStream input) throws XMLStreamException {
+ private ResWrap<AtomEntityImpl> entity(final InputStream input) throws XMLStreamException {
final XMLEventReader reader = getReader(input);
final StartElement start = skipBeforeFirstStartElement(reader);
- return getContainer(start, entry(reader, start));
+ return getContainer(start, entity(reader, start));
}
- private void count(final XMLEventReader reader, final StartElement start, final AtomFeedImpl feed)
+ private void count(final XMLEventReader reader, final StartElement start, final EntitySet entitySet)
throws XMLStreamException {
boolean foundEndElement = false;
@@ -566,7 +663,7 @@ public class AtomDeserializer extends AbstractAtomDealer {
final XMLEvent event = reader.nextEvent();
if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
- feed.setCount(Integer.valueOf(event.asCharacters().getData()));
+ entitySet.setCount(Integer.valueOf(event.asCharacters().getData()));
}
if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
@@ -575,14 +672,14 @@ public class AtomDeserializer extends AbstractAtomDealer {
}
}
- private AtomFeedImpl feed(final XMLEventReader reader, final StartElement start) throws XMLStreamException {
+ private AtomEntitySetImpl entitySet(final XMLEventReader reader, final StartElement start) throws XMLStreamException {
if (!Constants.QNAME_ATOM_ELEM_FEED.equals(start.getName())) {
return null;
}
- final AtomFeedImpl feed = new AtomFeedImpl();
+ final AtomEntitySetImpl entitySet = new AtomEntitySetImpl();
final Attribute xmlBase = start.getAttributeByName(Constants.QNAME_ATTR_XML_BASE);
if (xmlBase != null) {
- feed.setBaseURI(xmlBase.getValue());
+ entitySet.setBaseURI(xmlBase.getValue());
}
boolean foundEndFeed = false;
@@ -590,27 +687,27 @@ public class AtomDeserializer extends AbstractAtomDealer {
final XMLEvent event = reader.nextEvent();
if (event.isStartElement()) {
if (countQName.equals(event.asStartElement().getName())) {
- count(reader, event.asStartElement(), feed);
+ count(reader, event.asStartElement(), entitySet);
} else if (Constants.QNAME_ATOM_ELEM_ID.equals(event.asStartElement().getName())) {
- common(reader, event.asStartElement(), feed, "id");
+ common(reader, event.asStartElement(), entitySet, "id");
} else if (Constants.QNAME_ATOM_ELEM_TITLE.equals(event.asStartElement().getName())) {
- common(reader, event.asStartElement(), feed, "title");
+ common(reader, event.asStartElement(), entitySet, "title");
} else if (Constants.QNAME_ATOM_ELEM_SUMMARY.equals(event.asStartElement().getName())) {
- common(reader, event.asStartElement(), feed, "summary");
+ common(reader, event.asStartElement(), entitySet, "summary");
} else if (Constants.QNAME_ATOM_ELEM_UPDATED.equals(event.asStartElement().getName())) {
- common(reader, event.asStartElement(), feed, "updated");
+ common(reader, event.asStartElement(), entitySet, "updated");
} else if (Constants.QNAME_ATOM_ELEM_LINK.equals(event.asStartElement().getName())) {
final Attribute rel = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REL));
if (rel != null && Constants.NEXT_LINK_REL.equals(rel.getValue())) {
final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
if (href != null) {
- feed.setNext(URI.create(href.getValue()));
+ entitySet.setNext(URI.create(href.getValue()));
}
}
} else if (Constants.QNAME_ATOM_ELEM_ENTRY.equals(event.asStartElement().getName())) {
- feed.getEntries().add(entry(reader, event.asStartElement()));
+ entitySet.getEntities().add(entity(reader, event.asStartElement()));
} else if (entryRefQName.equals(event.asStartElement().getName())) {
- feed.getEntries().add(entryRef(event.asStartElement()));
+ entitySet.getEntities().add(entityRef(event.asStartElement()));
}
}
@@ -619,13 +716,13 @@ public class AtomDeserializer extends AbstractAtomDealer {
}
}
- return feed;
+ return entitySet;
}
- private ResWrap<AtomFeedImpl> feed(final InputStream input) throws XMLStreamException {
+ private ResWrap<AtomEntitySetImpl> entitySet(final InputStream input) throws XMLStreamException {
final XMLEventReader reader = getReader(input);
final StartElement start = skipBeforeFirstStartElement(reader);
- return getContainer(start, feed(reader, start));
+ return getContainer(start, entitySet(reader, start));
}
private XMLODataErrorImpl error(final XMLEventReader reader, final StartElement start) throws XMLStreamException {
@@ -700,14 +797,16 @@ public class AtomDeserializer extends AbstractAtomDealer {
if (XMLODataErrorImpl.class.equals(reference)) {
return (ResWrap<T>) error(input);
- } else if (AtomFeedImpl.class.equals(reference)) {
- return (ResWrap<T>) feed(input);
- } else if (AtomEntryImpl.class.equals(reference)) {
- return (ResWrap<T>) entry(input);
+ } else if (AtomEntitySetImpl.class.equals(reference)) {
+ return (ResWrap<T>) entitySet(input);
+ } else if (AtomEntityImpl.class.equals(reference)) {
+ return (ResWrap<T>) entity(input);
} else if (AtomPropertyImpl.class.equals(reference)) {
return (ResWrap<T>) property(input);
} else if (XMLLinkCollectionImpl.class.equals(reference)) {
return (ResWrap<T>) linkCollection(input);
+ } else if (AtomDeltaImpl.class.equals(reference)) {
+ return (ResWrap<T>) delta(input);
}
return null;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomEntityImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomEntityImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomEntityImpl.java
new file mode 100644
index 0000000..6c7fb13
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomEntityImpl.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.core.data;
+
+public class AtomEntityImpl extends AbstractEntity {
+
+ private static final long serialVersionUID = 6973729343868293279L;
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomEntitySetImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomEntitySetImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomEntitySetImpl.java
new file mode 100644
index 0000000..397b18e
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomEntitySetImpl.java
@@ -0,0 +1,28 @@
+/*
+ * 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;
+
+/**
+ * List of entries, represented via Atom.
+ */
+public class AtomEntitySetImpl extends AbstractEntitySet {
+
+ private static final long serialVersionUID = 5466590540021319153L;
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomEntryImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomEntryImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomEntryImpl.java
deleted file mode 100644
index 8eef97a..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomEntryImpl.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.data;
-
-public class AtomEntryImpl extends AbstractEntry {
-
- private static final long serialVersionUID = 6973729343868293279L;
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomFeedImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomFeedImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomFeedImpl.java
deleted file mode 100644
index 09dfdcf..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomFeedImpl.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.data;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.olingo.commons.api.data.Entry;
-import org.apache.olingo.commons.api.data.Feed;
-
-/**
- * List of entries, represented via Atom.
- *
- * @see AtomEntry
- */
-public class AtomFeedImpl extends AbstractODataObject implements Feed {
-
- private static final long serialVersionUID = 5466590540021319153L;
-
- private Integer count;
-
- private final List<Entry> entries = new ArrayList<Entry>();
-
- private URI next;
-
- @Override
- public void setCount(final Integer count) {
- this.count = count;
- }
-
- @Override
- public Integer getCount() {
- return count;
- }
-
- @Override
- public List<Entry> getEntries() {
- return entries;
- }
-
- @Override
- public void setNext(final URI next) {
- this.next = next;
- }
-
- @Override
- public URI getNext() {
- return next;
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/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 aba3d16..279e3fe 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
@@ -29,8 +29,8 @@ 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.ResWrap;
-import org.apache.olingo.commons.api.data.Entry;
-import org.apache.olingo.commons.api.data.Feed;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
import org.apache.olingo.commons.api.data.Link;
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.data.Value;
@@ -166,18 +166,18 @@ public class AtomSerializer extends AbstractAtomDealer {
writer.writeAttribute(Constants.ATTR_TYPE, link.getType());
}
- if (link.getInlineEntry() != null || link.getInlineFeed() != null) {
+ if (link.getInlineEntity() != null || link.getInlineEntitySet() != null) {
writer.writeStartElement(Constants.PREFIX_METADATA, Constants.ATOM_ELEM_INLINE,
version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA));
- if (link.getInlineEntry() != null) {
+ if (link.getInlineEntity() != null) {
writer.writeStartElement(Constants.ATOM_ELEM_ENTRY);
- entry(writer, link.getInlineEntry());
+ entity(writer, link.getInlineEntity());
writer.writeEndElement();
}
- if (link.getInlineFeed() != null) {
+ if (link.getInlineEntitySet() != null) {
writer.writeStartElement(Constants.ATOM_ELEM_FEED);
- feed(writer, link.getInlineFeed());
+ entitySet(writer, link.getInlineEntitySet());
writer.writeEndElement();
}
@@ -210,51 +210,51 @@ public class AtomSerializer extends AbstractAtomDealer {
}
}
- private void entry(final XMLStreamWriter writer, final Entry entry) throws XMLStreamException {
- if (entry.getBaseURI() != null) {
- writer.writeAttribute(XMLConstants.XML_NS_URI, Constants.ATTR_XML_BASE, entry.getBaseURI().toASCIIString());
+ private void entity(final XMLStreamWriter writer, final Entity entity) throws XMLStreamException {
+ if (entity.getBaseURI() != null) {
+ writer.writeAttribute(XMLConstants.XML_NS_URI, Constants.ATTR_XML_BASE, entity.getBaseURI().toASCIIString());
}
- if (serverMode && StringUtils.isNotBlank(entry.getETag())) {
+ if (serverMode && StringUtils.isNotBlank(entity.getETag())) {
writer.writeAttribute(
version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA),
- Constants.ATOM_ATTR_ETAG, entry.getETag());
+ Constants.ATOM_ATTR_ETAG, entity.getETag());
}
- if (StringUtils.isNotBlank(entry.getId())) {
+ if (StringUtils.isNotBlank(entity.getId())) {
writer.writeStartElement(Constants.ATOM_ELEM_ID);
- writer.writeCharacters(entry.getId());
+ writer.writeCharacters(entity.getId());
writer.writeEndElement();
}
writer.writeStartElement(Constants.ATOM_ELEM_CATEGORY);
writer.writeAttribute(Constants.ATOM_ATTR_SCHEME, version.getNamespaceMap().get(ODataServiceVersion.NS_SCHEME));
- if (StringUtils.isNotBlank(entry.getType())) {
+ if (StringUtils.isNotBlank(entity.getType())) {
writer.writeAttribute(Constants.ATOM_ATTR_TERM,
- new EdmTypeInfo.Builder().setTypeExpression(entry.getType()).build().external(version));
+ new EdmTypeInfo.Builder().setTypeExpression(entity.getType()).build().external(version));
}
writer.writeEndElement();
- if (entry instanceof AbstractODataObject) {
- common(writer, (AbstractODataObject) entry);
+ if (entity instanceof AbstractODataObject) {
+ common(writer, (AbstractODataObject) entity);
}
if (serverMode) {
- if (entry.getEditLink() != null) {
- links(writer, Collections.singletonList(entry.getEditLink()));
+ if (entity.getEditLink() != null) {
+ links(writer, Collections.singletonList(entity.getEditLink()));
}
- if (entry.getSelfLink() != null) {
- links(writer, Collections.singletonList(entry.getSelfLink()));
+ if (entity.getSelfLink() != null) {
+ links(writer, Collections.singletonList(entity.getSelfLink()));
}
}
- links(writer, entry.getAssociationLinks());
- links(writer, entry.getNavigationLinks());
- links(writer, entry.getMediaEditLinks());
+ links(writer, entity.getAssociationLinks());
+ links(writer, entity.getNavigationLinks());
+ links(writer, entity.getMediaEditLinks());
if (serverMode) {
- for (ODataOperation operation : entry.getOperations()) {
+ for (ODataOperation operation : entity.getOperations()) {
writer.writeStartElement(
version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ELEM_ACTION);
writer.writeAttribute(Constants.ATTR_METADATA, operation.getMetadataAnchor());
@@ -265,51 +265,51 @@ public class AtomSerializer extends AbstractAtomDealer {
}
writer.writeStartElement(Constants.ATOM_ELEM_CONTENT);
- if (entry.isMediaEntry()) {
- if (StringUtils.isNotBlank(entry.getMediaContentType())) {
- writer.writeAttribute(Constants.ATTR_TYPE, entry.getMediaContentType());
+ if (entity.isMediaEntity()) {
+ if (StringUtils.isNotBlank(entity.getMediaContentType())) {
+ writer.writeAttribute(Constants.ATTR_TYPE, entity.getMediaContentType());
}
- if (StringUtils.isNotBlank(entry.getMediaContentSource())) {
- writer.writeAttribute(Constants.ATOM_ATTR_SRC, entry.getMediaContentSource());
+ if (StringUtils.isNotBlank(entity.getMediaContentSource())) {
+ writer.writeAttribute(Constants.ATOM_ATTR_SRC, entity.getMediaContentSource());
}
writer.writeEndElement();
writer.writeStartElement(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.PROPERTIES);
- properties(writer, entry.getProperties());
+ properties(writer, entity.getProperties());
} else {
writer.writeAttribute(Constants.ATTR_TYPE, ContentType.APPLICATION_XML);
writer.writeStartElement(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.PROPERTIES);
- properties(writer, entry.getProperties());
+ properties(writer, entity.getProperties());
writer.writeEndElement();
}
writer.writeEndElement();
}
- private void entryRef(final XMLStreamWriter writer, final Entry entry) throws XMLStreamException {
+ private void entityRef(final XMLStreamWriter writer, final Entity entity) throws XMLStreamException {
writer.writeStartElement(Constants.ATOM_ELEM_ENTRY_REF);
writer.writeNamespace(StringUtils.EMPTY, version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA));
- writer.writeAttribute(Constants.ATOM_ATTR_ID, entry.getId());
+ writer.writeAttribute(Constants.ATOM_ATTR_ID, entity.getId());
}
- private void entryRef(final XMLStreamWriter writer, final ResWrap<Entry> container) throws XMLStreamException {
+ private void entityRef(final XMLStreamWriter writer, final ResWrap<Entity> container) throws XMLStreamException {
writer.writeStartElement(Constants.ATOM_ELEM_ENTRY_REF);
writer.writeNamespace(StringUtils.EMPTY, version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA));
addContextInfo(writer, container);
writer.writeAttribute(Constants.ATOM_ATTR_ID, container.getPayload().getId());
}
- private void entry(final Writer outWriter, final Entry entry) throws XMLStreamException {
+ private void entity(final Writer outWriter, final Entity entity) throws XMLStreamException {
final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
- if (entry.getType() == null && entry.getProperties().isEmpty()) {
+ if (entity.getType() == null && entity.getProperties().isEmpty()) {
writer.writeStartDocument();
writer.setDefaultNamespace(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA));
- entryRef(writer, entry);
+ entityRef(writer, entity);
} else {
startDocument(writer, Constants.ATOM_ELEM_ENTRY);
- entry(writer, entry);
+ entity(writer, entity);
}
writer.writeEndElement();
@@ -317,22 +317,22 @@ public class AtomSerializer extends AbstractAtomDealer {
writer.flush();
}
- private void entry(final Writer outWriter, final ResWrap<Entry> container) throws XMLStreamException {
- final Entry entry = container.getPayload();
+ private void entity(final Writer outWriter, final ResWrap<Entity> container) throws XMLStreamException {
+ final Entity entity = container.getPayload();
final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
- if (entry.getType() == null && entry.getProperties().isEmpty()) {
+ if (entity.getType() == null && entity.getProperties().isEmpty()) {
writer.writeStartDocument();
writer.setDefaultNamespace(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA));
- entryRef(writer, container);
+ entityRef(writer, container);
} else {
startDocument(writer, Constants.ATOM_ELEM_ENTRY);
addContextInfo(writer, container);
- entry(writer, entry);
+ entity(writer, entity);
}
writer.writeEndElement();
@@ -340,68 +340,68 @@ public class AtomSerializer extends AbstractAtomDealer {
writer.flush();
}
- private void feed(final XMLStreamWriter writer, final Feed feed) throws XMLStreamException {
- if (feed.getBaseURI() != null) {
- writer.writeAttribute(XMLConstants.XML_NS_URI, Constants.ATTR_XML_BASE, feed.getBaseURI().toASCIIString());
+ private void entitySet(final XMLStreamWriter writer, final EntitySet entitySet) throws XMLStreamException {
+ if (entitySet.getBaseURI() != null) {
+ writer.writeAttribute(XMLConstants.XML_NS_URI, Constants.ATTR_XML_BASE, entitySet.getBaseURI().toASCIIString());
}
- if (feed.getCount() != null) {
+ if (entitySet.getCount() != null) {
writer.writeStartElement(
version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ELEM_COUNT);
- writer.writeCharacters(Integer.toString(feed.getCount()));
+ writer.writeCharacters(Integer.toString(entitySet.getCount()));
writer.writeEndElement();
}
- if (StringUtils.isNotBlank(feed.getId())) {
+ if (StringUtils.isNotBlank(entitySet.getId())) {
writer.writeStartElement(Constants.ATOM_ELEM_ID);
- writer.writeCharacters(feed.getId());
+ writer.writeCharacters(entitySet.getId());
writer.writeEndElement();
}
- if (feed instanceof AbstractODataObject) {
- common(writer, (AbstractODataObject) feed);
+ if (entitySet instanceof AbstractODataObject) {
+ common(writer, (AbstractODataObject) entitySet);
}
- for (Entry entry : feed.getEntries()) {
- if (entry.getType() == null && entry.getProperties().isEmpty()) {
- entryRef(writer, entry);
+ for (Entity entity : entitySet.getEntities()) {
+ if (entity.getType() == null && entity.getProperties().isEmpty()) {
+ entityRef(writer, entity);
writer.writeEndElement();
} else {
writer.writeStartElement(Constants.ATOM_ELEM_ENTRY);
- entry(writer, entry);
+ entity(writer, entity);
writer.writeEndElement();
}
}
- if (feed.getNext() != null) {
+ if (entitySet.getNext() != null) {
final LinkImpl next = new LinkImpl();
next.setRel(Constants.NEXT_LINK_REL);
- next.setHref(feed.getNext().toASCIIString());
+ next.setHref(entitySet.getNext().toASCIIString());
links(writer, Collections.<Link>singletonList(next));
}
}
- private void feed(final Writer outWriter, final Feed feed) throws XMLStreamException {
+ private void entitySet(final Writer outWriter, final EntitySet entitySet) throws XMLStreamException {
final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
startDocument(writer, Constants.ATOM_ELEM_FEED);
- feed(writer, feed);
+ entitySet(writer, entitySet);
writer.writeEndElement();
writer.writeEndDocument();
writer.flush();
}
- private void feed(final Writer outWriter, final ResWrap<Feed> feed) throws XMLStreamException {
+ private void entitySet(final Writer outWriter, final ResWrap<EntitySet> entitySet) throws XMLStreamException {
final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
startDocument(writer, Constants.ATOM_ELEM_FEED);
- addContextInfo(writer, feed);
+ addContextInfo(writer, entitySet);
- feed(writer, feed.getPayload());
+ entitySet(writer, entitySet.getPayload());
writer.writeEndElement();
writer.writeEndDocument();
@@ -427,10 +427,10 @@ public class AtomSerializer extends AbstractAtomDealer {
}
public <T> void write(final Writer writer, final T obj) throws XMLStreamException {
- if (obj instanceof Feed) {
- feed(writer, (Feed) obj);
- } else if (obj instanceof Entry) {
- entry(writer, (Entry) obj);
+ if (obj instanceof EntitySet) {
+ entitySet(writer, (EntitySet) obj);
+ } else if (obj instanceof Entity) {
+ entity(writer, (Entity) obj);
} else if (obj instanceof Property) {
property(writer, (Property) obj);
} else if (obj instanceof Link) {
@@ -442,10 +442,10 @@ public class AtomSerializer extends AbstractAtomDealer {
public <T> void write(final Writer writer, final ResWrap<T> container) throws XMLStreamException {
final T obj = container == null ? null : container.getPayload();
- if (obj instanceof Feed) {
- this.feed(writer, (ResWrap<Feed>) container);
- } else if (obj instanceof Entry) {
- entry(writer, (ResWrap<Entry>) container);
+ if (obj instanceof EntitySet) {
+ this.entitySet(writer, (ResWrap<EntitySet>) container);
+ } else if (obj instanceof Entity) {
+ entity(writer, (ResWrap<Entity>) container);
} else if (obj instanceof Property) {
property(writer, (Property) obj);
} else if (obj instanceof Link) {
@@ -458,11 +458,11 @@ public class AtomSerializer extends AbstractAtomDealer {
if (container.getContextURL() != null) {
String base = container.getContextURL().getServiceRoot().toASCIIString();
- if (container.getPayload() instanceof AtomFeedImpl) {
- ((AtomFeedImpl) container.getPayload()).setBaseURI(base);
+ if (container.getPayload() instanceof AtomEntitySetImpl) {
+ ((AtomEntitySetImpl) container.getPayload()).setBaseURI(base);
}
- if (container.getPayload() instanceof AtomEntryImpl) {
- ((AtomEntryImpl) container.getPayload()).setBaseURI(base);
+ if (container.getPayload() instanceof AtomEntityImpl) {
+ ((AtomEntityImpl) container.getPayload()).setBaseURI(base);
}
writer.writeAttribute(
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeletedEntityImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeletedEntityImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeletedEntityImpl.java
new file mode 100644
index 0000000..0c97e9a
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeletedEntityImpl.java
@@ -0,0 +1,49 @@
+/*
+ * 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.DeletedEntity;
+
+public class DeletedEntityImpl extends AbstractPayloadObject implements DeletedEntity {
+
+ private static final long serialVersionUID = -3841730551749114664L;
+
+ private String id;
+
+ private String reason;
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ public void setId(final String id) {
+ this.id = id;
+ }
+
+ @Override
+ public String getReason() {
+ return reason;
+ }
+
+ public void setReason(final String reason) {
+ this.reason = reason;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaLinkImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaLinkImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaLinkImpl.java
new file mode 100644
index 0000000..972c6c6
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaLinkImpl.java
@@ -0,0 +1,64 @@
+/*
+ * 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 java.net.URI;
+import org.apache.olingo.commons.api.data.DeltaLink;
+
+public class DeltaLinkImpl extends AbstractPayloadObject implements DeltaLink {
+
+ private static final long serialVersionUID = -6686550836508873044L;
+
+ private URI source;
+
+ private String relationship;
+
+ private URI target;
+
+ @Override
+ public URI getSource() {
+ return source;
+ }
+
+ @Override
+ public void setSource(final URI source) {
+ this.source = source;
+ }
+
+ @Override
+ public String getRelationship() {
+ return relationship;
+ }
+
+ @Override
+ public void setRelationship(String relationship) {
+ this.relationship = relationship;
+ }
+
+ @Override
+ public URI getTarget() {
+ return target;
+ }
+
+ @Override
+ public void setTarget(URI target) {
+ this.target = target;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONDeltaDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONDeltaDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONDeltaDeserializer.java
new file mode 100644
index 0000000..a141111
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONDeltaDeserializer.java
@@ -0,0 +1,93 @@
+/*
+ * 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 com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import java.io.IOException;
+import java.net.URI;
+import java.util.Iterator;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.ContextURL;
+import org.apache.olingo.commons.api.data.ResWrap;
+
+public class JSONDeltaDeserializer extends AbstractJsonDeserializer<JSONDeltaImpl> {
+
+ @Override
+ protected ResWrap<JSONDeltaImpl> doDeserialize(final JsonParser parser, final DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+
+ final ObjectNode tree = parser.getCodec().readTree(parser);
+
+ final JSONDeltaImpl delta = new JSONDeltaImpl();
+
+ final URI contextURL;
+ if (tree.hasNonNull(Constants.JSON_CONTEXT)) {
+ contextURL = URI.create(tree.get(Constants.JSON_CONTEXT).textValue());
+ } else {
+ contextURL = null;
+ }
+ if (contextURL != null) {
+ delta.setBaseURI(StringUtils.substringBefore(contextURL.toASCIIString(), Constants.METADATA));
+ }
+
+ if (tree.hasNonNull(jsonCount)) {
+ delta.setCount(tree.get(jsonCount).asInt());
+ }
+ if (tree.hasNonNull(jsonNextLink)) {
+ delta.setNext(URI.create(tree.get(jsonNextLink).textValue()));
+ }
+ if (tree.hasNonNull(jsonDeltaLink)) {
+ delta.setDeltaLink(URI.create(tree.get(jsonDeltaLink).textValue()));
+ }
+
+ if (tree.hasNonNull(Constants.VALUE)) {
+ for (final Iterator<JsonNode> itor = tree.get(Constants.VALUE).iterator(); itor.hasNext();) {
+ final ObjectNode item = (ObjectNode) itor.next();
+ final ContextURL itemContextURL = item.hasNonNull(Constants.JSON_CONTEXT)
+ ? ContextURL.getInstance(URI.create(item.get(Constants.JSON_CONTEXT).textValue())) : null;
+ item.remove(Constants.JSON_CONTEXT);
+
+ if (itemContextURL == null || itemContextURL.isEntity()) {
+ final ResWrap<JSONEntityImpl> entity = item.traverse(parser.getCodec()).
+ readValueAs(new TypeReference<JSONEntityImpl>() {
+ });
+ delta.getEntities().add(entity.getPayload());
+ } else if (itemContextURL.isDeltaDeletedEntity()) {
+ delta.getDeletedEntities().
+ add(parser.getCodec().treeToValue(item, DeletedEntityImpl.class));
+ } else if (itemContextURL.isDeltaLink()) {
+ delta.getAddedLinks().
+ add(parser.getCodec().treeToValue(item, DeltaLinkImpl.class));
+ } else if (itemContextURL.isDeltaDeletedLink()) {
+ delta.getDeletedLinks().
+ add(parser.getCodec().treeToValue(item, DeltaLinkImpl.class));
+ }
+ }
+ }
+
+ return new ResWrap<JSONDeltaImpl>(contextURL, null, delta);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONDeltaImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONDeltaImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONDeltaImpl.java
new file mode 100644
index 0000000..d684069
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONDeltaImpl.java
@@ -0,0 +1,28 @@
+/*
+ * 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 com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+
+@JsonDeserialize(using = JSONDeltaDeserializer.class)
+public class JSONDeltaImpl extends AbstractDelta {
+
+ private static final long serialVersionUID = -7948494801560470246L;
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntityDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntityDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntityDeserializer.java
new file mode 100644
index 0000000..4fd7ace
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntityDeserializer.java
@@ -0,0 +1,200 @@
+/*
+ * 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 com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import java.io.IOException;
+import java.net.URI;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.data.Link;
+import org.apache.olingo.commons.api.domain.ODataLinkType;
+import org.apache.olingo.commons.api.domain.ODataOperation;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+
+/**
+ * Reads JSON string into an entity.
+ * <br/>
+ * If metadata information is available, the corresponding entity fields and content will be populated.
+ */
+public class JSONEntityDeserializer extends AbstractJsonDeserializer<JSONEntityImpl> {
+
+ @Override
+ protected ResWrap<JSONEntityImpl> doDeserialize(final JsonParser parser, final DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+
+ final ObjectNode tree = parser.getCodec().readTree(parser);
+
+ if (tree.has(Constants.VALUE) && tree.get(Constants.VALUE).isArray()) {
+ throw new JsonParseException("Expected OData Entity, found EntitySet", parser.getCurrentLocation());
+ }
+
+ final JSONEntityImpl entity = new JSONEntityImpl();
+
+ final URI contextURL;
+ if (tree.hasNonNull(Constants.JSON_CONTEXT)) {
+ contextURL = URI.create(tree.get(Constants.JSON_CONTEXT).textValue());
+ tree.remove(Constants.JSON_CONTEXT);
+ } else if (tree.hasNonNull(Constants.JSON_METADATA)) {
+ contextURL = URI.create(tree.get(Constants.JSON_METADATA).textValue());
+ tree.remove(Constants.JSON_METADATA);
+ } else {
+ contextURL = null;
+ }
+ if (contextURL != null) {
+ entity.setBaseURI(StringUtils.substringBefore(contextURL.toASCIIString(), Constants.METADATA));
+ }
+
+ final String metadataETag;
+ if (tree.hasNonNull(Constants.JSON_METADATA_ETAG)) {
+ metadataETag = tree.get(Constants.JSON_METADATA_ETAG).textValue();
+ tree.remove(Constants.JSON_METADATA_ETAG);
+ } else {
+ metadataETag = null;
+ }
+
+ if (tree.hasNonNull(jsonETag)) {
+ entity.setETag(tree.get(jsonETag).textValue());
+ tree.remove(jsonETag);
+ }
+
+ if (tree.hasNonNull(jsonType)) {
+ entity.setType(new EdmTypeInfo.Builder().setTypeExpression(tree.get(jsonType).textValue()).build().internal());
+ tree.remove(jsonType);
+ }
+
+ if (tree.hasNonNull(jsonId)) {
+ entity.setId(tree.get(jsonId).textValue());
+ tree.remove(jsonId);
+ }
+
+ if (tree.hasNonNull(jsonReadLink)) {
+ final LinkImpl link = new LinkImpl();
+ link.setRel(Constants.SELF_LINK_REL);
+ link.setHref(tree.get(jsonReadLink).textValue());
+ entity.setSelfLink(link);
+
+ tree.remove(jsonReadLink);
+ }
+
+ if (tree.hasNonNull(jsonEditLink)) {
+ final LinkImpl link = new LinkImpl();
+ // Server mode
+ if (serverMode) {
+ link.setRel(Constants.EDIT_LINK_REL);
+ }
+ link.setHref(tree.get(jsonEditLink).textValue());
+ entity.setEditLink(link);
+
+ tree.remove(jsonEditLink);
+ }
+
+ if (tree.hasNonNull(jsonMediaReadLink)) {
+ entity.setMediaContentSource(tree.get(jsonMediaReadLink).textValue());
+ tree.remove(jsonMediaReadLink);
+ }
+ if (tree.hasNonNull(jsonMediaEditLink)) {
+ entity.setMediaContentSource(tree.get(jsonMediaEditLink).textValue());
+ tree.remove(jsonMediaEditLink);
+ }
+ if (tree.hasNonNull(jsonMediaContentType)) {
+ entity.setMediaContentType(tree.get(jsonMediaContentType).textValue());
+ tree.remove(jsonMediaContentType);
+ }
+ if (tree.hasNonNull(jsonMediaETag)) {
+ entity.setMediaETag(tree.get(jsonMediaETag).textValue());
+ tree.remove(jsonMediaETag);
+ }
+
+ final Set<String> toRemove = new HashSet<String>();
+ for (final Iterator<Map.Entry<String, JsonNode>> itor = tree.fields(); itor.hasNext();) {
+ final Map.Entry<String, JsonNode> field = itor.next();
+
+ links(field, entity, toRemove, tree, parser.getCodec());
+ 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));
+ link.setHref(field.getValue().textValue());
+ link.setType(ODataLinkType.MEDIA_EDIT.toString());
+ entity.getMediaEditLinks().add(link);
+
+ if (tree.has(link.getTitle() + getJSONAnnotation(jsonMediaETag))) {
+ link.setMediaETag(tree.get(link.getTitle() + getJSONAnnotation(jsonMediaETag)).asText());
+ toRemove.add(link.getTitle() + getJSONAnnotation(jsonMediaETag));
+ }
+
+ toRemove.add(field.getKey());
+ toRemove.add(setInline(field.getKey(), getJSONAnnotation(jsonMediaEditLink), tree, parser.getCodec(), link));
+ } else if (field.getKey().endsWith(getJSONAnnotation(jsonMediaContentType))) {
+ final String linkTitle = getTitle(field);
+ for (Link link : entity.getMediaEditLinks()) {
+ if (linkTitle.equals(link.getTitle())) {
+ ((LinkImpl) link).setType(field.getValue().asText());
+ }
+ }
+ toRemove.add(field.getKey());
+ } else if (field.getKey().charAt(0) == '#') {
+ final ODataOperation operation = new ODataOperation();
+ operation.setMetadataAnchor(field.getKey());
+
+ final ObjectNode opNode = (ObjectNode) tree.get(field.getKey());
+ operation.setTitle(opNode.get(Constants.ATTR_TITLE).asText());
+ operation.setTarget(URI.create(opNode.get(Constants.ATTR_TARGET).asText()));
+
+ entity.getOperations().add(operation);
+
+ toRemove.add(field.getKey());
+ }
+ }
+ tree.remove(toRemove);
+
+ String type = null;
+ 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(getJSONAnnotation(jsonType))) {
+ type = field.getValue().asText();
+ } else {
+ final JSONPropertyImpl property = new JSONPropertyImpl();
+ property.setName(field.getKey());
+ property.setType(type == null
+ ? null
+ : new EdmTypeInfo.Builder().setTypeExpression(type).build().internal());
+ type = null;
+
+ value(property, field.getValue(), parser.getCodec());
+ entity.getProperties().add(property);
+ }
+ }
+
+ return new ResWrap<JSONEntityImpl>(contextURL, metadataETag, entity);
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntityImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntityImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntityImpl.java
new file mode 100644
index 0000000..57db805
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntityImpl.java
@@ -0,0 +1,33 @@
+/*
+ * 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 com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+
+/**
+ * A single entity, represented via JSON.
+ */
+@JsonSerialize(using = JSONEntitySerializer.class)
+@JsonDeserialize(using = JSONEntityDeserializer.class)
+public class JSONEntityImpl extends AbstractEntity {
+
+ private static final long serialVersionUID = -5275365545400797758L;
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySerializer.java
new file mode 100644
index 0000000..0439783
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySerializer.java
@@ -0,0 +1,123 @@
+/*
+ * 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 com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import java.io.IOException;
+import java.net.URI;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.Link;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.domain.ODataOperation;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+
+/**
+ * Writes out JSON string from an entity.
+ */
+public class JSONEntitySerializer extends AbstractJsonSerializer<JSONEntityImpl> {
+
+ @Override
+ protected void doSerialize(final JSONEntityImpl entity, final JsonGenerator jgen, final SerializerProvider provider)
+ throws IOException, JsonProcessingException {
+
+ doContainerSerialize(new ResWrap<JSONEntityImpl>((URI) null, null, entity), jgen, provider);
+ }
+
+ @Override
+ protected void doContainerSerialize(
+ final ResWrap<JSONEntityImpl> container, final JsonGenerator jgen, final SerializerProvider provider)
+ throws IOException, JsonProcessingException {
+
+ final Entity entity = container.getPayload();
+
+ jgen.writeStartObject();
+
+ if (serverMode) {
+ if (container.getContextURL() != null) {
+ jgen.writeStringField(version.compareTo(ODataServiceVersion.V40) >= 0
+ ? Constants.JSON_CONTEXT : Constants.JSON_METADATA,
+ container.getContextURL().getURI().toASCIIString());
+ }
+ if (version.compareTo(ODataServiceVersion.V40) >= 0 && StringUtils.isNotBlank(container.getMetadataETag())) {
+ jgen.writeStringField(Constants.JSON_METADATA_ETAG, container.getMetadataETag());
+ }
+
+ if (StringUtils.isNotBlank(entity.getETag())) {
+ jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_ETAG), entity.getETag());
+ }
+ }
+
+ if (StringUtils.isNotBlank(entity.getType())) {
+ jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_TYPE),
+ new EdmTypeInfo.Builder().setTypeExpression(entity.getType()).build().external(version));
+ }
+
+ if (entity.getId() != null) {
+ jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_ID), entity.getId());
+ }
+
+ for (Property property : entity.getProperties()) {
+ property(jgen, property, property.getName());
+ }
+
+ if (serverMode && entity.getEditLink() != null && StringUtils.isNotBlank(entity.getEditLink().getHref())) {
+ final URI link = URI.create(entity.getEditLink().getHref());
+ final String editLink = link.isAbsolute() ? link.toASCIIString()
+ : URI.create(entity.getBaseURI() + "/" + link.toASCIIString()).normalize().toASCIIString();
+
+ jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_EDIT_LINK), editLink);
+ }
+
+ links(entity, jgen);
+
+ for (Link link : entity.getMediaEditLinks()) {
+ if (link.getTitle() == null) {
+ jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK), link.getHref());
+ }
+
+ if (link.getInlineEntity() != null) {
+ jgen.writeObjectField(link.getTitle(), link.getInlineEntity());
+ }
+ if (link.getInlineEntitySet() != null) {
+ jgen.writeArrayFieldStart(link.getTitle());
+ for (Entity subEntry : link.getInlineEntitySet().getEntities()) {
+ jgen.writeObject(subEntry);
+ }
+ jgen.writeEndArray();
+ }
+ }
+
+ if (serverMode) {
+ for (ODataOperation operation : entity.getOperations()) {
+ jgen.writeObjectFieldStart("#" + StringUtils.substringAfterLast(operation.getMetadataAnchor(), "#"));
+ jgen.writeStringField(Constants.ATTR_TITLE, operation.getTitle());
+ jgen.writeStringField(Constants.ATTR_TARGET, operation.getTarget().toASCIIString());
+ jgen.writeEndObject();
+ }
+ }
+
+ jgen.writeEndObject();
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetDeserializer.java
new file mode 100644
index 0000000..044e269
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetDeserializer.java
@@ -0,0 +1,93 @@
+/*
+ * 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 com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import java.io.IOException;
+import java.net.URI;
+import java.util.Iterator;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.ResWrap;
+
+/**
+ * Reads JSON string into an entity set.
+ * <br/>
+ * If metadata information is available, the corresponding entity fields and content will be populated.
+ */
+public class JSONEntitySetDeserializer extends AbstractJsonDeserializer<JSONEntitySetImpl> {
+
+ @Override
+ protected ResWrap<JSONEntitySetImpl> doDeserialize(final JsonParser parser, final DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+
+ final ObjectNode tree = (ObjectNode) parser.getCodec().readTree(parser);
+
+ if (!tree.has(Constants.VALUE)) {
+ return null;
+ }
+
+ final JSONEntitySetImpl entitySet = new JSONEntitySetImpl();
+
+ final URI contextURL;
+ if (tree.hasNonNull(Constants.JSON_CONTEXT)) {
+ contextURL = URI.create(tree.get(Constants.JSON_CONTEXT).textValue());
+ tree.remove(Constants.JSON_CONTEXT);
+ } else if (tree.hasNonNull(Constants.JSON_METADATA)) {
+ contextURL = URI.create(tree.get(Constants.JSON_METADATA).textValue());
+ tree.remove(Constants.JSON_METADATA);
+ } else {
+ contextURL = null;
+ }
+ if (contextURL != null) {
+ entitySet.setBaseURI(StringUtils.substringBefore(contextURL.toASCIIString(), Constants.METADATA));
+ }
+
+ final String metadataETag;
+ if (tree.hasNonNull(Constants.JSON_METADATA_ETAG)) {
+ metadataETag = tree.get(Constants.JSON_METADATA_ETAG).textValue();
+ tree.remove(Constants.JSON_METADATA_ETAG);
+ } else {
+ metadataETag = null;
+ }
+
+ if (tree.hasNonNull(jsonCount)) {
+ entitySet.setCount(tree.get(jsonCount).asInt());
+ }
+ if (tree.hasNonNull(jsonNextLink)) {
+ entitySet.setNext(URI.create(tree.get(jsonNextLink).textValue()));
+ }
+
+ if (tree.hasNonNull(Constants.VALUE)) {
+ for (final Iterator<JsonNode> itor = tree.get(Constants.VALUE).iterator(); itor.hasNext();) {
+ entitySet.getEntities().add(
+ itor.next().traverse(parser.getCodec()).<ResWrap<JSONEntityImpl>>readValueAs(
+ new TypeReference<JSONEntityImpl>() {
+ }).getPayload());
+ }
+ }
+
+ return new ResWrap<JSONEntitySetImpl>(contextURL, metadataETag, entitySet);
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetImpl.java
new file mode 100644
index 0000000..dac67cd
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetImpl.java
@@ -0,0 +1,35 @@
+/*
+ * 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 com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+
+/**
+ * List of entries, represented via JSON.
+ *
+ * @see JSONEntry
+ */
+@JsonDeserialize(using = JSONEntitySetDeserializer.class)
+@JsonSerialize(using = JSONEntitySetSerializer.class)
+public class JSONEntitySetImpl extends AbstractEntitySet {
+
+ private static final long serialVersionUID = -3576372289800799417L;
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetSerializer.java
new file mode 100644
index 0000000..1e16fa8
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetSerializer.java
@@ -0,0 +1,82 @@
+/*
+ * 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 com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import java.io.IOException;
+import java.net.URI;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+
+public class JSONEntitySetSerializer extends AbstractJsonSerializer<JSONEntitySetImpl> {
+
+ @Override
+ protected void doSerialize(
+ final JSONEntitySetImpl entitySet, final JsonGenerator jgen, final SerializerProvider provider)
+ throws IOException, JsonProcessingException {
+
+ doContainerSerialize(new ResWrap<JSONEntitySetImpl>((URI) null, null, entitySet), jgen, provider);
+ }
+
+ @Override
+ protected void doContainerSerialize(
+ final ResWrap<JSONEntitySetImpl> container, final JsonGenerator jgen, final SerializerProvider provider)
+ throws IOException, JsonProcessingException {
+
+ final JSONEntitySetImpl entitySet = container.getPayload();
+
+ jgen.writeStartObject();
+
+ if (serverMode) {
+ if (container.getContextURL() != null) {
+ jgen.writeStringField(version.compareTo(ODataServiceVersion.V40) >= 0
+ ? Constants.JSON_CONTEXT : Constants.JSON_METADATA,
+ container.getContextURL().getURI().toASCIIString());
+ }
+
+ if (version.compareTo(ODataServiceVersion.V40) >= 0 && StringUtils.isNotBlank(container.getMetadataETag())) {
+ jgen.writeStringField(
+ Constants.JSON_METADATA_ETAG,
+ container.getMetadataETag());
+ }
+ }
+
+ if (entitySet.getId() != null) {
+ jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_ID), entitySet.getId());
+ }
+ jgen.writeNumberField(version.getJSONMap().get(ODataServiceVersion.JSON_COUNT),
+ entitySet.getCount() == null ? entitySet.getEntities().size() : entitySet.getCount());
+ if (entitySet.getNext() != null) {
+ jgen.writeStringField(
+ version.getJSONMap().get(ODataServiceVersion.JSON_NEXT_LINK), entitySet.getNext().toASCIIString());
+ }
+
+ jgen.writeArrayFieldStart(Constants.VALUE);
+ for (Entity entity : entitySet.getEntities()) {
+ jgen.writeObject(entity);
+ }
+
+ jgen.writeEndArray();
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/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
deleted file mode 100644
index dce4b74..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntryDeserializer.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.data;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import java.io.IOException;
-import java.net.URI;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.data.Link;
-import org.apache.olingo.commons.api.domain.ODataLinkType;
-import org.apache.olingo.commons.api.domain.ODataOperation;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.core.edm.EdmTypeInfo;
-
-/**
- * Reads JSON string into an entry.
- * <br/>
- * If metadata information is available, the corresponding entry fields and content will be populated.
- */
-public class JSONEntryDeserializer extends AbstractJsonDeserializer<JSONEntryImpl> {
-
- @Override
- protected ResWrap<JSONEntryImpl> doDeserialize(final JsonParser parser, final DeserializationContext ctxt)
- throws IOException, JsonProcessingException {
-
- final ObjectNode tree = parser.getCodec().readTree(parser);
-
- if (tree.has(Constants.VALUE) && tree.get(Constants.VALUE).isArray()) {
- throw new JsonParseException("Expected OData Entity, found EntitySet", parser.getCurrentLocation());
- }
-
- final JSONEntryImpl entry = new JSONEntryImpl();
-
- final URI contextURL;
- if (tree.hasNonNull(Constants.JSON_CONTEXT)) {
- contextURL = URI.create(tree.get(Constants.JSON_CONTEXT).textValue());
- tree.remove(Constants.JSON_CONTEXT);
- } else if (tree.hasNonNull(Constants.JSON_METADATA)) {
- contextURL = URI.create(tree.get(Constants.JSON_METADATA).textValue());
- tree.remove(Constants.JSON_METADATA);
- } else {
- contextURL = null;
- }
- if (contextURL != null) {
- entry.setBaseURI(StringUtils.substringBefore(contextURL.toASCIIString(), Constants.METADATA));
- }
-
- final String metadataETag;
- if (tree.hasNonNull(Constants.JSON_METADATA_ETAG)) {
- metadataETag = tree.get(Constants.JSON_METADATA_ETAG).textValue();
- tree.remove(Constants.JSON_METADATA_ETAG);
- } else {
- metadataETag = null;
- }
-
- if (tree.hasNonNull(jsonETag)) {
- entry.setETag(tree.get(jsonETag).textValue());
- tree.remove(jsonETag);
- }
-
- if (tree.hasNonNull(jsonType)) {
- entry.setType(new EdmTypeInfo.Builder().setTypeExpression(tree.get(jsonType).textValue()).build().internal());
- tree.remove(jsonType);
- }
-
- if (tree.hasNonNull(jsonId)) {
- entry.setId(tree.get(jsonId).textValue());
- tree.remove(jsonId);
- }
-
- if (tree.hasNonNull(jsonReadLink)) {
- final LinkImpl link = new LinkImpl();
- link.setRel(Constants.SELF_LINK_REL);
- link.setHref(tree.get(jsonReadLink).textValue());
- entry.setSelfLink(link);
-
- tree.remove(jsonReadLink);
- }
-
- if (tree.hasNonNull(jsonEditLink)) {
- final LinkImpl link = new LinkImpl();
- // Server mode
- if (serverMode) {
- link.setRel(Constants.EDIT_LINK_REL);
- }
- link.setHref(tree.get(jsonEditLink).textValue());
- entry.setEditLink(link);
-
- tree.remove(jsonEditLink);
- }
-
- if (tree.hasNonNull(jsonMediaReadLink)) {
- entry.setMediaContentSource(tree.get(jsonMediaReadLink).textValue());
- tree.remove(jsonMediaReadLink);
- }
- if (tree.hasNonNull(jsonMediaEditLink)) {
- entry.setMediaContentSource(tree.get(jsonMediaEditLink).textValue());
- tree.remove(jsonMediaEditLink);
- }
- if (tree.hasNonNull(jsonMediaContentType)) {
- entry.setMediaContentType(tree.get(jsonMediaContentType).textValue());
- tree.remove(jsonMediaContentType);
- }
- if (tree.hasNonNull(jsonMediaETag)) {
- entry.setMediaETag(tree.get(jsonMediaETag).textValue());
- tree.remove(jsonMediaETag);
- }
-
- final Set<String> toRemove = new HashSet<String>();
- for (final Iterator<Map.Entry<String, JsonNode>> itor = tree.fields(); itor.hasNext();) {
- final Map.Entry<String, JsonNode> field = itor.next();
-
- links(field, entry, toRemove, tree, parser.getCodec());
- 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));
- link.setHref(field.getValue().textValue());
- link.setType(ODataLinkType.MEDIA_EDIT.toString());
- entry.getMediaEditLinks().add(link);
-
- if (tree.has(link.getTitle() + getJSONAnnotation(jsonMediaETag))) {
- link.setMediaETag(tree.get(link.getTitle() + getJSONAnnotation(jsonMediaETag)).asText());
- toRemove.add(link.getTitle() + getJSONAnnotation(jsonMediaETag));
- }
-
- toRemove.add(field.getKey());
- toRemove.add(setInline(field.getKey(), getJSONAnnotation(jsonMediaEditLink), tree, parser.getCodec(), link));
- } else if (field.getKey().endsWith(getJSONAnnotation(jsonMediaContentType))) {
- final String linkTitle = getTitle(field);
- for (Link link : entry.getMediaEditLinks()) {
- if (linkTitle.equals(link.getTitle())) {
- ((LinkImpl) link).setType(field.getValue().asText());
- }
- }
- toRemove.add(field.getKey());
- } else if (field.getKey().charAt(0) == '#') {
- final ODataOperation operation = new ODataOperation();
- operation.setMetadataAnchor(field.getKey());
-
- final ObjectNode opNode = (ObjectNode) tree.get(field.getKey());
- operation.setTitle(opNode.get(Constants.ATTR_TITLE).asText());
- operation.setTarget(URI.create(opNode.get(Constants.ATTR_TARGET).asText()));
-
- entry.getOperations().add(operation);
-
- toRemove.add(field.getKey());
- }
- }
- tree.remove(toRemove);
-
- String type = null;
- 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(getJSONAnnotation(jsonType))) {
- type = field.getValue().asText();
- } else {
- final JSONPropertyImpl property = new JSONPropertyImpl();
- property.setName(field.getKey());
- property.setType(type == null
- ? null
- : new EdmTypeInfo.Builder().setTypeExpression(type).build().internal());
- type = null;
-
- value(property, field.getValue(), parser.getCodec());
- entry.getProperties().add(property);
- }
- }
-
- return new ResWrap<JSONEntryImpl>(contextURL, metadataETag, entry);
- }
-}
[3/5] [OLINGO-259] Delta response content parsing (including new
domain objects)
Posted by il...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/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
index 904e35e..663cff1 100644
--- 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
@@ -18,11 +18,16 @@
*/
package org.apache.olingo.client.core.v4;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
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.net.URI;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -31,10 +36,11 @@ 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.data.Delta;
+import org.apache.olingo.commons.api.data.Property;
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 {
@@ -79,21 +85,24 @@ public class JSONTest extends AbstractTest {
if (node.has(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIA_CONTENT_TYPE))) {
node.remove(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIA_CONTENT_TYPE));
}
+ if (node.has(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_COUNT))) {
+ node.remove(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_COUNT));
+ }
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))
+ getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_TYPE))
|| field.getKey().endsWith(
- getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK))
+ getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK))
|| field.getKey().endsWith(
- getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIA_CONTENT_TYPE))
+ getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIA_CONTENT_TYPE))
|| field.getKey().endsWith(
- getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_ASSOCIATION_LINK))
+ getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_ASSOCIATION_LINK))
|| field.getKey().endsWith(
- getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIA_ETAG))) {
+ getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIA_ETAG))) {
toRemove.add(field.getKey());
} else if (field.getValue().isObject()) {
@@ -113,51 +122,51 @@ public class JSONTest extends AbstractTest {
protected void assertSimilar(final String filename, final String actual) throws Exception {
final JsonNode expected = OBJECT_MAPPER.readTree(IOUtils.toString(getClass().getResourceAsStream(filename)).
replace(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_NAVIGATION_LINK),
- Constants.JSON_BIND_LINK_SUFFIX));
+ Constants.JSON_BIND_LINK_SUFFIX));
cleanup((ObjectNode) expected);
final ObjectNode actualNode = (ObjectNode) OBJECT_MAPPER.readTree(new ByteArrayInputStream(actual.getBytes()));
cleanup(actualNode);
assertEquals(expected, actualNode);
}
- protected void feed(final String filename, final ODataPubFormat format) throws Exception {
+ protected void entitySet(final String filename, final ODataPubFormat format) throws Exception {
final StringWriter writer = new StringWriter();
- getClient().getSerializer().feed(getClient().getDeserializer().toFeed(
+ getClient().getSerializer().entitySet(getClient().getDeserializer().toEntitySet(
getClass().getResourceAsStream(filename + "." + getSuffix(format)), format).getPayload(), writer);
assertSimilar(filename + "." + getSuffix(format), writer.toString());
}
@Test
- public void feeds() throws Exception {
- feed("Customers", getODataPubFormat());
- feed("collectionOfEntityReferences", getODataPubFormat());
+ public void entitySets() throws Exception {
+ entitySet("Customers", getODataPubFormat());
+ entitySet("collectionOfEntityReferences", getODataPubFormat());
}
- protected void entry(final String filename, final ODataPubFormat format) throws Exception {
+ protected void entity(final String filename, final ODataPubFormat format) throws Exception {
final StringWriter writer = new StringWriter();
- getClient().getSerializer().entry(getClient().getDeserializer().toEntry(
+ getClient().getSerializer().entity(getClient().getDeserializer().toEntity(
getClass().getResourceAsStream(filename + "." + getSuffix(format)), format).getPayload(), writer);
assertSimilar(filename + "." + getSuffix(format), writer.toString());
}
@Test
- public void additionalEntries() throws Exception {
- entry("entity.minimal", getODataPubFormat());
- entry("entity.primitive", getODataPubFormat());
- entry("entity.complex", getODataPubFormat());
- entry("entity.collection.primitive", getODataPubFormat());
- entry("entity.collection.complex", getODataPubFormat());
+ public void additionalEntities() throws Exception {
+ entity("entity.minimal", getODataPubFormat());
+ entity("entity.primitive", getODataPubFormat());
+ entity("entity.complex", getODataPubFormat());
+ entity("entity.collection.primitive", getODataPubFormat());
+ entity("entity.collection.complex", getODataPubFormat());
}
@Test
- public void entries() throws Exception {
- entry("Products_5", getODataPubFormat());
- entry("VipCustomer", getODataPubFormat());
- entry("Advertisements_f89dee73-af9f-4cd4-b330-db93c25ff3c7", getODataPubFormat());
- entry("entityReference", getODataPubFormat());
- entry("entity.withcomplexnavigation", getODataPubFormat());
+ public void entities() throws Exception {
+ entity("Products_5", getODataPubFormat());
+ entity("VipCustomer", getODataPubFormat());
+ entity("Advertisements_f89dee73-af9f-4cd4-b330-db93c25ff3c7", getODataPubFormat());
+ entity("entityReference", getODataPubFormat());
+ entity("entity.withcomplexnavigation", getODataPubFormat());
}
protected void property(final String filename, final ODataFormat format) throws Exception {
@@ -179,7 +188,39 @@ public class JSONTest extends AbstractTest {
@Test
public void crossjoin() throws Exception {
- getClient().getDeserializer().toFeed(
- getClass().getResourceAsStream("crossjoin.json"), ODataPubFormat.JSON_FULL_METADATA);
+ assertNotNull(getClient().getDeserializer().toEntitySet(
+ getClass().getResourceAsStream("crossjoin.json"), ODataPubFormat.JSON_FULL_METADATA));
+ }
+
+ protected void delta(final String filename, final ODataPubFormat format) throws Exception {
+ final Delta delta = getClient().getDeserializer().toDelta(
+ getClass().getResourceAsStream(filename + "." + getSuffix(format)), format).getPayload();
+ assertNotNull(delta);
+ assertNotNull(delta.getDeltaLink());
+ assertEquals(5, delta.getCount(), 0);
+
+ assertEquals(1, delta.getDeletedEntities().size());
+ assertTrue(delta.getDeletedEntities().get(0).getId().endsWith("Customers('ANTON')"));
+
+ assertEquals(1, delta.getAddedLinks().size());
+ assertTrue(delta.getAddedLinks().get(0).getSource().toASCIIString().endsWith("Customers('BOTTM')"));
+ assertEquals("Orders", delta.getAddedLinks().get(0).getRelationship());
+
+ assertEquals(1, delta.getDeletedLinks().size());
+ assertTrue(delta.getDeletedLinks().get(0).getSource().toASCIIString().endsWith("Customers('ALFKI')"));
+ assertEquals("Orders", delta.getDeletedLinks().get(0).getRelationship());
+
+ assertEquals(2, delta.getEntities().size());
+ Property property = delta.getEntities().get(0).getProperty("ContactName");
+ assertNotNull(property);
+ assertTrue(property.getValue().isPrimitive());
+ property = delta.getEntities().get(1).getProperty("ShippingAddress");
+ assertNotNull(property);
+ assertTrue(property.getValue().isComplex());
+ }
+
+ @Test
+ public void deltas() throws Exception {
+ delta("delta", getODataPubFormat());
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/Customers.json
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/Customers.json b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/Customers.json
index c8e2cdf..c37d5a5 100644
--- a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/Customers.json
+++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/Customers.json
@@ -1,6 +1,6 @@
{
"@odata.context": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/$metadata#Customers",
- "odata.count": 2,
+ "@odata.count": 2,
"value": [{
"@odata.id": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/Customers(PersonID=1)",
"@odata.editLink": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/Customers(PersonID=1)",
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/delta.json
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/delta.json b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/delta.json
new file mode 100644
index 0000000..d8e8f54
--- /dev/null
+++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/delta.json
@@ -0,0 +1,39 @@
+{
+ "@odata.context": "http://host/service/$metadata#Customers/$delta",
+ "@odata.count": 5,
+ "value":
+ [
+ {
+ "@odata.id": "Customers('BOTTM')'",
+ "ContactName": "Susan Halvenstern"
+ },
+ {
+ "@odata.context": "#Customers/$deletedLink",
+ "source": "Customers('ALFKI')",
+ "relationship": "Orders",
+ "target": "Orders(10643)"
+ },
+ {
+ "@odata.context": "#Customers/$link",
+ "source": "Customers('BOTTM')",
+ "relationship": "Orders",
+ "target": "Orders(10645)"
+ },
+ {
+ "@odata.context": "#Orders/$entity",
+ "@odata.id": "Orders(10643)",
+ "ShippingAddress": {
+ "Street": "23 Tsawassen Blvd.",
+ "City": " Tsawassen ",
+ "Region": "BC",
+ "PostalCode": "T2F 8M4"
+ }
+ },
+ {
+ "@odata.context": "#Customers/$deletedEntity",
+ "id": "Customers('ANTON')",
+ "reason": "deleted"
+ }
+ ],
+ "@odata.deltaLink": "Customers?$expand=Orders&$deltatoken=8015"
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/delta.xml
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/delta.xml b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/delta.xml
new file mode 100644
index 0000000..df65b49
--- /dev/null
+++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/delta.xml
@@ -0,0 +1,87 @@
+<?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.
+
+-->
+<feed xml:base="http://host/service/"
+ xmlns:data="http://docs.oasis-open.org/odata/ns/data"
+ xmlns:metadata="http://docs.oasis-open.org/odata/ns/metadata"
+ xmlns="http://www.w3.org/2005/Atom"
+ xmlns:at="http://purl.org/atompub/tombstones/1.0"
+ metadata:context="$metadata#Customers/$delta">
+ <title type="text">Customers</title>
+ <id>http://host/service/Customers</id>
+ <updated>2012-11-27T15:38:25Z</updated>
+ <metadata:count>5</metadata:count>
+ <entry>
+ <id>http://host/service/Customers('BOTTM')</id>
+ <title type="text" />
+ <updated>2012-11-17T15:38:22Z</updated>
+ <author>
+ <name />
+ </author>
+ <link rel="edit" title="Customer" href="Customers('BOTTM')"/>
+ <category term="#Model.Customer"
+ scheme="http://docs.oasis-open.org/odata/ns/scheme"/>
+ <content type="application/xml">
+ <metadata:properties>
+ <data:ContactName>Susan Halvenstern</data:ContactName>
+ </metadata:properties>
+ </content>
+ </entry>
+ <metadata:deleted-link
+ metadata:context="$metadata#Customers/$deleted-link"
+ source="http://host/service/Customers('ALFKI')"
+ relationship="Orders"
+ target="http://host/service/Orders(10643)"/>
+ <metadata:link
+ metadata:context="$metadata#Customers/$link"
+ source="http://host/service/Customers('BOTTM')"
+ relationship="Orders"
+ target="http://host/service/Orders(10645)"/>
+ <entry metadata:context="$metadata#Orders/$entity">
+ <id>http://host/service/Orders(10643)</id>
+ <title type="text" />
+ <updated>2012-11-27T15:38:24Z</updated>
+ <author>
+ <name/>
+ </author>
+ <link rel="edit" title="Order" href="Orders(10643)" />
+ <category term="#Model.Order"
+ scheme="http://docs.oasis-open.org/odata/ns/scheme" />
+ <content type="application/xml">
+ <metadata:properties>
+ <data:ShippingAddress>
+ <data:Street>23 Tsawassen Blvd.</data:Street>
+ <data:City>Tsawassen</data:City>
+ <data:Region>BC</data:Region>
+ <data:PostalCode>T2F 8M4</data:PostalCode>
+ </data:ShippingAddress>
+ </metadata:properties>
+ </content>
+ </entry>
+ <at:deleted-entry
+ metadata:context="$metadata#Customers/$deleted-entry"
+ ref="http://host/service/Customers('ANTON')"
+ when="2012-11-27T15:38:25Z"
+ metadata:reason="deleted"/>
+ <link
+ rel="http://docs.oasis-open.org/odata/ns/delta"
+ href="http://host/service/Customers?$expand=Orders&$deltatoken=8015"/>
+</feed>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/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 882c811..770f81c 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
@@ -42,6 +42,8 @@ public interface Constants {
public static final String NS_GML = "http://www.opengis.net/gml";
+ public static final String NS_ATOM_TOMBSTONE = "http://purl.org/atompub/tombstones/1.0";
+
public static final String PREFIX_DATASERVICES = "d";
public static final String PREFIX_METADATA = "m";
@@ -61,6 +63,8 @@ public interface Constants {
public static final String NEXT_LINK_REL = "next";
+ public static final String DELTA_LINK_REL = "http://docs.oasis-open.org/odata/ns/delta";
+
// XML elements and attributes
public static final String PROPERTIES = "properties";
@@ -84,6 +88,8 @@ public interface Constants {
public static final String ATTR_HREF = "href";
+ public static final String ATTR_REF = "ref";
+
public static final String ATTR_TARGET = "target";
public static final String ATTR_SRSNAME = "srsName";
@@ -138,6 +144,14 @@ public interface Constants {
public static final String ELEM_URI = "uri";
+ public final static String ELEM_REASON = "reason";
+
+ public static final String ELEM_DELETED_LINK = "deleted-link";
+
+ public static final String ATTR_SOURCE = "source";
+
+ public static final String ATTR_RELATIONSHIP = "relationship";
+
// JSON stuff
public final static String JSON_METADATA = "odata.metadata";
@@ -159,10 +173,6 @@ public interface Constants {
public final static String JSON_CRS = "crs";
- public final static String JSON_COUNT = "odata.count";
-
- public final static String JSON_NEXT_LINK = "odata.nextLink";
-
public final static String JSON_NAME = "name";
// Atom stuff
@@ -224,7 +234,9 @@ public interface Constants {
public static final String ATOM_ATTR_METADATAETAG = "metadata-etag";
- // error stuff
+ public static final String ATOM_ELEM_DELETED_ENTRY = "deleted-entry";
+
+// error stuff
public static final String ERROR_CODE = "code";
public static final String ERROR_MESSAGE = "message";
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ContextURL.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ContextURL.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ContextURL.java
index c2d503e..4fa1350 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ContextURL.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ContextURL.java
@@ -42,14 +42,38 @@ public class ContextURL {
private String navOrPropertyPath;
+ private boolean entity;
+
+ private boolean delta;
+
+ private boolean deltaDeletedEntity;
+
+ private boolean deltaLink;
+
+ private boolean deltaDeletedLink;
+
public static ContextURL getInstance(final URI contextURL) {
final ContextURL instance = new ContextURL();
instance.uri = contextURL;
- final String contextURLasString = instance.uri.toASCIIString().
- replace("/$entity", StringUtils.EMPTY).
- replace("/@Element", StringUtils.EMPTY);
-
+ String contextURLasString = instance.uri.toASCIIString();
+
+ instance.entity = contextURLasString.endsWith("/$entity") || contextURLasString.endsWith("/@Element");
+ contextURLasString = contextURLasString.
+ replace("/$entity", StringUtils.EMPTY).replace("/@Element", StringUtils.EMPTY);
+
+ instance.delta = contextURLasString.endsWith("/$delta");
+ contextURLasString = contextURLasString.replace("/$delta", StringUtils.EMPTY);
+
+ instance.deltaDeletedEntity = contextURLasString.endsWith("/$deletedEntity");
+ contextURLasString = contextURLasString.replace("/$deletedEntity", StringUtils.EMPTY);
+
+ instance.deltaLink = contextURLasString.endsWith("/$link");
+ contextURLasString = contextURLasString.replace("/$link", StringUtils.EMPTY);
+
+ instance.deltaDeletedLink = contextURLasString.endsWith("$deletedLink");
+ contextURLasString = contextURLasString.replace("$deletedLink", StringUtils.EMPTY);
+
instance.serviceRoot = URI.create(StringUtils.substringBefore(contextURLasString, Constants.METADATA));
final String rest = StringUtils.substringAfter(contextURLasString, Constants.METADATA + "#");
@@ -124,6 +148,26 @@ public class ContextURL {
return navOrPropertyPath;
}
+ public boolean isEntity() {
+ return entity;
+ }
+
+ public boolean isDelta() {
+ return delta;
+ }
+
+ public boolean isDeltaDeletedEntity() {
+ return deltaDeletedEntity;
+ }
+
+ public boolean isDeltaLink() {
+ return deltaLink;
+ }
+
+ public boolean isDeltaDeletedLink() {
+ return deltaDeletedLink;
+ }
+
@Override
public boolean equals(final Object obj) {
if (obj == null) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeletedEntity.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeletedEntity.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeletedEntity.java
new file mode 100644
index 0000000..98f2a89
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeletedEntity.java
@@ -0,0 +1,27 @@
+/*
+ * 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 DeletedEntity {
+
+ String getId();
+
+ String getReason();
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Delta.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Delta.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Delta.java
new file mode 100644
index 0000000..066033a
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Delta.java
@@ -0,0 +1,45 @@
+/*
+ * 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;
+
+import java.net.URI;
+import java.util.List;
+
+public interface Delta extends EntitySet {
+
+ List<DeletedEntity> getDeletedEntities();
+
+ List<DeltaLink> getAddedLinks();
+
+ List<DeltaLink> getDeletedLinks();
+
+ /**
+ * Gets delta link if exists.
+ *
+ * @return delta link if exists; null otherwise.
+ */
+ URI getDeltaLink();
+
+ /**
+ * Sets delta link.
+ *
+ * @param deltaLink delta link.
+ */
+ void setDeltaLink(URI deltaLink);
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeltaLink.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeltaLink.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeltaLink.java
new file mode 100644
index 0000000..a280165
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeltaLink.java
@@ -0,0 +1,36 @@
+/*
+ * 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;
+
+import java.net.URI;
+
+public interface DeltaLink {
+
+ URI getSource();
+
+ void setSource(URI source);
+
+ String getRelationship();
+
+ void setRelationship(String relationship);
+
+ URI getTarget();
+
+ void setTarget(URI target);
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Entity.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Entity.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Entity.java
new file mode 100644
index 0000000..ed0ad15
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Entity.java
@@ -0,0 +1,174 @@
+/*
+ * 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;
+
+import org.apache.olingo.commons.api.domain.ODataOperation;
+import java.net.URI;
+import java.util.List;
+
+public interface Entity extends Linked {
+
+ /**
+ * Gets ETag.
+ *
+ * @return ETag.
+ */
+ String getETag();
+
+ /**
+ * Gets base URI.
+ *
+ * @return base URI.
+ */
+ URI getBaseURI();
+
+ /**
+ * Gets entity type.
+ *
+ * @return entity type.
+ */
+ String getType();
+
+ /**
+ * Sets entity type.
+ *
+ * @param type entity type.
+ */
+ void setType(String type);
+
+ /**
+ * Gets entity ID.
+ *
+ * @return entity ID.
+ */
+ String getId();
+
+ /**
+ * Sets entity ID.
+ *
+ * @param id entity ID.
+ */
+ void setId(String id);
+
+ /**
+ * Gets entity self link.
+ *
+ * @return self link.
+ */
+ Link getSelfLink();
+
+ /**
+ * Sets entity self link.
+ *
+ * @param selfLink self link.
+ */
+ void setSelfLink(Link selfLink);
+
+ /**
+ * Gets entity edit link.
+ *
+ * @return edit link.
+ */
+ Link getEditLink();
+
+ /**
+ * Sets entity edit link.
+ *
+ * @param editLink edit link.
+ */
+ void setEditLink(Link editLink);
+
+ /**
+ * Gets media entity links.
+ *
+ * @return links.
+ */
+ List<Link> getMediaEditLinks();
+
+ /**
+ * Gets operations.
+ *
+ * @return operations.
+ */
+ List<ODataOperation> getOperations();
+
+ /**
+ * Gets properties.
+ *
+ * @return properties.
+ */
+ List<Property> getProperties();
+
+ /**
+ * Gets property with given name.
+ *
+ * @param name property name
+ * @return property with given name if found, null otherwise
+ */
+ Property getProperty(String name);
+
+ /**
+ * Gets media content type.
+ *
+ * @return media content type.
+ */
+ String getMediaContentType();
+
+ /**
+ * Gets media content resource.
+ *
+ * @return media content resource.
+ */
+ String getMediaContentSource();
+
+ /**
+ * Set media content source.
+ *
+ * @param mediaContentSource media content source.
+ */
+ void setMediaContentSource(String mediaContentSource);
+
+ /**
+ * Set media content type.
+ *
+ * @param mediaContentType media content type.
+ */
+ void setMediaContentType(String mediaContentType);
+
+ /**
+ * ETag of the binary stream represented by this media entity or named stream property.
+ *
+ * @return media ETag value
+ */
+ String getMediaETag();
+
+ /**
+ * Set media ETag.
+ *
+ * @param eTag media ETag value
+ */
+ void setMediaETag(String eTag);
+
+ /**
+ * Checks if the current entity is a media entity.
+ *
+ * @return 'TRUE' if is a media entity; 'FALSE' otherwise.
+ */
+ boolean isMediaEntity();
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EntitySet.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EntitySet.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EntitySet.java
new file mode 100644
index 0000000..0812acf
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EntitySet.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.commons.api.data;
+
+import java.net.URI;
+import java.util.List;
+
+public interface EntitySet {
+
+ /**
+ * Gets base URI.
+ *
+ * @return base URI.
+ */
+ URI getBaseURI();
+
+ /**
+ * Sets number of entries.
+ *
+ * @param count number of entries
+ */
+ void setCount(Integer count);
+
+ /**
+ * Gets number of entries - if it was required.
+ *
+ * @return number of entries into the entity set.
+ */
+ Integer getCount();
+
+ /**
+ * Gest ID.
+ *
+ * @return ID.
+ */
+ String getId();
+
+ /**
+ * Gets entities.
+ *
+ * @return entries.
+ */
+ List<Entity> getEntities();
+
+ /**
+ * Gets next link if exists.
+ *
+ * @return next link if exists; null otherwise.
+ */
+ URI getNext();
+
+ /**
+ * Sets next link.
+ *
+ * @param next next link.
+ */
+ void setNext(URI next);
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/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
deleted file mode 100644
index d82005e..0000000
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Entry.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.api.data;
-
-import org.apache.olingo.commons.api.domain.ODataOperation;
-import java.net.URI;
-import java.util.List;
-
-public interface Entry extends Linked {
-
- /**
- * Gets ETag.
- *
- * @return ETag.
- */
- String getETag();
-
- /**
- * Gets base URI.
- *
- * @return base URI.
- */
- URI getBaseURI();
-
- /**
- * Gets entry type.
- *
- * @return entry type.
- */
- String getType();
-
- /**
- * Sets entry type.
- *
- * @param type entry type.
- */
- void setType(String type);
-
- /**
- * Gets entry ID.
- *
- * @return entry ID.
- */
- String getId();
-
- /**
- * Sets entry ID.
- *
- * @param id entry ID.
- */
- void setId(String id);
-
- /**
- * Gets entry self link.
- *
- * @return self link.
- */
- Link getSelfLink();
-
- /**
- * Sets entry self link.
- *
- * @param selfLink self link.
- */
- void setSelfLink(Link selfLink);
-
- /**
- * Gets entry edit link.
- *
- * @return edit link.
- */
- Link getEditLink();
-
- /**
- * Sets entry edit link.
- *
- * @param editLink edit link.
- */
- void setEditLink(Link editLink);
-
- /**
- * Gets media entity links.
- *
- * @return links.
- */
- List<Link> getMediaEditLinks();
-
- /**
- * Gets operations.
- *
- * @return operations.
- */
- List<ODataOperation> getOperations();
-
- /**
- * Gets properties.
- *
- * @return properties.
- */
- List<Property> getProperties();
-
- /**
- * Gets property with given name.
- *
- * @param name property name
- * @return property with given name if found, null otherwise
- */
- Property getProperty(String name);
-
- /**
- * Gets media content type.
- *
- * @return media content type.
- */
- String getMediaContentType();
-
- /**
- * Gets media content resource.
- *
- * @return media content resource.
- */
- String getMediaContentSource();
-
- /**
- * Set media content source.
- *
- * @param mediaContentSource media content source.
- */
- void setMediaContentSource(String mediaContentSource);
-
- /**
- * Set media content type.
- *
- * @param mediaContentType media content type.
- */
- void setMediaContentType(String mediaContentType);
-
- /**
- * ETag of the binary stream represented by this media entity or named stream property.
- *
- * @return media ETag value
- */
- String getMediaETag();
-
- /**
- * Set media ETag.
- *
- * @param eTag media ETag value
- */
- void setMediaETag(String eTag);
-
- /**
- * Checks if the current entry is a media entry.
- *
- * @return 'TRUE' if is a media entry; 'FALSE' otherwise.
- */
- boolean isMediaEntry();
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/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
deleted file mode 100644
index 4f6a542..0000000
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Feed.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.api.data;
-
-import java.net.URI;
-import java.util.List;
-
-public interface Feed {
-
- /**
- * Gets base URI.
- *
- * @return base URI.
- */
- URI getBaseURI();
-
- /**
- * Sets number of entries.
- *
- * @param count number of entries
- */
- void setCount(Integer count);
-
- /**
- * Gets number of entries - if it was required.
- *
- * @return number of entries into the feed.
- */
- Integer getCount();
-
- /**
- * Gest feed ID.
- *
- * @return feed ID.
- */
- String getId();
-
- /**
- * Gets entries.
- *
- * @return entries.
- */
- List<Entry> getEntries();
-
- /**
- * Gets next link if exists.
- *
- * @return next link if exists; null otherwise.
- */
- URI getNext();
-
- /**
- * Sets next link.
- *
- * @param next next link.
- */
- void setNext(URI next);
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Link.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Link.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Link.java
index f0a35a5..63c953a 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Link.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Link.java
@@ -91,31 +91,31 @@ public interface Link {
void setMediaETag(String etag);
/**
- * Gets in-line entry.
+ * Gets in-line entity.
*
- * @return in-line entry.
+ * @return in-line entity.
*/
- Entry getInlineEntry();
+ Entity getInlineEntity();
/**
- * Sets in-line entry.
+ * Sets in-line entity.
*
- * @param entry entry.
+ * @param entity entity.
*/
- void setInlineEntry(Entry entry);
+ void setInlineEntity(Entity entity);
/**
- * Gets in-line feed.
+ * Gets in-line entity set.
*
- * @return in-line feed.
+ * @return in-line entity set.
*/
- Feed getInlineFeed();
+ EntitySet getInlineEntitySet();
/**
- * Sets in-line feed.
+ * Sets in-line entity set.
*
- * @param feed feed.
+ * @param entitySet entity set.
*/
- void setInlineFeed(Feed feed);
+ void setInlineEntitySet(EntitySet entitySet);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataEntitySet.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataEntitySet.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataEntitySet.java
index 3967748..e33055f 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataEntitySet.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataEntitySet.java
@@ -36,7 +36,7 @@ public interface CommonODataEntitySet extends ODataInvokeResult {
/**
* Gets contained entities.
*
- * @return feed entries.
+ * @return entity set's entities.
*/
List<? extends CommonODataEntity> getEntities();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinked.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinked.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinked.java
index 0dd5462..4e3852c 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinked.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinked.java
@@ -62,7 +62,7 @@ public interface ODataLinked {
ODataLink getNavigationLink(String name);
/**
- * Returns all entity navigation links (including inline entities / feeds).
+ * Returns all entity navigation links (including inline entities / entity sets).
*
* @return OData entity links.
*/
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/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 c6354ec..8e6b145 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
@@ -69,6 +69,13 @@ public enum ODataServiceVersion {
public static final String JSON_ASSOCIATION_LINK = "jsonAssociationLink";
public static final String JSON_NAVIGATION_LINK = "jsonNavigationLink";
+
+ public final static String JSON_COUNT = "jsonCount";
+
+ public final static String JSON_NEXT_LINK = "jsonNextLink";
+
+ public final static String JSON_DELTA_LINK = "jsonDeltaLink";
+
public static final String JSON_ERROR = "jsonError";
private static final Map<String, String> V30_NAMESPACES = Collections.unmodifiableMap(new HashMap<String, String>() {
@@ -101,6 +108,8 @@ public enum ODataServiceVersion {
put(JSON_MEDIA_ETAG, "odata.mediaEtag");
put(JSON_ASSOCIATION_LINK, "@odata.associationLinkUrl");
put(JSON_NAVIGATION_LINK, "@odata.navigationLinkUrl");
+ put(JSON_COUNT, "odata.count");
+ put(JSON_NEXT_LINK, "odata.nextLink");
put(JSON_ERROR, "odata.error");
}
});
@@ -135,6 +144,9 @@ public enum ODataServiceVersion {
put(JSON_MEDIA_ETAG, "@odata.mediaEtag");
put(JSON_ASSOCIATION_LINK, "@odata.associationLink");
put(JSON_NAVIGATION_LINK, "@odata.navigationLink");
+ put(JSON_COUNT, "@odata.count");
+ put(JSON_NEXT_LINK, "@odata.nextLink");
+ put(JSON_DELTA_LINK, "@odata.deltaLink");
put(JSON_ERROR, "error");
}
});
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/CommonODataDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/CommonODataDeserializer.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/CommonODataDeserializer.java
index 52b0103..a0d9a87 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/CommonODataDeserializer.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/CommonODataDeserializer.java
@@ -21,35 +21,35 @@ package org.apache.olingo.commons.api.op;
import java.io.InputStream;
import java.io.Serializable;
import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.data.Entry;
+import org.apache.olingo.commons.api.data.Entity;
import org.apache.olingo.commons.api.domain.ODataError;
-import org.apache.olingo.commons.api.data.Feed;
+import org.apache.olingo.commons.api.data.EntitySet;
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.format.ODataPubFormat;
/**
- * Interface for serialization.
+ * Interface for de-serialization.
*/
public interface CommonODataDeserializer extends Serializable {
/**
- * Gets a feed object from the given InputStream.
+ * Gets an entity set object from the given InputStream.
*
* @param input stream to be de-serialized.
* @param format Atom or JSON
- * @return Feed instance.
+ * @return {@link EntitySet} instance.
*/
- ResWrap<Feed> toFeed(InputStream input, ODataPubFormat format);
+ ResWrap<EntitySet> toEntitySet(InputStream input, ODataPubFormat format);
/**
- * Gets an entry object from the given InputStream.
+ * Gets an entity object from the given InputStream.
*
* @param input stream to be de-serialized.
* @param format Atom or JSON
- * @return Entry instance.
+ * @return {@link Entity} instance.
*/
- ResWrap<Entry> toEntry(InputStream input, ODataPubFormat format);
+ ResWrap<Entity> toEntity(InputStream input, ODataPubFormat format);
/**
* Gets a property object from the given InputStream.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataSerializer.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataSerializer.java
index 2a7beff..c8a02cf 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataSerializer.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataSerializer.java
@@ -21,8 +21,8 @@ package org.apache.olingo.commons.api.op;
import java.io.OutputStream;
import java.io.Serializable;
import java.io.Writer;
-import org.apache.olingo.commons.api.data.Entry;
-import org.apache.olingo.commons.api.data.Feed;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
import org.apache.olingo.commons.api.data.Link;
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.format.ODataFormat;
@@ -33,36 +33,36 @@ import org.apache.olingo.commons.api.format.ODataFormat;
public interface ODataSerializer extends Serializable {
/**
- * Writes Feed object onto the given stream.
+ * Writes entity set object onto the given stream.
*
* @param obj object to be streamed.
* @param out output stream.
*/
- void feed(Feed obj, OutputStream out);
+ void entitySet(EntitySet obj, OutputStream out);
/**
- * Writes Feed object by the given writer.
+ * Writes entity set object by the given writer.
*
* @param obj object to be streamed.
* @param writer writer.
*/
- void feed(Feed obj, Writer writer);
+ void entitySet(EntitySet obj, Writer writer);
/**
- * Writes theEntry object onto the given stream.
+ * Writes entity object onto the given stream.
*
* @param obj object to be streamed.
* @param out output stream.
*/
- void entry(Entry obj, OutputStream out);
+ void entity(Entity obj, OutputStream out);
/**
- * Writes the Entry object by the given writer.
+ * Writes entity object by the given writer.
*
* @param obj object to be streamed.
* @param writer writer.
*/
- void entry(Entry obj, Writer writer);
+ void entity(Entity obj, Writer writer);
/**
* Writes the property object onto the given stream.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-api/src/test/java/org/apache/olingo/commons/api/data/ContextURLTest.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/test/java/org/apache/olingo/commons/api/data/ContextURLTest.java b/lib/commons-api/src/test/java/org/apache/olingo/commons/api/data/ContextURLTest.java
index df7e649..14d42e2 100644
--- a/lib/commons-api/src/test/java/org/apache/olingo/commons/api/data/ContextURLTest.java
+++ b/lib/commons-api/src/test/java/org/apache/olingo/commons/api/data/ContextURLTest.java
@@ -19,7 +19,9 @@
package org.apache.olingo.commons.api.data;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import java.net.URI;
import org.junit.Test;
@@ -35,6 +37,7 @@ public class ContextURLTest {
assertNull(contextURL.getDerivedEntity());
assertNull(contextURL.getSelectList());
assertNull(contextURL.getNavOrPropertyPath());
+ assertFalse(contextURL.isEntity());
contextURL = ContextURL.getInstance(URI.create("http://host/service/$metadata#Orders(4711)/Items"));
@@ -42,6 +45,7 @@ public class ContextURLTest {
assertNull(contextURL.getDerivedEntity());
assertNull(contextURL.getSelectList());
assertEquals("Items", contextURL.getNavOrPropertyPath());
+ assertFalse(contextURL.isEntity());
}
@Test
@@ -52,6 +56,7 @@ public class ContextURLTest {
assertNull(contextURL.getDerivedEntity());
assertNull(contextURL.getSelectList());
assertNull(contextURL.getNavOrPropertyPath());
+ assertTrue(contextURL.isEntity());
contextURL = ContextURL.getInstance(URI.create("http://host/service/$metadata#Orders(4711)/Items/$entity"));
@@ -59,6 +64,7 @@ public class ContextURLTest {
assertNull(contextURL.getDerivedEntity());
assertNull(contextURL.getSelectList());
assertEquals("Items", contextURL.getNavOrPropertyPath());
+ assertTrue(contextURL.isEntity());
// v3
contextURL = ContextURL.getInstance(URI.create("http://host/service/$metadata#Products/@Element"));
@@ -67,6 +73,7 @@ public class ContextURLTest {
assertNull(contextURL.getDerivedEntity());
assertNull(contextURL.getSelectList());
assertNull(contextURL.getNavOrPropertyPath());
+ assertTrue(contextURL.isEntity());
}
@Test
@@ -77,6 +84,7 @@ public class ContextURLTest {
assertNull(contextURL.getDerivedEntity());
assertNull(contextURL.getSelectList());
assertNull(contextURL.getNavOrPropertyPath());
+ assertFalse(contextURL.isEntity());
}
@Test
@@ -88,6 +96,7 @@ public class ContextURLTest {
assertEquals("Model.VipCustomer", contextURL.getDerivedEntity());
assertNull(contextURL.getSelectList());
assertNull(contextURL.getNavOrPropertyPath());
+ assertFalse(contextURL.isEntity());
}
@Test
@@ -99,6 +108,7 @@ public class ContextURLTest {
assertEquals("Model.VipCustomer", contextURL.getDerivedEntity());
assertNull(contextURL.getSelectList());
assertNull(contextURL.getNavOrPropertyPath());
+ assertTrue(contextURL.isEntity());
}
@Test
@@ -110,6 +120,7 @@ public class ContextURLTest {
assertNull(contextURL.getDerivedEntity());
assertEquals("Address,Orders", contextURL.getSelectList());
assertNull(contextURL.getNavOrPropertyPath());
+ assertFalse(contextURL.isEntity());
}
@Test
@@ -121,6 +132,7 @@ public class ContextURLTest {
assertNull(contextURL.getDerivedEntity());
assertEquals("Name,Rating", contextURL.getSelectList());
assertNull(contextURL.getNavOrPropertyPath());
+ assertTrue(contextURL.isEntity());
contextURL = ContextURL.getInstance(
URI.create("http://host/service/$metadata#Customers(Name,Address/Country)"));
@@ -129,6 +141,7 @@ public class ContextURLTest {
assertNull(contextURL.getDerivedEntity());
assertEquals("Name,Address/Country", contextURL.getSelectList());
assertNull(contextURL.getNavOrPropertyPath());
+ assertFalse(contextURL.isEntity());
}
@Test
@@ -141,6 +154,7 @@ public class ContextURLTest {
assertEquals("Sales.Manager", contextURL.getDerivedEntity());
assertEquals("DirectReports,DirectReports+(FirstName,LastName)", contextURL.getSelectList());
assertNull(contextURL.getNavOrPropertyPath());
+ assertFalse(contextURL.isEntity());
}
@Test
@@ -152,6 +166,7 @@ public class ContextURLTest {
assertNull(contextURL.getDerivedEntity());
assertNull(contextURL.getSelectList());
assertEquals("Addresses", contextURL.getNavOrPropertyPath());
+ assertFalse(contextURL.isEntity());
}
@Test
@@ -163,6 +178,7 @@ public class ContextURLTest {
assertNull(contextURL.getDerivedEntity());
assertNull(contextURL.getSelectList());
assertNull(contextURL.getNavOrPropertyPath());
+ assertFalse(contextURL.isEntity());
}
@Test
@@ -173,6 +189,7 @@ public class ContextURLTest {
assertNull(contextURL.getDerivedEntity());
assertNull(contextURL.getSelectList());
assertNull(contextURL.getNavOrPropertyPath());
+ assertFalse(contextURL.isEntity());
contextURL = ContextURL.getInstance(URI.create("http://host/service/$metadata#ODataDemo.Address"));
@@ -180,5 +197,21 @@ public class ContextURLTest {
assertNull(contextURL.getDerivedEntity());
assertNull(contextURL.getSelectList());
assertNull(contextURL.getNavOrPropertyPath());
+ assertFalse(contextURL.isEntity());
+ }
+
+ @Test
+ public void delta() {
+ ContextURL contextURL = ContextURL.getInstance(URI.create("http://host/service/$metadata#Customers/$delta"));
+ assertTrue(contextURL.isDelta());
+
+ contextURL = ContextURL.getInstance(URI.create("http://host/service/$metadata#Customers/$deletedLink"));
+ assertTrue(contextURL.isDeltaDeletedLink());
+
+ contextURL = ContextURL.getInstance(URI.create("http://host/service/$metadata#Customers/$link"));
+ assertTrue(contextURL.isDeltaLink());
+
+ contextURL = ContextURL.getInstance(URI.create("http://host/service/$metadata#Customers/$deletedEntity"));
+ assertTrue(contextURL.isDeltaDeletedEntity());
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/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 f571c66..2f3ebb3 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
@@ -58,7 +58,15 @@ abstract class AbstractAtomDealer {
protected final QName entryRefQName;
- protected final QName v4PropertyValueQName;
+ protected final QName propertyValueQName;
+
+ protected final QName deletedEntryQName;
+
+ protected final QName reasonQName;
+
+ protected final QName linkQName;
+
+ protected final QName deletedLinkQName;
protected final QName errorCodeQName;
@@ -94,9 +102,17 @@ abstract class AbstractAtomDealer {
new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.CONTEXT);
this.entryRefQName =
new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ELEM_ENTRY_REF);
- this.v4PropertyValueQName =
+ this.propertyValueQName =
new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.VALUE);
+ this.deletedEntryQName = new QName(Constants.NS_ATOM_TOMBSTONE, Constants.ATOM_ELEM_DELETED_ENTRY);
+ this.reasonQName =
+ new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ELEM_REASON);
+ this.linkQName =
+ new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ELEM_LINK);
+ this.deletedLinkQName =
+ new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ELEM_DELETED_LINK);
+
this.errorCodeQName =
new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ERROR_CODE);
this.errorMessageQName =
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractDelta.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractDelta.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractDelta.java
new file mode 100644
index 0000000..73a65b7
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractDelta.java
@@ -0,0 +1,65 @@
+/*
+ * 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 java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.olingo.commons.api.data.DeletedEntity;
+import org.apache.olingo.commons.api.data.Delta;
+import org.apache.olingo.commons.api.data.DeltaLink;
+
+public abstract class AbstractDelta extends AbstractEntitySet implements Delta {
+
+ private static final long serialVersionUID = 4576771708961553195L;
+
+ private final List<DeletedEntity> deletedEntities = new ArrayList<DeletedEntity>();
+
+ private final List<DeltaLink> addedLinks = new ArrayList<DeltaLink>();
+
+ private final List<DeltaLink> deletedLinks = new ArrayList<DeltaLink>();
+
+ private URI deltaLink;
+
+ @Override
+ public List<DeletedEntity> getDeletedEntities() {
+ return deletedEntities;
+ }
+
+ @Override
+ public List<DeltaLink> getAddedLinks() {
+ return addedLinks;
+ }
+
+ @Override
+ public List<DeltaLink> getDeletedLinks() {
+ return deletedLinks;
+ }
+
+ @Override
+ public URI getDeltaLink() {
+ return deltaLink;
+ }
+
+ @Override
+ public void setDeltaLink(final URI deltaLink) {
+ this.deltaLink = deltaLink;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractEntity.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractEntity.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractEntity.java
new file mode 100644
index 0000000..fc89504
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractEntity.java
@@ -0,0 +1,171 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.Link;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.domain.ODataOperation;
+
+/**
+ * Abstract base for classes implementing an OData entity in Atom and JSON.
+ */
+public abstract class AbstractEntity extends AbstractODataObject implements Entity {
+
+ private static final long serialVersionUID = 2127764552600969783L;
+
+ private String eTag;
+
+ private String type;
+
+ private Link readLink;
+
+ private Link editLink;
+
+ private final List<Link> associationLinks = new ArrayList<Link>();
+
+ private final List<Link> navigationLinks = new ArrayList<Link>();
+
+ private final List<Link> mediaEditLinks = new ArrayList<Link>();
+
+ private final List<ODataOperation> operations = new ArrayList<ODataOperation>();
+
+ private final List<Property> properties = new ArrayList<Property>();
+
+ private String mediaContentSource;
+
+ private String mediaContentType;
+
+ private String mediaETag;
+
+ @Override
+ public String getETag() {
+ return eTag;
+ }
+
+ public void setETag(final String eTag) {
+ this.eTag = eTag;
+ }
+
+ @Override
+ public String getType() {
+ return type;
+ }
+
+ @Override
+ public void setType(final String type) {
+ this.type = type;
+ }
+
+ @Override
+ public Link getSelfLink() {
+ return readLink;
+ }
+
+ @Override
+ public void setSelfLink(final Link readLink) {
+ this.readLink = readLink;
+ }
+
+ @Override
+ public Link getEditLink() {
+ return editLink;
+ }
+
+ @Override
+ public void setEditLink(final Link editLink) {
+ this.editLink = editLink;
+ }
+
+ @Override
+ public List<Link> getAssociationLinks() {
+ return associationLinks;
+ }
+
+ @Override
+ public List<Link> getNavigationLinks() {
+ return navigationLinks;
+ }
+
+ @Override
+ public List<Link> getMediaEditLinks() {
+ return mediaEditLinks;
+ }
+
+ @Override
+ public List<ODataOperation> getOperations() {
+ return operations;
+ }
+
+ @Override
+ public List<Property> getProperties() {
+ return properties;
+ }
+
+ @Override
+ public Property getProperty(final String name) {
+ Property result = null;
+
+ for (Property property : properties) {
+ if (name.equals(property.getName())) {
+ result = property;
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public String getMediaContentType() {
+ return this.mediaContentType;
+ }
+
+ @Override
+ public void setMediaContentType(final String mediaContentType) {
+ this.mediaContentType = mediaContentType;
+ }
+
+ @Override
+ public String getMediaContentSource() {
+ return this.mediaContentSource;
+ }
+
+ @Override
+ public void setMediaContentSource(final String mediaContentSource) {
+ this.mediaContentSource = mediaContentSource;
+ }
+
+ @Override
+ public String getMediaETag() {
+ return mediaETag;
+ }
+
+ @Override
+ public void setMediaETag(final String eTag) {
+ this.mediaETag = eTag;
+ }
+
+ @Override
+ public boolean isMediaEntity() {
+ return StringUtils.isNotBlank(this.mediaContentSource);
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractEntitySet.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractEntitySet.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractEntitySet.java
new file mode 100644
index 0000000..b640812
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractEntitySet.java
@@ -0,0 +1,61 @@
+/*
+ * 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 java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
+
+public abstract class AbstractEntitySet extends AbstractODataObject implements EntitySet {
+
+ private static final long serialVersionUID = -9159884750819150969L;
+
+ private Integer count;
+
+ private final List<Entity> entities = new ArrayList<Entity>();
+
+ private URI next;
+
+ @Override
+ public void setCount(final Integer count) {
+ this.count = count;
+ }
+
+ @Override
+ public Integer getCount() {
+ return count;
+ }
+
+ @Override
+ public List<Entity> getEntities() {
+ return entities;
+ }
+
+ @Override
+ public void setNext(final URI next) {
+ this.next = next;
+ }
+
+ @Override
+ public URI getNext() {
+ return next;
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractEntry.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractEntry.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractEntry.java
deleted file mode 100644
index 4c0f346..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractEntry.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.data;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.data.Entry;
-import org.apache.olingo.commons.api.data.Link;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.domain.ODataOperation;
-
-/**
- * Abstract base for classes implementing an OData entry in Atom and JSON.
- */
-public abstract class AbstractEntry extends AbstractODataObject implements Entry {
-
- private static final long serialVersionUID = 2127764552600969783L;
-
- private String eTag;
-
- private String type;
-
- private Link readLink;
-
- private Link editLink;
-
- private final List<Link> associationLinks = new ArrayList<Link>();
-
- private final List<Link> navigationLinks = new ArrayList<Link>();
-
- private final List<Link> mediaEditLinks = new ArrayList<Link>();
-
- private final List<ODataOperation> operations = new ArrayList<ODataOperation>();
-
- private final List<Property> properties = new ArrayList<Property>();
-
- private String mediaContentSource;
-
- private String mediaContentType;
-
- private String mediaETag;
-
- @Override
- public String getETag() {
- return eTag;
- }
-
- public void setETag(final String eTag) {
- this.eTag = eTag;
- }
-
- @Override
- public String getType() {
- return type;
- }
-
- @Override
- public void setType(final String type) {
- this.type = type;
- }
-
- @Override
- public Link getSelfLink() {
- return readLink;
- }
-
- @Override
- public void setSelfLink(final Link readLink) {
- this.readLink = readLink;
- }
-
- @Override
- public Link getEditLink() {
- return editLink;
- }
-
- @Override
- public void setEditLink(final Link editLink) {
- this.editLink = editLink;
- }
-
- @Override
- public List<Link> getAssociationLinks() {
- return associationLinks;
- }
-
- @Override
- public List<Link> getNavigationLinks() {
- return navigationLinks;
- }
-
- @Override
- public List<Link> getMediaEditLinks() {
- return mediaEditLinks;
- }
-
- @Override
- public List<ODataOperation> getOperations() {
- return operations;
- }
-
- @Override
- public List<Property> getProperties() {
- return properties;
- }
-
- @Override
- public Property getProperty(final String name) {
- Property result = null;
-
- for (Property property : properties) {
- if (name.equals(property.getName())) {
- result = property;
- }
- }
-
- return result;
- }
-
- @Override
- public String getMediaContentType() {
- return this.mediaContentType;
- }
-
- @Override
- public void setMediaContentType(final String mediaContentType) {
- this.mediaContentType = mediaContentType;
- }
-
- @Override
- public String getMediaContentSource() {
- return this.mediaContentSource;
- }
-
- @Override
- public void setMediaContentSource(final String mediaContentSource) {
- this.mediaContentSource = mediaContentSource;
- }
-
- @Override
- public String getMediaETag() {
- return mediaETag;
- }
-
- @Override
- public void setMediaETag(final String eTag) {
- this.mediaETag = eTag;
- }
-
- @Override
- public boolean isMediaEntry() {
- return StringUtils.isNotBlank(this.mediaContentSource);
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/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 97be4eb..82f8ae0 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
@@ -60,33 +60,33 @@ abstract class AbstractJsonDeserializer<T> extends ODataJacksonDeserializer<ResW
protected String setInline(final String name, final String suffix, final JsonNode tree,
final ObjectCodec codec, final LinkImpl link) throws IOException {
- final String entryNamePrefix = name.substring(0, name.indexOf(suffix));
- if (tree.has(entryNamePrefix)) {
- final JsonNode inline = tree.path(entryNamePrefix);
+ final String entityNamePrefix = name.substring(0, name.indexOf(suffix));
+ if (tree.has(entityNamePrefix)) {
+ final JsonNode inline = tree.path(entityNamePrefix);
if (inline instanceof ObjectNode) {
link.setType(ODataLinkType.ENTITY_NAVIGATION.toString());
- link.setInlineEntry(inline.traverse(codec).<ResWrap<JSONEntryImpl>>readValueAs(
- new TypeReference<JSONEntryImpl>() {
+ link.setInlineEntity(inline.traverse(codec).<ResWrap<JSONEntityImpl>>readValueAs(
+ new TypeReference<JSONEntityImpl>() {
}).getPayload());
}
if (inline instanceof ArrayNode) {
link.setType(ODataLinkType.ENTITY_SET_NAVIGATION.toString());
- final JSONFeedImpl feed = new JSONFeedImpl();
+ final JSONEntitySetImpl entitySet = new JSONEntitySetImpl();
final Iterator<JsonNode> entries = ((ArrayNode) inline).elements();
while (entries.hasNext()) {
- feed.getEntries().add(entries.next().traverse(codec).<ResWrap<JSONEntryImpl>>readValuesAs(
- new TypeReference<JSONEntryImpl>() {
+ entitySet.getEntities().add(entries.next().traverse(codec).<ResWrap<JSONEntityImpl>>readValuesAs(
+ new TypeReference<JSONEntityImpl>() {
}).next().getPayload());
}
- link.setInlineFeed(feed);
+ link.setInlineEntitySet(entitySet);
}
}
- return entryNamePrefix;
+ return entityNamePrefix;
}
protected void links(final Map.Entry<String, JsonNode> field, final Linked linked, final Set<String> toRemove,
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/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 06e0e5e..9efc67c 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
@@ -30,7 +30,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.olingo.commons.api.Constants;
import org.apache.olingo.commons.api.data.CollectionValue;
-import org.apache.olingo.commons.api.data.Entry;
+import org.apache.olingo.commons.api.data.Entity;
import org.apache.olingo.commons.api.data.Link;
import org.apache.olingo.commons.api.data.Linked;
import org.apache.olingo.commons.api.data.PrimitiveValue;
@@ -86,11 +86,11 @@ abstract class AbstractJsonSerializer<T> extends ODataJacksonSerializer<T> {
}
}
- if (link.getInlineEntry() != null) {
- jgen.writeObjectField(link.getTitle(), link.getInlineEntry());
- } else if (link.getInlineFeed() != null) {
+ if (link.getInlineEntity() != null) {
+ jgen.writeObjectField(link.getTitle(), link.getInlineEntity());
+ } else if (link.getInlineEntitySet() != null) {
jgen.writeArrayFieldStart(link.getTitle());
- for (Entry subEntry : link.getInlineFeed().getEntries()) {
+ for (Entity subEntry : link.getInlineEntitySet().getEntities()) {
jgen.writeObject(subEntry);
}
jgen.writeEndArray();
@@ -123,11 +123,11 @@ abstract class AbstractJsonSerializer<T> extends ODataJacksonSerializer<T> {
link.getHref());
}
- if (link.getInlineEntry() != null) {
- jgen.writeObjectField(link.getTitle(), link.getInlineEntry());
- } else if (link.getInlineFeed() != null) {
+ if (link.getInlineEntity() != null) {
+ jgen.writeObjectField(link.getTitle(), link.getInlineEntity());
+ } else if (link.getInlineEntitySet() != null) {
jgen.writeArrayFieldStart(link.getTitle());
- for (Entry subEntry : link.getInlineFeed().getEntries()) {
+ for (Entity subEntry : link.getInlineEntitySet().getEntities()) {
jgen.writeObject(subEntry);
}
jgen.writeEndArray();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomDeltaImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomDeltaImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomDeltaImpl.java
new file mode 100644
index 0000000..165299b
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomDeltaImpl.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.core.data;
+
+public class AtomDeltaImpl extends AbstractDelta {
+
+ private static final long serialVersionUID = -730729098008847535L;
+
+}
[4/5] [OLINGO-259] Delta response content parsing (including new
domain objects)
Posted by il...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v3/ODataBinder.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v3/ODataBinder.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v3/ODataBinder.java
index 92d3061..88e3224 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v3/ODataBinder.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v3/ODataBinder.java
@@ -21,8 +21,8 @@ package org.apache.olingo.client.api.op.v3;
import org.apache.olingo.commons.api.data.v3.LinkCollection;
import org.apache.olingo.client.api.domain.v3.ODataLinkCollection;
import org.apache.olingo.client.api.op.CommonODataBinder;
-import org.apache.olingo.commons.api.data.Entry;
-import org.apache.olingo.commons.api.data.Feed;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
@@ -32,10 +32,10 @@ import org.apache.olingo.commons.api.domain.v3.ODataProperty;
public interface ODataBinder extends CommonODataBinder {
@Override
- ODataEntitySet getODataEntitySet(ResWrap<Feed> resource);
+ ODataEntitySet getODataEntitySet(ResWrap<EntitySet> resource);
@Override
- ODataEntity getODataEntity(ResWrap<Entry> resource);
+ ODataEntity getODataEntity(ResWrap<Entity> resource);
@Override
ODataProperty getODataProperty(ResWrap<Property> resource);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataBinder.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataBinder.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataBinder.java
index 9c84a8c..c6c53b3 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataBinder.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataBinder.java
@@ -19,8 +19,8 @@
package org.apache.olingo.client.api.op.v4;
import org.apache.olingo.client.api.op.CommonODataBinder;
-import org.apache.olingo.commons.api.data.Entry;
-import org.apache.olingo.commons.api.data.Feed;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.domain.v4.ODataEntity;
@@ -30,10 +30,10 @@ import org.apache.olingo.commons.api.domain.v4.ODataProperty;
public interface ODataBinder extends CommonODataBinder {
@Override
- ODataEntitySet getODataEntitySet(ResWrap<Feed> resource);
+ ODataEntitySet getODataEntitySet(ResWrap<EntitySet> resource);
@Override
- ODataEntity getODataEntity(ResWrap<Entry> resource);
+ ODataEntity getODataEntity(ResWrap<Entity> resource);
@Override
ODataProperty getODataProperty(ResWrap<Property> resource);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataDeserializer.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataDeserializer.java
index 8b0e0b7..199e98f 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataDeserializer.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataDeserializer.java
@@ -22,10 +22,21 @@ import java.io.InputStream;
import org.apache.olingo.client.api.edm.xml.v4.XMLMetadata;
import org.apache.olingo.client.api.op.ClientODataDeserializer;
+import org.apache.olingo.commons.api.data.Delta;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.format.ODataPubFormat;
public interface ODataDeserializer extends ClientODataDeserializer {
@Override
XMLMetadata toMetadata(InputStream input);
+ /**
+ * Gets a delta object from the given InputStream.
+ *
+ * @param input stream to be de-serialized.
+ * @param format Atom or JSON
+ * @return {@link Delta} instance.
+ */
+ ResWrap<Delta> toDelta(InputStream input, ODataPubFormat format);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java
index 19ed949..2822d82 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java
@@ -34,7 +34,7 @@ import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.data.Entry;
+import org.apache.olingo.commons.api.data.Entity;
/**
* This class implements an OData create request.
@@ -119,8 +119,8 @@ public class ODataEntityCreateRequestImpl<E extends CommonODataEntity>
public E getBody() {
if (entity == null) {
try {
- final ResWrap<Entry> resource = odataClient.getDeserializer().
- toEntry(getRawResponse(), ODataPubFormat.fromString(getAccept()));
+ final ResWrap<Entity> resource = odataClient.getDeserializer().
+ toEntity(getRawResponse(), ODataPubFormat.fromString(getAccept()));
entity = (E) odataClient.getBinder().getODataEntity(resource);
} finally {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityUpdateRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityUpdateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityUpdateRequestImpl.java
index 1134d79..c3b8359 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityUpdateRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityUpdateRequestImpl.java
@@ -34,7 +34,7 @@ import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.data.Entry;
+import org.apache.olingo.commons.api.data.Entity;
/**
* This class implements an OData update request.
@@ -124,8 +124,8 @@ public class ODataEntityUpdateRequestImpl<E extends CommonODataEntity>
public E getBody() {
if (entity == null) {
try {
- final ResWrap<Entry> resource = odataClient.getDeserializer().
- toEntry(getRawResponse(), ODataPubFormat.fromString(getAccept()));
+ final ResWrap<Entity> resource = odataClient.getDeserializer().
+ toEntity(getRawResponse(), ODataPubFormat.fromString(getAccept()));
entity = (E) odataClient.getBinder().getODataEntity(resource);
} finally {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntityRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntityRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntityRequestImpl.java
index c51bcdc..8652086 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntityRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntityRequestImpl.java
@@ -25,7 +25,7 @@ import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.data.Entry;
+import org.apache.olingo.commons.api.data.Entity;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.format.ODataPubFormat;
@@ -81,8 +81,8 @@ public class ODataEntityRequestImpl<E extends CommonODataEntity>
public E getBody() {
if (entity == null) {
try {
- final ResWrap<Entry> resource = odataClient.getDeserializer().
- toEntry(getRawResponse(), ODataPubFormat.fromString(getContentType()));
+ final ResWrap<Entity> resource = odataClient.getDeserializer().
+ toEntity(getRawResponse(), ODataPubFormat.fromString(getContentType()));
entity = (E) odataClient.getBinder().getODataEntity(resource);
} finally {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetIteratorRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetIteratorRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetIteratorRequestImpl.java
index b2e3b57..cca5053 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetIteratorRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetIteratorRequestImpl.java
@@ -36,7 +36,7 @@ public class ODataEntitySetIteratorRequestImpl<ES extends CommonODataEntitySet,
extends AbstractODataRetrieveRequest<ODataEntitySetIterator<ES, E>, ODataPubFormat>
implements ODataEntitySetIteratorRequest<ES, E> {
- private ODataEntitySetIterator feedIterator = null;
+ private ODataEntitySetIterator entitySetIterator = null;
/**
* Private constructor.
@@ -44,7 +44,7 @@ public class ODataEntitySetIteratorRequestImpl<ES extends CommonODataEntitySet,
* @param odataClient client instance getting this request
* @param query query to be executed.
*/
- public ODataEntitySetIteratorRequestImpl(final CommonODataClient odataClient, final URI query) {
+ public ODataEntitySetIteratorRequestImpl(final CommonODataClient<?> odataClient, final URI query) {
super(odataClient, ODataPubFormat.class, query);
}
@@ -78,11 +78,11 @@ public class ODataEntitySetIteratorRequestImpl<ES extends CommonODataEntitySet,
@Override
@SuppressWarnings("unchecked")
public ODataEntitySetIterator<ES, E> getBody() {
- if (feedIterator == null) {
- feedIterator = new ODataEntitySetIterator<ES, E>(
+ if (entitySetIterator == null) {
+ entitySetIterator = new ODataEntitySetIterator<ES, E>(
odataClient, getRawResponse(), ODataPubFormat.fromString(getContentType()));
}
- return feedIterator;
+ return entitySetIterator;
}
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java
index a14b4a8..1783789 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java
@@ -25,7 +25,7 @@ import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.data.Feed;
+import org.apache.olingo.commons.api.data.EntitySet;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.apache.olingo.commons.api.format.ODataPubFormat;
@@ -90,8 +90,8 @@ public class ODataEntitySetRequestImpl<ES extends CommonODataEntitySet>
public ES getBody() {
if (entitySet == null) {
try {
- final ResWrap<Feed> resource = odataClient.getDeserializer().
- toFeed(getRawResponse(), ODataPubFormat.fromString(getContentType()));
+ final ResWrap<EntitySet> resource = odataClient.getDeserializer().
+ toEntitySet(getRawResponse(), ODataPubFormat.fromString(getContentType()));
entitySet = (ES) odataClient.getBinder().getODataEntitySet(resource);
} finally {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityCreateRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityCreateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityCreateRequestImpl.java
index 0eb5037..89b0da0 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityCreateRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityCreateRequestImpl.java
@@ -32,7 +32,7 @@ import org.apache.olingo.client.api.http.HttpMethod;
import org.apache.olingo.client.core.communication.request.AbstractODataStreamManager;
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.data.Entry;
+import org.apache.olingo.commons.api.data.Entity;
/**
* This class implements an OData Media Entity create request. Get instance by using ODataStreamedRequestFactory.
@@ -123,7 +123,7 @@ public class ODataMediaEntityCreateRequestImpl<E extends CommonODataEntity>
public E getBody() {
if (entity == null) {
try {
- final ResWrap<Entry> resource = odataClient.getDeserializer().toEntry(getRawResponse(), getFormat());
+ final ResWrap<Entity> resource = odataClient.getDeserializer().toEntity(getRawResponse(), getFormat());
entity = (E) odataClient.getBinder().getODataEntity(resource);
} finally {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityUpdateRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityUpdateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityUpdateRequestImpl.java
index 476fb8d..bd9fa82 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityUpdateRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityUpdateRequestImpl.java
@@ -32,7 +32,7 @@ import org.apache.olingo.client.api.http.HttpMethod;
import org.apache.olingo.client.core.communication.request.AbstractODataStreamManager;
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.data.Entry;
+import org.apache.olingo.commons.api.data.Entity;
/**
* This class implements an OData Media Entity create request. Get instance by using ODataStreamedRequestFactory.
@@ -122,7 +122,7 @@ public class ODataMediaEntityUpdateRequestImpl<E extends CommonODataEntity>
public E getBody() {
if (entity == null) {
try {
- final ResWrap<Entry> resource = odataClient.getDeserializer().toEntry(getRawResponse(), getFormat());
+ final ResWrap<Entity> resource = odataClient.getDeserializer().toEntity(getRawResponse(), getFormat());
entity = (E) odataClient.getBinder().getODataEntity(resource);
} finally {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/v4/AsyncRequestFactoryImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/v4/AsyncRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/v4/AsyncRequestFactoryImpl.java
index d5331bc..afd08f0 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/v4/AsyncRequestFactoryImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/v4/AsyncRequestFactoryImpl.java
@@ -26,12 +26,11 @@ import org.apache.olingo.client.api.communication.request.v4.AsyncRequestWrapper
import org.apache.olingo.client.api.communication.response.ODataResponse;
import org.apache.olingo.client.api.v4.ODataClient;
-@SuppressWarnings("unchecked")
public class AsyncRequestFactoryImpl implements AsyncRequestFactory {
private static final long serialVersionUID = 546577958047902917L;
- protected final ODataClient client;
+ private final ODataClient client;
public AsyncRequestFactoryImpl(final ODataClient client) {
this.client = client;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/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 95efa7c..3107e8e 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
@@ -30,8 +30,8 @@ import org.apache.olingo.client.api.v4.EdmEnabledODataClient;
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.Constants;
import org.apache.olingo.commons.api.data.ContextURL;
-import org.apache.olingo.commons.api.data.Entry;
-import org.apache.olingo.commons.api.data.Feed;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
import org.apache.olingo.commons.api.data.Link;
import org.apache.olingo.commons.api.data.Linked;
import org.apache.olingo.commons.api.data.Property;
@@ -105,33 +105,33 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
}
@Override
- public Feed getFeed(final CommonODataEntitySet entitySet, final Class<? extends Feed> reference) {
- final Feed feed = ResourceFactory.newFeed(reference);
+ public EntitySet getEntitySet(final CommonODataEntitySet odataEntitySet, final Class<? extends EntitySet> reference) {
+ final EntitySet entitySet = ResourceFactory.newEntitySet(reference);
- feed.setCount(entitySet.getCount());
+ entitySet.setCount(odataEntitySet.getCount());
- final URI next = entitySet.getNext();
+ final URI next = odataEntitySet.getNext();
if (next != null) {
- feed.setNext(next);
+ entitySet.setNext(next);
}
- for (CommonODataEntity entity : entitySet.getEntities()) {
- feed.getEntries().add(getEntry(entity, ResourceFactory.entryClassForFeed(reference)));
+ for (CommonODataEntity entity : odataEntitySet.getEntities()) {
+ entitySet.getEntities().add(getEntity(entity, ResourceFactory.entityClassForEntitySet(reference)));
}
- return feed;
+ return entitySet;
}
- protected void links(final ODataLinked odataLinked, final Linked linked, final Class<? extends Entry> reference) {
+ protected void links(final ODataLinked odataLinked, final Linked linked, final Class<? extends Entity> reference) {
// -------------------------------------------------------------
- // Append navigation links (handling inline entry / feed as well)
+ // Append navigation links (handling inline entity / entity set as well)
// -------------------------------------------------------------
// handle navigation links
for (ODataLink link : odataLinked.getNavigationLinks()) {
// append link
LOG.debug("Append navigation link\n{}", link);
linked.getNavigationLinks().add(getLink(link,
- ResourceFactory.formatForEntryClass(reference) == ODataPubFormat.ATOM));
+ ResourceFactory.formatForEntityClass(reference) == ODataPubFormat.ATOM));
}
// -------------------------------------------------------------
@@ -141,61 +141,61 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
for (ODataLink link : odataLinked.getAssociationLinks()) {
LOG.debug("Append association link\n{}", link);
linked.getAssociationLinks().add(getLink(link,
- ResourceFactory.formatForEntryClass(reference) == ODataPubFormat.ATOM));
+ ResourceFactory.formatForEntityClass(reference) == ODataPubFormat.ATOM));
}
// -------------------------------------------------------------
}
@Override
- public Entry getEntry(final CommonODataEntity entity, final Class<? extends Entry> reference) {
- final Entry entry = ResourceFactory.newEntry(reference);
+ public Entity getEntity(final CommonODataEntity odataEntity, final Class<? extends Entity> reference) {
+ final Entity entity = ResourceFactory.newEntity(reference);
- entry.setType(entity.getTypeName() == null ? null : entity.getTypeName().toString());
+ entity.setType(odataEntity.getTypeName() == null ? null : odataEntity.getTypeName().toString());
// -------------------------------------------------------------
// Add edit and self link
// -------------------------------------------------------------
- final URI editLink = entity.getEditLink();
- if (editLink != null) {
- final LinkImpl entryEditLink = new LinkImpl();
- entryEditLink.setTitle(entry.getType());
- entryEditLink.setHref(editLink.toASCIIString());
- entryEditLink.setRel(Constants.EDIT_LINK_REL);
- entry.setEditLink(entryEditLink);
+ final URI odataEditLink = odataEntity.getEditLink();
+ if (odataEditLink != null) {
+ final LinkImpl editLink = new LinkImpl();
+ editLink.setTitle(entity.getType());
+ editLink.setHref(odataEditLink.toASCIIString());
+ editLink.setRel(Constants.EDIT_LINK_REL);
+ entity.setEditLink(editLink);
}
- if (entity.isReadOnly()) {
- final LinkImpl entrySelfLink = new LinkImpl();
- entrySelfLink.setTitle(entry.getType());
- entrySelfLink.setHref(entity.getLink().toASCIIString());
- entrySelfLink.setRel(Constants.SELF_LINK_REL);
- entry.setSelfLink(entrySelfLink);
+ if (odataEntity.isReadOnly()) {
+ final LinkImpl selfLink = new LinkImpl();
+ selfLink.setTitle(entity.getType());
+ selfLink.setHref(odataEntity.getLink().toASCIIString());
+ selfLink.setRel(Constants.SELF_LINK_REL);
+ entity.setSelfLink(selfLink);
}
// -------------------------------------------------------------
- links(entity, entry, reference);
+ links(odataEntity, entity, reference);
// -------------------------------------------------------------
// Append edit-media links
// -------------------------------------------------------------
- for (ODataLink link : entity.getEditMediaLinks()) {
+ for (ODataLink link : odataEntity.getEditMediaLinks()) {
LOG.debug("Append edit-media link\n{}", link);
- entry.getMediaEditLinks().add(getLink(link,
- ResourceFactory.formatForEntryClass(reference) == ODataPubFormat.ATOM));
+ entity.getMediaEditLinks().add(getLink(link,
+ ResourceFactory.formatForEntityClass(reference) == ODataPubFormat.ATOM));
}
// -------------------------------------------------------------
- if (entity.isMediaEntity()) {
- entry.setMediaContentSource(entity.getMediaContentSource());
- entry.setMediaContentType(entity.getMediaContentType());
- entry.setMediaETag(entity.getMediaETag());
+ if (odataEntity.isMediaEntity()) {
+ entity.setMediaContentSource(odataEntity.getMediaContentSource());
+ entity.setMediaContentType(odataEntity.getMediaContentType());
+ entity.setMediaETag(odataEntity.getMediaETag());
}
- for (CommonODataProperty property : entity.getProperties()) {
- entry.getProperties().add(getProperty(property, reference));
+ for (CommonODataProperty property : odataEntity.getProperties()) {
+ entity.getProperties().add(getProperty(property, reference));
}
- return entry;
+ return entity;
}
@Override
@@ -212,19 +212,19 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
final CommonODataEntity inlineEntity = ((ODataInlineEntity) link).getEntity();
LOG.debug("Append in-line entity\n{}", inlineEntity);
- linkResource.setInlineEntry(getEntry(inlineEntity, ResourceFactory.entryClassForFormat(isXML)));
+ linkResource.setInlineEntity(getEntity(inlineEntity, ResourceFactory.entityClassForFormat(isXML)));
} else if (link instanceof ODataInlineEntitySet) {
- // append inline feed
- final CommonODataEntitySet InlineFeed = ((ODataInlineEntitySet) link).getEntitySet();
- LOG.debug("Append in-line feed\n{}", InlineFeed);
+ // append inline entity set
+ final CommonODataEntitySet InlineEntitySet = ((ODataInlineEntitySet) link).getEntitySet();
+ LOG.debug("Append in-line entity set\n{}", InlineEntitySet);
- linkResource.setInlineFeed(getFeed(InlineFeed, ResourceFactory.feedClassForFormat(isXML)));
+ linkResource.setInlineEntitySet(getEntitySet(InlineEntitySet, ResourceFactory.entitySetClassForFormat(isXML)));
}
return linkResource;
}
- protected Value getValue(final ODataValue value, final Class<? extends Entry> reference) {
+ protected Value getValue(final ODataValue value, final Class<? extends Entity> reference) {
Value valueResource = null;
if (value == null) {
@@ -255,12 +255,12 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
protected abstract boolean add(CommonODataEntitySet entitySet, CommonODataEntity entity);
@Override
- public CommonODataEntitySet getODataEntitySet(final ResWrap<Feed> resource) {
+ public CommonODataEntitySet getODataEntitySet(final ResWrap<EntitySet> resource) {
if (LOG.isDebugEnabled()) {
final StringWriter writer = new StringWriter();
- client.getSerializer().feed(resource.getPayload(), writer);
+ client.getSerializer().entitySet(resource.getPayload(), writer);
writer.flush();
- LOG.debug("Feed -> ODataEntitySet:\n{}", writer.toString());
+ LOG.debug("EntitySet -> ODataEntitySet:\n{}", writer.toString());
}
final URI base = resource.getContextURL() == null
@@ -276,9 +276,9 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
entitySet.setCount(resource.getPayload().getCount());
}
- for (Entry entryResource : resource.getPayload().getEntries()) {
+ for (Entity entityResource : resource.getPayload().getEntities()) {
add(entitySet, getODataEntity(
- new ResWrap<Entry>(resource.getContextURL(), resource.getMetadataETag(), entryResource)));
+ new ResWrap<Entity>(resource.getContextURL(), resource.getMetadataETag(), entityResource)));
}
return entitySet;
@@ -288,10 +288,10 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
final Linked linked, final ODataLinked odataLinked, final String metadataETag, final URI base) {
for (Link link : linked.getNavigationLinks()) {
- final Entry inlineEntry = link.getInlineEntry();
- final Feed inlineFeed = link.getInlineFeed();
+ final Entity inlineEntity = link.getInlineEntity();
+ final EntitySet inlineEntitySet = link.getInlineEntitySet();
- if (inlineEntry == null && inlineFeed == null) {
+ if (inlineEntity == null && inlineEntitySet == null) {
ODataLinkType linkType = null;
if (edmType != null) {
final EdmNavigationProperty navProp = edmType.getNavigationProperty(link.getTitle());
@@ -312,20 +312,20 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
newEntityNavigationLink(link.getTitle(), URIUtils.getURI(base, link.getHref()))
: client.getObjectFactory().
newEntitySetNavigationLink(link.getTitle(), URIUtils.getURI(base, link.getHref())));
- } else if (inlineEntry != null) {
+ } else if (inlineEntity != null) {
odataLinked.addLink(new ODataInlineEntity(client.getServiceVersion(),
URIUtils.getURI(base, link.getHref()), ODataLinkType.ENTITY_NAVIGATION, link.getTitle(),
- getODataEntity(new ResWrap<Entry>(
- inlineEntry.getBaseURI() == null ? base : inlineEntry.getBaseURI(),
+ getODataEntity(new ResWrap<Entity>(
+ inlineEntity.getBaseURI() == null ? base : inlineEntity.getBaseURI(),
metadataETag,
- inlineEntry))));
+ inlineEntity))));
} else {
odataLinked.addLink(new ODataInlineEntitySet(client.getServiceVersion(),
URIUtils.getURI(base, link.getHref()), ODataLinkType.ENTITY_SET_NAVIGATION, link.getTitle(),
- getODataEntitySet(new ResWrap<Feed>(
- inlineFeed.getBaseURI() == null ? base : inlineFeed.getBaseURI(),
+ getODataEntitySet(new ResWrap<EntitySet>(
+ inlineEntitySet.getBaseURI() == null ? base : inlineEntitySet.getBaseURI(),
metadataETag,
- inlineFeed))));
+ inlineEntitySet))));
}
}
}
@@ -374,12 +374,12 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
}
@Override
- public CommonODataEntity getODataEntity(final ResWrap<Entry> resource) {
+ public CommonODataEntity getODataEntity(final ResWrap<Entity> resource) {
if (LOG.isDebugEnabled()) {
final StringWriter writer = new StringWriter();
- client.getSerializer().entry(resource.getPayload(), writer);
+ client.getSerializer().entity(resource.getPayload(), writer);
writer.flush();
- LOG.debug("EntryResource -> ODataEntity:\n{}", writer.toString());
+ LOG.debug("EntityResource -> ODataEntity:\n{}", writer.toString());
}
final URI base = resource.getContextURL() == null
@@ -428,7 +428,7 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
entity.getOperations().add(operation);
}
- if (resource.getPayload().isMediaEntry()) {
+ if (resource.getPayload().isMediaEntity()) {
entity.setMediaEntity(true);
entity.setMediaContentSource(resource.getPayload().getMediaContentSource());
entity.setMediaContentType(resource.getPayload().getMediaContentType());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataReader.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataReader.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataReader.java
index 0df51a5..9cc9548 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataReader.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataReader.java
@@ -37,8 +37,8 @@ import org.apache.olingo.client.api.edm.xml.XMLMetadata;
import org.apache.olingo.client.api.op.CommonODataReader;
import org.apache.olingo.client.core.edm.EdmClientImpl;
import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.data.Entry;
-import org.apache.olingo.commons.api.data.Feed;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.format.ODataPubFormat;
@@ -96,13 +96,14 @@ public abstract class AbstractODataReader implements CommonODataReader {
reference.cast(new ODataEntitySetIterator<CommonODataEntitySet, CommonODataEntity>(
client, src, ODataPubFormat.fromString(format))));
} else if (CommonODataEntitySet.class.isAssignableFrom(reference)) {
- final ResWrap<Feed> resource = client.getDeserializer().toFeed(src, ODataPubFormat.fromString(format));
+ final ResWrap<EntitySet> resource = client.getDeserializer().
+ toEntitySet(src, ODataPubFormat.fromString(format));
res = new ResWrap<T>(
resource.getContextURL(),
resource.getMetadataETag(),
reference.cast(client.getBinder().getODataEntitySet(resource)));
} else if (CommonODataEntity.class.isAssignableFrom(reference)) {
- final ResWrap<Entry> container = client.getDeserializer().toEntry(src, ODataPubFormat.fromString(format));
+ final ResWrap<Entity> container = client.getDeserializer().toEntity(src, ODataPubFormat.fromString(format));
res = new ResWrap<T>(
container.getContextURL(),
container.getMetadataETag(),
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/ODataWriterImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/ODataWriterImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/ODataWriterImpl.java
index 7230704..a1c7e5e 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/ODataWriterImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/ODataWriterImpl.java
@@ -48,8 +48,8 @@ public class ODataWriterImpl implements ODataWriter {
final ByteArrayOutputStream output = new ByteArrayOutputStream();
try {
for (CommonODataEntity entity : entities) {
- client.getSerializer().entry(client.getBinder().getEntry(
- entity, ResourceFactory.entryClassForFormat(format == ODataPubFormat.ATOM)), output);
+ client.getSerializer().entity(client.getBinder().getEntity(
+ entity, ResourceFactory.entityClassForFormat(format == ODataPubFormat.ATOM)), output);
}
return new ByteArrayInputStream(output.toByteArray());
@@ -68,7 +68,7 @@ public class ODataWriterImpl implements ODataWriter {
final ByteArrayOutputStream output = new ByteArrayOutputStream();
try {
client.getSerializer().property(client.getBinder().getProperty(
- property, ResourceFactory.entryClassForFormat(format == ODataFormat.XML)), output);
+ property, ResourceFactory.entityClassForFormat(format == ODataFormat.XML)), output);
return new ByteArrayInputStream(output.toByteArray());
} finally {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java
index 75d3eaa..c429177 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java
@@ -22,8 +22,8 @@ import org.apache.olingo.client.api.domain.v3.ODataLinkCollection;
import org.apache.olingo.client.api.op.v3.ODataBinder;
import org.apache.olingo.client.core.op.AbstractODataBinder;
import org.apache.olingo.client.core.v3.ODataClientImpl;
-import org.apache.olingo.commons.api.data.Entry;
-import org.apache.olingo.commons.api.data.Feed;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.data.v3.LinkCollection;
@@ -55,7 +55,7 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
}
@Override
- public Property getProperty(final CommonODataProperty property, final Class<? extends Entry> reference) {
+ public Property getProperty(final CommonODataProperty property, final Class<? extends Entity> reference) {
final Property propertyResource = ResourceFactory.newProperty(reference);
propertyResource.setName(property.getName());
propertyResource.setValue(getValue(property.getValue(), reference));
@@ -72,12 +72,12 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
}
@Override
- public ODataEntitySet getODataEntitySet(final ResWrap<Feed> resource) {
+ public ODataEntitySet getODataEntitySet(final ResWrap<EntitySet> resource) {
return (ODataEntitySet) super.getODataEntitySet(resource);
}
@Override
- public ODataEntity getODataEntity(final ResWrap<Entry> resource) {
+ public ODataEntity getODataEntity(final ResWrap<Entity> resource) {
return (ODataEntity) super.getODataEntity(resource);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataReaderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataReaderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataReaderImpl.java
index 2b8bc5d..c64d5c8 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataReaderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataReaderImpl.java
@@ -42,12 +42,12 @@ public class ODataReaderImpl extends AbstractODataReader implements ODataReader
@Override
public ODataEntitySet readEntitySet(final InputStream input, final ODataPubFormat format) {
- return ((ODataClient) client).getBinder().getODataEntitySet(client.getDeserializer().toFeed(input, format));
+ return ((ODataClient) client).getBinder().getODataEntitySet(client.getDeserializer().toEntitySet(input, format));
}
@Override
public ODataEntity readEntity(final InputStream input, final ODataPubFormat format) {
- return ((ODataClient) client).getBinder().getODataEntity(client.getDeserializer().toEntry(input, format));
+ return ((ODataClient) client).getBinder().getODataEntity(client.getDeserializer().toEntity(input, format));
}
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java
index 407ab1b..cbdd773 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java
@@ -25,8 +25,8 @@ import org.apache.olingo.client.api.v4.EdmEnabledODataClient;
import org.apache.olingo.client.api.v4.ODataClient;
import org.apache.olingo.client.core.op.AbstractODataBinder;
import org.apache.olingo.client.core.uri.URIUtils;
-import org.apache.olingo.commons.api.data.Entry;
-import org.apache.olingo.commons.api.data.Feed;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
import org.apache.olingo.commons.api.data.LinkedComplexValue;
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.data.ResWrap;
@@ -89,14 +89,14 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
}
@Override
- public Entry getEntry(final CommonODataEntity entity, final Class<? extends Entry> reference) {
- final Entry entry = super.getEntry(entity, reference);
- entry.setId(((ODataEntity) entity).getReference());
- return entry;
+ public Entity getEntity(final CommonODataEntity odataEntity, final Class<? extends Entity> reference) {
+ final Entity entity = super.getEntity(odataEntity, reference);
+ entity.setId(((ODataEntity) odataEntity).getReference());
+ return entity;
}
@Override
- public Property getProperty(final CommonODataProperty property, final Class<? extends Entry> reference) {
+ public Property getProperty(final CommonODataProperty property, final Class<? extends Entity> reference) {
final ODataProperty _property = (ODataProperty) property;
final Property propertyResource = ResourceFactory.newProperty(reference);
@@ -117,7 +117,7 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
}
@Override
- protected Value getValue(final ODataValue value, final Class<? extends Entry> reference) {
+ protected Value getValue(final ODataValue value, final Class<? extends Entity> reference) {
Value valueResource;
if (value instanceof org.apache.olingo.commons.api.domain.v4.ODataValue
&& ((org.apache.olingo.commons.api.domain.v4.ODataValue) value).isEnum()) {
@@ -144,12 +144,12 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
}
@Override
- public ODataEntitySet getODataEntitySet(final ResWrap<Feed> resource) {
+ public ODataEntitySet getODataEntitySet(final ResWrap<EntitySet> resource) {
return (ODataEntitySet) super.getODataEntitySet(resource);
}
@Override
- public ODataEntity getODataEntity(final ResWrap<Entry> resource) {
+ public ODataEntity getODataEntity(final ResWrap<Entity> resource) {
final ODataEntity entity = (ODataEntity) super.getODataEntity(resource);
entity.setReference(resource.getPayload().getId());
return entity;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataDeserializerImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataDeserializerImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataDeserializerImpl.java
index 9bb6727..ae7d5cd 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataDeserializerImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataDeserializerImpl.java
@@ -28,9 +28,13 @@ import org.apache.olingo.client.core.data.v4.JSONServiceDocumentImpl;
import org.apache.olingo.client.core.data.v4.XMLServiceDocumentImpl;
import org.apache.olingo.client.core.edm.xml.v4.EdmxImpl;
import org.apache.olingo.client.core.edm.xml.v4.XMLMetadataImpl;
+import org.apache.olingo.commons.api.data.Delta;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.core.op.AbstractODataDeserializer;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.core.data.AtomDeltaImpl;
+import org.apache.olingo.commons.core.data.JSONDeltaImpl;
public class ODataDeserializerImpl extends AbstractODataDeserializer implements ODataDeserializer {
@@ -56,4 +60,12 @@ public class ODataDeserializerImpl extends AbstractODataDeserializer implements
: this.<ServiceDocument, JSONServiceDocumentImpl>json(input, JSONServiceDocumentImpl.class);
}
+
+ @Override
+ public ResWrap<Delta> toDelta(final InputStream input, final ODataPubFormat format) {
+ return format == ODataPubFormat.ATOM
+ ? this.<Delta, AtomDeltaImpl>atom(input, AtomDeltaImpl.class)
+ : this.<Delta, JSONDeltaImpl>json(input, JSONDeltaImpl.class);
+ }
+
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataReaderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataReaderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataReaderImpl.java
index eb446d1..71c2244 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataReaderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataReaderImpl.java
@@ -38,12 +38,12 @@ public class ODataReaderImpl extends AbstractODataReader implements ODataReader
@Override
public ODataEntitySet readEntitySet(final InputStream input, final ODataPubFormat format) {
- return ((ODataClient) client).getBinder().getODataEntitySet(client.getDeserializer().toFeed(input, format));
+ return ((ODataClient) client).getBinder().getODataEntitySet(client.getDeserializer().toEntitySet(input, format));
}
@Override
public ODataEntity readEntity(final InputStream input, final ODataPubFormat format) {
- return ((ODataClient) client).getBinder().getODataEntity(client.getDeserializer().toEntry(input, format));
+ return ((ODataClient) client).getBinder().getODataEntity(client.getDeserializer().toEntity(input, format));
}
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/AbstractBaseTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/AbstractBaseTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/AbstractBaseTestITCase.java
index fc1e91d..33c27a6 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/AbstractBaseTestITCase.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/AbstractBaseTestITCase.java
@@ -23,13 +23,13 @@ import java.io.InputStream;
import java.io.StringWriter;
import org.apache.commons.io.IOUtils;
import org.apache.olingo.client.api.CommonODataClient;
-import org.apache.olingo.commons.api.data.Entry;
-import org.apache.olingo.commons.api.data.Feed;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.domain.ODataValue;
-import org.apache.olingo.commons.core.data.AtomEntryImpl;
-import org.apache.olingo.commons.core.data.JSONEntryImpl;
+import org.apache.olingo.commons.core.data.AtomEntityImpl;
+import org.apache.olingo.commons.core.data.JSONEntityImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -43,19 +43,19 @@ public abstract class AbstractBaseTestITCase {
@SuppressWarnings("rawtypes")
protected abstract CommonODataClient getClient();
- protected void debugEntry(final Entry entry, final String message) {
+ protected void debugEntity(final Entity entity, final String message) {
if (LOG.isDebugEnabled()) {
final StringWriter writer = new StringWriter();
- getClient().getSerializer().entry(entry, writer);
+ getClient().getSerializer().entity(entity, writer);
writer.flush();
LOG.debug(message + "\n{}", writer.toString());
}
}
- protected void debugFeed(final Feed feed, final String message) {
+ protected void debugEntitySet(final EntitySet entitySet, final String message) {
if (LOG.isDebugEnabled()) {
final StringWriter writer = new StringWriter();
- getClient().getSerializer().feed(feed, writer);
+ getClient().getSerializer().entitySet(entitySet, writer);
writer.flush();
LOG.debug(message + "\n{}", writer.toString());
}
@@ -72,12 +72,12 @@ public abstract class AbstractBaseTestITCase {
protected void debugODataEntity(final CommonODataEntity entity, final String message) {
if (LOG.isDebugEnabled()) {
StringWriter writer = new StringWriter();
- getClient().getSerializer().entry(getClient().getBinder().getEntry(entity, AtomEntryImpl.class), writer);
+ getClient().getSerializer().entity(getClient().getBinder().getEntity(entity, AtomEntityImpl.class), writer);
writer.flush();
LOG.debug(message + " (Atom)\n{}", writer.toString());
writer = new StringWriter();
- getClient().getSerializer().entry(getClient().getBinder().getEntry(entity, JSONEntryImpl.class), writer);
+ getClient().getSerializer().entity(getClient().getBinder().getEntity(entity, JSONEntityImpl.class), writer);
writer.flush();
LOG.debug(message + " (JSON)\n{}", writer.toString());
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityRetrieveTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityRetrieveTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityRetrieveTestITCase.java
index 2693fb2..de51167 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityRetrieveTestITCase.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityRetrieveTestITCase.java
@@ -78,8 +78,8 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
final CommonODataEntity inline = ((ODataInlineEntity) link).getEntity();
assertNotNull(inline);
- debugEntry(client.getBinder().getEntry(
- inline, ResourceFactory.entryClassForFormat(format == ODataPubFormat.ATOM)), "Just read");
+ debugEntity(client.getBinder().getEntity(
+ inline, ResourceFactory.entityClassForFormat(format == ODataPubFormat.ATOM)), "Just read");
final List<? extends CommonODataProperty> properties = inline.getProperties();
assertEquals(2, properties.size());
@@ -125,7 +125,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
final CommonODataEntitySet inline = ((ODataInlineEntitySet) link).getEntitySet();
assertNotNull(inline);
- debugFeed(client.getBinder().getFeed(inline, ResourceFactory.feedClassForFormat(
+ debugEntitySet(client.getBinder().getEntitySet(inline, ResourceFactory.entitySetClassForFormat(
format == ODataPubFormat.ATOM)), "Just read");
found = true;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntitySetTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntitySetTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntitySetTestITCase.java
index abf0964..077a6b1 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntitySetTestITCase.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntitySetTestITCase.java
@@ -111,7 +111,7 @@ public class EntitySetTestITCase extends AbstractTestITCase {
assertNotNull(feed);
- debugFeed(client.getBinder().getFeed(feed, ResourceFactory.feedClassForFormat(
+ debugEntitySet(client.getBinder().getEntitySet(feed, ResourceFactory.entitySetClassForFormat(
ODataPubFormat.ATOM == format)), "Just retrieved feed");
assertEquals(2, feed.getEntities().size());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/QueryOptionsTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/QueryOptionsTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/QueryOptionsTestITCase.java
index 827ad2a..a00f057 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/QueryOptionsTestITCase.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/QueryOptionsTestITCase.java
@@ -30,13 +30,13 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySe
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.api.uri.v3.URIBuilder;
import org.apache.olingo.client.api.uri.v3.URIBuilder.InlineCount;
-import org.apache.olingo.commons.api.data.Entry;
+import org.apache.olingo.commons.api.data.Entity;
import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.core.data.AtomEntryImpl;
+import org.apache.olingo.commons.core.data.AtomEntityImpl;
import org.junit.Test;
/**
@@ -194,9 +194,9 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setFormat(ODataPubFormat.ATOM);
- final Entry atomEntry =
- client.getDeserializer().toEntry(req.execute().getRawResponse(), ODataPubFormat.ATOM).getPayload();
+ final Entity atomEntry =
+ client.getDeserializer().toEntity(req.execute().getRawResponse(), ODataPubFormat.ATOM).getPayload();
assertEquals("remotingdestructorprinterswitcheschannelssatellitelanguageresolve",
- ((AtomEntryImpl) atomEntry).getSummary());
+ ((AtomEntityImpl) atomEntry).getSummary());
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/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 1e6df49..1b047a8 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
@@ -67,37 +67,37 @@ public class AtomTest extends AbstractTest {
assertTrue(diff.similar());
}
- protected void feed(final String filename, final ODataPubFormat format) throws Exception {
+ protected void entitySet(final String filename, final ODataPubFormat format) throws Exception {
final StringWriter writer = new StringWriter();
- getClient().getSerializer().feed(getClient().getDeserializer().toFeed(
+ getClient().getSerializer().entitySet(getClient().getDeserializer().toEntitySet(
getClass().getResourceAsStream("Customer." + getSuffix(format)), format).getPayload(), writer);
assertSimilar("Customer." + getSuffix(format), writer.toString());
}
@Test
- public void feeds() throws Exception {
- feed("Customer", getODataPubFormat());
+ public void entitySets() throws Exception {
+ entitySet("Customer", getODataPubFormat());
}
- protected void entry(final String filename, final ODataPubFormat format) throws Exception {
+ protected void entity(final String filename, final ODataPubFormat format) throws Exception {
final StringWriter writer = new StringWriter();
- getClient().getSerializer().entry(getClient().getDeserializer().toEntry(
+ getClient().getSerializer().entity(getClient().getDeserializer().toEntity(
getClass().getResourceAsStream(filename + "." + getSuffix(format)), format).getPayload(), writer);
assertSimilar(filename + "." + getSuffix(format), writer.toString());
}
@Test
- public void entries() throws Exception {
- entry("AllGeoTypesSet_-5", getODataPubFormat());
- entry("AllGeoTypesSet_-8", getODataPubFormat());
- entry("Car_16", getODataPubFormat());
- entry("ComputerDetail_-10", getODataPubFormat());
- entry("Customer_-10", getODataPubFormat());
- entry("Products_1", getODataPubFormat());
- entry("PersonDetails_0_Person", getODataPubFormat());
- entry("Products_0_Categories", getODataPubFormat());
+ public void entities() throws Exception {
+ entity("AllGeoTypesSet_-5", getODataPubFormat());
+ entity("AllGeoTypesSet_-8", getODataPubFormat());
+ entity("Car_16", getODataPubFormat());
+ entity("ComputerDetail_-10", getODataPubFormat());
+ entity("Customer_-10", getODataPubFormat());
+ entity("Products_1", getODataPubFormat());
+ entity("PersonDetails_0_Person", getODataPubFormat());
+ entity("Products_0_Categories", getODataPubFormat());
}
protected void property(final String filename, final ODataFormat format) throws Exception {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntitySetTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntitySetTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntitySetTest.java
index f01a7f5..46a6995 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntitySetTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntitySetTest.java
@@ -27,7 +27,7 @@ import java.net.URI;
import org.apache.olingo.client.api.v3.ODataClient;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.client.core.AbstractTest;
-import org.apache.olingo.commons.api.data.Feed;
+import org.apache.olingo.commons.api.data.EntitySet;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
import org.apache.olingo.commons.core.op.ResourceFactory;
@@ -43,15 +43,15 @@ public class EntitySetTest extends AbstractTest {
private void read(final ODataPubFormat format) throws IOException {
final InputStream input = getClass().getResourceAsStream("Customer." + getSuffix(format));
final ODataEntitySet entitySet = getClient().getBinder().getODataEntitySet(
- getClient().getDeserializer().toFeed(input, format));
+ getClient().getDeserializer().toEntitySet(input, format));
assertNotNull(entitySet);
assertEquals(2, entitySet.getEntities().size());
assertNotNull(entitySet.getNext());
- final ODataEntitySet written = getClient().getBinder().getODataEntitySet(new ResWrap<Feed>((URI) null, null,
- getClient().getBinder().getFeed(
- entitySet, ResourceFactory.feedClassForFormat(format == ODataPubFormat.ATOM))));
+ final ODataEntitySet written = getClient().getBinder().getODataEntitySet(new ResWrap<EntitySet>((URI) null, null,
+ getClient().getBinder().getEntitySet(
+ entitySet, ResourceFactory.entitySetClassForFormat(format == ODataPubFormat.ATOM))));
assertEquals(entitySet, written);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntityTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntityTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntityTest.java
index cbc8041..20f7536 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntityTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntityTest.java
@@ -28,7 +28,7 @@ import org.apache.olingo.client.api.v3.ODataClient;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.client.core.AbstractTest;
-import org.apache.olingo.commons.api.data.Entry;
+import org.apache.olingo.commons.api.data.Entity;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.domain.v3.ODataProperty;
@@ -49,7 +49,7 @@ public class EntityTest extends AbstractTest {
private void readAndWrite(final ODataPubFormat format) {
final InputStream input = getClass().getResourceAsStream("Customer_-10." + getSuffix(format));
final ODataEntity entity = getClient().getBinder().getODataEntity(
- getClient().getDeserializer().toEntry(input, format));
+ getClient().getDeserializer().toEntity(input, format));
assertNotNull(entity);
assertEquals("Microsoft.Test.OData.Services.AstoriaDefaultService.Customer", entity.getTypeName().toString());
@@ -67,8 +67,9 @@ public class EntityTest extends AbstractTest {
assertTrue(check);
- final ODataEntity written = getClient().getBinder().getODataEntity(new ResWrap<Entry>((URI) null, null, getClient().
- getBinder().getEntry(entity, ResourceFactory.entryClassForFormat(format == ODataPubFormat.ATOM))));
+ final ODataEntity written = getClient().getBinder().getODataEntity(
+ new ResWrap<Entity>((URI) null, null, getClient().
+ getBinder().getEntity(entity, ResourceFactory.entityClassForFormat(format == ODataPubFormat.ATOM))));
assertEquals(entity, written);
}
@@ -85,7 +86,7 @@ public class EntityTest extends AbstractTest {
private void readGeospatial(final ODataPubFormat format) {
final InputStream input = getClass().getResourceAsStream("AllGeoTypesSet_-8." + getSuffix(format));
final ODataEntity entity = getClient().getBinder().getODataEntity(
- getClient().getDeserializer().toEntry(input, format));
+ getClient().getDeserializer().toEntity(input, format));
assertNotNull(entity);
boolean found = false;
@@ -98,8 +99,9 @@ public class EntityTest extends AbstractTest {
}
assertTrue(found);
- final ODataEntity written = getClient().getBinder().getODataEntity(new ResWrap<Entry>((URI) null, null, getClient().
- getBinder().getEntry(entity, ResourceFactory.entryClassForFormat(format == ODataPubFormat.ATOM))));
+ final ODataEntity written = getClient().getBinder().getODataEntity(
+ new ResWrap<Entity>((URI) null, null, getClient().
+ getBinder().getEntity(entity, ResourceFactory.entityClassForFormat(format == ODataPubFormat.ATOM))));
assertEquals(entity, written);
}
@@ -117,14 +119,15 @@ public class EntityTest extends AbstractTest {
private void withActions(final ODataPubFormat format) {
final InputStream input = getClass().getResourceAsStream("ComputerDetail_-10." + getSuffix(format));
final ODataEntity entity = getClient().getBinder().getODataEntity(
- getClient().getDeserializer().toEntry(input, format));
+ getClient().getDeserializer().toEntity(input, format));
assertNotNull(entity);
assertEquals(1, entity.getOperations().size());
assertEquals("ResetComputerDetailsSpecifications", entity.getOperations().get(0).getTitle());
- final ODataEntity written = getClient().getBinder().getODataEntity(new ResWrap<Entry>((URI) null, null, getClient().
- getBinder().getEntry(entity, ResourceFactory.entryClassForFormat(format == ODataPubFormat.ATOM))));
+ final ODataEntity written = getClient().getBinder().getODataEntity(
+ new ResWrap<Entity>((URI) null, null, getClient().
+ getBinder().getEntity(entity, ResourceFactory.entityClassForFormat(format == ODataPubFormat.ATOM))));
entity.getOperations().clear();
assertEquals(entity, written);
}
@@ -143,14 +146,15 @@ public class EntityTest extends AbstractTest {
private void mediaEntity(final ODataPubFormat format) {
final InputStream input = getClass().getResourceAsStream("Car_16." + getSuffix(format));
final ODataEntity entity = getClient().getBinder().getODataEntity(
- getClient().getDeserializer().toEntry(input, format));
+ getClient().getDeserializer().toEntity(input, format));
assertNotNull(entity);
assertTrue(entity.isMediaEntity());
assertNotNull(entity.getMediaContentSource());
assertNotNull(entity.getMediaContentType());
- final ODataEntity written = getClient().getBinder().getODataEntity(new ResWrap<Entry>((URI) null, null, getClient().
- getBinder().getEntry(entity, ResourceFactory.entryClassForFormat(format == ODataPubFormat.ATOM))));
+ final ODataEntity written = getClient().getBinder().getODataEntity(
+ new ResWrap<Entity>((URI) null, null, getClient().
+ getBinder().getEntity(entity, ResourceFactory.entityClassForFormat(format == ODataPubFormat.ATOM))));
assertEquals(entity, written);
}
@@ -167,7 +171,7 @@ public class EntityTest extends AbstractTest {
private void issue128(final ODataPubFormat format) throws EdmPrimitiveTypeException {
final InputStream input = getClass().getResourceAsStream("AllGeoTypesSet_-5." + getSuffix(format));
final ODataEntity entity = getClient().getBinder().getODataEntity(
- getClient().getDeserializer().toEntry(input, format));
+ getClient().getDeserializer().toEntity(input, format));
assertNotNull(entity);
final ODataProperty geogCollection = entity.getProperty("GeogCollection");
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/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
index fad3624..75d4bb1 100644
--- 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
@@ -68,7 +68,7 @@ public class AtomTest extends JSONTest {
}
@Override
- public void additionalEntries() throws Exception {
+ public void additionalEntities() throws Exception {
// no test
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntitySetTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntitySetTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntitySetTest.java
index 88a0f07..e213a54 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntitySetTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntitySetTest.java
@@ -27,7 +27,7 @@ import java.io.InputStream;
import java.net.URI;
import org.apache.olingo.client.api.v4.ODataClient;
import org.apache.olingo.client.core.AbstractTest;
-import org.apache.olingo.commons.api.data.Feed;
+import org.apache.olingo.commons.api.data.EntitySet;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.domain.v4.ODataEntity;
import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
@@ -45,15 +45,15 @@ public class EntitySetTest extends AbstractTest {
private void read(final ODataPubFormat format) throws IOException {
final InputStream input = getClass().getResourceAsStream("Customers." + getSuffix(format));
final ODataEntitySet entitySet = getClient().getBinder().getODataEntitySet(
- getClient().getDeserializer().toFeed(input, format));
+ getClient().getDeserializer().toEntitySet(input, format));
assertNotNull(entitySet);
assertEquals(2, entitySet.getEntities().size());
assertNull(entitySet.getNext());
- final ODataEntitySet written = getClient().getBinder().getODataEntitySet(new ResWrap<Feed>((URI) null, null,
- getClient().getBinder().getFeed(
- entitySet, ResourceFactory.feedClassForFormat(format == ODataPubFormat.ATOM))));
+ final ODataEntitySet written = getClient().getBinder().getODataEntitySet(new ResWrap<EntitySet>((URI) null, null,
+ getClient().getBinder().getEntitySet(
+ entitySet, ResourceFactory.entitySetClassForFormat(format == ODataPubFormat.ATOM))));
assertEquals(entitySet, written);
}
@@ -70,7 +70,7 @@ public class EntitySetTest extends AbstractTest {
private void ref(final ODataPubFormat format) {
final InputStream input = getClass().getResourceAsStream("collectionOfEntityReferences." + getSuffix(format));
final ODataEntitySet entitySet = getClient().getBinder().getODataEntitySet(
- getClient().getDeserializer().toFeed(input, format));
+ getClient().getDeserializer().toEntitySet(input, format));
assertNotNull(entitySet);
for (ODataEntity entity : entitySet.getEntities()) {
@@ -78,9 +78,9 @@ public class EntitySetTest extends AbstractTest {
}
entitySet.setCount(entitySet.getEntities().size());
- final ODataEntitySet written = getClient().getBinder().getODataEntitySet(new ResWrap<Feed>((URI) null, null,
- getClient().getBinder().getFeed(
- entitySet, ResourceFactory.feedClassForFormat(format == ODataPubFormat.ATOM))));
+ final ODataEntitySet written = getClient().getBinder().getODataEntitySet(new ResWrap<EntitySet>((URI) null, null,
+ getClient().getBinder().getEntitySet(
+ entitySet, ResourceFactory.entitySetClassForFormat(format == ODataPubFormat.ATOM))));
assertEquals(entitySet, written);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
index 317f916..212c527 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
@@ -28,7 +28,7 @@ import java.net.URI;
import java.util.Iterator;
import org.apache.olingo.client.api.v4.ODataClient;
import org.apache.olingo.client.core.AbstractTest;
-import org.apache.olingo.commons.api.data.Entry;
+import org.apache.olingo.commons.api.data.Entity;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
import org.apache.olingo.commons.api.domain.ODataLink;
@@ -53,7 +53,7 @@ public class EntityTest extends AbstractTest {
private void singleton(final ODataPubFormat format) {
final InputStream input = getClass().getResourceAsStream("VipCustomer." + getSuffix(format));
final ODataEntity entity = getClient().getBinder().getODataEntity(
- getClient().getDeserializer().toEntry(input, format));
+ getClient().getDeserializer().toEntity(input, format));
assertNotNull(entity);
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString());
@@ -93,8 +93,9 @@ public class EntityTest extends AbstractTest {
// operations won't get serialized
entity.getOperations().clear();
- final ODataEntity written = getClient().getBinder().getODataEntity(new ResWrap<Entry>((URI) null, null, getClient().
- getBinder().getEntry(entity, ResourceFactory.entryClassForFormat(format == ODataPubFormat.ATOM))));
+ final ODataEntity written = getClient().getBinder().getODataEntity(
+ new ResWrap<Entity>((URI) null, null, getClient().
+ getBinder().getEntity(entity, ResourceFactory.entityClassForFormat(format == ODataPubFormat.ATOM))));
assertEquals(entity, written);
}
@@ -111,7 +112,7 @@ public class EntityTest extends AbstractTest {
private void withEnums(final ODataPubFormat format) {
final InputStream input = getClass().getResourceAsStream("Products_5." + getSuffix(format));
final ODataEntity entity = getClient().getBinder().getODataEntity(
- getClient().getDeserializer().toEntry(input, format));
+ getClient().getDeserializer().toEntity(input, format));
assertNotNull(entity);
final ODataProperty skinColor = entity.getProperty("SkinColor");
@@ -128,8 +129,9 @@ public class EntityTest extends AbstractTest {
// operations won't get serialized
entity.getOperations().clear();
- final ODataEntity written = getClient().getBinder().getODataEntity(new ResWrap<Entry>((URI) null, null, getClient().
- getBinder().getEntry(entity, ResourceFactory.entryClassForFormat(format == ODataPubFormat.ATOM))));
+ final ODataEntity written = getClient().getBinder().getODataEntity(
+ new ResWrap<Entity>((URI) null, null, getClient().
+ getBinder().getEntity(entity, ResourceFactory.entityClassForFormat(format == ODataPubFormat.ATOM))));
assertEquals(entity, written);
}
@@ -147,7 +149,7 @@ public class EntityTest extends AbstractTest {
final InputStream input = getClass().getResourceAsStream(
"Accounts_101_expand_MyPaymentInstruments." + getSuffix(format));
final ODataEntity entity = getClient().getBinder().getODataEntity(
- getClient().getDeserializer().toEntry(input, format));
+ getClient().getDeserializer().toEntity(input, format));
assertNotNull(entity);
final ODataLink instruments = entity.getNavigationLink("MyPaymentInstruments");
@@ -162,8 +164,9 @@ public class EntityTest extends AbstractTest {
inline.getEntitySet().setCount(3);
// operations won't get serialized
entity.getOperations().clear();
- final ODataEntity written = getClient().getBinder().getODataEntity(new ResWrap<Entry>((URI) null, null, getClient().
- getBinder().getEntry(entity, ResourceFactory.entryClassForFormat(format == ODataPubFormat.ATOM))));
+ final ODataEntity written = getClient().getBinder().getODataEntity(
+ new ResWrap<Entity>((URI) null, null, getClient().
+ getBinder().getEntity(entity, ResourceFactory.entityClassForFormat(format == ODataPubFormat.ATOM))));
assertEquals(entity, written);
}
@@ -181,15 +184,16 @@ public class EntityTest extends AbstractTest {
final InputStream input = getClass().getResourceAsStream(
"Advertisements_f89dee73-af9f-4cd4-b330-db93c25ff3c7." + getSuffix(format));
final ODataEntity entity = getClient().getBinder().getODataEntity(
- getClient().getDeserializer().toEntry(input, format));
+ getClient().getDeserializer().toEntity(input, format));
assertNotNull(entity);
assertTrue(entity.isMediaEntity());
assertNotNull(entity.getMediaContentSource());
assertEquals("\"8zOOKKvgOtptr4gt8IrnapX3jds=\"", entity.getMediaETag());
- final ODataEntity written = getClient().getBinder().getODataEntity(new ResWrap<Entry>((URI) null, null, getClient().
- getBinder().getEntry(entity, ResourceFactory.entryClassForFormat(format == ODataPubFormat.ATOM))));
+ final ODataEntity written = getClient().getBinder().getODataEntity(
+ new ResWrap<Entity>((URI) null, null, getClient().
+ getBinder().getEntity(entity, ResourceFactory.entityClassForFormat(format == ODataPubFormat.ATOM))));
assertEquals(entity, written);
}
@@ -206,7 +210,7 @@ public class EntityTest extends AbstractTest {
private void withStream(final ODataPubFormat format) {
final InputStream input = getClass().getResourceAsStream("PersonDetails_1." + getSuffix(format));
final ODataEntity entity = getClient().getBinder().getODataEntity(
- getClient().getDeserializer().toEntry(input, format));
+ getClient().getDeserializer().toEntity(input, format));
assertNotNull(entity);
assertFalse(entity.isMediaEntity());
@@ -214,8 +218,9 @@ public class EntityTest extends AbstractTest {
final ODataLink editMedia = entity.getEditMediaLink("Photo");
assertNotNull(editMedia);
- final ODataEntity written = getClient().getBinder().getODataEntity(new ResWrap<Entry>((URI) null, null, getClient().
- getBinder().getEntry(entity, ResourceFactory.entryClassForFormat(format == ODataPubFormat.ATOM))));
+ final ODataEntity written = getClient().getBinder().getODataEntity(
+ new ResWrap<Entity>((URI) null, null, getClient().
+ getBinder().getEntity(entity, ResourceFactory.entityClassForFormat(format == ODataPubFormat.ATOM))));
assertEquals(entity, written);
}
@@ -232,13 +237,14 @@ public class EntityTest extends AbstractTest {
private void ref(final ODataPubFormat format) {
final InputStream input = getClass().getResourceAsStream("entityReference." + getSuffix(format));
final ODataEntity entity = getClient().getBinder().getODataEntity(
- getClient().getDeserializer().toEntry(input, format));
+ getClient().getDeserializer().toEntity(input, format));
assertNotNull(entity);
assertNotNull(entity.getReference());
- final ODataEntity written = getClient().getBinder().getODataEntity(new ResWrap<Entry>((URI) null, null, getClient().
- getBinder().getEntry(entity, ResourceFactory.entryClassForFormat(format == ODataPubFormat.ATOM))));
+ final ODataEntity written = getClient().getBinder().getODataEntity(
+ new ResWrap<Entity>((URI) null, null, getClient().
+ getBinder().getEntity(entity, ResourceFactory.entityClassForFormat(format == ODataPubFormat.ATOM))));
assertEquals(entity, written);
}
@@ -255,7 +261,7 @@ public class EntityTest extends AbstractTest {
private void complexNavigationProperties(final ODataPubFormat format) {
final InputStream input = getClass().getResourceAsStream("entity.withcomplexnavigation." + getSuffix(format));
final ODataEntity entity = getClient().getBinder().getODataEntity(
- getClient().getDeserializer().toEntry(input, format));
+ getClient().getDeserializer().toEntity(input, format));
assertNotNull(entity);
final ODataLinkedComplexValue addressValue = entity.getProperty("Address").getLinkedComplexValue();
@@ -264,8 +270,9 @@ public class EntityTest extends AbstractTest {
// ETag is not serialized
entity.setETag(null);
- final ODataEntity written = getClient().getBinder().getODataEntity(new ResWrap<Entry>((URI) null, null, getClient().
- getBinder().getEntry(entity, ResourceFactory.entryClassForFormat(format == ODataPubFormat.ATOM))));
+ final ODataEntity written = getClient().getBinder().getODataEntity(
+ new ResWrap<Entity>((URI) null, null, getClient().
+ getBinder().getEntity(entity, ResourceFactory.entityClassForFormat(format == ODataPubFormat.ATOM))));
assertEquals(entity, written);
}
[5/5] git commit: [OLINGO-259] Delta response content parsing
(including new domain objects)
Posted by il...@apache.org.
[OLINGO-259] Delta response content parsing (including new domain objects)
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/118b779b
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/118b779b
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/118b779b
Branch: refs/heads/master
Commit: 118b779bc4817e19e746c295c09b15f0df7a713c
Parents: 0b05798
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Mon Apr 28 17:00:23 2014 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Mon Apr 28 17:00:23 2014 +0200
----------------------------------------------------------------------
.../org/apache/olingo/fit/AbstractServices.java | 109 +++++-----
.../apache/olingo/fit/V3ActionOverloading.java | 4 +-
.../java/org/apache/olingo/fit/V3Services.java | 6 +-
.../java/org/apache/olingo/fit/V4Services.java | 96 ++++----
.../apache/olingo/fit/metadata/Metadata.java | 2 +-
.../olingo/fit/metadata/NavigationProperty.java | 10 +-
.../fit/serializer/JSONEntryContainer.java | 14 +-
.../fit/serializer/JSONFeedContainer.java | 14 +-
.../olingo/fit/utils/AbstractUtilities.java | 64 +++---
.../org/apache/olingo/fit/utils/DataBinder.java | 153 +++++++------
.../org/apache/olingo/fit/utils/FSManager.java | 6 +-
.../apache/olingo/fit/utils/XMLUtilities.java | 2 +-
.../client/api/CommonEdmEnabledODataClient.java | 1 -
.../request/v4/AsyncRequestFactory.java | 1 -
.../api/domain/ODataEntitySetIterator.java | 77 +++----
.../olingo/client/api/op/CommonODataBinder.java | 32 +--
.../olingo/client/api/op/CommonODataReader.java | 6 +-
.../olingo/client/api/op/v3/ODataBinder.java | 8 +-
.../olingo/client/api/op/v4/ODataBinder.java | 8 +-
.../client/api/op/v4/ODataDeserializer.java | 11 +
.../cud/ODataEntityCreateRequestImpl.java | 6 +-
.../cud/ODataEntityUpdateRequestImpl.java | 6 +-
.../retrieve/ODataEntityRequestImpl.java | 6 +-
.../ODataEntitySetIteratorRequestImpl.java | 10 +-
.../retrieve/ODataEntitySetRequestImpl.java | 6 +-
.../ODataMediaEntityCreateRequestImpl.java | 4 +-
.../ODataMediaEntityUpdateRequestImpl.java | 4 +-
.../request/v4/AsyncRequestFactoryImpl.java | 3 +-
.../client/core/op/AbstractODataBinder.java | 132 +++++------
.../client/core/op/AbstractODataReader.java | 9 +-
.../olingo/client/core/op/ODataWriterImpl.java | 6 +-
.../client/core/op/impl/v3/ODataBinderImpl.java | 10 +-
.../client/core/op/impl/v3/ODataReaderImpl.java | 4 +-
.../client/core/op/impl/v4/ODataBinderImpl.java | 20 +-
.../core/op/impl/v4/ODataDeserializerImpl.java | 12 +
.../client/core/op/impl/v4/ODataReaderImpl.java | 4 +-
.../client/core/it/AbstractBaseTestITCase.java | 20 +-
.../core/it/v3/EntityRetrieveTestITCase.java | 6 +-
.../client/core/it/v3/EntitySetTestITCase.java | 2 +-
.../core/it/v3/QueryOptionsTestITCase.java | 10 +-
.../apache/olingo/client/core/v3/AtomTest.java | 30 +--
.../olingo/client/core/v3/EntitySetTest.java | 10 +-
.../olingo/client/core/v3/EntityTest.java | 32 +--
.../apache/olingo/client/core/v4/AtomTest.java | 2 +-
.../olingo/client/core/v4/EntitySetTest.java | 18 +-
.../olingo/client/core/v4/EntityTest.java | 51 +++--
.../apache/olingo/client/core/v4/JSONTest.java | 97 ++++++---
.../apache/olingo/client/core/v4/Customers.json | 2 +-
.../org/apache/olingo/client/core/v4/delta.json | 39 ++++
.../org/apache/olingo/client/core/v4/delta.xml | 87 ++++++++
.../apache/olingo/commons/api/Constants.java | 22 +-
.../olingo/commons/api/data/ContextURL.java | 52 ++++-
.../olingo/commons/api/data/DeletedEntity.java | 27 +++
.../apache/olingo/commons/api/data/Delta.java | 45 ++++
.../olingo/commons/api/data/DeltaLink.java | 36 +++
.../apache/olingo/commons/api/data/Entity.java | 174 +++++++++++++++
.../olingo/commons/api/data/EntitySet.java | 74 +++++++
.../apache/olingo/commons/api/data/Entry.java | 174 ---------------
.../apache/olingo/commons/api/data/Feed.java | 74 -------
.../apache/olingo/commons/api/data/Link.java | 24 +-
.../api/domain/CommonODataEntitySet.java | 2 +-
.../olingo/commons/api/domain/ODataLinked.java | 2 +-
.../api/edm/constants/ODataServiceVersion.java | 12 +
.../commons/api/op/CommonODataDeserializer.java | 18 +-
.../olingo/commons/api/op/ODataSerializer.java | 20 +-
.../olingo/commons/api/data/ContextURLTest.java | 33 +++
.../commons/core/data/AbstractAtomDealer.java | 20 +-
.../olingo/commons/core/data/AbstractDelta.java | 65 ++++++
.../commons/core/data/AbstractEntity.java | 171 +++++++++++++++
.../commons/core/data/AbstractEntitySet.java | 61 ++++++
.../olingo/commons/core/data/AbstractEntry.java | 171 ---------------
.../core/data/AbstractJsonDeserializer.java | 20 +-
.../core/data/AbstractJsonSerializer.java | 18 +-
.../olingo/commons/core/data/AtomDeltaImpl.java | 25 +++
.../commons/core/data/AtomDeserializer.java | 217 ++++++++++++++-----
.../commons/core/data/AtomEntityImpl.java | 25 +++
.../commons/core/data/AtomEntitySetImpl.java | 28 +++
.../olingo/commons/core/data/AtomEntryImpl.java | 25 ---
.../olingo/commons/core/data/AtomFeedImpl.java | 66 ------
.../commons/core/data/AtomSerializer.java | 154 ++++++-------
.../commons/core/data/DeletedEntityImpl.java | 49 +++++
.../olingo/commons/core/data/DeltaLinkImpl.java | 64 ++++++
.../core/data/JSONDeltaDeserializer.java | 93 ++++++++
.../olingo/commons/core/data/JSONDeltaImpl.java | 28 +++
.../core/data/JSONEntityDeserializer.java | 200 +++++++++++++++++
.../commons/core/data/JSONEntityImpl.java | 33 +++
.../commons/core/data/JSONEntitySerializer.java | 123 +++++++++++
.../core/data/JSONEntitySetDeserializer.java | 93 ++++++++
.../commons/core/data/JSONEntitySetImpl.java | 35 +++
.../core/data/JSONEntitySetSerializer.java | 82 +++++++
.../core/data/JSONEntryDeserializer.java | 200 -----------------
.../olingo/commons/core/data/JSONEntryImpl.java | 33 ---
.../commons/core/data/JSONEntrySerializer.java | 123 -----------
.../commons/core/data/JSONFeedDeserializer.java | 90 --------
.../olingo/commons/core/data/JSONFeedImpl.java | 99 ---------
.../commons/core/data/JSONFeedSerializer.java | 82 -------
.../olingo/commons/core/data/LinkImpl.java | 24 +-
.../core/data/ODataJacksonDeserializer.java | 9 +
.../core/data/v3/JSONLinkCollectionImpl.java | 2 +-
.../core/domain/AbstractODataEntity.java | 2 +-
.../core/domain/AbstractODataEntitySet.java | 5 +-
.../core/domain/v4/ODataComplexValueImpl.java | 2 +-
.../core/edm/AbstractEdmNavigationProperty.java | 1 -
.../core/op/AbstractODataDeserializer.java | 24 +-
.../core/op/AbstractODataSerializer.java | 36 +--
.../olingo/commons/core/op/ResourceFactory.java | 84 +++----
106 files changed, 2777 insertions(+), 1966 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
index a3a414d..202d118 100644
--- a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
+++ b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
@@ -68,22 +68,21 @@ import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
import org.apache.cxf.jaxrs.ext.multipart.MultipartBody;
import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.data.Entry;
+import org.apache.olingo.commons.api.data.Entity;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.commons.api.data.Feed;
+import org.apache.olingo.commons.api.data.EntitySet;
import org.apache.olingo.commons.api.data.Link;
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.core.data.AtomFeedImpl;
+import org.apache.olingo.commons.core.data.AtomEntitySetImpl;
import org.apache.olingo.commons.core.data.LinkImpl;
-import org.apache.olingo.commons.core.data.AtomEntryImpl;
+import org.apache.olingo.commons.core.data.AtomEntityImpl;
import org.apache.olingo.commons.core.data.AtomPropertyImpl;
import org.apache.olingo.commons.core.data.AtomSerializer;
-import org.apache.olingo.commons.core.data.JSONEntryImpl;
+import org.apache.olingo.commons.core.data.JSONEntityImpl;
import org.apache.olingo.commons.core.data.NullValueImpl;
import org.apache.olingo.commons.core.data.PrimitiveValueImpl;
-import org.apache.olingo.fit.metadata.EntitySet;
import org.apache.olingo.fit.metadata.EntityType;
import org.apache.olingo.fit.metadata.NavigationProperty;
import org.apache.olingo.fit.methods.MERGE;
@@ -401,22 +400,22 @@ public abstract class AbstractServices {
final Accept contentTypeValue = Accept.parse(contentType, version);
- final AtomEntryImpl entryChanges;
+ final AtomEntityImpl entryChanges;
if (contentTypeValue == Accept.XML || contentTypeValue == Accept.TEXT) {
throw new UnsupportedMediaTypeException("Unsupported media type");
} else if (contentTypeValue == Accept.ATOM) {
- entryChanges = atomDeserializer.<AtomEntryImpl, AtomEntryImpl>read(
- IOUtils.toInputStream(changes, Constants.ENCODING), AtomEntryImpl.class).getPayload();
+ entryChanges = atomDeserializer.<AtomEntityImpl, AtomEntityImpl>read(
+ IOUtils.toInputStream(changes, Constants.ENCODING), AtomEntityImpl.class).getPayload();
} else {
- final ResWrap<JSONEntryImpl> jcont = mapper.readValue(IOUtils.toInputStream(changes, Constants.ENCODING),
- new TypeReference<JSONEntryImpl>() {
+ final ResWrap<JSONEntityImpl> jcont = mapper.readValue(IOUtils.toInputStream(changes, Constants.ENCODING),
+ new TypeReference<JSONEntityImpl>() {
});
- entryChanges = dataBinder.toAtomEntry(jcont.getPayload());
+ entryChanges = dataBinder.toAtomEntity(jcont.getPayload());
}
- final ResWrap<AtomEntryImpl> container = atomDeserializer.read(entityInfo.getValue(), AtomEntryImpl.class);
+ final ResWrap<AtomEntityImpl> container = atomDeserializer.read(entityInfo.getValue(), AtomEntityImpl.class);
for (Property property : entryChanges.getProperties()) {
container.getPayload().getProperty(property.getName()).setValue(property.getValue());
@@ -435,7 +434,7 @@ public abstract class AbstractServices {
final InputStream res = xml.addOrReplaceEntity(
entityId, entitySetName, new ByteArrayInputStream(content.toByteArray()), container.getPayload());
- final ResWrap<AtomEntryImpl> cres = atomDeserializer.read(res, AtomEntryImpl.class);
+ final ResWrap<AtomEntityImpl> cres = atomDeserializer.read(res, AtomEntityImpl.class);
normalizeAtomEntry(cres.getPayload(), entitySetName, entityId);
@@ -492,14 +491,14 @@ public abstract class AbstractServices {
IOUtils.toInputStream(entity, Constants.ENCODING),
xml.readEntry(acceptType, IOUtils.toInputStream(entity, Constants.ENCODING)));
- final ResWrap<AtomEntryImpl> cres;
+ final ResWrap<AtomEntityImpl> cres;
if (acceptType == Accept.ATOM) {
- cres = atomDeserializer.read(res, AtomEntryImpl.class);
+ cres = atomDeserializer.read(res, AtomEntityImpl.class);
} else {
- final ResWrap<JSONEntryImpl> jcont = mapper.readValue(res, new TypeReference<JSONEntryImpl>() {
+ final ResWrap<JSONEntityImpl> jcont = mapper.readValue(res, new TypeReference<JSONEntityImpl>() {
});
- cres = new ResWrap<AtomEntryImpl>(jcont.getContextURL(), jcont.getMetadataETag(),
- dataBinder.toAtomEntry(jcont.getPayload()));
+ cres = new ResWrap<AtomEntityImpl>(jcont.getContextURL(), jcont.getMetadataETag(),
+ dataBinder.toAtomEntity(jcont.getPayload()));
}
final String path = Commons.getEntityBasePath(entitySetName, entityId);
@@ -552,14 +551,14 @@ public abstract class AbstractServices {
throw new UnsupportedMediaTypeException("Unsupported media type");
}
- final ResWrap<AtomEntryImpl> container;
+ final ResWrap<AtomEntityImpl> container;
- final EntitySet entitySet = getMetadataObj().getEntitySet(entitySetName);
+ final org.apache.olingo.fit.metadata.EntitySet entitySet = getMetadataObj().getEntitySet(entitySetName);
- final AtomEntryImpl entry;
+ final AtomEntityImpl entry;
final String entityKey;
if (xml.isMediaContent(entitySetName)) {
- entry = new AtomEntryImpl();
+ entry = new AtomEntityImpl();
entry.setMediaContentType(ContentType.WILDCARD);
entry.setType(entitySet.getType());
@@ -584,21 +583,21 @@ public abstract class AbstractServices {
entry.setMediaContentSource(editLink.getHref() + "/$value");
- container = new ResWrap<AtomEntryImpl>((URI) null, null, entry);
+ container = new ResWrap<AtomEntityImpl>((URI) null, null, entry);
} else {
final Accept contentTypeValue = Accept.parse(contentType, version);
if (Accept.ATOM == contentTypeValue) {
- container = atomDeserializer.read(IOUtils.toInputStream(entity, Constants.ENCODING), AtomEntryImpl.class);
+ container = atomDeserializer.read(IOUtils.toInputStream(entity, Constants.ENCODING), AtomEntityImpl.class);
entry = container.getPayload();
} else {
- final ResWrap<JSONEntryImpl> jcontainer =
+ final ResWrap<JSONEntityImpl> jcontainer =
mapper.readValue(IOUtils.toInputStream(entity, Constants.ENCODING),
- new TypeReference<JSONEntryImpl>() {
+ new TypeReference<JSONEntityImpl>() {
});
- entry = dataBinder.toAtomEntry(jcontainer.getPayload());
+ entry = dataBinder.toAtomEntity(jcontainer.getPayload());
- container = new ResWrap<AtomEntryImpl>(
+ container = new ResWrap<AtomEntityImpl>(
jcontainer.getContextURL(),
jcontainer.getMetadataETag(),
entry);
@@ -618,8 +617,8 @@ public abstract class AbstractServices {
final InputStream serialization =
xml.addOrReplaceEntity(null, entitySetName, new ByteArrayInputStream(content.toByteArray()), entry);
- ResWrap<AtomEntryImpl> result = atomDeserializer.read(serialization, AtomEntryImpl.class);
- result = new ResWrap<AtomEntryImpl>(
+ ResWrap<AtomEntityImpl> result = atomDeserializer.read(serialization, AtomEntityImpl.class);
+ result = new ResWrap<AtomEntityImpl>(
URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX)
+ entitySetName + Constants.get(version, ConstantKey.ODATA_METADATA_ENTITY_SUFFIX)),
null, result.getPayload());
@@ -862,7 +861,7 @@ public abstract class AbstractServices {
final InputStream feed = FSManager.instance(version).readFile(builder.toString(), Accept.ATOM);
- final ResWrap<AtomFeedImpl> container = atomDeserializer.read(feed, AtomFeedImpl.class);
+ final ResWrap<AtomEntitySetImpl> container = atomDeserializer.read(feed, AtomEntitySetImpl.class);
setInlineCount(container.getPayload(), count);
@@ -872,7 +871,7 @@ public abstract class AbstractServices {
// -----------------------------------------------
// Evaluate $skip and $top
// -----------------------------------------------
- List<Entry> entries = new ArrayList<Entry>(container.getPayload().getEntries());
+ List<Entity> entries = new ArrayList<Entity>(container.getPayload().getEntities());
if (StringUtils.isNotBlank(skip)) {
entries = entries.subList(Integer.valueOf(skip), entries.size());
@@ -882,8 +881,8 @@ public abstract class AbstractServices {
entries = entries.subList(0, Integer.valueOf(top));
}
- container.getPayload().getEntries().clear();
- container.getPayload().getEntries().addAll(entries);
+ container.getPayload().getEntities().clear();
+ container.getPayload().getEntities().addAll(entries);
// -----------------------------------------------
if (acceptType == Accept.ATOM) {
@@ -893,7 +892,7 @@ public abstract class AbstractServices {
} else {
mapper.writeValue(
writer, new JSONFeedContainer(container.getContextURL(), container.getMetadataETag(),
- dataBinder.toJSONFeed(container.getPayload())));
+ dataBinder.toJSONEntitySet(container.getPayload())));
}
return xml.createResponse(
@@ -907,7 +906,7 @@ public abstract class AbstractServices {
}
}
- protected abstract void setInlineCount(final Feed feed, final String count);
+ protected abstract void setInlineCount(final EntitySet feed, final String count);
/**
* Retrieve entity with key as segment.
@@ -1000,13 +999,13 @@ public abstract class AbstractServices {
final InputStream entity = entityInfo.getValue();
- ResWrap<AtomEntryImpl> container = atomDeserializer.read(entity, AtomEntryImpl.class);
+ ResWrap<AtomEntityImpl> container = atomDeserializer.read(entity, AtomEntityImpl.class);
if (container.getContextURL() == null) {
- container = new ResWrap<AtomEntryImpl>(URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX)
+ container = new ResWrap<AtomEntityImpl>(URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX)
+ entitySetName + Constants.get(version, ConstantKey.ODATA_METADATA_ENTITY_SUFFIX)),
container.getMetadataETag(), container.getPayload());
}
- final Entry entry = container.getPayload();
+ final Entity entry = container.getPayload();
if (keyAsSegment) {
final Link editLink = new LinkImpl();
@@ -1055,16 +1054,16 @@ public abstract class AbstractServices {
rep.setType(link.getType());
if (link.getType().equals(Constants.get(version, ConstantKey.ATOM_LINK_ENTRY))) {
// inline entry
- final Entry inline = atomDeserializer.<Entry, AtomEntryImpl>read(
+ final Entity inline = atomDeserializer.<Entity, AtomEntityImpl>read(
xml.expandEntity(entitySetName, entityId, link.getTitle()),
- AtomEntryImpl.class).getPayload();
- rep.setInlineEntry(inline);
+ AtomEntityImpl.class).getPayload();
+ rep.setInlineEntity(inline);
} else if (link.getType().equals(Constants.get(version, ConstantKey.ATOM_LINK_FEED))) {
// inline feed
- final Feed inline = atomDeserializer.<Feed, AtomFeedImpl>read(
+ final EntitySet inline = atomDeserializer.<EntitySet, AtomEntitySetImpl>read(
xml.expandEntity(entitySetName, entityId, link.getTitle()),
- AtomFeedImpl.class).getPayload();
- rep.setInlineFeed(inline);
+ AtomEntitySetImpl.class).getPayload();
+ rep.setInlineEntitySet(inline);
}
replace.put(link, rep);
}
@@ -1508,7 +1507,8 @@ public abstract class AbstractServices {
final OutputStreamWriter writer = new OutputStreamWriter(content, Constants.ENCODING);
if (linkInfo.isFeed()) {
- final ResWrap<Feed> container = atomDeserializer.<Feed, AtomFeedImpl>read(stream, AtomFeedImpl.class);
+ final ResWrap<EntitySet> container =
+ atomDeserializer.<EntitySet, AtomEntitySetImpl>read(stream, AtomEntitySetImpl.class);
if (acceptType == Accept.ATOM) {
atomSerializer.write(writer, container);
@@ -1519,10 +1519,11 @@ public abstract class AbstractServices {
writer,
new JSONFeedContainer(container.getContextURL(),
container.getMetadataETag(),
- dataBinder.toJSONFeed((AtomFeedImpl) container.getPayload())));
+ dataBinder.toJSONEntitySet((AtomEntitySetImpl) container.getPayload())));
}
} else {
- final ResWrap<Entry> container = atomDeserializer.<Entry, AtomEntryImpl>read(stream, AtomEntryImpl.class);
+ final ResWrap<Entity> container =
+ atomDeserializer.<Entity, AtomEntityImpl>read(stream, AtomEntityImpl.class);
if (acceptType == Accept.ATOM) {
atomSerializer.write(writer, container);
writer.flush();
@@ -1532,7 +1533,7 @@ public abstract class AbstractServices {
writer,
new JSONEntryContainer(container.getContextURL(),
container.getMetadataETag(),
- dataBinder.toJSONEntry((AtomEntryImpl) container.getPayload())));
+ dataBinder.toJSONEntityType((AtomEntityImpl) container.getPayload())));
}
}
@@ -1581,7 +1582,7 @@ public abstract class AbstractServices {
final InputStream entity = entityInfo.getValue();
- final ResWrap<AtomEntryImpl> entryContainer = atomDeserializer.read(entity, AtomEntryImpl.class);
+ final ResWrap<AtomEntityImpl> entryContainer = atomDeserializer.read(entity, AtomEntityImpl.class);
final String[] pathElems = StringUtils.split(path, "/");
AtomPropertyImpl property = (AtomPropertyImpl) entryContainer.getPayload().getProperty(pathElems[0]);
@@ -1676,8 +1677,8 @@ public abstract class AbstractServices {
return utils;
}
- protected void normalizeAtomEntry(final AtomEntryImpl entry, final String entitySetName, final String entityKey) {
- final EntitySet entitySet = getMetadataObj().getEntitySet(entitySetName);
+ protected void normalizeAtomEntry(final AtomEntityImpl entry, final String entitySetName, final String entityKey) {
+ final org.apache.olingo.fit.metadata.EntitySet entitySet = getMetadataObj().getEntitySet(entitySetName);
final EntityType entityType = getMetadataObj().getEntityType(entitySet.getType());
for (Map.Entry<String, org.apache.olingo.fit.metadata.Property> property
: entityType.getPropertyMap().entrySet()) {
@@ -1700,7 +1701,7 @@ public abstract class AbstractServices {
if (!found) {
final LinkImpl link = new LinkImpl();
link.setTitle(property.getKey());
- link.setType(property.getValue().isFeed()
+ link.setType(property.getValue().isEntitySet()
? Constants.get(version, ConstantKey.ATOM_LINK_FEED)
: Constants.get(version, ConstantKey.ATOM_LINK_ENTRY));
link.setRel(Constants.get(version, ConstantKey.ATOM_LINK_REL) + property.getKey());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/fit/src/main/java/org/apache/olingo/fit/V3ActionOverloading.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/V3ActionOverloading.java b/fit/src/main/java/org/apache/olingo/fit/V3ActionOverloading.java
index 974014b..b87b638 100644
--- a/fit/src/main/java/org/apache/olingo/fit/V3ActionOverloading.java
+++ b/fit/src/main/java/org/apache/olingo/fit/V3ActionOverloading.java
@@ -40,7 +40,7 @@ import javax.ws.rs.core.UriInfo;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
-import org.apache.olingo.commons.api.data.Feed;
+import org.apache.olingo.commons.api.data.EntitySet;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import static org.apache.olingo.fit.AbstractServices.LOG;
import org.apache.olingo.fit.utils.AbstractUtilities;
@@ -206,7 +206,7 @@ public class V3ActionOverloading extends AbstractServices {
}
@Override
- protected void setInlineCount(Feed feed, String count) {
+ protected void setInlineCount(EntitySet feed, String count) {
throw new UnsupportedOperationException("Not supported yet.");
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/fit/src/main/java/org/apache/olingo/fit/V3Services.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/V3Services.java b/fit/src/main/java/org/apache/olingo/fit/V3Services.java
index 66b1150..4c08cf9 100644
--- a/fit/src/main/java/org/apache/olingo/fit/V3Services.java
+++ b/fit/src/main/java/org/apache/olingo/fit/V3Services.java
@@ -45,7 +45,7 @@ import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.cxf.interceptor.InInterceptors;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
-import org.apache.olingo.commons.api.data.Feed;
+import org.apache.olingo.commons.api.data.EntitySet;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.fit.methods.MERGE;
import org.apache.olingo.fit.methods.PATCH;
@@ -109,9 +109,9 @@ public class V3Services extends AbstractServices {
}
@Override
- protected void setInlineCount(final Feed feed, final String count) {
+ protected void setInlineCount(final EntitySet feed, final String count) {
if ("allpages".equals(count)) {
- feed.setCount(feed.getEntries().size());
+ feed.setCount(feed.getEntities().size());
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/fit/src/main/java/org/apache/olingo/fit/V4Services.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/V4Services.java b/fit/src/main/java/org/apache/olingo/fit/V4Services.java
index 38d8696..386d97b 100644
--- a/fit/src/main/java/org/apache/olingo/fit/V4Services.java
+++ b/fit/src/main/java/org/apache/olingo/fit/V4Services.java
@@ -55,17 +55,17 @@ import org.apache.cxf.jaxrs.ext.multipart.Multipart;
import org.apache.cxf.jaxrs.ext.multipart.MultipartBody;
import org.apache.olingo.commons.api.data.CollectionValue;
import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.data.Entry;
-import org.apache.olingo.commons.api.data.Feed;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.commons.core.data.AtomEntryImpl;
-import org.apache.olingo.commons.core.data.AtomFeedImpl;
+import org.apache.olingo.commons.core.data.AtomEntityImpl;
+import org.apache.olingo.commons.core.data.AtomEntitySetImpl;
import org.apache.olingo.commons.core.data.AtomPropertyImpl;
import org.apache.olingo.commons.core.data.CollectionValueImpl;
import org.apache.olingo.commons.core.data.EnumValueImpl;
-import org.apache.olingo.commons.core.data.JSONEntryImpl;
+import org.apache.olingo.commons.core.data.JSONEntityImpl;
import org.apache.olingo.commons.core.data.JSONPropertyImpl;
import org.apache.olingo.commons.core.data.PrimitiveValueImpl;
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
@@ -192,7 +192,7 @@ public class V4Services extends AbstractServices {
final UUID uuid = UUID.randomUUID();
providedAsync.put(uuid.toString(), bos.toString(Constants.ENCODING.toString()));
-
+
bos.flush();
bos.close();
@@ -242,9 +242,9 @@ public class V4Services extends AbstractServices {
}
@Override
- protected void setInlineCount(final Feed feed, final String count) {
+ protected void setInlineCount(final EntitySet feed, final String count) {
if ("true".equals(count)) {
- feed.setCount(feed.getEntries().size());
+ feed.setCount(feed.getEntities().size());
}
}
@@ -392,7 +392,7 @@ public class V4Services extends AbstractServices {
}
final Accept contentTypeValue = Accept.parse(contentType, version);
- final Entry entry = xml.readEntry(contentTypeValue, IOUtils.toInputStream(param, Constants.ENCODING));
+ final Entity entry = xml.readEntry(contentTypeValue, IOUtils.toInputStream(param, Constants.ENCODING));
return xml.createResponse(
null,
@@ -419,7 +419,7 @@ public class V4Services extends AbstractServices {
acceptType = Accept.parse(accept, version);
}
- final AtomEntryImpl entry = new AtomEntryImpl();
+ final AtomEntityImpl entry = new AtomEntityImpl();
entry.setType("Microsoft.Test.OData.Services.ODataWCFService.ProductDetail");
final Property productId = new AtomPropertyImpl();
productId.setName("ProductID");
@@ -432,10 +432,10 @@ public class V4Services extends AbstractServices {
productDetailId.setValue(new PrimitiveValueImpl("2"));
entry.getProperties().add(productDetailId);
- final AtomFeedImpl feed = new AtomFeedImpl();
- feed.getEntries().add(entry);
+ final AtomEntitySetImpl feed = new AtomEntitySetImpl();
+ feed.getEntities().add(entry);
- final ResWrap<AtomFeedImpl> container = new ResWrap<AtomFeedImpl>(
+ final ResWrap<AtomEntitySetImpl> container = new ResWrap<AtomEntitySetImpl>(
URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + "ProductDetail"), null,
feed);
@@ -466,7 +466,7 @@ public class V4Services extends AbstractServices {
}
final Accept contentTypeValue = Accept.parse(contentType, version);
- final Entry entry = xml.readEntry(contentTypeValue, IOUtils.toInputStream(param, Constants.ENCODING));
+ final Entity entry = xml.readEntry(contentTypeValue, IOUtils.toInputStream(param, Constants.ENCODING));
assert 1 == entry.getProperties().size();
assert entry.getProperty("accessRight") != null;
@@ -495,7 +495,7 @@ public class V4Services extends AbstractServices {
try {
final Accept contentTypeValue = Accept.parse(contentType, version);
- final Entry entry = xml.readEntry(contentTypeValue, IOUtils.toInputStream(param, Constants.ENCODING));
+ final Entity entry = xml.readEntry(contentTypeValue, IOUtils.toInputStream(param, Constants.ENCODING));
assert 2 == entry.getProperties().size();
assert entry.getProperty("addresses") != null;
@@ -532,7 +532,7 @@ public class V4Services extends AbstractServices {
try {
final Accept contentTypeValue = Accept.parse(contentType, version);
- final Entry entry = xml.readEntry(contentTypeValue, IOUtils.toInputStream(param, Constants.ENCODING));
+ final Entity entry = xml.readEntry(contentTypeValue, IOUtils.toInputStream(param, Constants.ENCODING));
assert 1 == entry.getProperties().size();
assert entry.getProperty("newDate") != null;
@@ -619,7 +619,7 @@ public class V4Services extends AbstractServices {
return utils.getValue().createResponse(
FSManager.instance(version).readFile(Constants.get(version, ConstantKey.REF)
- + File.separatorChar + filename, utils.getKey()),
+ + File.separatorChar + filename, utils.getKey()),
null,
utils.getKey());
} catch (Exception e) {
@@ -641,7 +641,7 @@ public class V4Services extends AbstractServices {
final Response response =
getEntityInternal(uriInfo.getRequestUri().toASCIIString(),
- accept, entitySetName, entityId, accept, StringUtils.EMPTY, StringUtils.EMPTY, false);
+ accept, entitySetName, entityId, accept, StringUtils.EMPTY, StringUtils.EMPTY, false);
return response.getStatus() >= 400
? postNewEntity(uriInfo, accept, contentType, prefer, entitySetName, changes)
: super.patchEntity(uriInfo, accept, contentType, prefer, ifMatch, entitySetName, entityId, changes);
@@ -699,7 +699,7 @@ public class V4Services extends AbstractServices {
}
final InputStream entry = FSManager.instance(version).readFile(containedPath.toString(), Accept.ATOM);
- final ResWrap<AtomEntryImpl> container = atomDeserializer.read(entry, AtomEntryImpl.class);
+ final ResWrap<AtomEntityImpl> container = atomDeserializer.read(entry, AtomEntityImpl.class);
return xml.createResponse(
null,
@@ -730,21 +730,21 @@ public class V4Services extends AbstractServices {
final AbstractUtilities utils = getUtilities(acceptType);
// 1. parse the entry (from Atom or JSON) into AtomEntryImpl
- final ResWrap<AtomEntryImpl> entryContainer;
- final AtomEntryImpl entry;
+ final ResWrap<AtomEntityImpl> entryContainer;
+ final AtomEntityImpl entry;
final Accept contentTypeValue = Accept.parse(contentType, version);
if (Accept.ATOM == contentTypeValue) {
- entryContainer = atomDeserializer.read(IOUtils.toInputStream(entity, Constants.ENCODING), AtomEntryImpl.class);
+ entryContainer = atomDeserializer.read(IOUtils.toInputStream(entity, Constants.ENCODING), AtomEntityImpl.class);
entry = entryContainer.getPayload();
} else {
- final ResWrap<JSONEntryImpl> jcontainer =
+ final ResWrap<JSONEntityImpl> jcontainer =
mapper.readValue(IOUtils.toInputStream(entity, Constants.ENCODING),
- new TypeReference<JSONEntryImpl>() {
- });
+ new TypeReference<JSONEntityImpl>() {
+ });
- entry = dataBinder.toAtomEntry(jcontainer.getPayload());
+ entry = dataBinder.toAtomEntity(jcontainer.getPayload());
- entryContainer = new ResWrap<AtomEntryImpl>(
+ entryContainer = new ResWrap<AtomEntityImpl>(
jcontainer.getContextURL(),
jcontainer.getMetadataETag(),
entry);
@@ -765,8 +765,8 @@ public class V4Services extends AbstractServices {
// 3. Update the contained entity set
final String atomFeedRelativePath = containedPath(entityId, containedEntitySetName).toString();
final InputStream feedIS = FSManager.instance(version).readFile(atomFeedRelativePath, Accept.ATOM);
- final ResWrap<AtomFeedImpl> feedContainer = atomDeserializer.read(feedIS, AtomFeedImpl.class);
- feedContainer.getPayload().getEntries().add(entry);
+ final ResWrap<AtomEntitySetImpl> feedContainer = atomDeserializer.read(feedIS, AtomEntitySetImpl.class);
+ feedContainer.getPayload().getEntities().add(entry);
final ByteArrayOutputStream content = new ByteArrayOutputStream();
final OutputStreamWriter writer = new OutputStreamWriter(content, Constants.ENCODING);
@@ -823,12 +823,12 @@ public class V4Services extends AbstractServices {
final LinkInfo links = xml.readLinks(
entitySetName, entityId, containedEntitySetName + "(" + containedEntityId + ")", Accept.ATOM);
- ResWrap<AtomEntryImpl> container = atomDeserializer.read(links.getLinks(), AtomEntryImpl.class);
- final AtomEntryImpl original = container.getPayload();
+ ResWrap<AtomEntityImpl> container = atomDeserializer.read(links.getLinks(), AtomEntityImpl.class);
+ final AtomEntityImpl original = container.getPayload();
- final AtomEntryImpl entryChanges;
+ final AtomEntityImpl entryChanges;
if (Accept.ATOM == contentTypeValue) {
- container = atomDeserializer.read(IOUtils.toInputStream(changes, Constants.ENCODING), AtomEntryImpl.class);
+ container = atomDeserializer.read(IOUtils.toInputStream(changes, Constants.ENCODING), AtomEntityImpl.class);
entryChanges = container.getPayload();
} else {
final String entityType = getMetadataObj().getEntitySet(entitySetName).getType();
@@ -836,11 +836,11 @@ public class V4Services extends AbstractServices {
getNavigationProperty(containedEntitySetName).getType();
final EdmTypeInfo typeInfo = new EdmTypeInfo.Builder().setTypeExpression(containedType).build();
- final ResWrap<JSONEntryImpl> jsonContainer = mapper.readValue(
- IOUtils.toInputStream(changes, Constants.ENCODING), new TypeReference<JSONEntryImpl>() {
- });
+ final ResWrap<JSONEntityImpl> jsonContainer = mapper.readValue(
+ IOUtils.toInputStream(changes, Constants.ENCODING), new TypeReference<JSONEntityImpl>() {
+ });
jsonContainer.getPayload().setType(typeInfo.getFullQualifiedName().toString());
- entryChanges = dataBinder.toAtomEntry(jsonContainer.getPayload());
+ entryChanges = dataBinder.toAtomEntity(jsonContainer.getPayload());
}
for (Property property : entryChanges.getProperties()) {
@@ -851,7 +851,7 @@ public class V4Services extends AbstractServices {
original.getProperties().add(property);
}
- FSManager.instance(version).putInMemory(new ResWrap<AtomEntryImpl>((URI) null, null, original),
+ FSManager.instance(version).putInMemory(new ResWrap<AtomEntityImpl>((URI) null, null, original),
xml.getLinksBasePath(entitySetName, entityId) + containedEntitySetName + "(" + containedEntityId + ")");
return xml.createResponse(null, null, acceptType, Response.Status.NO_CONTENT);
@@ -871,8 +871,8 @@ public class V4Services extends AbstractServices {
// 1. Fetch the contained entity to be removed
final InputStream entry = FSManager.instance(version).
readFile(containedPath(entityId, containedEntitySetName).
- append('(').append(containedEntityId).append(')').toString(), Accept.ATOM);
- final ResWrap<AtomEntryImpl> container = atomDeserializer.read(entry, AtomEntryImpl.class);
+ append('(').append(containedEntityId).append(')').toString(), Accept.ATOM);
+ final ResWrap<AtomEntityImpl> container = atomDeserializer.read(entry, AtomEntityImpl.class);
// 2. Remove the contained entity
final String atomEntryRelativePath = containedPath(entityId, containedEntitySetName).
@@ -882,8 +882,8 @@ public class V4Services extends AbstractServices {
// 3. Update the contained entity set
final String atomFeedRelativePath = containedPath(entityId, containedEntitySetName).toString();
final InputStream feedIS = FSManager.instance(version).readFile(atomFeedRelativePath, Accept.ATOM);
- final ResWrap<AtomFeedImpl> feedContainer = atomDeserializer.read(feedIS, AtomFeedImpl.class);
- feedContainer.getPayload().getEntries().remove(container.getPayload());
+ final ResWrap<AtomEntitySetImpl> feedContainer = atomDeserializer.read(feedIS, AtomEntitySetImpl.class);
+ feedContainer.getPayload().getEntities().remove(container.getPayload());
final ByteArrayOutputStream content = new ByteArrayOutputStream();
final OutputStreamWriter writer = new OutputStreamWriter(content, Constants.ENCODING);
@@ -927,7 +927,7 @@ public class V4Services extends AbstractServices {
final InputStream feed = FSManager.instance(version).
readFile(containedPath(entityId, containedEntitySetName).toString(), Accept.ATOM);
- final ResWrap<AtomFeedImpl> container = atomDeserializer.read(feed, AtomFeedImpl.class);
+ final ResWrap<AtomEntitySetImpl> container = atomDeserializer.read(feed, AtomEntitySetImpl.class);
return xml.createResponse(
null,
@@ -1100,8 +1100,8 @@ public class V4Services extends AbstractServices {
} else {
final ResWrap<JSONPropertyImpl> paramContainer =
mapper.readValue(IOUtils.toInputStream(param, Constants.ENCODING),
- new TypeReference<JSONPropertyImpl>() {
- });
+ new TypeReference<JSONPropertyImpl>() {
+ });
property = paramContainer.getPayload();
}
@@ -1142,8 +1142,8 @@ public class V4Services extends AbstractServices {
} else {
final ResWrap<JSONPropertyImpl> paramContainer =
mapper.readValue(IOUtils.toInputStream(param, Constants.ENCODING),
- new TypeReference<JSONPropertyImpl>() {
- });
+ new TypeReference<JSONPropertyImpl>() {
+ });
property = paramContainer.getPayload();
}
@@ -1177,7 +1177,7 @@ public class V4Services extends AbstractServices {
}
final Accept contentTypeValue = Accept.parse(contentType, version);
- final Entry entry = xml.readEntry(contentTypeValue, IOUtils.toInputStream(param, Constants.ENCODING));
+ final Entity entry = xml.readEntry(contentTypeValue, IOUtils.toInputStream(param, Constants.ENCODING));
assert 1 == entry.getProperties().size();
assert "Collection(Edm.String)".equals(entry.getProperty("emails").getType());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/fit/src/main/java/org/apache/olingo/fit/metadata/Metadata.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/metadata/Metadata.java b/fit/src/main/java/org/apache/olingo/fit/metadata/Metadata.java
index ebd599b..af6518c 100644
--- a/fit/src/main/java/org/apache/olingo/fit/metadata/Metadata.java
+++ b/fit/src/main/java/org/apache/olingo/fit/metadata/Metadata.java
@@ -81,7 +81,7 @@ public class Metadata extends AbstractMetadataElement {
property.getReleationship().replaceAll(schemaEntry.getKey() + "\\.", ""));
final Association.Role role = association.getRole(property.getToRole());
property.setFeed(role.getMultiplicity().equals("*"));
- property.setType(property.isFeed() ? "Collection(" + role.getType() + ")" : role.getType());
+ property.setType(property.isEntitySet() ? "Collection(" + role.getType() + ")" : role.getType());
// let me assume that it will be just a single container
final AssociationSet associationSet = schemaEntry.getValue().getContainers().iterator().next().
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/fit/src/main/java/org/apache/olingo/fit/metadata/NavigationProperty.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/metadata/NavigationProperty.java b/fit/src/main/java/org/apache/olingo/fit/metadata/NavigationProperty.java
index eb3a74f..ab3a88b 100644
--- a/fit/src/main/java/org/apache/olingo/fit/metadata/NavigationProperty.java
+++ b/fit/src/main/java/org/apache/olingo/fit/metadata/NavigationProperty.java
@@ -34,7 +34,7 @@ public class NavigationProperty extends AbstractMetadataElement {
private String target;
- private boolean feed;
+ private boolean entitySet;
public NavigationProperty(final String name) {
this.name = name;
@@ -76,11 +76,11 @@ public class NavigationProperty extends AbstractMetadataElement {
this.target = target;
}
- public boolean isFeed() {
- return feed;
+ public boolean isEntitySet() {
+ return entitySet;
}
- public void setFeed(boolean feed) {
- this.feed = feed;
+ public void setFeed(boolean entitySet) {
+ this.entitySet = entitySet;
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/fit/src/main/java/org/apache/olingo/fit/serializer/JSONEntryContainer.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/serializer/JSONEntryContainer.java b/fit/src/main/java/org/apache/olingo/fit/serializer/JSONEntryContainer.java
index 364380d..0d3318d 100644
--- a/fit/src/main/java/org/apache/olingo/fit/serializer/JSONEntryContainer.java
+++ b/fit/src/main/java/org/apache/olingo/fit/serializer/JSONEntryContainer.java
@@ -22,15 +22,15 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.apache.olingo.commons.api.data.ContextURL;
import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.core.data.JSONEntryDeserializer;
-import org.apache.olingo.commons.core.data.JSONEntryImpl;
-import org.apache.olingo.commons.core.data.JSONEntrySerializer;
+import org.apache.olingo.commons.core.data.JSONEntityDeserializer;
+import org.apache.olingo.commons.core.data.JSONEntityImpl;
+import org.apache.olingo.commons.core.data.JSONEntitySerializer;
-@JsonDeserialize(using = JSONEntryDeserializer.class)
-@JsonSerialize(using = JSONEntrySerializer.class)
-public class JSONEntryContainer extends ResWrap<JSONEntryImpl> {
+@JsonDeserialize(using = JSONEntityDeserializer.class)
+@JsonSerialize(using = JSONEntitySerializer.class)
+public class JSONEntryContainer extends ResWrap<JSONEntityImpl> {
- public JSONEntryContainer(final ContextURL contextURL, final String metadataETag, final JSONEntryImpl object) {
+ public JSONEntryContainer(final ContextURL contextURL, final String metadataETag, final JSONEntityImpl object) {
super(contextURL, metadataETag, object);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/fit/src/main/java/org/apache/olingo/fit/serializer/JSONFeedContainer.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/serializer/JSONFeedContainer.java b/fit/src/main/java/org/apache/olingo/fit/serializer/JSONFeedContainer.java
index 7a53213..c641444 100644
--- a/fit/src/main/java/org/apache/olingo/fit/serializer/JSONFeedContainer.java
+++ b/fit/src/main/java/org/apache/olingo/fit/serializer/JSONFeedContainer.java
@@ -22,15 +22,15 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.apache.olingo.commons.api.data.ContextURL;
import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.core.data.JSONFeedDeserializer;
-import org.apache.olingo.commons.core.data.JSONFeedImpl;
-import org.apache.olingo.commons.core.data.JSONFeedSerializer;
+import org.apache.olingo.commons.core.data.JSONEntitySetDeserializer;
+import org.apache.olingo.commons.core.data.JSONEntitySetImpl;
+import org.apache.olingo.commons.core.data.JSONEntitySetSerializer;
-@JsonDeserialize(using = JSONFeedDeserializer.class)
-@JsonSerialize(using = JSONFeedSerializer.class)
-public class JSONFeedContainer extends ResWrap<JSONFeedImpl> {
+@JsonDeserialize(using = JSONEntitySetDeserializer.class)
+@JsonSerialize(using = JSONEntitySetSerializer.class)
+public class JSONFeedContainer extends ResWrap<JSONEntitySetImpl> {
- public JSONFeedContainer(final ContextURL contextURL, final String metadataETag, final JSONFeedImpl object) {
+ public JSONFeedContainer(final ContextURL contextURL, final String metadataETag, final JSONEntitySetImpl object) {
super(contextURL, metadataETag, object);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java b/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java
index c017186..57e2049 100644
--- a/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java
@@ -43,16 +43,16 @@ import javax.xml.stream.XMLStreamException;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.vfs2.FileObject;
-import org.apache.olingo.commons.api.data.Entry;
+import org.apache.olingo.commons.api.data.Entity;
import org.apache.olingo.commons.api.data.Link;
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.core.data.AtomEntryImpl;
-import org.apache.olingo.commons.core.data.AtomFeedImpl;
+import org.apache.olingo.commons.core.data.AtomEntityImpl;
+import org.apache.olingo.commons.core.data.AtomEntitySetImpl;
import org.apache.olingo.commons.core.data.AtomPropertyImpl;
import org.apache.olingo.commons.core.data.AtomSerializer;
-import org.apache.olingo.commons.core.data.JSONEntryImpl;
+import org.apache.olingo.commons.core.data.JSONEntityImpl;
import org.apache.olingo.commons.core.data.JSONPropertyImpl;
import org.apache.olingo.fit.UnsupportedMediaTypeException;
import org.apache.olingo.fit.metadata.Metadata;
@@ -199,7 +199,7 @@ public abstract class AbstractUtilities {
return fo.getContent().getInputStream();
}
- private InputStream toInputStream(final AtomEntryImpl entry) throws XMLStreamException {
+ private InputStream toInputStream(final AtomEntityImpl entry) throws XMLStreamException {
final StringWriter writer = new StringWriter();
atomSerializer.write(writer, entry);
@@ -210,7 +210,7 @@ public abstract class AbstractUtilities {
final String key,
final String entitySetName,
final InputStream is,
- final AtomEntryImpl entry) throws Exception {
+ final AtomEntityImpl entry) throws Exception {
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
IOUtils.copy(is, bos);
@@ -297,27 +297,27 @@ public abstract class AbstractUtilities {
navigationProperties == null ? null : navigationProperties.get(link.getTitle());
if (navProp != null) {
final String inlineEntitySetName = navProp.getTarget();
- if (link.getInlineEntry() != null) {
+ if (link.getInlineEntity() != null) {
final String inlineEntryKey = getDefaultEntryKey(
- inlineEntitySetName, (AtomEntryImpl) link.getInlineEntry());
+ inlineEntitySetName, (AtomEntityImpl) link.getInlineEntity());
addOrReplaceEntity(
inlineEntryKey,
inlineEntitySetName,
- toInputStream((AtomEntryImpl) link.getInlineEntry()),
- (AtomEntryImpl) link.getInlineEntry());
+ toInputStream((AtomEntityImpl) link.getInlineEntity()),
+ (AtomEntityImpl) link.getInlineEntity());
hrefs.add(inlineEntitySetName + "(" + inlineEntryKey + ")");
- } else if (link.getInlineFeed() != null) {
- for (Entry subentry : link.getInlineFeed().getEntries()) {
+ } else if (link.getInlineEntitySet() != null) {
+ for (Entity subentry : link.getInlineEntitySet().getEntities()) {
final String inlineEntryKey = getDefaultEntryKey(
- inlineEntitySetName, (AtomEntryImpl) subentry);
+ inlineEntitySetName, (AtomEntityImpl) subentry);
addOrReplaceEntity(
inlineEntryKey,
inlineEntitySetName,
- toInputStream((AtomEntryImpl) subentry),
- (AtomEntryImpl) subentry);
+ toInputStream((AtomEntityImpl) subentry),
+ (AtomEntityImpl) subentry);
hrefs.add(inlineEntitySetName + "(" + inlineEntryKey + ")");
}
@@ -365,7 +365,7 @@ public abstract class AbstractUtilities {
final Metadata metadata = Commons.getMetadata(version);
final Map<String, NavigationProperty> navigationProperties = metadata.getNavigationProperties(entitySetName);
- if (navigationProperties.get(linkName).isFeed()) {
+ if (navigationProperties.get(linkName).isEntitySet()) {
try {
final Map.Entry<String, List<String>> currents = extractLinkURIs(entitySetName, entityKey, linkName);
uris.addAll(currents.getValue());
@@ -540,7 +540,7 @@ public abstract class AbstractUtilities {
return builder.build();
}
- public InputStream writeFeed(final Accept accept, final ResWrap<AtomFeedImpl> container)
+ public InputStream writeFeed(final Accept accept, final ResWrap<AtomEntitySetImpl> container)
throws XMLStreamException, IOException {
final StringWriter writer = new StringWriter();
@@ -551,31 +551,31 @@ public abstract class AbstractUtilities {
} else {
mapper.writeValue(
writer, new JSONFeedContainer(container.getContextURL(),
- container.getMetadataETag(), dataBinder.toJSONFeed(container.getPayload())));
+ container.getMetadataETag(), dataBinder.toJSONEntitySet(container.getPayload())));
}
return IOUtils.toInputStream(writer.toString(), Constants.ENCODING);
}
- public AtomEntryImpl readEntry(final Accept accept, final InputStream entity)
+ public AtomEntityImpl readEntry(final Accept accept, final InputStream entity)
throws XMLStreamException, IOException {
- final AtomEntryImpl entry;
+ final AtomEntityImpl entry;
if (accept == Accept.ATOM || accept == Accept.XML) {
- final ResWrap<AtomEntryImpl> container = atomDeserializer.read(entity, AtomEntryImpl.class);
+ final ResWrap<AtomEntityImpl> container = atomDeserializer.read(entity, AtomEntityImpl.class);
entry = container.getPayload();
} else {
- final ResWrap<JSONEntryImpl> container =
- mapper.readValue(entity, new TypeReference<JSONEntryImpl>() {
+ final ResWrap<JSONEntityImpl> container =
+ mapper.readValue(entity, new TypeReference<JSONEntityImpl>() {
});
- entry = dataBinder.toAtomEntry(container.getPayload());
+ entry = dataBinder.toAtomEntity(container.getPayload());
}
return entry;
}
- public InputStream writeEntry(final Accept accept, final ResWrap<AtomEntryImpl> container)
+ public InputStream writeEntry(final Accept accept, final ResWrap<AtomEntityImpl> container)
throws XMLStreamException, IOException {
final StringWriter writer = new StringWriter();
@@ -584,7 +584,7 @@ public abstract class AbstractUtilities {
} else {
mapper.writeValue(
writer, new JSONEntryContainer(container.getContextURL(), container.getMetadataETag(),
- dataBinder.toJSONEntry(container.getPayload())));
+ dataBinder.toJSONEntityType(container.getPayload())));
}
return IOUtils.toInputStream(writer.toString(), Constants.ENCODING);
@@ -620,7 +620,7 @@ public abstract class AbstractUtilities {
return IOUtils.toInputStream(writer.toString(), Constants.ENCODING);
}
- private String getDefaultEntryKey(final String entitySetName, final AtomEntryImpl entry, final String propertyName)
+ private String getDefaultEntryKey(final String entitySetName, final AtomEntityImpl entry, final String propertyName)
throws Exception {
String res;
@@ -638,7 +638,7 @@ public abstract class AbstractUtilities {
return res;
}
- public String getDefaultEntryKey(final String entitySetName, final AtomEntryImpl entry) throws IOException {
+ public String getDefaultEntryKey(final String entitySetName, final AtomEntityImpl entry) throws IOException {
try {
String res;
@@ -734,7 +734,7 @@ public abstract class AbstractUtilities {
final Metadata metadata = Commons.getMetadata(version);
final Map<String, NavigationProperty> navigationProperties = metadata.getNavigationProperties(entitySetName);
- linkInfo.setFeed(navigationProperties.get(linkName.replaceAll("\\(.*\\)", "")).isFeed());
+ linkInfo.setFeed(navigationProperties.get(linkName.replaceAll("\\(.*\\)", "")).isEntitySet());
return linkInfo;
}
@@ -800,7 +800,7 @@ public abstract class AbstractUtilities {
links.getValue(),
linkName,
links.getKey(),
- navigationProperties.get(linkName).isFeed());
+ navigationProperties.get(linkName).isEntitySet());
}
public InputStream expandEntity(
@@ -832,8 +832,8 @@ public abstract class AbstractUtilities {
InputStream stream = fsManager.readFile(basePath + Constants.get(version, ConstantKey.ENTITY), acceptType);
stream = replaceProperty(stream, changes, path, justValue);
- final AtomEntryImpl entry = readEntry(acceptType, stream);
- final ResWrap<AtomEntryImpl> container = new ResWrap<AtomEntryImpl>((URI) null, null, entry);
+ final AtomEntityImpl entry = readEntry(acceptType, stream);
+ final ResWrap<AtomEntityImpl> container = new ResWrap<AtomEntityImpl>((URI) null, null, entry);
fsManager.putInMemory(writeEntry(Accept.ATOM, container),
fsManager.getAbsolutePath(basePath + Constants.get(version, ConstantKey.ENTITY), Accept.ATOM));
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/fit/src/main/java/org/apache/olingo/fit/utils/DataBinder.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/DataBinder.java b/fit/src/main/java/org/apache/olingo/fit/utils/DataBinder.java
index c9b3646..2b69f39 100644
--- a/fit/src/main/java/org/apache/olingo/fit/utils/DataBinder.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/DataBinder.java
@@ -18,25 +18,24 @@
*/
package org.apache.olingo.fit.utils;
-import java.net.URI;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.data.Entry;
-import org.apache.olingo.commons.api.data.Feed;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
import org.apache.olingo.commons.api.data.Link;
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.data.AtomEntryImpl;
-import org.apache.olingo.commons.core.data.AtomFeedImpl;
+import org.apache.olingo.commons.core.data.AtomEntityImpl;
+import org.apache.olingo.commons.core.data.AtomEntitySetImpl;
import org.apache.olingo.commons.core.data.AtomPropertyImpl;
import org.apache.olingo.commons.core.data.CollectionValueImpl;
import org.apache.olingo.commons.core.data.ComplexValueImpl;
-import org.apache.olingo.commons.core.data.JSONEntryImpl;
-import org.apache.olingo.commons.core.data.JSONFeedImpl;
+import org.apache.olingo.commons.core.data.JSONEntityImpl;
+import org.apache.olingo.commons.core.data.JSONEntitySetImpl;
import org.apache.olingo.commons.core.data.JSONPropertyImpl;
import org.apache.olingo.commons.core.data.LinkImpl;
import org.apache.olingo.fit.metadata.EntityType;
@@ -52,157 +51,157 @@ public class DataBinder {
this.version = version;
}
- public JSONFeedImpl toJSONFeed(final AtomFeedImpl atomfeed) {
- final JSONFeedImpl jsonfeed = new JSONFeedImpl();
+ public JSONEntitySetImpl toJSONEntitySet(final AtomEntitySetImpl atomEntitySet) {
+ final JSONEntitySetImpl jsonEntitySet = new JSONEntitySetImpl();
- BeanUtils.copyProperties(atomfeed, jsonfeed, "baseURI", "metadataContextURL");
- jsonfeed.setMetadataContextURL(atomfeed.getBaseURI() == null
+ BeanUtils.copyProperties(atomEntitySet, jsonEntitySet, "baseURI", "metadataContextURL");
+ jsonEntitySet.setBaseURI(atomEntitySet.getBaseURI() == null
? null
- : URI.create(atomfeed.getBaseURI().toASCIIString() + "/$metadata").normalize());
+ : atomEntitySet.getBaseURI().toASCIIString() + "/$metadata");
- final Collection<Entry> entries = jsonfeed.getEntries();
- for (Entry entry : atomfeed.getEntries()) {
- entries.add(toJSONEntry((AtomEntryImpl) entry));
+ final Collection<Entity> entries = jsonEntitySet.getEntities();
+ for (Entity entity : atomEntitySet.getEntities()) {
+ entries.add(toJSONEntityType((AtomEntityImpl) entity));
}
- return jsonfeed;
+ return jsonEntitySet;
}
- public AtomFeedImpl toAtomFeed(final JSONFeedImpl jsonfeed) {
- final AtomFeedImpl atomfeed = new AtomFeedImpl();
+ public AtomEntitySetImpl toAtomEntitySet(final JSONEntitySetImpl jsonEntitySet) {
+ final AtomEntitySetImpl atomEntitySet = new AtomEntitySetImpl();
- BeanUtils.copyProperties(jsonfeed, atomfeed, "baseURI", "metadataContextURL");
- atomfeed.setBaseURI(jsonfeed.getBaseURI() == null
+ BeanUtils.copyProperties(jsonEntitySet, atomEntitySet, "baseURI", "metadataContextURL");
+ atomEntitySet.setBaseURI(jsonEntitySet.getBaseURI() == null
? null
- : jsonfeed.getBaseURI().toASCIIString() + "/$metadata");
+ : jsonEntitySet.getBaseURI().toASCIIString() + "/$metadata");
- final Collection<Entry> entries = atomfeed.getEntries();
- for (Entry entry : jsonfeed.getEntries()) {
- entries.add(toAtomEntry((JSONEntryImpl) entry));
+ final Collection<Entity> entries = atomEntitySet.getEntities();
+ for (Entity entity : jsonEntitySet.getEntities()) {
+ entries.add(toAtomEntity((JSONEntityImpl) entity));
}
- return atomfeed;
+ return atomEntitySet;
}
- public JSONEntryImpl toJSONEntry(final AtomEntryImpl atomentry) {
- final JSONEntryImpl jsonentry = new JSONEntryImpl();
+ public JSONEntityImpl toJSONEntityType(final AtomEntityImpl atomEntity) {
+ final JSONEntityImpl jsonEntity = new JSONEntityImpl();
- BeanUtils.copyProperties(atomentry, jsonentry, "baseURI", "properties", "links");
- jsonentry.setBaseURI(atomentry.getBaseURI() == null ? null : atomentry.getBaseURI().toASCIIString());
- jsonentry.getOperations().addAll(atomentry.getOperations());
+ BeanUtils.copyProperties(atomEntity, jsonEntity, "baseURI", "properties", "links");
+ jsonEntity.setBaseURI(atomEntity.getBaseURI() == null ? null : atomEntity.getBaseURI().toASCIIString());
+ jsonEntity.getOperations().addAll(atomEntity.getOperations());
- for (Link link : atomentry.getNavigationLinks()) {
+ for (Link link : atomEntity.getNavigationLinks()) {
final Link jlink = new LinkImpl();
jlink.setHref(link.getHref());
jlink.setTitle(link.getTitle());
jlink.setType(link.getType());
jlink.setRel(link.getRel());
- if (link.getInlineEntry() instanceof AtomEntryImpl) {
- final Entry inlineEntry = link.getInlineEntry();
- if (inlineEntry instanceof AtomEntryImpl) {
- jlink.setInlineEntry(toJSONEntry((AtomEntryImpl) link.getInlineEntry()));
+ if (link.getInlineEntity() instanceof AtomEntityImpl) {
+ final Entity inlineEntity = link.getInlineEntity();
+ if (inlineEntity instanceof AtomEntityImpl) {
+ jlink.setInlineEntity(toJSONEntityType((AtomEntityImpl) link.getInlineEntity()));
}
- } else if (link.getInlineFeed() instanceof AtomFeedImpl) {
- final Feed inlineFeed = link.getInlineFeed();
- if (inlineFeed instanceof AtomFeedImpl) {
- jlink.setInlineFeed(toJSONFeed((AtomFeedImpl) link.getInlineFeed()));
+ } else if (link.getInlineEntitySet() instanceof AtomEntitySetImpl) {
+ final EntitySet inlineEntitySet = link.getInlineEntitySet();
+ if (inlineEntitySet instanceof AtomEntitySetImpl) {
+ jlink.setInlineEntitySet(toJSONEntitySet((AtomEntitySetImpl) link.getInlineEntitySet()));
}
}
- jsonentry.getNavigationLinks().add(jlink);
+ jsonEntity.getNavigationLinks().add(jlink);
}
- final Collection<Property> properties = jsonentry.getProperties();
- for (Property property : atomentry.getProperties()) {
+ final Collection<Property> properties = jsonEntity.getProperties();
+ for (Property property : atomEntity.getProperties()) {
properties.add(toJSONProperty((AtomPropertyImpl) property));
}
- return jsonentry;
+ return jsonEntity;
}
- public AtomEntryImpl toAtomEntry(final JSONEntryImpl jsonentry) {
- final AtomEntryImpl atomentry = new AtomEntryImpl();
+ public AtomEntityImpl toAtomEntity(final JSONEntityImpl jsonEntity) {
+ final AtomEntityImpl atomEntity = new AtomEntityImpl();
final Metadata metadata = Commons.getMetadata(version);
- BeanUtils.copyProperties(jsonentry, atomentry, "baseURI", "properties", "links");
- atomentry.setBaseURI(jsonentry.getBaseURI() == null ? null : jsonentry.getBaseURI().toASCIIString());
+ BeanUtils.copyProperties(jsonEntity, atomEntity, "baseURI", "properties", "links");
+ atomEntity.setBaseURI(jsonEntity.getBaseURI() == null ? null : jsonEntity.getBaseURI().toASCIIString());
- for (Link link : jsonentry.getNavigationLinks()) {
+ for (Link link : jsonEntity.getNavigationLinks()) {
final Link alink = new LinkImpl();
alink.setHref(link.getHref());
alink.setTitle(link.getTitle());
final NavigationProperty navPropDetails =
- metadata.getEntityType(jsonentry.getType()).getNavigationProperty(link.getTitle());
+ metadata.getEntityType(jsonEntity.getType()).getNavigationProperty(link.getTitle());
- alink.setType(navPropDetails != null && navPropDetails.isFeed()
+ alink.setType(navPropDetails != null && navPropDetails.isEntitySet()
? Constants.get(ConstantKey.ATOM_LINK_FEED) : Constants.get(ConstantKey.ATOM_LINK_ENTRY));
alink.setRel(link.getRel());
- if (link.getInlineEntry() instanceof JSONEntryImpl) {
- final Entry inlineEntry = link.getInlineEntry();
- if (inlineEntry instanceof JSONEntryImpl) {
- alink.setInlineEntry(toAtomEntry((JSONEntryImpl) link.getInlineEntry()));
+ if (link.getInlineEntity() instanceof JSONEntityImpl) {
+ final Entity inlineEntity = link.getInlineEntity();
+ if (inlineEntity instanceof JSONEntityImpl) {
+ alink.setInlineEntity(toAtomEntity((JSONEntityImpl) link.getInlineEntity()));
}
- } else if (link.getInlineFeed() instanceof JSONFeedImpl) {
- final Feed inlineFeed = link.getInlineFeed();
- if (inlineFeed instanceof JSONFeedImpl) {
- alink.setInlineFeed(toAtomFeed((JSONFeedImpl) link.getInlineFeed()));
+ } else if (link.getInlineEntitySet() instanceof JSONEntitySetImpl) {
+ final EntitySet inlineEntitySet = link.getInlineEntitySet();
+ if (inlineEntitySet instanceof JSONEntitySetImpl) {
+ alink.setInlineEntitySet(toAtomEntitySet((JSONEntitySetImpl) link.getInlineEntitySet()));
}
}
- atomentry.getNavigationLinks().add(alink);
+ atomEntity.getNavigationLinks().add(alink);
}
- final EntityType entityType = StringUtils.isBlank(jsonentry.getType())
- ? null : metadata.getEntityType(jsonentry.getType());
+ final EntityType entityType = StringUtils.isBlank(jsonEntity.getType())
+ ? null : metadata.getEntityType(jsonEntity.getType());
final Map<String, NavigationProperty> navProperties = entityType == null
? Collections.<String, NavigationProperty>emptyMap() : entityType.getNavigationPropertyMap();
- final List<Property> properties = atomentry.getProperties();
+ final List<Property> properties = atomEntity.getProperties();
- for (Property property : jsonentry.getProperties()) {
+ for (Property property : jsonEntity.getProperties()) {
if (navProperties.containsKey(property.getName())) {
final Link alink = new LinkImpl();
alink.setTitle(property.getName());
- alink.setType(navProperties.get(property.getName()).isFeed()
+ alink.setType(navProperties.get(property.getName()).isEntitySet()
? Constants.get(version, ConstantKey.ATOM_LINK_FEED)
: Constants.get(version, ConstantKey.ATOM_LINK_ENTRY));
alink.setRel(Constants.get(version, ConstantKey.ATOM_LINK_REL) + property.getName());
if (property.getValue().isComplex()) {
- final Entry inline = new AtomEntryImpl();
+ final Entity inline = new AtomEntityImpl();
inline.setType(navProperties.get(property.getName()).getType());
for (Property prop : property.getValue().asComplex().get()) {
inline.getProperties().add(prop);
}
- alink.setInlineEntry(inline);
+ alink.setInlineEntity(inline);
} else if (property.getValue().isCollection()) {
- final Feed inline = new AtomFeedImpl();
- for (Value entry : property.getValue().asCollection().get()) {
- final Entry inlineEntry = new AtomEntryImpl();
- inlineEntry.setType(navProperties.get(property.getName()).getType());
- for (Property prop : entry.asComplex().get()) {
- inlineEntry.getProperties().add(toAtomProperty((JSONPropertyImpl) prop, inlineEntry.getType()));
+ final EntitySet inline = new AtomEntitySetImpl();
+ for (Value value : property.getValue().asCollection().get()) {
+ final Entity inlineEntity = new AtomEntityImpl();
+ inlineEntity.setType(navProperties.get(property.getName()).getType());
+ for (Property prop : value.asComplex().get()) {
+ inlineEntity.getProperties().add(toAtomProperty((JSONPropertyImpl) prop, inlineEntity.getType()));
}
- inline.getEntries().add(inlineEntry);
+ inline.getEntities().add(inlineEntity);
}
- alink.setInlineFeed(inline);
+ alink.setInlineEntitySet(inline);
} else {
throw new IllegalStateException("Invalid navigation property " + property);
}
- atomentry.getNavigationLinks().add(alink);
+ atomEntity.getNavigationLinks().add(alink);
} else {
- properties.add(toAtomProperty((JSONPropertyImpl) property, atomentry.getType()));
+ properties.add(toAtomProperty((JSONPropertyImpl) property, atomEntity.getType()));
}
}
- return atomentry;
+ return atomEntity;
}
public JSONPropertyImpl toJSONProperty(final AtomPropertyImpl atomproperty) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java b/fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java
index 9304454..ae89ec4 100644
--- a/fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java
@@ -38,7 +38,7 @@ import org.apache.commons.vfs2.FileSystemManager;
import org.apache.commons.vfs2.VFS;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.core.data.AtomEntryImpl;
+import org.apache.olingo.commons.core.data.AtomEntityImpl;
import org.apache.olingo.commons.core.data.AtomSerializer;
import org.apache.olingo.fit.serializer.JSONEntryContainer;
import org.slf4j.Logger;
@@ -98,7 +98,7 @@ public class FSManager {
return memObject;
}
- public void putInMemory(final ResWrap<AtomEntryImpl> container, final String relativePath)
+ public void putInMemory(final ResWrap<AtomEntityImpl> container, final String relativePath)
throws IOException {
try {
final AtomSerializer atomSerializer = Commons.getAtomSerializer(version);
@@ -117,7 +117,7 @@ public class FSManager {
writer, new JSONEntryContainer(
container.getContextURL(),
container.getMetadataETag(),
- new DataBinder(version).toJSONEntry(container.getPayload())));
+ new DataBinder(version).toJSONEntityType(container.getPayload())));
putInMemory(new ByteArrayInputStream(content.toByteArray()), getAbsolutePath(relativePath, Accept.JSON_FULLMETA));
} catch (Exception e) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java b/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java
index 162221a..0b38524 100644
--- a/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java
@@ -159,7 +159,7 @@ public class XMLUtilities extends AbstractUtilities {
attributes.add(eventFactory.createAttribute(new QName("rel"),
Constants.get(version, ConstantKey.ATOM_LINK_REL) + link));
attributes.add(eventFactory.createAttribute(new QName("type"),
- navigationProperties.get(link).isFeed()
+ navigationProperties.get(link).isEntitySet()
? Constants.get(version, ConstantKey.ATOM_LINK_FEED)
: Constants.get(version, ConstantKey.ATOM_LINK_ENTRY)));
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonEdmEnabledODataClient.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonEdmEnabledODataClient.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonEdmEnabledODataClient.java
index 2b5478f..4967fc6 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonEdmEnabledODataClient.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonEdmEnabledODataClient.java
@@ -18,7 +18,6 @@
*/
package org.apache.olingo.client.api;
-import java.net.URI;
import org.apache.olingo.client.api.communication.request.cud.CommonUpdateType;
import org.apache.olingo.commons.api.edm.Edm;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/v4/AsyncRequestFactory.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/v4/AsyncRequestFactory.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/v4/AsyncRequestFactory.java
index 17b510f..45dfc11 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/v4/AsyncRequestFactory.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/v4/AsyncRequestFactory.java
@@ -22,7 +22,6 @@ import org.apache.olingo.client.api.communication.request.ODataRequest;
import org.apache.olingo.client.api.communication.request.batch.v4.ODataBatchRequest;
import org.apache.olingo.client.api.communication.response.ODataResponse;
-@SuppressWarnings("unchecked")
public interface AsyncRequestFactory {
<R extends ODataResponse> AsyncRequestWrapper<R> getAsyncRequestWrapper(final ODataRequest odataRequest);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataEntitySetIterator.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataEntitySetIterator.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataEntitySetIterator.java
index 8002845..f51285d 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataEntitySetIterator.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataEntitySetIterator.java
@@ -30,7 +30,7 @@ import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.Entry;
+import org.apache.olingo.commons.api.data.Entity;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
@@ -62,11 +62,11 @@ public class ODataEntitySetIterator<ES extends CommonODataEntitySet, E extends C
private final ODataPubFormat format;
- private ResWrap<Entry> cached;
+ private ResWrap<Entity> cached;
private ES entitySet;
- private final ByteArrayOutputStream osFeed;
+ private final ByteArrayOutputStream osEntitySet;
private final String namespaces;
@@ -85,21 +85,21 @@ public class ODataEntitySetIterator<ES extends CommonODataEntitySet, E extends C
this.odataClient = odataClient;
this.stream = stream;
this.format = format;
- this.osFeed = new ByteArrayOutputStream();
+ this.osEntitySet = new ByteArrayOutputStream();
if (format == ODataPubFormat.ATOM) {
- namespaces = getAllElementAttributes(stream, "feed", osFeed);
+ namespaces = getAllElementAttributes(stream, "feed", osEntitySet);
} else {
namespaces = null;
try {
- if (consume(stream, "\"value\":", osFeed, true) >= 0) {
+ if (consume(stream, "\"value\":", osEntitySet, true) >= 0) {
int c = 0;
while (c != '[' && (c = stream.read()) >= 0) {
- osFeed.write(c);
+ osEntitySet.write(c);
}
}
} catch (IOException e) {
- LOG.error("Error parsing feed", e);
+ LOG.error("Error parsing entity set", e);
throw new IllegalStateException(e);
}
}
@@ -113,15 +113,15 @@ public class ODataEntitySetIterator<ES extends CommonODataEntitySet, E extends C
public boolean hasNext() {
if (available && cached == null) {
if (format == ODataPubFormat.ATOM) {
- cached = nextAtomEntryFromFeed(stream, osFeed, namespaces);
+ cached = nextAtomEntityFromEntitySet(stream, osEntitySet, namespaces);
} else {
- cached = nextJsonEntryFromFeed(stream, osFeed);
+ cached = nextJSONEntityFromEntitySet(stream, osEntitySet);
}
if (cached == null) {
available = false;
entitySet = (ES) odataClient.getReader().
- readEntitySet(new ByteArrayInputStream(osFeed.toByteArray()), format);
+ readEntitySet(new ByteArrayInputStream(osEntitySet.toByteArray()), format);
close();
}
}
@@ -157,7 +157,7 @@ public class ODataEntitySetIterator<ES extends CommonODataEntitySet, E extends C
*/
public void close() {
IOUtils.closeQuietly(stream);
- IOUtils.closeQuietly(osFeed);
+ IOUtils.closeQuietly(osEntitySet);
}
/**
@@ -172,10 +172,10 @@ public class ODataEntitySetIterator<ES extends CommonODataEntitySet, E extends C
return entitySet.getNext();
}
- private ResWrap<Entry> nextJsonEntryFromFeed(final InputStream input, final OutputStream osFeed) {
- final ByteArrayOutputStream entry = new ByteArrayOutputStream();
+ private ResWrap<Entity> nextJSONEntityFromEntitySet(final InputStream input, final OutputStream osEntitySet) {
+ final ByteArrayOutputStream entity = new ByteArrayOutputStream();
- ResWrap<Entry> jsonEntry = null;
+ ResWrap<Entity> jsonEntity = null;
try {
int c;
@@ -184,12 +184,12 @@ public class ODataEntitySetIterator<ES extends CommonODataEntitySet, E extends C
do {
c = input.read();
if (c == '{') {
- entry.write(c);
+ entity.write(c);
c = -1;
foundNewOne = true;
}
if (c == ']') {
- osFeed.write(c);
+ osEntitySet.write(c);
c = -1;
}
} while (c >= 0);
@@ -205,55 +205,48 @@ public class ODataEntitySetIterator<ES extends CommonODataEntitySet, E extends C
} else if (c == '}') {
count--;
}
- entry.write(c);
+ entity.write(c);
}
if (c >= 0) {
- jsonEntry = odataClient.getDeserializer().toEntry(
- new ByteArrayInputStream(entry.toByteArray()), ODataPubFormat.JSON);
+ jsonEntity = odataClient.getDeserializer().toEntity(
+ new ByteArrayInputStream(entity.toByteArray()), ODataPubFormat.JSON);
}
} else {
while ((c = input.read()) >= 0) {
- osFeed.write(c);
+ osEntitySet.write(c);
}
}
} catch (Exception e) {
LOG.error("Error retrieving entities from EntitySet", e);
}
- return jsonEntry;
+ return jsonEntity;
}
- /**
- * De-Serializes a stream into an OData entity set.
- *
- * @param input stream to de-serialize.
- * @param format de-serialize as AtomFeed or JSONFeed
- * @return de-serialized entity set.
- */
- private ResWrap<Entry> nextAtomEntryFromFeed(
- final InputStream input, final OutputStream osFeed, final String namespaces) {
+ private ResWrap<Entity> nextAtomEntityFromEntitySet(
+ final InputStream input, final OutputStream osEntitySet, final String namespaces) {
- final ByteArrayOutputStream entry = new ByteArrayOutputStream();
+ final ByteArrayOutputStream entity = new ByteArrayOutputStream();
- ResWrap<Entry> atomEntry = null;
+ ResWrap<Entity> atomEntity = null;
try {
- if (consume(input, "<entry>", osFeed, false) >= 0) {
- entry.write("<entry ".getBytes(Constants.UTF8));
- entry.write(namespaces.getBytes(Constants.UTF8));
- entry.write(">".getBytes(Constants.UTF8));
-
- if (consume(input, "</entry>", entry, true) >= 0) {
- atomEntry = odataClient.getDeserializer().
- toEntry(new ByteArrayInputStream(entry.toByteArray()), ODataPubFormat.ATOM);
+ if (consume(input, "<entry>", osEntitySet, false) >= 0) {
+ entity.write("<entry ".getBytes(Constants.UTF8));
+ entity.write(namespaces.getBytes(Constants.UTF8));
+ entity.write(">".getBytes(Constants.UTF8));
+
+ if (consume(input, "</entry>", entity, true) >= 0) {
+ atomEntity = odataClient.getDeserializer().
+ toEntity(new ByteArrayInputStream(entity.toByteArray()), ODataPubFormat.ATOM);
}
}
} catch (Exception e) {
LOG.error("Error retrieving entities from EntitySet", e);
}
- return atomEntry;
+ return atomEntity;
}
private String getAllElementAttributes(final InputStream input, final String name, final OutputStream os) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataBinder.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataBinder.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataBinder.java
index acb08ae..08ee08d 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataBinder.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataBinder.java
@@ -19,8 +19,8 @@
package org.apache.olingo.client.api.op;
import java.io.Serializable;
-import org.apache.olingo.commons.api.data.Entry;
-import org.apache.olingo.commons.api.data.Feed;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
import org.apache.olingo.commons.api.data.Link;
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.client.api.data.ServiceDocument;
@@ -34,22 +34,22 @@ import org.apache.olingo.commons.api.domain.ODataServiceDocument;
public interface CommonODataBinder extends Serializable {
/**
- * Gets a <tt>Feed</tt> from the given OData entity set.
+ * Gets a <tt>EntitySet</tt> from the given OData entity set.
*
- * @param feed OData entity set.
+ * @param entitySet OData entity set.
* @param reference reference class.
- * @return <tt>Feed</tt> object.
+ * @return {@link EntitySet} object.
*/
- Feed getFeed(CommonODataEntitySet feed, Class<? extends Feed> reference);
+ EntitySet getEntitySet(CommonODataEntitySet entitySet, Class<? extends EntitySet> reference);
/**
- * Gets an <tt>Entry</tt> from the given OData entity.
+ * Gets an <tt>Entity</tt> from the given OData entity.
*
* @param entity OData entity.
* @param reference reference class.
- * @return <tt>Entry</tt> object.
+ * @return {@link Entity} object.
*/
- Entry getEntry(CommonODataEntity entity, Class<? extends Entry> reference);
+ Entity getEntity(CommonODataEntity entity, Class<? extends Entity> reference);
/**
* Gets a <tt>Link</tt> from the given OData link.
@@ -67,7 +67,7 @@ public interface CommonODataBinder extends Serializable {
* @param reference reference class.
* @return <tt>Property</tt> object.
*/
- Property getProperty(CommonODataProperty property, Class<? extends Entry> reference);
+ Property getProperty(CommonODataProperty property, Class<? extends Entity> reference);
/**
* Adds the given property to the given entity.
@@ -87,20 +87,20 @@ public interface CommonODataBinder extends Serializable {
ODataServiceDocument getODataServiceDocument(ServiceDocument resource);
/**
- * Gets <tt>ODataEntitySet</tt> from the given feed resource.
+ * Gets <tt>ODataEntitySet</tt> from the given entity set resource.
*
- * @param resource feed resource.
+ * @param resource entity set resource.
* @return {@link CommonODataEntitySet} object.
*/
- CommonODataEntitySet getODataEntitySet(ResWrap<Feed> resource);
+ CommonODataEntitySet getODataEntitySet(ResWrap<EntitySet> resource);
/**
- * Gets <tt>ODataEntity</tt> from the given entry resource.
+ * Gets <tt>ODataEntity</tt> from the given entity resource.
*
- * @param resource entry resource.
+ * @param resource entity resource.
* @return {@link CommonODataEntity} object.
*/
- CommonODataEntity getODataEntity(ResWrap<Entry> resource);
+ CommonODataEntity getODataEntity(ResWrap<Entity> resource);
/**
* Gets an <tt>ODataProperty</tt> from the given property resource.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/118b779b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataReader.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataReader.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataReader.java
index 0f1335a..eea1567 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataReader.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataReader.java
@@ -37,7 +37,7 @@ import org.apache.olingo.commons.api.format.ODataPubFormat;
* <br/>
* Use this class to de-serialize an OData response body.
* <br/>
- * This class provides method helpers to de-serialize an entire feed, a set of entities and a single entity as well.
+ * This class provides method helpers to de-serialize an entire entity set, a set of entities or a single entity.
*/
public interface CommonODataReader extends Serializable {
@@ -71,7 +71,7 @@ public interface CommonODataReader extends Serializable {
* De-Serializes a stream into an OData entity set.
*
* @param input stream to de-serialize.
- * @param format de-serialize as AtomFeed or JSONFeed
+ * @param format de-serialize format
* @return de-serialized entity set.
*/
CommonODataEntitySet readEntitySet(InputStream input, ODataPubFormat format);
@@ -80,7 +80,7 @@ public interface CommonODataReader extends Serializable {
* Parses a stream taking care to de-serializes the first OData entity found.
*
* @param input stream to de-serialize.
- * @param format de-serialize as AtomEntry or JSONEntry
+ * @param format de-serialize format
* @return entity de-serialized.
*/
CommonODataEntity readEntity(InputStream input, ODataPubFormat format);