Repository: olingo-odata4 Updated Branches: refs/heads/OLINGO-317_JSON-for-server [created] bd9bf1e26
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bd9bf1e2/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/LinkCollectionImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/LinkCollectionImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/LinkCollectionImpl.java new file mode 100755 index 0000000..3310723 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/LinkCollectionImpl.java @@ -0,0 +1,78 @@ +/* + * 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.v3; + +import java.net.URI; +import java.util.ArrayList; +import java.util.List; +import org.apache.olingo.commons.api.data.v3.LinkCollection; + +public class LinkCollectionImpl implements LinkCollection { + + private final List<URI> links = new ArrayList<URI>(); + private URI next; + private URI metadata; + + /** + * Constructor. + */ + public LinkCollectionImpl() { + } + + /** + * Constructor. + * + * @param next next page link. + */ + public LinkCollectionImpl(final URI next) { + this.next = next; + } + + @Override + public List<URI> getLinks() { + return links; + } + + @Override + public void setNext(final URI next) { + this.next = next; + } + + @Override + public URI getNext() { + return next; + } + + /** + * Gets the metadata URI. + */ + public URI getMetadata() { + return metadata; + } + + /** + * Sets the metadata URI. + * + * @param metadata metadata URI. + */ + public void setMetadata(final URI metadata) { + this.metadata = metadata; + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bd9bf1e2/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/XMLLinkCollectionImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/XMLLinkCollectionImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/XMLLinkCollectionImpl.java deleted file mode 100644 index 8d9001c..0000000 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/XMLLinkCollectionImpl.java +++ /dev/null @@ -1,70 +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.v3; - -import java.net.URI; -import java.util.ArrayList; -import java.util.List; -import org.apache.olingo.commons.api.data.v3.LinkCollection; - -public class XMLLinkCollectionImpl implements LinkCollection { - - private final List<URI> links = new ArrayList<URI>(); - - private URI next; - - /** - * Constructor. - */ - public XMLLinkCollectionImpl() { - } - - /** - * Constructor. - * - * @param next next page link. - */ - public XMLLinkCollectionImpl(final URI next) { - this.next = next; - } - - /** - * {@inheritDoc } - */ - @Override - public List<URI> getLinks() { - return links; - } - - /** - * {@inheritDoc } - */ - @Override - public void setNext(final URI next) { - this.next = next; - } - - /** - * {@inheritDoc } - */ - @Override - public URI getNext() { - return next; - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bd9bf1e2/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/AbstractDelta.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/AbstractDelta.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/AbstractDelta.java deleted file mode 100644 index d4a50ed..0000000 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/AbstractDelta.java +++ /dev/null @@ -1,52 +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.v4; - -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; -import org.apache.olingo.commons.core.data.AbstractEntitySet; - -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>(); - - @Override - public List<DeletedEntity> getDeletedEntities() { - return deletedEntities; - } - - @Override - public List<DeltaLink> getAddedLinks() { - return addedLinks; - } - - @Override - public List<DeltaLink> getDeletedLinks() { - return deletedLinks; - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bd9bf1e2/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/AtomDeltaImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/AtomDeltaImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/AtomDeltaImpl.java deleted file mode 100644 index d2f85b2..0000000 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/AtomDeltaImpl.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.v4; - -public class AtomDeltaImpl extends AbstractDelta { - - private static final long serialVersionUID = -730729098008847535L; - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bd9bf1e2/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/DeltaImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/DeltaImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/DeltaImpl.java new file mode 100755 index 0000000..021a77d --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/DeltaImpl.java @@ -0,0 +1,52 @@ +/* + * 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.v4; + +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; +import org.apache.olingo.commons.core.data.EntitySetImpl; + +public class DeltaImpl extends EntitySetImpl 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>(); + + @Override + public List<DeletedEntity> getDeletedEntities() { + return deletedEntities; + } + + @Override + public List<DeltaLink> getAddedLinks() { + return addedLinks; + } + + @Override + public List<DeltaLink> getDeletedLinks() { + return deletedLinks; + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bd9bf1e2/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/JSONDeltaImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/JSONDeltaImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/JSONDeltaImpl.java deleted file mode 100644 index 7b60d5f..0000000 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/JSONDeltaImpl.java +++ /dev/null @@ -1,29 +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.v4; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import org.apache.olingo.commons.core.data.JSONDeltaDeserializer; - -@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/bd9bf1e2/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/AbstractJacksonTool.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/AbstractJacksonTool.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/AbstractJacksonTool.java deleted file mode 100644 index c4c32ad..0000000 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/AbstractJacksonTool.java +++ /dev/null @@ -1,86 +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.op; - -import com.fasterxml.aalto.stax.InputFactoryImpl; -import com.fasterxml.aalto.stax.OutputFactoryImpl; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.InjectableValues; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.deser.DeserializationProblemHandler; -import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; -import com.fasterxml.jackson.dataformat.xml.XmlFactory; -import com.fasterxml.jackson.dataformat.xml.XmlMapper; -import java.io.IOException; -import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -abstract class AbstractJacksonTool { - - protected static final Logger LOG = LoggerFactory.getLogger(AbstractJacksonTool.class); - - protected final ODataServiceVersion version; - - protected AbstractJacksonTool(final ODataServiceVersion client) { - this.version = client; - } - - protected ObjectMapper getObjectMapper() { - final ObjectMapper mapper = new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL); - - mapper.setInjectableValues(new InjectableValues.Std(). - addValue(ODataServiceVersion.class, version). - addValue(Boolean.class, Boolean.FALSE)); - - mapper.setSerializerProvider(new InjectableSerializerProvider(mapper.getSerializerProvider(), - mapper.getSerializationConfig().withAttribute(ODataServiceVersion.class, version). - withAttribute(Boolean.class, Boolean.FALSE), - mapper.getSerializerFactory())); - - return mapper; - } - - protected XmlMapper getXmlMapper() { - final XmlMapper xmlMapper = new XmlMapper( - new XmlFactory(new InputFactoryImpl(), new OutputFactoryImpl()), new JacksonXmlModule()); - - xmlMapper.setInjectableValues(new InjectableValues.Std(). - addValue(ODataServiceVersion.class, version). - addValue(Boolean.class, Boolean.FALSE)); - - xmlMapper.addHandler(new DeserializationProblemHandler() { - @Override - public boolean handleUnknownProperty(final DeserializationContext ctxt, final JsonParser jp, - final JsonDeserializer<?> deserializer, final Object beanOrClass, final String propertyName) - throws IOException, JsonProcessingException { - - // skip any unknown property - LOG.warn("Skipping unknown property {}", propertyName); - ctxt.getParser().skipChildren(); - return true; - } - }); - return xmlMapper; - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bd9bf1e2/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 f584868..a2ef134 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 @@ -18,109 +18,84 @@ */ package org.apache.olingo.commons.core.op; -import com.fasterxml.jackson.core.type.TypeReference; +import java.io.IOException; import java.io.InputStream; -import java.lang.reflect.Type; -import java.net.URI; + import org.apache.olingo.commons.api.data.Entity; -import org.apache.olingo.commons.api.domain.ODataError; 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.ODataError; +import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; +import org.apache.olingo.commons.api.format.Format; import org.apache.olingo.commons.api.format.ODataFormat; import org.apache.olingo.commons.api.format.ODataPubFormat; -import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; -import org.apache.olingo.commons.api.op.CommonODataDeserializer; +import org.apache.olingo.commons.api.op.ODataDeserializer; +import org.apache.olingo.commons.api.op.ODataDeserializerException; import org.apache.olingo.commons.core.data.AtomDeserializer; -import org.apache.olingo.commons.api.data.ResWrap; -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.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; - -public abstract class AbstractODataDeserializer extends AbstractJacksonTool implements CommonODataDeserializer { +import org.apache.olingo.commons.core.data.JsonDeserializer; - private static final long serialVersionUID = -4244158979195609909L; +import com.fasterxml.aalto.stax.InputFactoryImpl; +import com.fasterxml.aalto.stax.OutputFactoryImpl; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.InjectableValues; +import com.fasterxml.jackson.databind.deser.DeserializationProblemHandler; +import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; +import com.fasterxml.jackson.dataformat.xml.XmlFactory; +import com.fasterxml.jackson.dataformat.xml.XmlMapper; - private final AtomDeserializer atomDeserializer; +public abstract class AbstractODataDeserializer { - public AbstractODataDeserializer(final ODataServiceVersion version) { - super(version); + protected final ODataServiceVersion version; + protected final ODataDeserializer deserializer; - this.atomDeserializer = new AtomDeserializer(version); + public AbstractODataDeserializer(final ODataServiceVersion version, final Format format) { + this.version = version; + if (format == ODataFormat.XML || format == ODataPubFormat.ATOM) { + deserializer = new AtomDeserializer(version); + } else { + deserializer = new JsonDeserializer(version, false); + } } - @Override - public ResWrap<EntitySet> toEntitySet(final InputStream input, final ODataPubFormat format) { - return format == ODataPubFormat.ATOM - ? this.<EntitySet, AtomEntitySetImpl>atom(input, AtomEntitySetImpl.class) - : this.<EntitySet, JSONEntitySetImpl>json(input, JSONEntitySetImpl.class); + public ResWrap<EntitySet> toEntitySet(final InputStream input) throws ODataDeserializerException { + return deserializer.toEntitySet(input); } - @Override - public ResWrap<Entity> toEntity(final InputStream input, final ODataPubFormat format) { - return format == ODataPubFormat.ATOM - ? this.<Entity, AtomEntityImpl>atom(input, AtomEntityImpl.class) - : this.<Entity, JSONEntityImpl>json(input, JSONEntityImpl.class); + public ResWrap<Entity> toEntity(final InputStream input) throws ODataDeserializerException { + return deserializer.toEntity(input); } - @Override - public ResWrap<Property> toProperty(final InputStream input, final ODataFormat format) { - return format == ODataFormat.XML - ? this.<Property, AtomPropertyImpl>atom(input, AtomPropertyImpl.class) - : this.<Property, JSONPropertyImpl>json(input, JSONPropertyImpl.class); + public ResWrap<Property> toProperty(final InputStream input) throws ODataDeserializerException { + return deserializer.toProperty(input); } - @Override - public ODataError toError(final InputStream input, final boolean isXML) { - return isXML - ? this.<ODataError, XMLODataErrorImpl>atom(input, XMLODataErrorImpl.class).getPayload() - : this.<ODataError, JSONODataErrorImpl>json(input, JSONODataErrorImpl.class).getPayload(); + public ODataError toError(final InputStream input) throws ODataDeserializerException { + return deserializer.toError(input); } - /* - * ------------------ Protected methods ------------------ - */ - protected <T, V extends T> ResWrap<T> atom(final InputStream input, final Class<V> reference) { - try { - return atomDeserializer.<T, V>read(input, reference); - } catch (Exception e) { - throw new IllegalArgumentException("While deserializing " + reference.getName(), e); - } - } + protected XmlMapper getXmlMapper() { + final XmlMapper xmlMapper = new XmlMapper( + new XmlFactory(new InputFactoryImpl(), new OutputFactoryImpl()), new JacksonXmlModule()); - @SuppressWarnings("unchecked") - protected <T, V extends T> ResWrap<T> xml(final InputStream input, final Class<V> reference) { - try { - final T obj = getXmlMapper().readValue(input, new TypeReference<V>() { - @Override - public Type getType() { - return reference; - } - }); + xmlMapper.setInjectableValues(new InjectableValues.Std(). + addValue(ODataServiceVersion.class, version). + addValue(Boolean.class, Boolean.FALSE)); - return obj instanceof ResWrap ? (ResWrap<T>) obj : new ResWrap<T>((URI) null, null, obj); - } catch (Exception e) { - throw new IllegalArgumentException("While deserializing " + reference.getName(), e); - } - } - - @SuppressWarnings("unchecked") - protected <T, V extends T> ResWrap<T> json(final InputStream input, final Class<V> reference) { - try { - final T obj = getObjectMapper().readValue(input, new TypeReference<V>() { - @Override - public Type getType() { - return reference; - } - }); + xmlMapper.addHandler(new DeserializationProblemHandler() { + @Override + public boolean handleUnknownProperty(final DeserializationContext ctxt, final JsonParser jp, + final com.fasterxml.jackson.databind.JsonDeserializer<?> deserializer, + final Object beanOrClass, final String propertyName) + throws IOException, JsonProcessingException { - return obj instanceof ResWrap ? (ResWrap<T>) obj : new ResWrap<T>((URI) null, null, obj); - } catch (Exception e) { - throw new IllegalArgumentException("While deserializing " + reference.getName(), e); - } + // skip any unknown property + ctxt.getParser().skipChildren(); + return true; + } + }); + return xmlMapper; } } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bd9bf1e2/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 deleted file mode 100644 index 32b9e99..0000000 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/AbstractODataSerializer.java +++ /dev/null @@ -1,141 +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.op; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; -import java.io.IOException; -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.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.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.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 { - - private static final long serialVersionUID = -357777648541325363L; - - private final AtomSerializer atomSerializer; - - public AbstractODataSerializer(final ODataServiceVersion version) { - super(version); - - this.atomSerializer = new AtomSerializer(version); - } - - @Override - public void entitySet(final EntitySet obj, final OutputStream out) { - entitySet(obj, new OutputStreamWriter(out)); - } - - @Override - public void entitySet(final EntitySet obj, final Writer writer) { - if (obj instanceof AtomEntitySetImpl) { - atom((AtomEntitySetImpl) obj, writer); - } else { - json((JSONEntitySetImpl) obj, writer); - } - } - - @Override - public void entity(final Entity obj, final OutputStream out) { - entity(obj, new OutputStreamWriter(out)); - } - - @Override - public void entity(final Entity obj, final Writer writer) { - if (obj instanceof AtomEntityImpl) { - atom((AtomEntityImpl) obj, writer); - } else { - json((JSONEntityImpl) obj, writer); - } - } - - @Override - public void property(final Property obj, final OutputStream out) { - property(obj, new OutputStreamWriter(out)); - } - - @Override - public void property(final Property obj, final Writer writer) { - if (obj instanceof AtomPropertyImpl) { - atom((AtomPropertyImpl) obj, writer); - } else { - json((JSONPropertyImpl) obj, writer); - } - } - - @Override - public void link(final Link link, final ODataFormat format, final OutputStream out) { - link(link, format, new OutputStreamWriter(out)); - } - - @Override - public void link(final Link link, final ODataFormat format, final Writer writer) { - if (format == ODataFormat.XML) { - atom(link, writer); - } else { - jsonLink(link, writer); - } - } - - /* - * ------------------ Protected methods ------------------ - */ - protected <T> void atom(final T obj, final Writer writer) { - try { - atomSerializer.write(writer, obj); - } catch (Exception e) { - throw new IllegalArgumentException("While serializing Atom object", e); - } - } - - protected <T> void json(final T obj, final Writer writer) { - try { - getObjectMapper().writeValue(writer, obj); - } catch (IOException e) { - throw new IllegalArgumentException("While serializing JSON object", e); - } - } - - protected void jsonLink(final Link link, final Writer writer) { - final ObjectMapper mapper = getObjectMapper(); - final ObjectNode uri = mapper.createObjectNode(); - uri.put(Constants.JSON_URL, link.getHref()); - - try { - mapper.writeValue(writer, uri); - } catch (Exception e) { - throw new IllegalArgumentException("While serializing JSON link", e); - } - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bd9bf1e2/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 deleted file mode 100644 index a2efe34..0000000 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/ResourceFactory.java +++ /dev/null @@ -1,125 +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.op; - -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.AtomEntityImpl; -import org.apache.olingo.commons.core.data.AtomEntitySetImpl; -import org.apache.olingo.commons.core.data.AtomPropertyImpl; -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>EntitySet</tt>. - * - * @param resourceClass reference class. - * @return {@link EntitySet} object. - */ - public static EntitySet newEntitySet(final Class<? extends EntitySet> resourceClass) { - EntitySet result = null; - - if (AtomEntitySetImpl.class.equals(resourceClass)) { - result = new AtomEntitySetImpl(); - } - if (JSONEntitySetImpl.class.equals(resourceClass)) { - result = new JSONEntitySetImpl(); - } - - return result; - } - - /** - * Gets a new instance of <tt>Entity</tt>. - * - * @param resourceClass reference class. - * @return {@link Entity} object. - */ - public static Entity newEntity(final Class<? extends Entity> resourceClass) { - Entity result = null; - if (AtomEntityImpl.class.equals(resourceClass)) { - result = new AtomEntityImpl(); - } - if (JSONEntityImpl.class.equals(resourceClass)) { - result = new JSONEntityImpl(); - } - - return result; - } - - public static Property newProperty(final Class<? extends Entity> resourceClass) { - Property result = null; - if (AtomEntityImpl.class.equals(resourceClass)) { - result = new AtomPropertyImpl(); - } - if (JSONEntityImpl.class.equals(resourceClass)) { - result = new JSONPropertyImpl(); - } - - return result; - } - - /** - * 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 EntitySet> entitySetClassForFormat(final boolean isXML) { - return isXML ? AtomEntitySetImpl.class : JSONEntitySetImpl.class; - } - - /** - * 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 Entity> entityClassForFormat(final boolean isXML) { - return isXML ? AtomEntityImpl.class : JSONEntityImpl.class; - } - - /** - * Gets <tt>Entity</tt> object from entity set resource. - * - * @param resourceClass entity set reference class. - * @return {@link Entity} object. - */ - public static Class<? extends Entity> entityClassForEntitySet(final Class<? extends EntitySet> resourceClass) { - Class<? extends Entity> result = null; - - if (AtomEntitySetImpl.class.equals(resourceClass)) { - result = AtomEntityImpl.class; - } - if (JSONEntitySetImpl.class.equals(resourceClass)) { - result = JSONEntityImpl.class; - } - - return result; - } - - public static ODataPubFormat formatForEntityClass(final Class<? extends Entity> reference) { - return reference.equals(AtomEntityImpl.class) ? ODataPubFormat.ATOM : ODataPubFormat.JSON; - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bd9bf1e2/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java ---------------------------------------------------------------------- diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java index fd57c89..0eaf440 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java @@ -20,7 +20,12 @@ package org.apache.olingo.server.api.serializer; import java.io.InputStream; +import org.apache.olingo.commons.api.data.ContextURL; +import org.apache.olingo.commons.api.data.Entity; +import org.apache.olingo.commons.api.data.EntitySet; import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmEntitySet; +import org.apache.olingo.commons.api.edm.EdmEntityType; public interface ODataSerializer { @@ -30,4 +35,7 @@ public interface ODataSerializer { InputStream metadataDocument(Edm edm); + InputStream entity(EdmEntityType edmEntityType, Entity entity, ContextURL contextURL); + + InputStream entitySet(EdmEntitySet edmEntitySet, EntitySet entitySet, ContextURL contextURL); } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bd9bf1e2/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java ---------------------------------------------------------------------- diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java index e5ca20c..cf9f3f3 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java @@ -18,16 +18,31 @@ */ package org.apache.olingo.server.core; +import java.io.IOException; +import java.net.URI; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.UUID; import org.apache.olingo.commons.api.ODataRuntimeException; +import org.apache.olingo.commons.api.data.ContextURL; +import org.apache.olingo.commons.api.data.Entity; +import org.apache.olingo.commons.api.data.EntitySet; +import org.apache.olingo.commons.api.data.Property; +import org.apache.olingo.commons.api.data.ResWrap; import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; +import org.apache.olingo.commons.api.format.ContentType; import org.apache.olingo.commons.api.http.HttpContentType; import org.apache.olingo.commons.api.http.HttpMethod; import org.apache.olingo.commons.api.http.HttpHeader; +import org.apache.olingo.commons.core.data.EntityImpl; +import org.apache.olingo.commons.core.data.EntitySetImpl; +import org.apache.olingo.commons.core.data.PrimitiveValueImpl; +import org.apache.olingo.commons.core.data.PropertyImpl; +import org.apache.olingo.commons.core.op.InjectableSerializerProvider; import org.apache.olingo.server.api.OData; import org.apache.olingo.server.api.ODataRequest; import org.apache.olingo.server.api.ODataResponse; @@ -37,13 +52,19 @@ import org.apache.olingo.server.api.processor.EntitySetProcessor; import org.apache.olingo.server.api.processor.MetadataProcessor; import org.apache.olingo.server.api.processor.Processor; import org.apache.olingo.server.api.processor.ServiceDocumentProcessor; +import org.apache.olingo.server.api.serializer.ODataSerializer; import org.apache.olingo.server.api.uri.UriInfo; import org.apache.olingo.server.api.uri.UriResource; import org.apache.olingo.server.api.uri.UriResourceNavigation; import org.apache.olingo.server.api.uri.UriResourcePartTyped; +import org.apache.olingo.server.core.serializer.utils.CircleStreamBuffer; import org.apache.olingo.server.core.uri.parser.Parser; import org.apache.olingo.server.core.uri.validator.UriValidator; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.databind.InjectableValues; +import com.fasterxml.jackson.databind.ObjectMapper; + public class ODataHandler { private final OData odata; @@ -113,6 +134,39 @@ public class ODataHandler { UriResource lastPathSegment = uriInfo.getUriResourceParts().get(lastPathSegmentIndex); switch (lastPathSegment.getKind()) { case entitySet: + long time = System.nanoTime(); + ResWrap<EntitySet> wrap = new ResWrap<EntitySet>( + ContextURL.getInstance(URI.create("dummyContextURL")), "dummyMetadataETag", + createEntitySet()); + System.out.println((System.nanoTime() - time) / 1000 + " microseconds"); + time = System.nanoTime(); + CircleStreamBuffer buffer = new CircleStreamBuffer(); + if (false) { + ObjectMapper mapper = new ObjectMapper().setSerializationInclusion(Include.NON_NULL); + mapper.setInjectableValues(new InjectableValues.Std() + .addValue(ODataServiceVersion.class, ODataServiceVersion.V40) + .addValue(Boolean.class, Boolean.TRUE)); + mapper.setSerializerProvider(new InjectableSerializerProvider(mapper.getSerializerProvider(), + mapper.getSerializationConfig() + .withAttribute(ODataServiceVersion.class, ODataServiceVersion.V40) + .withAttribute(Boolean.class, Boolean.TRUE), + mapper.getSerializerFactory())); + try { + mapper.writeValue(buffer.getOutputStream(), wrap); + } catch (final IOException e) {} + response.setContent(buffer.getInputStream()); + } else { + ODataSerializer serializer = odata.createSerializer(org.apache.olingo.server.api.serializer.ODataFormat.JSON); + response.setContent(serializer.entitySet( + edm.getEntityContainer(new FullQualifiedName("com.sap.odata.test1", "Container")) + .getEntitySet("ESAllPrim"), + wrap.getPayload(), + ContextURL.getInstance(URI.create("dummyContextURL")))); + } + System.out.println((System.nanoTime() - time) / 1000 + " microseconds"); + response.setStatusCode(200); + response.setHeader("Content-Type", ContentType.APPLICATION_JSON); + if (((UriResourcePartTyped) lastPathSegment).isCollection()) { if (request.getMethod().equals(HttpMethod.GET)) { EntitySetProcessor esp = selectProcessor(EntitySetProcessor.class); @@ -186,4 +240,34 @@ public class ODataHandler { } } } + + protected Entity createEntity() { + Entity entity = new EntityImpl(); + Property property = new PropertyImpl(); + property.setName("PropertyString"); + property.setType("String"); //"dummyType"); + property.setValue(new PrimitiveValueImpl("dummyValue")); + entity.getProperties().add(property); + Property propertyInt = new PropertyImpl(); + propertyInt.setName("PropertyInt16"); + // propertyInt.setType("Edm.Int32"); + propertyInt.setValue(new PrimitiveValueImpl("042")); + entity.getProperties().add(propertyInt); + Property propertyGuid = new PropertyImpl(); + propertyGuid.setName("PropertyGuid"); + propertyGuid.setType("Edm.Guid"); + propertyGuid.setValue(new PrimitiveValueImpl(UUID.randomUUID().toString())); + entity.getProperties().add(propertyGuid); + return entity; + } + + protected EntitySet createEntitySet() { + EntitySet entitySet = new EntitySetImpl(); + entitySet.setCount(4242); + entitySet.setNext(URI.create("nextLinkURI")); + for (int i = 0; i < 1000; i++) { + entitySet.getEntities().add(createEntity()); + } + return entitySet; + } } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bd9bf1e2/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataJsonSerializer.java ---------------------------------------------------------------------- diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataJsonSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataJsonSerializer.java index 333d5b7..62634da 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataJsonSerializer.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataJsonSerializer.java @@ -23,8 +23,19 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; +import org.apache.olingo.commons.api.Constants; import org.apache.olingo.commons.api.ODataRuntimeException; +import org.apache.olingo.commons.api.data.ContextURL; +import org.apache.olingo.commons.api.data.Entity; +import org.apache.olingo.commons.api.data.EntitySet; +import org.apache.olingo.commons.api.data.Property; import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmEntitySet; +import org.apache.olingo.commons.api.edm.EdmEntityType; +import org.apache.olingo.commons.api.edm.EdmPrimitiveType; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; +import org.apache.olingo.commons.api.edm.EdmProperty; +import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; import org.apache.olingo.server.api.serializer.ODataSerializer; import org.apache.olingo.server.core.serializer.json.ServiceDocumentJsonSerializer; import org.apache.olingo.server.core.serializer.utils.CircleStreamBuffer; @@ -84,4 +95,97 @@ public class ODataJsonSerializer implements ODataSerializer { public InputStream metadataDocument(final Edm edm) { throw new ODataRuntimeException("Metadata in JSON format not supported!"); } + + @Override + public InputStream entity(final EdmEntityType edmEntityType, final Entity entity, final ContextURL contextURL) { + CircleStreamBuffer buffer = new CircleStreamBuffer(); + try { + JsonGenerator json = new JsonFactory().createGenerator(buffer.getOutputStream()); + writeEntity(edmEntityType, entity, contextURL, json); + json.close(); + } catch (final IOException e) { + throw new ODataRuntimeException(e); + } + return buffer.getInputStream(); + } + + protected void writeEntity(final EdmEntityType entityType, final Entity entity, final ContextURL contextURL, + JsonGenerator json) throws IOException { + json.writeStartObject(); + if (contextURL != null) { + json.writeStringField(Constants.JSON_CONTEXT, contextURL.getURI().toASCIIString()); + } + if (entity.getETag() != null) { + json.writeStringField("@odata.etag", entity.getETag()); + } + if (entity.getMediaETag() != null) { + json.writeStringField("@odata.mediaEtag", entity.getMediaETag()); + } + if (entity.getMediaContentType() != null) { + json.writeStringField("@odata.mediaContentType", entity.getMediaContentType()); + } + for (final String propertyName : entityType.getPropertyNames()) { + json.writeFieldName(propertyName); + final EdmProperty edmProperty = (EdmProperty) entityType.getProperty(propertyName); + final Property property = entity.getProperty(propertyName); + if (property == null) { + if (edmProperty.isNullable() == Boolean.FALSE) { + throw new ODataRuntimeException("Non-nullable property not present!"); + } else { + json.writeNull(); + } + } else { + if (edmProperty.isPrimitive()) { + final EdmPrimitiveType type = (EdmPrimitiveType) edmProperty.getType(); + final String value = property.getValue().asPrimitive().get(); + if (type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Boolean)) { + json.writeBoolean(Boolean.parseBoolean(value)); + } else if (type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Byte) + || type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Decimal) + || type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Double) + || type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Int16) + || type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Int32) + || type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Int64) + || type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.SByte) + || type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Single)) { + json.writeNumber(value); + } else { + json.writeString(value); + } + } else { + throw new ODataRuntimeException("Non-primitive properties not yet supported!"); + } + } + } + json.writeEndObject(); + } + + @Override + public InputStream entitySet(final EdmEntitySet edmEntitySet, final EntitySet entitySet, + final ContextURL contextURL) { + CircleStreamBuffer buffer = new CircleStreamBuffer(); + try { + JsonGenerator json = new JsonFactory().createGenerator(buffer.getOutputStream()); + json.writeStartObject(); + if (contextURL != null) { + json.writeStringField(Constants.JSON_CONTEXT, contextURL.getURI().toASCIIString()); + } + if (entitySet.getCount() != null) { + json.writeNumberField("@odata.count", entitySet.getCount()); + } + json.writeFieldName(Constants.VALUE); + json.writeStartArray(); + for (Entity entity : entitySet.getEntities()) { + writeEntity(edmEntitySet.getEntityType(), entity, null, json); + } + json.writeEndArray(); + if (entitySet.getNext() != null) { + json.writeStringField("@odata.nextLink", entitySet.getNext().toASCIIString()); + } + json.close(); + } catch (final IOException e) { + throw new ODataRuntimeException(e); + } + return buffer.getInputStream(); + } } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bd9bf1e2/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataXmlSerializerImpl.java ---------------------------------------------------------------------- diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataXmlSerializerImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataXmlSerializerImpl.java index a8a943f..169f7a8 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataXmlSerializerImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataXmlSerializerImpl.java @@ -25,7 +25,12 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; import org.apache.olingo.commons.api.ODataRuntimeException; +import org.apache.olingo.commons.api.data.ContextURL; +import org.apache.olingo.commons.api.data.Entity; +import org.apache.olingo.commons.api.data.EntitySet; import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmEntitySet; +import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.server.api.serializer.ODataSerializer; import org.apache.olingo.server.core.serializer.utils.CircleStreamBuffer; import org.apache.olingo.server.core.serializer.xml.MetadataDocumentXmlSerializer; @@ -70,4 +75,14 @@ public class ODataXmlSerializerImpl implements ODataSerializer { } } + @Override + public InputStream entity(EdmEntityType edmEntityType, Entity entity, ContextURL contextURL) { + throw new ODataRuntimeException("Entity serialization not implemented for XML format"); + } + + @Override + public InputStream entitySet(EdmEntitySet edmEntitySet, EntitySet entitySet, ContextURL contextURL) { + throw new ODataRuntimeException("Entityset serialization not implemented for XML format"); + } + }
