You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2014/06/12 13:01:33 UTC
[6/9] [OLINGO-317] Rename and move of some packages and classes
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ODataClientImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ODataClientImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ODataClientImpl.java
index a0813eb..6da23bb 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ODataClientImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ODataClientImpl.java
@@ -25,9 +25,9 @@ import org.apache.olingo.client.api.communication.request.cud.v3.CUDRequestFacto
import org.apache.olingo.client.api.communication.request.cud.v3.UpdateType;
import org.apache.olingo.client.api.communication.request.invoke.InvokeRequestFactory;
import org.apache.olingo.client.api.communication.request.retrieve.v3.RetrieveRequestFactory;
-import org.apache.olingo.client.api.op.v3.ODataBinder;
-import org.apache.olingo.client.api.op.v3.ODataDeserializer;
-import org.apache.olingo.client.api.op.v3.ODataReader;
+import org.apache.olingo.client.api.serialization.v3.ODataBinder;
+import org.apache.olingo.client.api.serialization.v3.ODataDeserializer;
+import org.apache.olingo.client.api.serialization.v3.ODataReader;
import org.apache.olingo.client.api.uri.v3.FilterFactory;
import org.apache.olingo.client.api.uri.v3.URIBuilder;
import org.apache.olingo.client.api.v3.Configuration;
@@ -38,9 +38,9 @@ import org.apache.olingo.client.core.communication.request.batch.v3.BatchRequest
import org.apache.olingo.client.core.communication.request.cud.v3.CUDRequestFactoryImpl;
import org.apache.olingo.client.core.communication.request.invoke.v3.InvokeRequestFactoryImpl;
import org.apache.olingo.client.core.communication.request.retrieve.v3.RetrieveRequestFactoryImpl;
-import org.apache.olingo.client.core.op.impl.v3.ODataBinderImpl;
-import org.apache.olingo.client.core.op.impl.v3.ODataDeserializerImpl;
-import org.apache.olingo.client.core.op.impl.v3.ODataReaderImpl;
+import org.apache.olingo.client.core.serialization.v3.ODataBinderImpl;
+import org.apache.olingo.client.core.serialization.v3.ODataDeserializerImpl;
+import org.apache.olingo.client.core.serialization.v3.ODataReaderImpl;
import org.apache.olingo.client.core.uri.v3.FilterFactoryImpl;
import org.apache.olingo.client.core.uri.v3.URIBuilderImpl;
import org.apache.olingo.commons.api.domain.v3.ODataObjectFactory;
@@ -48,10 +48,10 @@ 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.op.ODataSerializer;
-import org.apache.olingo.commons.core.data.AtomSerializer;
-import org.apache.olingo.commons.core.data.JsonSerializer;
+import org.apache.olingo.commons.api.serialization.ODataSerializer;
import org.apache.olingo.commons.core.domain.v3.ODataObjectFactoryImpl;
+import org.apache.olingo.commons.core.serialization.AtomSerializer;
+import org.apache.olingo.commons.core.serialization.JsonSerializer;
public class ODataClientImpl extends AbstractODataClient<UpdateType> implements ODataClient {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ODataClientImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ODataClientImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ODataClientImpl.java
index 4907a0b..2ae30e2 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ODataClientImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ODataClientImpl.java
@@ -26,9 +26,9 @@ import org.apache.olingo.client.api.communication.request.cud.v4.UpdateType;
import org.apache.olingo.client.api.communication.request.invoke.InvokeRequestFactory;
import org.apache.olingo.client.api.communication.request.retrieve.v4.RetrieveRequestFactory;
import org.apache.olingo.client.api.communication.request.v4.AsyncRequestFactory;
-import org.apache.olingo.client.api.op.v4.ODataBinder;
-import org.apache.olingo.client.api.op.v4.ODataDeserializer;
-import org.apache.olingo.client.api.op.v4.ODataReader;
+import org.apache.olingo.client.api.serialization.v4.ODataBinder;
+import org.apache.olingo.client.api.serialization.v4.ODataDeserializer;
+import org.apache.olingo.client.api.serialization.v4.ODataReader;
import org.apache.olingo.client.api.uri.v4.FilterFactory;
import org.apache.olingo.client.api.uri.v4.SearchFactory;
import org.apache.olingo.client.api.uri.v4.URIBuilder;
@@ -41,9 +41,9 @@ import org.apache.olingo.client.core.communication.request.cud.v4.CUDRequestFact
import org.apache.olingo.client.core.communication.request.invoke.v4.InvokeRequestFactoryImpl;
import org.apache.olingo.client.core.communication.request.retrieve.v4.RetrieveRequestFactoryImpl;
import org.apache.olingo.client.core.communication.request.v4.AsyncRequestFactoryImpl;
-import org.apache.olingo.client.core.op.impl.v4.ODataBinderImpl;
-import org.apache.olingo.client.core.op.impl.v4.ODataDeserializerImpl;
-import org.apache.olingo.client.core.op.impl.v4.ODataReaderImpl;
+import org.apache.olingo.client.core.serialization.v4.ODataBinderImpl;
+import org.apache.olingo.client.core.serialization.v4.ODataDeserializerImpl;
+import org.apache.olingo.client.core.serialization.v4.ODataReaderImpl;
import org.apache.olingo.client.core.uri.v4.FilterFactoryImpl;
import org.apache.olingo.client.core.uri.v4.URIBuilderImpl;
import org.apache.olingo.commons.api.domain.v4.ODataObjectFactory;
@@ -51,10 +51,10 @@ 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.op.ODataSerializer;
-import org.apache.olingo.commons.core.data.AtomSerializer;
-import org.apache.olingo.commons.core.data.JsonSerializer;
+import org.apache.olingo.commons.api.serialization.ODataSerializer;
import org.apache.olingo.commons.core.domain.v4.ODataObjectFactoryImpl;
+import org.apache.olingo.commons.core.serialization.AtomSerializer;
+import org.apache.olingo.commons.core.serialization.JsonSerializer;
public class ODataClientImpl extends AbstractODataClient<UpdateType> implements ODataClient {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/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 dd5057d..d335232 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
@@ -31,7 +31,7 @@ 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.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
import org.junit.Test;
public class EntitySetTest extends AbstractTest {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/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 1d4a04f..faca1f6 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
@@ -37,7 +37,7 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.geo.Geospatial;
import org.apache.olingo.commons.api.edm.geo.GeospatialCollection;
import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
import org.junit.Test;
public class EntityTest extends AbstractTest {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/ErrorTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/ErrorTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/ErrorTest.java
index 1b340e9..bdccec8 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/ErrorTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/ErrorTest.java
@@ -24,7 +24,7 @@ import static org.junit.Assert.assertNotNull;
import org.apache.olingo.client.api.v3.ODataClient;
import org.apache.olingo.commons.api.domain.ODataError;
import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
import org.apache.olingo.client.core.AbstractTest;
import org.junit.Test;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PropertyTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PropertyTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PropertyTest.java
index b561f28..99c000a 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PropertyTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PropertyTest.java
@@ -37,8 +37,8 @@ import org.apache.olingo.commons.api.domain.v3.ODataProperty;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
-import org.apache.olingo.commons.api.op.ODataSerializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataSerializerException;
import org.junit.Test;
public class PropertyTest extends AbstractTest {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/ServiceDocumentTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/ServiceDocumentTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/ServiceDocumentTest.java
index b14c635..fab9b1f 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/ServiceDocumentTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/ServiceDocumentTest.java
@@ -21,7 +21,7 @@ package org.apache.olingo.client.core.v3;
import org.apache.olingo.client.api.v3.ODataClient;
import org.apache.olingo.commons.api.domain.ODataServiceDocument;
import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
import org.apache.olingo.client.core.AbstractTest;
import static org.junit.Assert.assertNotNull;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/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 453a8ab..651272e 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
@@ -33,7 +33,7 @@ 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;
import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
import org.junit.Test;
public class EntitySetTest extends AbstractTest {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/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 38cbd8d..ebfeb7d 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
@@ -44,7 +44,7 @@ import org.apache.olingo.commons.api.domain.v4.ODataValue;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
import org.apache.olingo.commons.core.edm.primitivetype.EdmDateTimeOffset;
import org.apache.olingo.commons.core.edm.primitivetype.EdmDuration;
import org.junit.Test;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ErrorTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ErrorTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ErrorTest.java
index b221ade..baf26e6 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ErrorTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ErrorTest.java
@@ -24,7 +24,7 @@ import static org.junit.Assert.assertNotNull;
import org.apache.olingo.client.api.v4.ODataClient;
import org.apache.olingo.commons.api.domain.ODataError;
import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
import org.apache.olingo.client.core.AbstractTest;
import org.junit.Test;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PropertyTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PropertyTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PropertyTest.java
index 1535355..c4355ed 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PropertyTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PropertyTest.java
@@ -32,8 +32,8 @@ import org.apache.olingo.commons.api.domain.ODataComplexValue;
import org.apache.olingo.commons.api.domain.v4.ODataProperty;
import org.apache.olingo.commons.api.domain.v4.ODataValue;
import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
-import org.apache.olingo.commons.api.op.ODataSerializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataSerializerException;
import org.junit.Test;
public class PropertyTest extends AbstractTest {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ServiceDocumentTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ServiceDocumentTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ServiceDocumentTest.java
index 403fbcf..fb298c7 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ServiceDocumentTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ServiceDocumentTest.java
@@ -28,7 +28,7 @@ import org.apache.olingo.client.api.data.ServiceDocument;
import org.apache.olingo.client.api.v4.ODataClient;
import org.apache.olingo.commons.api.domain.ODataServiceDocument;
import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
import org.apache.olingo.client.core.AbstractTest;
import org.apache.olingo.commons.api.data.ResWrap;
import org.junit.Test;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataDeserializer.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataDeserializer.java
deleted file mode 100755
index 9b6bd5a..0000000
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataDeserializer.java
+++ /dev/null
@@ -1,65 +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.op;
-
-import java.io.InputStream;
-
-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.ODataError;
-
-/**
- * Interface for de-serialization.
- */
-public interface ODataDeserializer {
-
- /**
- * Gets an entity set object from the given InputStream.
- *
- * @param input stream to be de-serialized.
- * @return {@link EntitySet} instance.
- */
- ResWrap<EntitySet> toEntitySet(InputStream input) throws ODataDeserializerException;
-
- /**
- * Gets an entity object from the given InputStream.
- *
- * @param input stream to be de-serialized.
- * @return {@link Entity} instance.
- */
- ResWrap<Entity> toEntity(InputStream input) throws ODataDeserializerException;
-
- /**
- * Gets a property object from the given InputStream.
- *
- * @param input stream to be de-serialized.
- * @return Property instance.
- */
- ResWrap<Property> toProperty(InputStream input) throws ODataDeserializerException;
-
- /**
- * Gets the ODataError object represented by the given InputStream.
- *
- * @param input stream to be parsed and de-serialized.
- * @return
- */
- ODataError toError(InputStream input) throws ODataDeserializerException;
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataDeserializerException.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataDeserializerException.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataDeserializerException.java
deleted file mode 100755
index 7852a5f..0000000
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataDeserializerException.java
+++ /dev/null
@@ -1,38 +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.op;
-
-import org.apache.olingo.commons.api.ODataException;
-
-public class ODataDeserializerException extends ODataException {
-
- private static final long serialVersionUID = -3236099963180859670L;
-
- public ODataDeserializerException(final String msg) {
- super(msg);
- }
-
- public ODataDeserializerException(final Throwable cause) {
- super(cause);
- }
-
- public ODataDeserializerException(final String msg, final Throwable cause) {
- super(msg, cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/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
deleted file mode 100644
index 6fc95da..0000000
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataSerializer.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.api.op;
-
-import java.io.Writer;
-
-import org.apache.olingo.commons.api.data.ResWrap;
-
-/**
- * Interface for serialization.
- */
-public interface ODataSerializer {
-
- public <T> void write(final Writer writer, final T obj) throws ODataSerializerException;
-
- public <T> void write(final Writer writer, final ResWrap<T> container) throws ODataSerializerException;
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataSerializerException.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataSerializerException.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataSerializerException.java
deleted file mode 100755
index 69b5c3f..0000000
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/op/ODataSerializerException.java
+++ /dev/null
@@ -1,38 +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.op;
-
-import org.apache.olingo.commons.api.ODataException;
-
-public class ODataSerializerException extends ODataException {
-
- private static final long serialVersionUID = -3236099963180859670L;
-
- public ODataSerializerException(final String msg) {
- super(msg);
- }
-
- public ODataSerializerException(final Throwable cause) {
- super(cause);
- }
-
- public ODataSerializerException(final String msg, final Throwable cause) {
- super(msg, cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializer.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializer.java
new file mode 100755
index 0000000..abadea6
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializer.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.api.serialization;
+
+import java.io.InputStream;
+
+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.ODataError;
+
+/**
+ * Interface for de-serialization.
+ */
+public interface ODataDeserializer {
+
+ /**
+ * Gets an entity set object from the given InputStream.
+ *
+ * @param input stream to be de-serialized.
+ * @return {@link EntitySet} instance.
+ */
+ ResWrap<EntitySet> toEntitySet(InputStream input) throws ODataDeserializerException;
+
+ /**
+ * Gets an entity object from the given InputStream.
+ *
+ * @param input stream to be de-serialized.
+ * @return {@link Entity} instance.
+ */
+ ResWrap<Entity> toEntity(InputStream input) throws ODataDeserializerException;
+
+ /**
+ * Gets a property object from the given InputStream.
+ *
+ * @param input stream to be de-serialized.
+ * @return Property instance.
+ */
+ ResWrap<Property> toProperty(InputStream input) throws ODataDeserializerException;
+
+ /**
+ * Gets the ODataError object represented by the given InputStream.
+ *
+ * @param input stream to be parsed and de-serialized.
+ * @return
+ */
+ ODataError toError(InputStream input) throws ODataDeserializerException;
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializerException.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializerException.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializerException.java
new file mode 100755
index 0000000..132635f
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializerException.java
@@ -0,0 +1,38 @@
+/*
+ * 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.serialization;
+
+import org.apache.olingo.commons.api.ODataException;
+
+public class ODataDeserializerException extends ODataException {
+
+ private static final long serialVersionUID = -3236099963180859670L;
+
+ public ODataDeserializerException(final String msg) {
+ super(msg);
+ }
+
+ public ODataDeserializerException(final Throwable cause) {
+ super(cause);
+ }
+
+ public ODataDeserializerException(final String msg, final Throwable cause) {
+ super(msg, cause);
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataSerializer.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataSerializer.java
new file mode 100644
index 0000000..d75b108
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataSerializer.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.api.serialization;
+
+import java.io.Writer;
+
+import org.apache.olingo.commons.api.data.ResWrap;
+
+/**
+ * Interface for serialization.
+ */
+public interface ODataSerializer {
+
+ public <T> void write(final Writer writer, final T obj) throws ODataSerializerException;
+
+ public <T> void write(final Writer writer, final ResWrap<T> container) throws ODataSerializerException;
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataSerializerException.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataSerializerException.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataSerializerException.java
new file mode 100755
index 0000000..fd241ee
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataSerializerException.java
@@ -0,0 +1,38 @@
+/*
+ * 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.serialization;
+
+import org.apache.olingo.commons.api.ODataException;
+
+public class ODataSerializerException extends ODataException {
+
+ private static final long serialVersionUID = -3236099963180859670L;
+
+ public ODataSerializerException(final String msg) {
+ super(msg);
+ }
+
+ public ODataSerializerException(final Throwable cause) {
+ super(cause);
+ }
+
+ public ODataSerializerException(final String msg, final Throwable cause) {
+ super(msg, cause);
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/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
deleted file mode 100644
index 9c3fec2..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractAtomDealer.java
+++ /dev/null
@@ -1,137 +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 javax.xml.XMLConstants;
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-
-abstract class AbstractAtomDealer {
-
- protected static final String TYPE_TEXT = "text";
-
- protected final ODataServiceVersion version;
-
- protected final QName etagQName;
-
- protected final QName metadataEtagQName;
-
- protected final QName inlineQName;
-
- protected final QName actionQName;
-
- protected final QName propertiesQName;
-
- protected final QName typeQName;
-
- protected final QName nullQName;
-
- protected final QName elementQName;
-
- protected final QName countQName;
-
- protected final QName uriQName;
-
- protected final QName nextQName;
-
- protected final QName annotationQName;
-
- protected final QName contextQName;
-
- protected final QName entryRefQName;
-
- protected final QName propertyValueQName;
-
- protected final QName deletedEntryQName;
-
- protected final QName reasonQName;
-
- protected final QName linkQName;
-
- protected final QName deletedLinkQName;
-
- protected final QName errorCodeQName;
-
- protected final QName errorMessageQName;
-
- protected final QName errorTargetQName;
-
- public AbstractAtomDealer(final ODataServiceVersion version) {
- this.version = version;
-
- this.etagQName =
- new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ATTR_ETAG);
- this.metadataEtagQName =
- new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ATTR_METADATAETAG);
- this.inlineQName =
- new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ELEM_INLINE);
- this.actionQName =
- new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ELEM_ACTION);
- this.propertiesQName =
- new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.PROPERTIES);
- this.typeQName = new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATTR_TYPE);
- this.nullQName = new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATTR_NULL);
- this.elementQName = version.compareTo(ODataServiceVersion.V40) < 0
- ? new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES), Constants.ELEM_ELEMENT)
- : new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ELEM_ELEMENT);
- this.countQName =
- new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ELEM_COUNT);
- this.uriQName =
- new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES), Constants.ELEM_URI);
- this.nextQName =
- new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES), Constants.NEXT_LINK_REL);
- this.annotationQName =
- new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ANNOTATION);
- this.contextQName =
- 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.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 =
- new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ERROR_MESSAGE);
- this.errorTargetQName =
- new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ERROR_TARGET);
- }
-
- protected void namespaces(final XMLStreamWriter writer) throws XMLStreamException {
- writer.writeNamespace(StringUtils.EMPTY, Constants.NS_ATOM);
- writer.writeNamespace(XMLConstants.XML_NS_PREFIX, XMLConstants.XML_NS_URI);
- writer.writeNamespace(Constants.PREFIX_METADATA, version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA));
- writer.writeNamespace(
- Constants.PREFIX_DATASERVICES, version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES));
- writer.writeNamespace(Constants.PREFIX_GML, Constants.NS_GML);
- writer.writeNamespace(Constants.PREFIX_GEORSS, Constants.NS_GEORSS);
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/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
deleted file mode 100644
index dec0028..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomDeserializer.java
+++ /dev/null
@@ -1,882 +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.io.InputStream;
-import java.net.URI;
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLEventReader;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.events.Attribute;
-import javax.xml.stream.events.StartElement;
-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.Annotation;
-import org.apache.olingo.commons.api.data.CollectionValue;
-import org.apache.olingo.commons.api.data.DeletedEntity.Reason;
-import org.apache.olingo.commons.api.data.Delta;
-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.Valuable;
-import org.apache.olingo.commons.api.data.Value;
-import org.apache.olingo.commons.api.data.v3.LinkCollection;
-import org.apache.olingo.commons.api.domain.ODataError;
-import org.apache.olingo.commons.api.domain.ODataOperation;
-import org.apache.olingo.commons.api.domain.ODataPropertyType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.commons.api.op.ODataDeserializer;
-import org.apache.olingo.commons.api.op.ODataDeserializerException;
-import org.apache.olingo.commons.core.data.v3.LinkCollectionImpl;
-import org.apache.olingo.commons.core.data.v4.DeltaImpl;
-import org.apache.olingo.commons.core.edm.EdmTypeInfo;
-
-import com.fasterxml.aalto.stax.InputFactoryImpl;
-
-public class AtomDeserializer extends AbstractAtomDealer implements ODataDeserializer {
-
- protected static final XMLInputFactory FACTORY = new InputFactoryImpl();
-
- private final AtomGeoValueDeserializer geoDeserializer;
-
- protected XMLEventReader getReader(final InputStream input) throws XMLStreamException {
- return FACTORY.createXMLEventReader(input);
- }
-
- public AtomDeserializer(final ODataServiceVersion version) {
- super(version);
- this.geoDeserializer = new AtomGeoValueDeserializer();
- }
-
- private Value fromPrimitive(final XMLEventReader reader, final StartElement start,
- final EdmTypeInfo typeInfo) throws XMLStreamException {
-
- Value value = null;
-
- boolean foundEndProperty = false;
- while (reader.hasNext() && !foundEndProperty) {
- final XMLEvent event = reader.nextEvent();
-
- if (event.isStartElement() && typeInfo != null && typeInfo.getPrimitiveTypeKind().isGeospatial()) {
- final EdmPrimitiveTypeKind geoType = EdmPrimitiveTypeKind.valueOfFQN(
- version, typeInfo.getFullQualifiedName().toString());
- value = new GeospatialValueImpl(this.geoDeserializer.deserialize(reader, event.asStartElement(), geoType));
- }
-
- if (event.isCharacters() && !event.asCharacters().isWhiteSpace()
- && (typeInfo == null || !typeInfo.getPrimitiveTypeKind().isGeospatial())) {
-
- value = new PrimitiveValueImpl(event.asCharacters().getData());
- }
-
- if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
- foundEndProperty = true;
- }
- }
-
- return value == null ? new PrimitiveValueImpl(StringUtils.EMPTY) : value;
- }
-
- private Value fromComplexOrEnum(final XMLEventReader reader, final StartElement start)
- throws XMLStreamException {
-
- Value value = null;
-
- boolean foundEndProperty = false;
- while (reader.hasNext() && !foundEndProperty) {
- final XMLEvent event = reader.nextEvent();
-
- if (event.isStartElement()) {
- if (value == null) {
- value = version.compareTo(ODataServiceVersion.V40) < 0
- ? new ComplexValueImpl()
- : new LinkedComplexValueImpl();
- }
-
- if (Constants.QNAME_ATOM_ELEM_LINK.equals(event.asStartElement().getName())) {
- final LinkImpl link = new LinkImpl();
- final Attribute rel = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REL));
- if (rel != null) {
- link.setRel(rel.getValue());
- }
- final Attribute title = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TITLE));
- if (title != null) {
- link.setTitle(title.getValue());
- }
- final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
- if (href != null) {
- link.setHref(href.getValue());
- }
- final Attribute type = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TYPE));
- if (type != null) {
- link.setType(type.getValue());
- }
-
- if (link.getRel().startsWith(
- version.getNamespaceMap().get(ODataServiceVersion.NAVIGATION_LINK_REL))) {
-
- value.asLinkedComplex().getNavigationLinks().add(link);
- inline(reader, event.asStartElement(), link);
- } else if (link.getRel().startsWith(
- version.getNamespaceMap().get(ODataServiceVersion.ASSOCIATION_LINK_REL))) {
-
- value.asLinkedComplex().getAssociationLinks().add(link);
- }
- } else {
- value.asComplex().get().add(property(reader, event.asStartElement()));
- }
- }
-
- if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
- value = new EnumValueImpl(event.asCharacters().getData());
- }
-
- if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
- foundEndProperty = true;
- }
- }
-
- return value;
- }
-
- private CollectionValue fromCollection(final XMLEventReader reader, final StartElement start,
- final EdmTypeInfo typeInfo) throws XMLStreamException {
-
- final CollectionValueImpl value = new CollectionValueImpl();
-
- final EdmTypeInfo type = typeInfo == null
- ? null
- : new EdmTypeInfo.Builder().setTypeExpression(typeInfo.getFullQualifiedName().toString()).build();
-
- boolean foundEndProperty = false;
- while (reader.hasNext() && !foundEndProperty) {
- final XMLEvent event = reader.nextEvent();
-
- if (event.isStartElement()) {
- switch (guessPropertyType(reader, typeInfo)) {
- case COMPLEX:
- case ENUM:
- value.get().add(fromComplexOrEnum(reader, event.asStartElement()));
- break;
-
- case PRIMITIVE:
- value.get().add(fromPrimitive(reader, event.asStartElement(), type));
- break;
-
- default:
- // do not add null or empty values
- }
- }
-
- if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
- foundEndProperty = true;
- }
- }
-
- return value;
- }
-
- private ODataPropertyType guessPropertyType(final XMLEventReader reader, final EdmTypeInfo typeInfo)
- throws XMLStreamException {
-
- XMLEvent child = null;
- while (reader.hasNext() && child == null) {
- final XMLEvent event = reader.peek();
- if (event.isCharacters() && event.asCharacters().isWhiteSpace()) {
- reader.nextEvent();
- } else {
- child = event;
- }
- }
-
- final ODataPropertyType type;
- if (child == null) {
- type = typeInfo == null || typeInfo.isPrimitiveType()
- ? ODataPropertyType.PRIMITIVE
- : ODataPropertyType.ENUM;
- } else {
- if (child.isStartElement()) {
- if (Constants.NS_GML.equals(child.asStartElement().getName().getNamespaceURI())) {
- type = ODataPropertyType.PRIMITIVE;
- } else if (elementQName.equals(child.asStartElement().getName())) {
- type = ODataPropertyType.COLLECTION;
- } else {
- type = ODataPropertyType.COMPLEX;
- }
- } else if (child.isCharacters()) {
- type = typeInfo == null || typeInfo.isPrimitiveType()
- ? ODataPropertyType.PRIMITIVE
- : ODataPropertyType.ENUM;
- } else {
- type = ODataPropertyType.EMPTY;
- }
- }
-
- return type;
- }
-
- private Property property(final XMLEventReader reader, final StartElement start)
- throws XMLStreamException {
-
- final PropertyImpl property = new PropertyImpl();
-
- if (ODataServiceVersion.V40 == version && propertyValueQName.equals(start.getName())) {
- // retrieve name from context
- final Attribute context = start.getAttributeByName(contextQName);
- if (context != null) {
- property.setName(StringUtils.substringAfterLast(context.getValue(), "/"));
- }
- } else {
- property.setName(start.getName().getLocalPart());
- }
-
- valuable(property, reader, start);
-
- return property;
- }
-
- private void valuable(final Valuable valuable, final XMLEventReader reader, final StartElement start)
- throws XMLStreamException {
-
- final Attribute nullAttr = start.getAttributeByName(this.nullQName);
-
- Value value;
- if (nullAttr == null) {
- final Attribute typeAttr = start.getAttributeByName(this.typeQName);
- final String typeAttrValue = typeAttr == null ? null : typeAttr.getValue();
-
- final EdmTypeInfo typeInfo = StringUtils.isBlank(typeAttrValue)
- ? null
- : new EdmTypeInfo.Builder().setTypeExpression(typeAttrValue).build();
-
- if (typeInfo != null) {
- valuable.setType(typeInfo.internal());
- }
-
- final ODataPropertyType propType = typeInfo == null
- ? guessPropertyType(reader, typeInfo)
- : typeInfo.isCollection()
- ? ODataPropertyType.COLLECTION
- : typeInfo.isPrimitiveType()
- ? ODataPropertyType.PRIMITIVE
- : ODataPropertyType.COMPLEX;
-
- switch (propType) {
- case COLLECTION:
- value = fromCollection(reader, start, typeInfo);
- break;
-
- case COMPLEX:
- value = fromComplexOrEnum(reader, start);
- break;
-
- case PRIMITIVE:
- // No type specified? Defaults to Edm.String
- if (typeInfo == null) {
- valuable.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName().toString());
- }
- value = fromPrimitive(reader, start, typeInfo);
- break;
-
- case EMPTY:
- default:
- value = new PrimitiveValueImpl(StringUtils.EMPTY);
- }
- } else {
- value = new NullValueImpl();
- }
-
- valuable.setValue(value);
- }
-
- @Override
- public ResWrap<Property> toProperty(final InputStream input) throws ODataDeserializerException {
- try {
- final XMLEventReader reader = getReader(input);
- final StartElement start = skipBeforeFirstStartElement(reader);
- return getContainer(start, property(reader, start));
- } catch (XMLStreamException e) {
- throw new ODataDeserializerException(e);
- }
- }
-
- private StartElement skipBeforeFirstStartElement(final XMLEventReader reader) throws XMLStreamException {
- StartElement startEvent = null;
- while (reader.hasNext() && startEvent == null) {
- final XMLEvent event = reader.nextEvent();
- if (event.isStartElement()) {
- startEvent = event.asStartElement();
- }
- }
- if (startEvent == null) {
- throw new IllegalArgumentException("Cannot find any XML start element");
- }
-
- return startEvent;
- }
-
- private void common(final XMLEventReader reader, final StartElement start,
- final AbstractODataObject object, final String key) throws XMLStreamException {
-
- boolean foundEndElement = false;
- while (reader.hasNext() && !foundEndElement) {
- final XMLEvent event = reader.nextEvent();
-
- if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
- try {
- object.setCommonProperty(key, event.asCharacters().getData());
- } catch (ParseException e) {
- throw new XMLStreamException("While parsing Atom entry or feed common elements", e);
- }
- }
-
- if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
- foundEndElement = true;
- }
- }
- }
-
- private void inline(final XMLEventReader reader, final StartElement start, final LinkImpl link)
- throws XMLStreamException {
-
- boolean foundEndElement = false;
- while (reader.hasNext() && !foundEndElement) {
- final XMLEvent event = reader.nextEvent();
-
- if (event.isStartElement()) {
- if (inlineQName.equals(event.asStartElement().getName())) {
- StartElement inline = null;
- while (reader.hasNext() && inline == null) {
- final XMLEvent innerEvent = reader.peek();
- if (innerEvent.isCharacters() && innerEvent.asCharacters().isWhiteSpace()) {
- reader.nextEvent();
- } else if (innerEvent.isStartElement()) {
- inline = innerEvent.asStartElement();
- }
- }
- if (inline != null) {
- if (Constants.QNAME_ATOM_ELEM_ENTRY.equals(inline.getName())) {
- link.setInlineEntity(entity(reader, inline));
- }
- if (Constants.QNAME_ATOM_ELEM_FEED.equals(inline.getName())) {
- link.setInlineEntitySet(entitySet(reader, inline));
- }
- }
- } else if (annotationQName.equals(event.asStartElement().getName())) {
- link.getAnnotations().add(annotation(reader, event.asStartElement()));
- }
- }
-
- if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
- foundEndElement = true;
- }
- }
- }
-
- public ResWrap<Delta> delta(final InputStream input) throws XMLStreamException {
- final XMLEventReader reader = getReader(input);
- final StartElement start = skipBeforeFirstStartElement(reader);
- return getContainer(start, delta(reader, start));
- }
-
- private Delta delta(final XMLEventReader reader, final StartElement start) throws XMLStreamException {
- if (!Constants.QNAME_ATOM_ELEM_FEED.equals(start.getName())) {
- return null;
- }
- final DeltaImpl delta = new DeltaImpl();
- 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(URI.create(ref.getValue()));
- }
- final Attribute reason = event.asStartElement().getAttributeByName(reasonQName);
- if (reason != null) {
- deletedEntity.setReason(Reason.valueOf(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;
- }
-
- public ResWrap<LinkCollection> linkCollection(final InputStream input) throws XMLStreamException {
- final XMLEventReader reader = getReader(input);
- final StartElement start = skipBeforeFirstStartElement(reader);
- return getContainer(start, linkCollection(reader, start));
- }
-
- private LinkCollection linkCollection(final XMLEventReader reader, final StartElement start)
- throws XMLStreamException {
-
- final LinkCollectionImpl linkCollection = new LinkCollectionImpl();
-
- boolean isURI = false;
- boolean isNext = false;
- while (reader.hasNext()) {
- final XMLEvent event = reader.nextEvent();
- if (event.isStartElement()) {
- isURI = uriQName.equals(event.asStartElement().getName());
- isNext = nextQName.equals(event.asStartElement().getName());
- }
-
- if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
- if (isURI) {
- linkCollection.getLinks().add(URI.create(event.asCharacters().getData()));
- isURI = false;
- } else if (isNext) {
- linkCollection.setNext(URI.create(event.asCharacters().getData()));
- isNext = false;
- }
- }
- }
-
- return linkCollection;
- }
-
- private void properties(final XMLEventReader reader, final StartElement start, final EntityImpl entity)
- throws XMLStreamException {
-
- final Map<String, List<Annotation>> annotations = new HashMap<String, List<Annotation>>();
-
- boolean foundEndProperties = false;
- while (reader.hasNext() && !foundEndProperties) {
- final XMLEvent event = reader.nextEvent();
-
- if (event.isStartElement()) {
- if (annotationQName.equals(event.asStartElement().getName())) {
- final String target = event.asStartElement().
- getAttributeByName(QName.valueOf(Constants.ATTR_TARGET)).getValue();
- if (!annotations.containsKey(target)) {
- annotations.put(target, new ArrayList<Annotation>());
- }
- annotations.get(target).add(annotation(reader, event.asStartElement()));
- } else {
- entity.getProperties().add(property(reader, event.asStartElement()));
- }
- }
-
- if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
- foundEndProperties = true;
- }
- }
-
- for (Property property : entity.getProperties()) {
- if (annotations.containsKey(property.getName())) {
- property.getAnnotations().addAll(annotations.get(property.getName()));
- }
- }
- }
-
- private Annotation annotation(final XMLEventReader reader, final StartElement start)
- throws XMLStreamException {
-
- final Annotation annotation = new AnnotationImpl();
-
- annotation.setTerm(start.getAttributeByName(QName.valueOf(Constants.ATOM_ATTR_TERM)).getValue());
- valuable(annotation, reader, start);
-
- return annotation;
- }
-
- private EntityImpl entityRef(final StartElement start) throws XMLStreamException {
- final EntityImpl entity = new EntityImpl();
-
- final Attribute entityRefId = start.getAttributeByName(Constants.QNAME_ATOM_ATTR_ID);
- if (entityRefId != null) {
- entity.setId(URI.create(entityRefId.getValue()));
- }
-
- return entity;
- }
-
- private Entity entity(final XMLEventReader reader, final StartElement start) throws XMLStreamException {
- final EntityImpl entity;
- if (entryRefQName.equals(start.getName())) {
- entity = entityRef(start);
- } else if (Constants.QNAME_ATOM_ELEM_ENTRY.equals(start.getName())) {
- entity = new EntityImpl();
- final Attribute xmlBase = start.getAttributeByName(Constants.QNAME_ATTR_XML_BASE);
- if (xmlBase != null) {
- entity.setBaseURI(xmlBase.getValue());
- }
-
- final Attribute etag = start.getAttributeByName(etagQName);
- if (etag != null) {
- entity.setETag(etag.getValue());
- }
-
- boolean foundEndEntry = false;
- while (reader.hasNext() && !foundEndEntry) {
- final XMLEvent event = reader.nextEvent();
-
- if (event.isStartElement()) {
- if (Constants.QNAME_ATOM_ELEM_ID.equals(event.asStartElement().getName())) {
- common(reader, event.asStartElement(), entity, "id");
- } else if (Constants.QNAME_ATOM_ELEM_TITLE.equals(event.asStartElement().getName())) {
- common(reader, event.asStartElement(), entity, "title");
- } else if (Constants.QNAME_ATOM_ELEM_SUMMARY.equals(event.asStartElement().getName())) {
- common(reader, event.asStartElement(), entity, "summary");
- } else if (Constants.QNAME_ATOM_ELEM_UPDATED.equals(event.asStartElement().getName())) {
- 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) {
- 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();
- final Attribute rel = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REL));
- if (rel != null) {
- link.setRel(rel.getValue());
- }
- final Attribute title = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TITLE));
- if (title != null) {
- link.setTitle(title.getValue());
- }
- final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
- if (href != null) {
- link.setHref(href.getValue());
- }
- final Attribute type = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TYPE));
- if (type != null) {
- link.setType(type.getValue());
- }
-
- if (Constants.SELF_LINK_REL.equals(link.getRel())) {
- entity.setSelfLink(link);
- } else if (Constants.EDIT_LINK_REL.equals(link.getRel())) {
- entity.setEditLink(link);
- } else if (Constants.EDITMEDIA_LINK_REL.equals(link.getRel())) {
- final Attribute mediaETag = event.asStartElement().getAttributeByName(etagQName);
- if (mediaETag != null) {
- entity.setMediaETag(mediaETag.getValue());
- }
- } else if (link.getRel().startsWith(
- version.getNamespaceMap().get(ODataServiceVersion.NAVIGATION_LINK_REL))) {
-
- entity.getNavigationLinks().add(link);
- inline(reader, event.asStartElement(), link);
- } else if (link.getRel().startsWith(
- version.getNamespaceMap().get(ODataServiceVersion.ASSOCIATION_LINK_REL))) {
-
- entity.getAssociationLinks().add(link);
- } else if (link.getRel().startsWith(
- version.getNamespaceMap().get(ODataServiceVersion.MEDIA_EDIT_LINK_REL))) {
-
- final Attribute metag = event.asStartElement().getAttributeByName(etagQName);
- if (metag != null) {
- link.setMediaETag(metag.getValue());
- }
- entity.getMediaEditLinks().add(link);
- }
- } else if (actionQName.equals(event.asStartElement().getName())) {
- final ODataOperation operation = new ODataOperation();
- final Attribute metadata =
- event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_METADATA));
- if (metadata != null) {
- operation.setMetadataAnchor(metadata.getValue());
- }
- final Attribute title = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TITLE));
- if (title != null) {
- operation.setTitle(title.getValue());
- }
- final Attribute target = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TARGET));
- if (target != null) {
- operation.setTarget(URI.create(target.getValue()));
- }
-
- 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), entity);
- } else {
- entity.setMediaContentType(type.getValue());
- final Attribute src = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATOM_ATTR_SRC));
- if (src != null) {
- entity.setMediaContentSource(URI.create(src.getValue()));
- }
- }
- } else if (propertiesQName.equals(event.asStartElement().getName())) {
- properties(reader, event.asStartElement(), entity);
- } else if (annotationQName.equals(event.asStartElement().getName())) {
- entity.getAnnotations().add(annotation(reader, event.asStartElement()));
- }
- }
-
- if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
- foundEndEntry = true;
- }
- }
- } else {
- entity = null;
- }
-
- return entity;
- }
-
- @Override
- public ResWrap<Entity> toEntity(final InputStream input) throws ODataDeserializerException {
- try {
- final XMLEventReader reader = getReader(input);
- final StartElement start = skipBeforeFirstStartElement(reader);
- return getContainer(start, entity(reader, start));
- } catch (XMLStreamException e) {
- throw new ODataDeserializerException(e);
- }
- }
-
- private void count(final XMLEventReader reader, final StartElement start, final EntitySet entitySet)
- throws XMLStreamException {
-
- boolean foundEndElement = false;
- while (reader.hasNext() && !foundEndElement) {
- final XMLEvent event = reader.nextEvent();
-
- if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
- entitySet.setCount(Integer.valueOf(event.asCharacters().getData()));
- }
-
- if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
- foundEndElement = true;
- }
- }
- }
-
- private EntitySet entitySet(final XMLEventReader reader, final StartElement start) throws XMLStreamException {
- if (!Constants.QNAME_ATOM_ELEM_FEED.equals(start.getName())) {
- return null;
- }
- final EntitySetImpl entitySet = new EntitySetImpl();
- final Attribute xmlBase = start.getAttributeByName(Constants.QNAME_ATTR_XML_BASE);
- if (xmlBase != null) {
- entitySet.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(), entitySet);
- } else if (Constants.QNAME_ATOM_ELEM_ID.equals(event.asStartElement().getName())) {
- common(reader, event.asStartElement(), entitySet, "id");
- } else if (Constants.QNAME_ATOM_ELEM_TITLE.equals(event.asStartElement().getName())) {
- common(reader, event.asStartElement(), entitySet, "title");
- } else if (Constants.QNAME_ATOM_ELEM_SUMMARY.equals(event.asStartElement().getName())) {
- common(reader, event.asStartElement(), entitySet, "summary");
- } else if (Constants.QNAME_ATOM_ELEM_UPDATED.equals(event.asStartElement().getName())) {
- 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) {
- if (Constants.NEXT_LINK_REL.equals(rel.getValue())) {
- final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
- if (href != null) {
- entitySet.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) {
- entitySet.setDeltaLink(URI.create(href.getValue()));
- }
- }
- }
- } else if (Constants.QNAME_ATOM_ELEM_ENTRY.equals(event.asStartElement().getName())) {
- entitySet.getEntities().add(entity(reader, event.asStartElement()));
- } else if (entryRefQName.equals(event.asStartElement().getName())) {
- entitySet.getEntities().add(entityRef(event.asStartElement()));
- } else if (annotationQName.equals(event.asStartElement().getName())) {
- entitySet.getAnnotations().add(annotation(reader, event.asStartElement()));
- }
- }
-
- if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
- foundEndFeed = true;
- }
- }
-
- return entitySet;
- }
-
- @Override
- public ResWrap<EntitySet> toEntitySet(final InputStream input) throws ODataDeserializerException {
- try {
- final XMLEventReader reader = getReader(input);
- final StartElement start = skipBeforeFirstStartElement(reader);
- return getContainer(start, entitySet(reader, start));
- } catch (XMLStreamException e) {
- throw new ODataDeserializerException(e);
- }
- }
-
- private ODataError error(final XMLEventReader reader, final StartElement start) throws XMLStreamException {
- final ODataErrorImpl error = new ODataErrorImpl();
-
- boolean setCode = false;
- boolean codeSet = false;
- boolean setMessage = false;
- boolean messageSet = false;
- boolean setTarget = false;
- boolean targetSet = false;
-
- boolean foundEndElement = false;
- while (reader.hasNext() && !foundEndElement) {
- final XMLEvent event = reader.nextEvent();
-
- if (event.isStartElement()) {
- if (errorCodeQName.equals(event.asStartElement().getName())) {
- setCode = true;
- } else if (errorMessageQName.equals(event.asStartElement().getName())) {
- setMessage = true;
- } else if (errorTargetQName.equals(event.asStartElement().getName())) {
- setTarget = true;
- }
- }
-
- if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
- if (setCode && !codeSet) {
- error.setCode(event.asCharacters().getData());
- setCode = false;
- codeSet = true;
- }
- if (setMessage && !messageSet) {
- error.setMessage(event.asCharacters().getData());
- setMessage = false;
- messageSet = true;
- }
- if (setTarget && !targetSet) {
- error.setTarget(event.asCharacters().getData());
- setTarget = false;
- targetSet = true;
- }
- }
-
- if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
- foundEndElement = true;
- }
- }
-
- return error;
- }
-
- @Override
- public ODataError toError(final InputStream input) throws ODataDeserializerException {
- try {
- final XMLEventReader reader = getReader(input);
- final StartElement start = skipBeforeFirstStartElement(reader);
- return error(reader, start);
- } catch (XMLStreamException e) {
- throw new ODataDeserializerException(e);
- }
- }
-
- private <T> ResWrap<T> getContainer(final StartElement start, final T object) {
- final Attribute context = start.getAttributeByName(contextQName);
- final Attribute metadataETag = start.getAttributeByName(metadataEtagQName);
-
- return new ResWrap<T>(
- context == null ? null : URI.create(context.getValue()),
- metadataETag == null ? null : metadataETag.getValue(),
- object);
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b15439ff/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomGeoValueDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomGeoValueDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomGeoValueDeserializer.java
deleted file mode 100644
index 41a129f..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomGeoValueDeserializer.java
+++ /dev/null
@@ -1,267 +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.Collections;
-import java.util.List;
-import javax.xml.stream.XMLEventReader;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.events.Attribute;
-import javax.xml.stream.events.StartElement;
-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.GeoUtils;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.geo.Geospatial;
-import org.apache.olingo.commons.api.edm.geo.GeospatialCollection;
-import org.apache.olingo.commons.api.edm.geo.LineString;
-import org.apache.olingo.commons.api.edm.geo.MultiLineString;
-import org.apache.olingo.commons.api.edm.geo.MultiPoint;
-import org.apache.olingo.commons.api.edm.geo.MultiPolygon;
-import org.apache.olingo.commons.api.edm.geo.Point;
-import org.apache.olingo.commons.api.edm.geo.Polygon;
-import org.apache.olingo.commons.api.edm.geo.SRID;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmDouble;
-
-class AtomGeoValueDeserializer {
-
- private List<Point> points(final XMLEventReader reader, final StartElement start,
- final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
-
- final List<Point> result = new ArrayList<Point>();
-
- boolean foundEndProperty = false;
- while (reader.hasNext() && !foundEndProperty) {
- final XMLEvent event = reader.nextEvent();
-
- if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
- final String[] pointInfo = event.asCharacters().getData().split(" ");
-
- final Point point = new Point(GeoUtils.getDimension(type), srid);
- try {
- point.setX(EdmDouble.getInstance().valueOfString(pointInfo[0], null, null,
- Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, Double.class));
- point.setY(EdmDouble.getInstance().valueOfString(pointInfo[1], null, null,
- Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, Double.class));
- } catch (EdmPrimitiveTypeException e) {
- throw new XMLStreamException("While deserializing point coordinates as double", e);
- }
- result.add(point);
- }
-
- if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
- foundEndProperty = true;
- }
- }
-
- // handles bad input, e.g. things like <gml:pos/>
- if (result.isEmpty()) {
- result.add(new Point(GeoUtils.getDimension(type), srid));
- }
-
- return result;
- }
-
- private MultiPoint multipoint(final XMLEventReader reader, final StartElement start,
- final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
-
- List<Point> points = Collections.<Point>emptyList();
-
- boolean foundEndProperty = false;
- while (reader.hasNext() && !foundEndProperty) {
- final XMLEvent event = reader.nextEvent();
-
- if (event.isStartElement() && event.asStartElement().getName().equals(Constants.QNAME_POINTMEMBERS)) {
- points = points(reader, event.asStartElement(), type, null);
- }
-
- if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
- foundEndProperty = true;
- }
- }
-
- return new MultiPoint(GeoUtils.getDimension(type), srid, points);
- }
-
- private LineString lineString(final XMLEventReader reader, final StartElement start,
- final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
-
- return new LineString(GeoUtils.getDimension(type), srid, points(reader, start, type, null));
- }
-
- private Polygon polygon(final XMLEventReader reader, final StartElement start,
- final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
-
- List<Point> extPoints = null;
- List<Point> intPoints = null;
-
- boolean foundEndProperty = false;
- while (reader.hasNext() && !foundEndProperty) {
- final XMLEvent event = reader.nextEvent();
-
- if (event.isStartElement()) {
- if (event.asStartElement().getName().equals(Constants.QNAME_POLYGON_EXTERIOR)) {
- extPoints = points(reader, event.asStartElement(), type, null);
- }
- if (event.asStartElement().getName().equals(Constants.QNAME_POLYGON_INTERIOR)) {
- intPoints = points(reader, event.asStartElement(), type, null);
- }
- }
-
- if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
- foundEndProperty = true;
- }
- }
-
- return new Polygon(GeoUtils.getDimension(type), srid, intPoints, extPoints);
- }
-
- private MultiLineString multiLineString(final XMLEventReader reader, final StartElement start,
- final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
-
- final List<LineString> lineStrings = new ArrayList<LineString>();
-
- boolean foundEndProperty = false;
- while (reader.hasNext() && !foundEndProperty) {
- final XMLEvent event = reader.nextEvent();
-
- if (event.isStartElement() && event.asStartElement().getName().equals(Constants.QNAME_LINESTRING)) {
- lineStrings.add(lineString(reader, event.asStartElement(), type, null));
- }
-
- if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
- foundEndProperty = true;
- }
- }
-
- return new MultiLineString(GeoUtils.getDimension(type), srid, lineStrings);
- }
-
- private MultiPolygon multiPolygon(final XMLEventReader reader, final StartElement start,
- final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
-
- final List<Polygon> polygons = new ArrayList<Polygon>();
-
- boolean foundEndProperty = false;
- while (reader.hasNext() && !foundEndProperty) {
- final XMLEvent event = reader.nextEvent();
-
- if (event.isStartElement() && event.asStartElement().getName().equals(Constants.QNAME_POLYGON)) {
- polygons.add(polygon(reader, event.asStartElement(), type, null));
- }
-
- if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
- foundEndProperty = true;
- }
- }
-
- return new MultiPolygon(GeoUtils.getDimension(type), srid, polygons);
- }
-
- private GeospatialCollection collection(final XMLEventReader reader, final StartElement start,
- final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException {
-
- final List<Geospatial> geospatials = new ArrayList<Geospatial>();
-
- boolean foundEndCollection = false;
- while (reader.hasNext() && !foundEndCollection) {
- final XMLEvent event = reader.nextEvent();
-
- if (event.isStartElement() && event.asStartElement().getName().equals(Constants.QNAME_GEOMEMBERS)) {
- boolean foundEndMembers = false;
- while (reader.hasNext() && !foundEndMembers) {
- final XMLEvent subevent = reader.nextEvent();
-
- if (subevent.isStartElement()) {
- geospatials.add(deserialize(reader, subevent.asStartElement(),
- GeoUtils.getType(GeoUtils.getDimension(type), subevent.asStartElement().getName().getLocalPart())));
- }
-
- if (subevent.isEndElement() && Constants.QNAME_GEOMEMBERS.equals(subevent.asEndElement().getName())) {
- foundEndMembers = true;
- }
- }
- }
-
- if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
- foundEndCollection = true;
- }
- }
-
- return new GeospatialCollection(GeoUtils.getDimension(type), srid, geospatials);
- }
-
- public Geospatial deserialize(final XMLEventReader reader, final StartElement start,
- final EdmPrimitiveTypeKind type) throws XMLStreamException {
-
- SRID srid = null;
- final Attribute srsName = start.getAttributeByName(Constants.QNAME_ATTR_SRSNAME);
- if (srsName != null) {
- srid = SRID.valueOf(StringUtils.substringAfterLast(srsName.getValue(), "/"));
- }
-
- Geospatial value;
-
- switch (type) {
- case GeographyPoint:
- case GeometryPoint:
- value = points(reader, start, type, srid).get(0);
- break;
-
- case GeographyMultiPoint:
- case GeometryMultiPoint:
- value = multipoint(reader, start, type, srid);
- break;
-
- case GeographyLineString:
- case GeometryLineString:
- value = lineString(reader, start, type, srid);
- break;
-
- case GeographyMultiLineString:
- case GeometryMultiLineString:
- value = multiLineString(reader, start, type, srid);
- break;
-
- case GeographyPolygon:
- case GeometryPolygon:
- value = polygon(reader, start, type, srid);
- break;
-
- case GeographyMultiPolygon:
- case GeometryMultiPolygon:
- value = multiPolygon(reader, start, type, srid);
- break;
-
- case GeographyCollection:
- case GeometryCollection:
- value = collection(reader, start, type, srid);
- break;
-
- default:
- value = null;
- }
-
- return value;
- }
-
-}