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/24 10:16:49 UTC
[1/8] [OLINGO-317] Merged the format ENUMs
Repository: olingo-odata4
Updated Branches:
refs/heads/master 1e8ad44a0 -> ce3598521
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataDeserializerImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataDeserializerImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataDeserializerImpl.java
index f0d4149..7706d93 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataDeserializerImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataDeserializerImpl.java
@@ -33,18 +33,16 @@ import org.apache.olingo.client.core.serialization.AbstractODataDeserializer;
import org.apache.olingo.commons.api.data.Delta;
import org.apache.olingo.commons.api.data.ResWrap;
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.serialization.ODataDeserializerException;
import org.apache.olingo.commons.core.serialization.AtomDeserializer;
import org.apache.olingo.commons.core.serialization.JsonDeltaDeserializer;
public class ODataDeserializerImpl extends AbstractODataDeserializer implements ODataDeserializer {
- private final Format format;
+ private final ODataFormat format;
- public ODataDeserializerImpl(final ODataServiceVersion version, final boolean serverMode, final Format format) {
+ public ODataDeserializerImpl(final ODataServiceVersion version, final boolean serverMode, final ODataFormat format) {
super(version, serverMode, format);
this.format = format;
}
@@ -68,7 +66,7 @@ public class ODataDeserializerImpl extends AbstractODataDeserializer implements
@Override
public ResWrap<Delta> toDelta(final InputStream input) throws ODataDeserializerException {
try {
- return format == ODataPubFormat.ATOM ?
+ return format == ODataFormat.ATOM ?
new AtomDeserializer(version).delta(input) :
new JsonDeltaDeserializer(version, false).toDelta(input);
} catch (XMLStreamException e) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataReaderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataReaderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataReaderImpl.java
index c6528f8..795108b 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataReaderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataReaderImpl.java
@@ -27,7 +27,6 @@ import org.apache.olingo.commons.api.domain.v4.ODataEntity;
import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
import org.apache.olingo.commons.api.domain.v4.ODataProperty;
import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
public class ODataReaderImpl extends AbstractODataReader implements ODataReader {
@@ -37,13 +36,13 @@ public class ODataReaderImpl extends AbstractODataReader implements ODataReader
}
@Override
- public ODataEntitySet readEntitySet(final InputStream input, final ODataPubFormat format)
+ public ODataEntitySet readEntitySet(final InputStream input, final ODataFormat format)
throws ODataDeserializerException {
return ((ODataClient) client).getBinder().getODataEntitySet(client.getDeserializer(format).toEntitySet(input));
}
@Override
- public ODataEntity readEntity(final InputStream input, final ODataPubFormat format)
+ public ODataEntity readEntity(final InputStream input, final ODataFormat format)
throws ODataDeserializerException {
return ((ODataClient) client).getBinder().getODataEntity(client.getDeserializer(format).toEntity(input));
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/v3/URIBuilderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/v3/URIBuilderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/v3/URIBuilderImpl.java
index 4092b02..1d23167 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/v3/URIBuilderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/v3/URIBuilderImpl.java
@@ -19,7 +19,7 @@
package org.apache.olingo.client.core.uri.v3;
import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.client.api.v3.Configuration;
+import org.apache.olingo.client.api.CommonConfiguration;
import org.apache.olingo.client.api.uri.QueryOption;
import org.apache.olingo.client.api.uri.SegmentType;
import org.apache.olingo.client.api.uri.v3.URIBuilder;
@@ -28,15 +28,9 @@ import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
public class URIBuilderImpl extends AbstractURIBuilder<URIBuilder> implements URIBuilder {
- private static final long serialVersionUID = -3506851722447870532L;
-
- private final ODataServiceVersion version;
-
public URIBuilderImpl(
- final ODataServiceVersion version, final Configuration configuration, final String serviceRoot) {
-
+ final ODataServiceVersion version, final CommonConfiguration configuration, final String serviceRoot) {
super(version, configuration, serviceRoot);
- this.version = version;
}
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/v4/URIBuilderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/v4/URIBuilderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/v4/URIBuilderImpl.java
index 62bff9f..f5ab420 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/v4/URIBuilderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/v4/URIBuilderImpl.java
@@ -20,24 +20,22 @@ package org.apache.olingo.client.core.uri.v4;
import java.util.LinkedHashMap;
import java.util.Map;
+
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
+import org.apache.olingo.client.api.CommonConfiguration;
import org.apache.olingo.client.api.uri.QueryOption;
import org.apache.olingo.client.api.uri.SegmentType;
import org.apache.olingo.client.api.uri.v4.URIBuilder;
import org.apache.olingo.client.api.uri.v4.URISearch;
-import org.apache.olingo.client.api.v4.Configuration;
import org.apache.olingo.client.core.uri.AbstractURIBuilder;
import org.apache.olingo.commons.api.edm.EdmEnumType;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
public class URIBuilderImpl extends AbstractURIBuilder<URIBuilder> implements URIBuilder {
- private static final long serialVersionUID = -3506851722447870532L;
-
public URIBuilderImpl(
- final ODataServiceVersion version, final Configuration configuration, final String serviceRoot) {
-
+ final ODataServiceVersion version, final CommonConfiguration configuration, final String serviceRoot) {
super(version, configuration, serviceRoot);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ConfigurationImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ConfigurationImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ConfigurationImpl.java
deleted file mode 100644
index 8a065f0..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ConfigurationImpl.java
+++ /dev/null
@@ -1,32 +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.client.core.v3;
-
-import org.apache.olingo.client.api.v3.Configuration;
-import org.apache.olingo.client.core.AbstractConfiguration;
-
-public class ConfigurationImpl extends AbstractConfiguration implements Configuration {
-
- private static final long serialVersionUID = -8719958537946884777L;
-
- protected ConfigurationImpl() {
- super();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/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 6da23bb..ec8cd33 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
@@ -18,6 +18,7 @@
*/
package org.apache.olingo.client.core.v3;
+import org.apache.olingo.client.api.CommonConfiguration;
import org.apache.olingo.client.api.communication.header.HeaderName;
import org.apache.olingo.client.api.communication.header.ODataHeaders;
import org.apache.olingo.client.api.communication.request.batch.v3.BatchRequestFactory;
@@ -30,9 +31,9 @@ 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;
import org.apache.olingo.client.api.v3.ODataClient;
import org.apache.olingo.client.core.AbstractODataClient;
+import org.apache.olingo.client.core.Configuration;
import org.apache.olingo.client.core.communication.header.ODataHeadersImpl;
import org.apache.olingo.client.core.communication.request.batch.v3.BatchRequestFactoryImpl;
import org.apache.olingo.client.core.communication.request.cud.v3.CUDRequestFactoryImpl;
@@ -45,9 +46,7 @@ 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;
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.serialization.ODataSerializer;
import org.apache.olingo.commons.core.domain.v3.ODataObjectFactoryImpl;
import org.apache.olingo.commons.core.serialization.AtomSerializer;
@@ -55,7 +54,7 @@ import org.apache.olingo.commons.core.serialization.JsonSerializer;
public class ODataClientImpl extends AbstractODataClient<UpdateType> implements ODataClient {
- protected final Configuration configuration = new ConfigurationImpl();
+ protected final Configuration configuration = new Configuration();
private final FilterFactory filterFactory = new FilterFactoryImpl(getServiceVersion());
@@ -88,7 +87,7 @@ public class ODataClientImpl extends AbstractODataClient<UpdateType> implements
}
@Override
- public Configuration getConfiguration() {
+ public CommonConfiguration getConfiguration() {
return configuration;
}
@@ -103,14 +102,13 @@ public class ODataClientImpl extends AbstractODataClient<UpdateType> implements
}
@Override
- public ODataDeserializer getDeserializer(final Format format) {
+ public ODataDeserializer getDeserializer(final ODataFormat format) {
return new ODataDeserializerImpl(getServiceVersion(), false, format);
}
@Override
- public ODataSerializer getSerializer(final Format format) {
- return format instanceof ODataPubFormat && format == ODataPubFormat.ATOM
- || format instanceof ODataFormat && format == ODataFormat.XML ?
+ public ODataSerializer getSerializer(final ODataFormat format) {
+ return format == ODataFormat.ATOM || format == ODataFormat.XML ?
new AtomSerializer(getServiceVersion()) : new JsonSerializer(getServiceVersion(), false);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ConfigurationImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ConfigurationImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ConfigurationImpl.java
deleted file mode 100644
index fab57da..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ConfigurationImpl.java
+++ /dev/null
@@ -1,32 +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.client.core.v4;
-
-import org.apache.olingo.client.api.v4.Configuration;
-import org.apache.olingo.client.core.AbstractConfiguration;
-
-public class ConfigurationImpl extends AbstractConfiguration implements Configuration {
-
- private static final long serialVersionUID = -1134213707190176857L;
-
- protected ConfigurationImpl() {
- super();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/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 2ae30e2..dec4e84 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
@@ -32,9 +32,9 @@ 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;
-import org.apache.olingo.client.api.v4.Configuration;
import org.apache.olingo.client.api.v4.ODataClient;
import org.apache.olingo.client.core.AbstractODataClient;
+import org.apache.olingo.client.core.Configuration;
import org.apache.olingo.client.core.communication.header.ODataHeadersImpl;
import org.apache.olingo.client.core.communication.request.batch.v4.BatchRequestFactoryImpl;
import org.apache.olingo.client.core.communication.request.cud.v4.CUDRequestFactoryImpl;
@@ -48,9 +48,7 @@ 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;
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.serialization.ODataSerializer;
import org.apache.olingo.commons.core.domain.v4.ODataObjectFactoryImpl;
import org.apache.olingo.commons.core.serialization.AtomSerializer;
@@ -58,7 +56,7 @@ import org.apache.olingo.commons.core.serialization.JsonSerializer;
public class ODataClientImpl extends AbstractODataClient<UpdateType> implements ODataClient {
- protected final Configuration configuration = new ConfigurationImpl();
+ protected final Configuration configuration = new Configuration();
private final FilterFactory filterFactory = new FilterFactoryImpl(getServiceVersion());
@@ -114,14 +112,13 @@ public class ODataClientImpl extends AbstractODataClient<UpdateType> implements
}
@Override
- public ODataDeserializer getDeserializer(final Format format) {
+ public ODataDeserializer getDeserializer(final ODataFormat format) {
return new ODataDeserializerImpl(getServiceVersion(), false, format);
}
@Override
- public ODataSerializer getSerializer(final Format format) {
- return format instanceof ODataPubFormat && format == ODataPubFormat.ATOM
- || format instanceof ODataFormat && format == ODataFormat.XML ?
+ public ODataSerializer getSerializer(final ODataFormat format) {
+ return format == ODataFormat.ATOM || format == ODataFormat.XML ?
new AtomSerializer(getServiceVersion()) : new JsonSerializer(getServiceVersion(), false);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/test/java/org/apache/olingo/client/core/AbstractTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/AbstractTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/AbstractTest.java
index 27666c0..089c3f4 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/AbstractTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/AbstractTest.java
@@ -20,7 +20,6 @@ package org.apache.olingo.client.core;
import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.custommonkey.xmlunit.XMLUnit;
import org.junit.BeforeClass;
@@ -47,11 +46,7 @@ public abstract class AbstractTest {
v4Client = ODataClientFactory.getV4();
}
- protected String getSuffix(final ODataPubFormat format) {
- return format == ODataPubFormat.ATOM ? "xml" : "json";
- }
-
protected String getSuffix(final ODataFormat format) {
- return format == ODataFormat.XML ? "xml" : "json";
+ return format == ODataFormat.ATOM || format == ODataFormat.XML ? "xml" : "json";
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/AtomTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/AtomTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/AtomTest.java
index 2fcdb4c..bacba17 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/AtomTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/AtomTest.java
@@ -22,17 +22,18 @@ import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.StringWriter;
+
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
+
import org.apache.commons.io.IOUtils;
import org.apache.olingo.client.api.v3.ODataClient;
-import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.client.core.AbstractTest;
import org.apache.olingo.client.core.AtomLinksQualifier;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.custommonkey.xmlunit.Diff;
import org.junit.Test;
@@ -43,8 +44,8 @@ public class AtomTest extends AbstractTest {
return v3Client;
}
- protected ODataPubFormat getODataPubFormat() {
- return ODataPubFormat.ATOM;
+ protected ODataFormat getODataPubFormat() {
+ return ODataFormat.ATOM;
}
protected ODataFormat getODataFormat() {
@@ -67,7 +68,7 @@ public class AtomTest extends AbstractTest {
assertTrue(diff.similar());
}
- protected void entitySet(final String filename, final ODataPubFormat format) throws Exception {
+ protected void entitySet(final String filename, final ODataFormat format) throws Exception {
final StringWriter writer = new StringWriter();
getClient().getSerializer(format).write(writer, getClient().getDeserializer(format).toEntitySet(
getClass().getResourceAsStream(filename + "." + getSuffix(format))).getPayload());
@@ -80,7 +81,7 @@ public class AtomTest extends AbstractTest {
entitySet("Customer", getODataPubFormat());
}
- protected void entity(final String filename, final ODataPubFormat format) throws Exception {
+ protected void entity(final String filename, final ODataFormat format) throws Exception {
final StringWriter writer = new StringWriter();
getClient().getSerializer(format).write(writer, getClient().getDeserializer(format).toEntity(
getClass().getResourceAsStream(filename + "." + getSuffix(format))).getPayload());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/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 d335232..ea3c3f9 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
@@ -30,7 +30,7 @@ import org.apache.olingo.client.core.AbstractTest;
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.format.ODataFormat;
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
import org.junit.Test;
@@ -41,7 +41,7 @@ public class EntitySetTest extends AbstractTest {
return v3Client;
}
- private void read(final ODataPubFormat format) throws IOException, ODataDeserializerException {
+ private void read(final ODataFormat format) throws IOException, ODataDeserializerException {
final InputStream input = getClass().getResourceAsStream("Customer." + getSuffix(format));
final ODataEntitySet entitySet = getClient().getBinder().getODataEntitySet(
getClient().getDeserializer(format).toEntitySet(input));
@@ -57,11 +57,11 @@ public class EntitySetTest extends AbstractTest {
@Test
public void fromAtom() throws Exception {
- read(ODataPubFormat.ATOM);
+ read(ODataFormat.ATOM);
}
@Test
public void fromJSON() throws Exception {
- read(ODataPubFormat.JSON);
+ read(ODataFormat.JSON);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/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 faca1f6..e799215 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
@@ -36,7 +36,7 @@ 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.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
import org.junit.Test;
@@ -47,7 +47,7 @@ public class EntityTest extends AbstractTest {
return v3Client;
}
- private void readAndWrite(final ODataPubFormat format) throws ODataDeserializerException {
+ private void readAndWrite(final ODataFormat format) throws ODataDeserializerException {
final InputStream input = getClass().getResourceAsStream("Customer_-10." + getSuffix(format));
final ODataEntity entity = getClient().getBinder().getODataEntity(
getClient().getDeserializer(format).toEntity(input));
@@ -75,15 +75,15 @@ public class EntityTest extends AbstractTest {
@Test
public void fromAtom() throws Exception {
- readAndWrite(ODataPubFormat.ATOM);
+ readAndWrite(ODataFormat.ATOM);
}
@Test
public void fromJSON() throws Exception {
- readAndWrite(ODataPubFormat.JSON_FULL_METADATA);
+ readAndWrite(ODataFormat.JSON_FULL_METADATA);
}
- private void readGeospatial(final ODataPubFormat format) throws ODataDeserializerException {
+ private void readGeospatial(final ODataFormat format) throws ODataDeserializerException {
final InputStream input = getClass().getResourceAsStream("AllGeoTypesSet_-8." + getSuffix(format));
final ODataEntity entity = getClient().getBinder().getODataEntity(
getClient().getDeserializer(format).toEntity(input));
@@ -106,16 +106,16 @@ public class EntityTest extends AbstractTest {
@Test
public void withGeospatialFromAtom() throws Exception {
- readGeospatial(ODataPubFormat.ATOM);
+ readGeospatial(ODataFormat.ATOM);
}
@Test
public void withGeospatialFromJSON() throws Exception {
// this needs to be full, otherwise there is no mean to recognize geospatial types
- readGeospatial(ODataPubFormat.JSON_FULL_METADATA);
+ readGeospatial(ODataFormat.JSON_FULL_METADATA);
}
- private void withActions(final ODataPubFormat format) throws ODataDeserializerException {
+ private void withActions(final ODataFormat format) throws ODataDeserializerException {
final InputStream input = getClass().getResourceAsStream("ComputerDetail_-10." + getSuffix(format));
final ODataEntity entity = getClient().getBinder().getODataEntity(
getClient().getDeserializer(format).toEntity(input));
@@ -132,16 +132,16 @@ public class EntityTest extends AbstractTest {
@Test
public void withActionsFromAtom() throws Exception {
- withActions(ODataPubFormat.ATOM);
+ withActions(ODataFormat.ATOM);
}
@Test
public void withActionsFromJSON() throws Exception {
// this needs to be full, otherwise actions will not be provided
- withActions(ODataPubFormat.JSON_FULL_METADATA);
+ withActions(ODataFormat.JSON_FULL_METADATA);
}
- private void mediaEntity(final ODataPubFormat format) throws ODataDeserializerException {
+ private void mediaEntity(final ODataFormat format) throws ODataDeserializerException {
final InputStream input = getClass().getResourceAsStream("Car_16." + getSuffix(format));
final ODataEntity entity = getClient().getBinder().getODataEntity(
getClient().getDeserializer(format).toEntity(input));
@@ -157,15 +157,15 @@ public class EntityTest extends AbstractTest {
@Test
public void mediaEntityFromAtom() throws Exception {
- mediaEntity(ODataPubFormat.ATOM);
+ mediaEntity(ODataFormat.ATOM);
}
@Test
public void mediaEntityFromJSON() throws Exception {
- mediaEntity(ODataPubFormat.JSON_FULL_METADATA);
+ mediaEntity(ODataFormat.JSON_FULL_METADATA);
}
- private void issue128(final ODataPubFormat format) throws EdmPrimitiveTypeException, ODataDeserializerException {
+ private void issue128(final ODataFormat format) throws EdmPrimitiveTypeException, ODataDeserializerException {
final InputStream input = getClass().getResourceAsStream("AllGeoTypesSet_-5." + getSuffix(format));
final ODataEntity entity = getClient().getBinder().getODataEntity(
getClient().getDeserializer(format).toEntity(input));
@@ -184,11 +184,11 @@ public class EntityTest extends AbstractTest {
@Test
public void issue128FromAtom() throws Exception {
- issue128(ODataPubFormat.ATOM);
+ issue128(ODataFormat.ATOM);
}
@Test
public void issue128FromJSON() throws Exception {
- issue128(ODataPubFormat.JSON_FULL_METADATA);
+ issue128(ODataFormat.JSON_FULL_METADATA);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/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 bdccec8..94ff0c3 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
@@ -22,10 +22,10 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.apache.olingo.client.api.v3.ODataClient;
+import org.apache.olingo.client.core.AbstractTest;
import org.apache.olingo.commons.api.domain.ODataError;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
-import org.apache.olingo.client.core.AbstractTest;
import org.junit.Test;
public class ErrorTest extends AbstractTest {
@@ -35,41 +35,41 @@ public class ErrorTest extends AbstractTest {
return v3Client;
}
- private ODataError error(final String name, final ODataPubFormat format) throws ODataDeserializerException {
+ private ODataError error(final String name, final ODataFormat format) throws ODataDeserializerException {
final ODataError error = getClient().getDeserializer(format).toError(
getClass().getResourceAsStream(name + "." + getSuffix(format)));
assertNotNull(error);
return error;
}
- private void simple(final ODataPubFormat format) throws ODataDeserializerException {
+ private void simple(final ODataFormat format) throws ODataDeserializerException {
final ODataError error = error("error", format);
assertEquals("The URL representing the root of the service only supports GET requests.", error.getMessage());
}
@Test
public void jsonSimple() throws Exception {
- simple(ODataPubFormat.JSON);
+ simple(ODataFormat.JSON);
}
@Test
public void atomSimple() throws Exception {
- simple(ODataPubFormat.ATOM);
+ simple(ODataFormat.ATOM);
}
- private void stacktrace(final ODataPubFormat format) throws ODataDeserializerException {
+ private void stacktrace(final ODataFormat format) throws ODataDeserializerException {
final ODataError error = error("stacktrace", format);
assertEquals("Unsupported media type requested.", error.getMessage());
}
@Test
public void jsonStacktrace() throws Exception {
- stacktrace(ODataPubFormat.JSON);
+ stacktrace(ODataFormat.JSON);
}
@Test
public void atomStacktrace() throws Exception {
- stacktrace(ODataPubFormat.ATOM);
+ stacktrace(ODataFormat.ATOM);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/JSONTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/JSONTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/JSONTest.java
index ccc458c..d373344 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/JSONTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/JSONTest.java
@@ -20,27 +20,28 @@ package org.apache.olingo.client.core.v3;
import static org.junit.Assert.assertEquals;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
import java.io.ByteArrayInputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+
import org.apache.commons.io.IOUtils;
import org.apache.olingo.commons.api.Constants;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
public class JSONTest extends AtomTest {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
@Override
- protected ODataPubFormat getODataPubFormat() {
- return ODataPubFormat.JSON;
+ protected ODataFormat getODataPubFormat() {
+ return ODataFormat.JSON;
}
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/AtomTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/AtomTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/AtomTest.java
index 75d4bb1..1ba887c 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/AtomTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/AtomTest.java
@@ -18,20 +18,22 @@
*/
package org.apache.olingo.client.core.v4;
+import static org.junit.Assert.assertTrue;
+
import java.io.ByteArrayInputStream;
import java.io.StringWriter;
+
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
+
import org.apache.commons.io.IOUtils;
import org.apache.olingo.client.api.v4.ODataClient;
import org.apache.olingo.client.core.AtomLinksQualifier;
import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.custommonkey.xmlunit.Diff;
-import static org.junit.Assert.assertTrue;
public class AtomTest extends JSONTest {
@@ -41,8 +43,8 @@ public class AtomTest extends JSONTest {
}
@Override
- protected ODataPubFormat getODataPubFormat() {
- return ODataPubFormat.ATOM;
+ protected ODataFormat getODataPubFormat() {
+ return ODataFormat.ATOM;
}
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/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 651272e..3d8c980 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
@@ -32,7 +32,7 @@ import org.apache.olingo.commons.api.data.EntitySet;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.domain.v4.ODataEntity;
import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
import org.junit.Test;
@@ -43,7 +43,7 @@ public class EntitySetTest extends AbstractTest {
return v4Client;
}
- private void read(final ODataPubFormat format) throws IOException, ODataDeserializerException {
+ private void read(final ODataFormat format) throws IOException, ODataDeserializerException {
final InputStream input = getClass().getResourceAsStream("Customers." + getSuffix(format));
final ODataEntitySet entitySet = getClient().getBinder().getODataEntitySet(
getClient().getDeserializer(format).toEntitySet(input));
@@ -59,15 +59,15 @@ public class EntitySetTest extends AbstractTest {
@Test
public void fromAtom() throws Exception {
- read(ODataPubFormat.ATOM);
+ read(ODataFormat.ATOM);
}
@Test
public void fromJSON() throws Exception {
- read(ODataPubFormat.JSON);
+ read(ODataFormat.JSON);
}
- private void ref(final ODataPubFormat format) throws ODataDeserializerException {
+ private void ref(final ODataFormat format) throws ODataDeserializerException {
final InputStream input = getClass().getResourceAsStream("collectionOfEntityReferences." + getSuffix(format));
final ODataEntitySet entitySet = getClient().getBinder().getODataEntitySet(
getClient().getDeserializer(format).toEntitySet(input));
@@ -85,11 +85,11 @@ public class EntitySetTest extends AbstractTest {
@Test
public void atomRef() throws Exception {
- ref(ODataPubFormat.ATOM);
+ ref(ODataFormat.ATOM);
}
@Test
public void jsonRef() throws Exception {
- ref(ODataPubFormat.JSON);
+ ref(ODataFormat.JSON);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/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 ebfeb7d..f70ad8e 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
@@ -39,11 +39,10 @@ import org.apache.olingo.commons.api.domain.v4.ODataAnnotation;
import org.apache.olingo.commons.api.domain.v4.ODataEntity;
import org.apache.olingo.commons.api.domain.v4.ODataLinkedComplexValue;
import org.apache.olingo.commons.api.domain.v4.ODataProperty;
-import org.apache.olingo.commons.api.domain.v4.ODataValuable;
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.format.ODataFormat;
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;
@@ -77,7 +76,7 @@ public class EntityTest extends AbstractTest {
};
}
- private void singleton(final ODataPubFormat format) throws ODataDeserializerException {
+ private void singleton(final ODataFormat format) throws ODataDeserializerException {
final InputStream input = getClass().getResourceAsStream("VipCustomer." + getSuffix(format));
final ODataEntity entity = getClient().getBinder().getODataEntity(
getClient().getDeserializer(format).toEntity(input));
@@ -101,7 +100,7 @@ public class EntityTest extends AbstractTest {
}
if ("Orders".equals(link.getName())) {
checked++;
- if (format == ODataPubFormat.ATOM) {
+ if (format == ODataFormat.ATOM) {
assertEquals(ODataLinkType.ENTITY_SET_NAVIGATION, link.getType());
}
}
@@ -127,15 +126,15 @@ public class EntityTest extends AbstractTest {
@Test
public void atomSingleton() throws Exception {
- singleton(ODataPubFormat.ATOM);
+ singleton(ODataFormat.ATOM);
}
@Test
public void jsonSingleton() throws Exception {
- singleton(ODataPubFormat.JSON_FULL_METADATA);
+ singleton(ODataFormat.JSON_FULL_METADATA);
}
- private void withEnums(final ODataPubFormat format) throws ODataDeserializerException {
+ private void withEnums(final ODataFormat format) throws ODataDeserializerException {
final InputStream input = getClass().getResourceAsStream("Products_5." + getSuffix(format));
final ODataEntity entity = getClient().getBinder().getODataEntity(
getClient().getDeserializer(format).toEntity(input));
@@ -162,15 +161,15 @@ public class EntityTest extends AbstractTest {
@Test
public void atomWithEnums() throws Exception {
- withEnums(ODataPubFormat.ATOM);
+ withEnums(ODataFormat.ATOM);
}
@Test
public void jsonWithEnums() throws Exception {
- withEnums(ODataPubFormat.JSON_FULL_METADATA);
+ withEnums(ODataFormat.JSON_FULL_METADATA);
}
- private void withInlineEntitySet(final ODataPubFormat format) throws ODataDeserializerException {
+ private void withInlineEntitySet(final ODataFormat format) throws ODataDeserializerException {
final InputStream input = getClass().getResourceAsStream(
"Accounts_101_expand_MyPaymentInstruments." + getSuffix(format));
final ODataEntity entity = getClient().getBinder().getODataEntity(
@@ -196,15 +195,15 @@ public class EntityTest extends AbstractTest {
@Test
public void atomWithInlineEntitySet() throws Exception {
- withInlineEntitySet(ODataPubFormat.ATOM);
+ withInlineEntitySet(ODataFormat.ATOM);
}
@Test
public void jsonWithInlineEntitySet() throws Exception {
- withInlineEntitySet(ODataPubFormat.JSON_FULL_METADATA);
+ withInlineEntitySet(ODataFormat.JSON_FULL_METADATA);
}
- private void mediaEntity(final ODataPubFormat format) throws ODataDeserializerException {
+ private void mediaEntity(final ODataFormat format) throws ODataDeserializerException {
final InputStream input = getClass().getResourceAsStream(
"Advertisements_f89dee73-af9f-4cd4-b330-db93c25ff3c7." + getSuffix(format));
final ODataEntity entity = getClient().getBinder().getODataEntity(
@@ -222,15 +221,15 @@ public class EntityTest extends AbstractTest {
@Test
public void atomMediaEntity() throws Exception {
- mediaEntity(ODataPubFormat.ATOM);
+ mediaEntity(ODataFormat.ATOM);
}
@Test
public void jsonMediaEntity() throws Exception {
- mediaEntity(ODataPubFormat.JSON_FULL_METADATA);
+ mediaEntity(ODataFormat.JSON_FULL_METADATA);
}
- private void withStream(final ODataPubFormat format) throws ODataDeserializerException {
+ private void withStream(final ODataFormat format) throws ODataDeserializerException {
final InputStream input = getClass().getResourceAsStream("PersonDetails_1." + getSuffix(format));
final ODataEntity entity = getClient().getBinder().getODataEntity(
getClient().getDeserializer(format).toEntity(input));
@@ -248,15 +247,15 @@ public class EntityTest extends AbstractTest {
@Test
public void atomWithStream() throws Exception {
- withStream(ODataPubFormat.ATOM);
+ withStream(ODataFormat.ATOM);
}
@Test
public void jsonWithStream() throws Exception {
- withStream(ODataPubFormat.JSON_FULL_METADATA);
+ withStream(ODataFormat.JSON_FULL_METADATA);
}
- private void ref(final ODataPubFormat format) throws ODataDeserializerException {
+ private void ref(final ODataFormat format) throws ODataDeserializerException {
final InputStream input = getClass().getResourceAsStream("entityReference." + getSuffix(format));
final ODataEntity entity = getClient().getBinder().getODataEntity(
getClient().getDeserializer(format).toEntity(input));
@@ -271,15 +270,15 @@ public class EntityTest extends AbstractTest {
@Test
public void atomRef() throws Exception {
- ref(ODataPubFormat.ATOM);
+ ref(ODataFormat.ATOM);
}
@Test
public void jsonRef() throws Exception {
- ref(ODataPubFormat.JSON);
+ ref(ODataFormat.JSON);
}
- private void complexNavigationProperties(final ODataPubFormat format) throws ODataDeserializerException {
+ private void complexNavigationProperties(final ODataFormat format) throws ODataDeserializerException {
final InputStream input = getClass().getResourceAsStream("entity.withcomplexnavigation." + getSuffix(format));
final ODataEntity entity = getClient().getBinder().getODataEntity(
getClient().getDeserializer(format).toEntity(input));
@@ -298,15 +297,15 @@ public class EntityTest extends AbstractTest {
@Test
public void atomComplexNavigationProperties() throws Exception {
- complexNavigationProperties(ODataPubFormat.ATOM);
+ complexNavigationProperties(ODataFormat.ATOM);
}
@Test
public void jsonComplexNavigationProperties() throws Exception {
- complexNavigationProperties(ODataPubFormat.JSON);
+ complexNavigationProperties(ODataFormat.JSON);
}
- private void annotated(final ODataPubFormat format) throws EdmPrimitiveTypeException, ODataDeserializerException {
+ private void annotated(final ODataFormat format) throws EdmPrimitiveTypeException, ODataDeserializerException {
final InputStream input = getClass().getResourceAsStream("annotated." + getSuffix(format));
final ODataEntity entity = getClient().getBinder().getODataEntity(
getClient().getDeserializer(format).toEntity(input));
@@ -343,36 +342,36 @@ public class EntityTest extends AbstractTest {
@Test
public void atomAnnotated() throws Exception {
- complexNavigationProperties(ODataPubFormat.ATOM);
+ complexNavigationProperties(ODataFormat.ATOM);
}
@Test
public void jsonAnnotated() throws Exception {
- complexNavigationProperties(ODataPubFormat.JSON);
+ complexNavigationProperties(ODataFormat.JSON);
}
- private void derived(final ODataClient client, final ODataPubFormat format) throws ODataDeserializerException {
+ private void derived(final ODataClient client, final ODataFormat format) throws ODataDeserializerException {
final InputStream input = getClass().getResourceAsStream("Customer." + getSuffix(format));
final ODataEntity entity = client.getBinder().getODataEntity(client.getDeserializer(format).toEntity(input));
assertNotNull(entity);
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString());
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.CompanyAddress",
- ((ODataValuable) entity.getProperty("HomeAddress")).getValue().getTypeName());
+ entity.getProperty("HomeAddress").getValue().getTypeName());
}
@Test
public void derivedFromAtom() throws Exception {
- derived(getClient(), ODataPubFormat.ATOM);
+ derived(getClient(), ODataFormat.ATOM);
}
@Test
public void derivedFromJSON() throws Exception {
- derived(getEdmEnabledClient(), ODataPubFormat.JSON);
+ derived(getEdmEnabledClient(), ODataFormat.JSON);
}
@Test
public void derivedFromFullJSON() throws Exception {
- derived(getClient(), ODataPubFormat.JSON_FULL_METADATA);
+ derived(getClient(), ODataFormat.JSON_FULL_METADATA);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/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 baf26e6..681bf45 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
@@ -22,10 +22,10 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.apache.olingo.client.api.v4.ODataClient;
+import org.apache.olingo.client.core.AbstractTest;
import org.apache.olingo.commons.api.domain.ODataError;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
-import org.apache.olingo.client.core.AbstractTest;
import org.junit.Test;
public class ErrorTest extends AbstractTest {
@@ -35,14 +35,14 @@ public class ErrorTest extends AbstractTest {
return v4Client;
}
- private ODataError error(final String name, final ODataPubFormat format) throws ODataDeserializerException {
+ private ODataError error(final String name, final ODataFormat format) throws ODataDeserializerException {
final ODataError error = getClient().getDeserializer(format).toError(
getClass().getResourceAsStream(name + "." + getSuffix(format)));
assertNotNull(error);
return error;
}
- private void simple(final ODataPubFormat format) throws ODataDeserializerException {
+ private void simple(final ODataFormat format) throws ODataDeserializerException {
final ODataError error = error("error", format);
assertEquals("501", error.getCode());
assertEquals("Unsupported functionality", error.getMessage());
@@ -51,12 +51,12 @@ public class ErrorTest extends AbstractTest {
@Test
public void jsonSimple() throws Exception {
- simple(ODataPubFormat.JSON);
+ simple(ODataFormat.JSON);
}
@Test
public void atomSimple() throws Exception {
- simple(ODataPubFormat.ATOM);
+ simple(ODataFormat.ATOM);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java
index 20967b9..1c96534 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java
@@ -22,15 +22,13 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
import java.io.ByteArrayInputStream;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+
import org.apache.commons.io.IOUtils;
import org.apache.olingo.client.api.v4.ODataClient;
import org.apache.olingo.client.core.AbstractTest;
@@ -39,9 +37,12 @@ import org.apache.olingo.commons.api.data.Delta;
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.junit.Test;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
public class JSONTest extends AbstractTest {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
@@ -51,8 +52,8 @@ public class JSONTest extends AbstractTest {
return v4Client;
}
- protected ODataPubFormat getODataPubFormat() {
- return ODataPubFormat.JSON;
+ protected ODataFormat getODataPubFormat() {
+ return ODataFormat.JSON;
}
protected ODataFormat getODataFormat() {
@@ -128,7 +129,7 @@ public class JSONTest extends AbstractTest {
assertEquals(expected, actualNode);
}
- protected void entitySet(final String filename, final ODataPubFormat format) throws Exception {
+ protected void entitySet(final String filename, final ODataFormat format) throws Exception {
final StringWriter writer = new StringWriter();
getClient().getSerializer(format).write(writer, getClient().getDeserializer(format).toEntitySet(
getClass().getResourceAsStream(filename + "." + getSuffix(format))).getPayload());
@@ -142,7 +143,7 @@ public class JSONTest extends AbstractTest {
entitySet("collectionOfEntityReferences", getODataPubFormat());
}
- protected void entity(final String filename, final ODataPubFormat format) throws Exception {
+ protected void entity(final String filename, final ODataFormat format) throws Exception {
final StringWriter writer = new StringWriter();
getClient().getSerializer(format).write(writer, getClient().getDeserializer(format).toEntity(
getClass().getResourceAsStream(filename + "." + getSuffix(format))).getPayload());
@@ -187,11 +188,11 @@ public class JSONTest extends AbstractTest {
@Test
public void crossjoin() throws Exception {
- assertNotNull(getClient().getDeserializer(ODataPubFormat.JSON_FULL_METADATA).toEntitySet(
+ assertNotNull(getClient().getDeserializer(ODataFormat.JSON_FULL_METADATA).toEntitySet(
getClass().getResourceAsStream("crossjoin.json")));
}
- protected void delta(final String filename, final ODataPubFormat format) throws Exception {
+ protected void delta(final String filename, final ODataFormat format) throws Exception {
final Delta delta = getClient().getDeserializer(format).toDelta(
getClass().getResourceAsStream(filename + "." + getSuffix(format))).getPayload();
assertNotNull(delta);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java
index 8e5f27d..c37131c 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java
@@ -56,19 +56,15 @@ public abstract class ContentType {
static {
final Map<String, String> v3 = new HashMap<String, String>();
- v3.put(ODataPubFormat.JSON_NO_METADATA.name(), ContentType.APPLICATION_JSON + ";odata=nometadata");
- v3.put(ODataPubFormat.JSON.name(), ContentType.APPLICATION_JSON + ";odata=minimalmetadata");
- v3.put(ODataPubFormat.JSON_FULL_METADATA.name(), ContentType.APPLICATION_JSON + ";odata=fullmetadata");
- v3.put(ODataPubFormat.ATOM.name(), ContentType.APPLICATION_ATOM_XML);
- v3.put(ODataFormat.XML.name(), ContentType.APPLICATION_XML);
+ v3.put(ODataFormat.JSON_NO_METADATA.name(), ContentType.APPLICATION_JSON + ";odata=nometadata");
+ v3.put(ODataFormat.JSON.name(), ContentType.APPLICATION_JSON + ";odata=minimalmetadata");
+ v3.put(ODataFormat.JSON_FULL_METADATA.name(), ContentType.APPLICATION_JSON + ";odata=fullmetadata");
formatPerVersion.put(ODataServiceVersion.V30, v3);
final Map<String, String> v4 = new HashMap<String, String>();
- v4.put(ODataPubFormat.JSON_NO_METADATA.name(), ContentType.APPLICATION_JSON + ";odata.metadata=none");
- v4.put(ODataPubFormat.JSON.name(), ContentType.APPLICATION_JSON + ";odata.metadata=minimal");
- v4.put(ODataPubFormat.JSON_FULL_METADATA.name(), ContentType.APPLICATION_JSON + ";odata.metadata=full");
- v4.put(ODataPubFormat.ATOM.name(), ContentType.APPLICATION_ATOM_XML);
- v4.put(ODataFormat.XML.name(), ContentType.APPLICATION_XML);
+ v4.put(ODataFormat.JSON_NO_METADATA.name(), ContentType.APPLICATION_JSON + ";odata.metadata=none");
+ v4.put(ODataFormat.JSON.name(), ContentType.APPLICATION_JSON + ";odata.metadata=minimal");
+ v4.put(ODataFormat.JSON_FULL_METADATA.name(), ContentType.APPLICATION_JSON + ";odata.metadata=full");
formatPerVersion.put(ODataServiceVersion.V40, v4);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/Format.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/Format.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/Format.java
deleted file mode 100644
index f031018..0000000
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/Format.java
+++ /dev/null
@@ -1,26 +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.format;
-
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-
-public interface Format {
-
- String toString(ODataServiceVersion version);
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataFormat.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataFormat.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataFormat.java
index 301ada9..37d0731 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataFormat.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataFormat.java
@@ -23,24 +23,44 @@ import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
/**
* Available formats to be used in various contexts.
*/
-public enum ODataFormat implements Format {
+public enum ODataFormat {
- /**
- * JSON format with no metadata.
- */
+ /** JSON format with no metadata. */
JSON_NO_METADATA,
- /**
- * JSON format with minimal metadata (default).
- */
+ /** JSON format with minimal metadata (default). */
JSON,
- /**
- * JSON format with no metadata.
- */
+ /** JSON format with full metadata. */
JSON_FULL_METADATA,
- /**
- * XML format.
- */
- XML;
+
+ /** XML format. */
+ XML(ContentType.APPLICATION_XML),
+ /** Atom format. */
+ ATOM(ContentType.APPLICATION_ATOM_XML),
+
+ // media formats
+ MEDIA_TYPE_WILDCARD("*"),
+ WILDCARD(ContentType.WILDCARD),
+ APPLICATION_XML(ContentType.APPLICATION_XML),
+ APPLICATION_ATOM_XML(ContentType.APPLICATION_ATOM_XML),
+ APPLICATION_XHTML_XML(ContentType.APPLICATION_XHTML_XML),
+ APPLICATION_SVG_XML(ContentType.APPLICATION_SVG_XML),
+ APPLICATION_JSON(ContentType.APPLICATION_JSON),
+ APPLICATION_FORM_URLENCODED(ContentType.APPLICATION_FORM_URLENCODED),
+ MULTIPART_FORM_DATA(ContentType.MULTIPART_FORM_DATA),
+ APPLICATION_OCTET_STREAM(ContentType.APPLICATION_OCTET_STREAM),
+ TEXT_PLAIN(ContentType.TEXT_PLAIN),
+ TEXT_XML(ContentType.TEXT_XML),
+ TEXT_HTML(ContentType.TEXT_HTML);
+
+ private final String format;
+
+ ODataFormat() {
+ this.format = null;
+ }
+
+ ODataFormat(final String format) {
+ this.format = format;
+ }
/**
* Gets format as a string.
@@ -48,18 +68,21 @@ public enum ODataFormat implements Format {
* @param version OData service version.
* @return format as a string.
*/
- @Override
public String toString(final ODataServiceVersion version) {
if (version.ordinal() < ODataServiceVersion.V30.ordinal()) {
throw new IllegalArgumentException("Unsupported version " + version);
}
- return ContentType.formatPerVersion.get(version).get(this.name());
+ return format == null ? ContentType.formatPerVersion.get(version).get(this.name()) : format;
}
@Override
public String toString() {
- throw new UnsupportedOperationException();
+ if (format == null) {
+ throw new UnsupportedOperationException();
+ } else {
+ return format;
+ }
}
/**
@@ -77,7 +100,11 @@ public enum ODataFormat implements Format {
_format.append(parts[0].trim());
if (ContentType.APPLICATION_JSON.equals(parts[0].trim())) {
if (parts.length > 1) {
- _format.append(';').append(parts[1].trim());
+ if (parts[1].trim().equalsIgnoreCase("charset=UTF-8")) {
+ result = ODataFormat.JSON;
+ } else {
+ _format.append(';').append(parts[1].trim());
+ }
} else {
result = ODataFormat.JSON;
}
@@ -89,6 +116,7 @@ public enum ODataFormat implements Format {
if (candidate.equals(value.toString(ODataServiceVersion.V30))
|| candidate.equals(value.toString(ODataServiceVersion.V40))) {
result = value;
+ break;
}
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataMediaFormat.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataMediaFormat.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataMediaFormat.java
deleted file mode 100644
index a9410d5..0000000
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataMediaFormat.java
+++ /dev/null
@@ -1,76 +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.format;
-
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-
-/**
- * Available formats for media.
- */
-public enum ODataMediaFormat implements Format{
-
- CHARSET_PARAMETER("charset"),
- MEDIA_TYPE_WILDCARD("*"),
- WILDCARD(ContentType.WILDCARD),
- APPLICATION_XML(ContentType.APPLICATION_XML),
- APPLICATION_ATOM_XML(ContentType.APPLICATION_ATOM_XML),
- APPLICATION_XHTML_XML(ContentType.APPLICATION_XHTML_XML),
- APPLICATION_SVG_XML(ContentType.APPLICATION_SVG_XML),
- APPLICATION_JSON(ContentType.APPLICATION_JSON),
- APPLICATION_FORM_URLENCODED(ContentType.APPLICATION_FORM_URLENCODED),
- MULTIPART_FORM_DATA(ContentType.MULTIPART_FORM_DATA),
- APPLICATION_OCTET_STREAM(ContentType.APPLICATION_OCTET_STREAM),
- TEXT_PLAIN(ContentType.TEXT_PLAIN),
- TEXT_XML(ContentType.TEXT_XML),
- TEXT_HTML(ContentType.TEXT_HTML);
-
- private final String format;
-
- private ODataMediaFormat(final String format) {
- this.format = format;
- }
-
- @Override
- public String toString() {
- return format;
- }
-
- public static ODataMediaFormat fromFormat(final String format) {
- final String _format = format.split(";")[0];
-
- ODataMediaFormat result = null;
-
- for (ODataMediaFormat value : values()) {
- if (_format.equals(value.toString())) {
- result = value;
- }
- }
-
- if (result == null) {
- throw new IllegalArgumentException("Unsupported format: " + format);
- }
-
- return result;
- }
-
- @Override
- public String toString(final ODataServiceVersion version) {
- return this.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataPubFormat.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataPubFormat.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataPubFormat.java
deleted file mode 100644
index 4b4c063..0000000
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataPubFormat.java
+++ /dev/null
@@ -1,102 +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.format;
-
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-
-/**
- * Available formats for AtomPub exchange.
- */
-public enum ODataPubFormat implements Format {
-
- /**
- * JSON format with no metadata.
- */
- JSON_NO_METADATA,
- /**
- * JSON format with minimal metadata (default).
- */
- JSON,
- /**
- * JSON format with no metadata.
- */
- JSON_FULL_METADATA,
- /**
- * Atom format.
- */
- ATOM;
-
- /**
- * Gets format as a string.
- *
- * @param version OData service version.
- * @return format as a string.
- */
- @Override
- public String toString(final ODataServiceVersion version) {
- if (version.ordinal() < ODataServiceVersion.V30.ordinal()) {
- throw new IllegalArgumentException("Unsupported version " + version);
- }
-
- return ContentType.formatPerVersion.get(version).get(this.name());
- }
-
- @Override
- public String toString() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Gets OData format from its string representation.
- *
- * @param format string representation of the format.
- * @return OData format.
- */
- public static ODataPubFormat fromString(final String format) {
- ODataPubFormat result = null;
-
- final StringBuffer _format = new StringBuffer();
-
- final String[] parts = format.split(";");
- _format.append(parts[0].trim());
- if (ContentType.APPLICATION_JSON.equals(parts[0].trim())) {
- if (parts.length > 1 && parts[1].startsWith("odata")) {
- _format.append(';').append(parts[1].trim());
- } else {
- result = ODataPubFormat.JSON;
- }
- }
-
- if (result == null) {
- final String candidate = _format.toString();
- for (ODataPubFormat value : values()) {
- if (candidate.equals(value.toString(ODataServiceVersion.V30))
- || candidate.equals(value.toString(ODataServiceVersion.V40))) {
- result = value;
- }
- }
- }
-
- if (result == null) {
- throw new IllegalArgumentException("Unsupported format: " + format);
- }
-
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataValueFormat.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataValueFormat.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataValueFormat.java
deleted file mode 100644
index 28ce108..0000000
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataValueFormat.java
+++ /dev/null
@@ -1,81 +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.format;
-
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-
-/**
- * Available formats for property values.
- */
-public enum ODataValueFormat implements Format {
-
- /**
- * Application octet stream.
- */
- STREAM(ContentType.APPLICATION_OCTET_STREAM),
- /**
- * Plain text format.
- */
- TEXT(ContentType.TEXT_PLAIN);
-
- private final String format;
-
- ODataValueFormat(final String format) {
- this.format = format;
- }
-
- /**
- * Gets format as a string.
- *
- * @return format as a string.
- */
- @Override
- public String toString() {
- return format;
- }
-
- /**
- * Gets format from its string representation.
- *
- * @param format string representation of the format.
- * @return OData format.
- */
- public static ODataValueFormat fromString(final String format) {
- final String _format = format.split(";")[0];
-
- ODataValueFormat result = null;
-
- for (ODataValueFormat value : values()) {
- if (_format.equals(value.toString())) {
- result = value;
- }
- }
-
- if (result == null) {
- throw new IllegalArgumentException("Unsupported format: " + format);
- }
-
- return result;
- }
-
- @Override
- public String toString(final ODataServiceVersion version) {
- return this.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java
index cce71c8..9168b89 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java
@@ -733,7 +733,12 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
try {
final XMLEventReader reader = getReader(input);
final StartElement start = skipBeforeFirstStartElement(reader);
- return getContainer(start, entity(reader, start));
+ final Entity entity = entity(reader, start);
+ if (entity == null) {
+ throw new ODataDeserializerException("No entity found!");
+ } else {
+ return getContainer(start, entity);
+ }
} catch (XMLStreamException e) {
throw new ODataDeserializerException(e);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java
index 9e1e8fc..2fae3ac 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java
@@ -20,8 +20,8 @@ package org.apache.olingo.server.api;
import org.apache.olingo.commons.api.ODataRuntimeException;
import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.server.api.edm.provider.EdmProvider;
-import org.apache.olingo.server.api.serializer.ODataFormat;
import org.apache.olingo.server.api.serializer.ODataSerializer;
public abstract class OData {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java
index 3a98543..e14e6d3 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java
@@ -21,12 +21,12 @@ package org.apache.olingo.server.api.processor;
import java.io.InputStream;
import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.http.HttpContentType;
import org.apache.olingo.commons.api.http.HttpHeader;
import org.apache.olingo.server.api.OData;
import org.apache.olingo.server.api.ODataRequest;
import org.apache.olingo.server.api.ODataResponse;
-import org.apache.olingo.server.api.serializer.ODataFormat;
import org.apache.olingo.server.api.serializer.ODataSerializer;
import org.apache.olingo.server.api.uri.UriInfo;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataFormat.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataFormat.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataFormat.java
deleted file mode 100644
index 51425d8..0000000
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataFormat.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.server.api.serializer;
-
-public enum ODataFormat {
- XML, JSON
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java
index 8b18e87..814459a 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java
@@ -20,10 +20,10 @@ package org.apache.olingo.server.core;
import org.apache.olingo.commons.api.ODataRuntimeException;
import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.server.api.ODataHttpHandler;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.ODataHttpHandler;
import org.apache.olingo.server.api.edm.provider.EdmProvider;
-import org.apache.olingo.server.api.serializer.ODataFormat;
import org.apache.olingo.server.api.serializer.ODataSerializer;
import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
import org.apache.olingo.server.core.serializer.ODataJsonSerializer;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
index 66e863b..7e56c55 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
@@ -18,6 +18,9 @@
*/
package org.apache.olingo.server.tecsvc.processor;
+import java.net.URI;
+import java.util.UUID;
+
import org.apache.olingo.commons.api.data.ContextURL;
import org.apache.olingo.commons.api.data.Entity;
import org.apache.olingo.commons.api.data.EntitySet;
@@ -25,6 +28,7 @@ import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.core.data.EntityImpl;
import org.apache.olingo.commons.core.data.EntitySetImpl;
import org.apache.olingo.commons.core.data.PrimitiveValueImpl;
@@ -34,15 +38,11 @@ import org.apache.olingo.server.api.ODataRequest;
import org.apache.olingo.server.api.ODataResponse;
import org.apache.olingo.server.api.processor.EntityProcessor;
import org.apache.olingo.server.api.processor.EntitySetProcessor;
-import org.apache.olingo.server.api.serializer.ODataFormat;
import org.apache.olingo.server.api.serializer.ODataSerializer;
import org.apache.olingo.server.api.uri.UriInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.net.URI;
-import java.util.UUID;
-
public class SampleJsonProcessor implements EntitySetProcessor, EntityProcessor {
private static final Logger LOG = LoggerFactory.getLogger(SampleJsonProcessor.class);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java
index 35e816c..969dd42 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java
@@ -34,8 +34,8 @@ import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmEntitySet;
import org.apache.olingo.commons.api.edm.EdmFunctionImport;
import org.apache.olingo.commons.api.edm.EdmSingleton;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.server.api.OData;
-import org.apache.olingo.server.api.serializer.ODataFormat;
import org.apache.olingo.server.api.serializer.ODataSerializer;
import org.junit.Before;
import org.junit.Test;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
index 5721d42..ae3d053 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
@@ -34,6 +34,7 @@ import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.Target;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.server.api.OData;
import org.apache.olingo.server.api.edm.provider.Action;
import org.apache.olingo.server.api.edm.provider.ActionImport;
@@ -54,7 +55,6 @@ import org.apache.olingo.server.api.edm.provider.ReturnType;
import org.apache.olingo.server.api.edm.provider.Schema;
import org.apache.olingo.server.api.edm.provider.Singleton;
import org.apache.olingo.server.api.edm.provider.TypeDefinition;
-import org.apache.olingo.server.api.serializer.ODataFormat;
import org.apache.olingo.server.api.serializer.ODataSerializer;
import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
[6/8] git commit: Merge branch 'master' into
Olingo-317_DeSerializerRefactoring
Posted by mi...@apache.org.
Merge branch 'master' into Olingo-317_DeSerializerRefactoring
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/176bee4b
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/176bee4b
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/176bee4b
Branch: refs/heads/master
Commit: 176bee4b02ed3548a9f485d339287429f0bbde47
Parents: 37abba5 1e8ad44
Author: Michael Bolz <mi...@sap.com>
Authored: Tue Jun 17 14:24:05 2014 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Tue Jun 17 14:24:05 2014 +0200
----------------------------------------------------------------------
.../olingo/ext/proxy/commons/FilterImpl.java | 10 +++--
.../olingo/client/api/CommonConfiguration.java | 25 ++++++++++++
.../olingo/client/core/Configuration.java | 12 ++++++
.../client/core/uri/AbstractURIBuilder.java | 41 +++++++++++++-------
4 files changed, 71 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/176bee4b/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonConfiguration.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/176bee4b/lib/client-core/src/main/java/org/apache/olingo/client/core/Configuration.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/Configuration.java
index 1bad32f,0000000..a67bc11
mode 100644,000000..100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/Configuration.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/Configuration.java
@@@ -1,197 -1,0 +1,209 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.core;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import org.apache.olingo.client.api.CommonConfiguration;
+import org.apache.olingo.client.api.http.HttpClientFactory;
+import org.apache.olingo.client.api.http.HttpUriRequestFactory;
+import org.apache.olingo.client.core.http.DefaultHttpClientFactory;
+import org.apache.olingo.client.core.http.DefaultHttpUriRequestFactory;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.commons.api.format.ODataFormat;
+
+public class Configuration implements CommonConfiguration {
+
+ private static final String DEFAULT_PUB_FORMAT = "pubFormat";
+
+ private static final String DEFAULT_VALUE_FORMAT = "valueFormat";
+
+ private static final String DEFAULT_BATCH_ACCEPT_FORMAT = "batchAcceptFormat";
+
+ private static final String DEFAULT_MEDIA_FORMAT = "valueFormat";
+
+ private static final String HTTP_CLIENT_FACTORY = "httpClientFactory";
+
+ private static final String HTTP_URI_REQUEST_FACTORY = "httpUriRequestFactory";
+
+ private static final String USE_XHTTP_METHOD = "useHTTPMethod";
+
+ private static final String KEY_AS_SEGMENT = "keyAsSegment";
++
++ private static final String ADDRESS_DERIVED_TYPE = "addressDerivedType";
+
+ private static final String GZIP_COMPRESSION = "gzipCompression";
+
+ private static final String CHUNKING = "chunking";
+
+ private final Map<String, Object> CONF = new HashMap<String, Object>();
+
+ private transient ExecutorService executor = Executors.newFixedThreadPool(10);
+
+ /**
+ * Gets given configuration property.
+ *
+ * @param key key value of the property to be retrieved.
+ * @param defaultValue default value to be used in case of the given key doesn't exist.
+ * @return property value if exists; default value if does not exist.
+ */
+ protected Object getProperty(final String key, final Object defaultValue) {
+ return CONF.containsKey(key) ? CONF.get(key) : defaultValue;
+ }
+
+ /**
+ * Sets new configuration property.
+ *
+ * @param key configuration property key.
+ * @param value configuration property value.
+ * @return given value.
+ */
+ protected Object setProperty(final String key, final Object value) {
+ return CONF.put(key, value);
+ }
+
+ @Override
+ public String getDefaultBatchAcceptFormat() {
+ return getProperty(DEFAULT_BATCH_ACCEPT_FORMAT, ContentType.MULTIPART_MIXED).toString();
+ }
+
+ @Override
+ public void setDefaultBatchAcceptFormat(final String contentType) {
+ setProperty(DEFAULT_BATCH_ACCEPT_FORMAT, contentType);
+ }
+
+ @Override
+ public ODataFormat getDefaultPubFormat() {
+ return (ODataFormat) getProperty(DEFAULT_PUB_FORMAT, ODataFormat.JSON_FULL_METADATA);
+ }
+
+ @Override
+ public void setDefaultPubFormat(final ODataFormat format) {
+ setProperty(DEFAULT_PUB_FORMAT, format);
+ }
+
+ @Override
+ public ODataFormat getDefaultFormat() {
+ ODataFormat format = getDefaultPubFormat();
+ return format == ODataFormat.ATOM ? ODataFormat.XML : format;
+ }
+
+ @Override
+ public ODataFormat getDefaultValueFormat() {
+ return (ODataFormat) getProperty(DEFAULT_VALUE_FORMAT, ODataFormat.TEXT_PLAIN);
+ }
+
+ @Override
+ public void setDefaultValueFormat(final ODataFormat format) {
+ setProperty(DEFAULT_VALUE_FORMAT, format);
+ }
+
+ @Override
+ public ODataFormat getDefaultMediaFormat() {
+ return (ODataFormat) getProperty(DEFAULT_VALUE_FORMAT, ODataFormat.APPLICATION_OCTET_STREAM);
+ }
+
+ @Override
+ public void setDefaultMediaFormat(final ODataFormat format) {
+ setProperty(DEFAULT_MEDIA_FORMAT, format);
+ }
+
+ @Override
+ public HttpClientFactory getHttpClientFactory() {
+ return (HttpClientFactory) getProperty(HTTP_CLIENT_FACTORY, new DefaultHttpClientFactory());
+ }
+
+ @Override
+ public void setHttpClientFactory(final HttpClientFactory factory) {
+ setProperty(HTTP_CLIENT_FACTORY, factory);
+ }
+
+ @Override
+ public HttpUriRequestFactory getHttpUriRequestFactory() {
+ return (HttpUriRequestFactory) getProperty(HTTP_URI_REQUEST_FACTORY, new DefaultHttpUriRequestFactory());
+ }
+
+ @Override
+ public void setHttpUriRequestFactory(final HttpUriRequestFactory factory) {
+ setProperty(HTTP_URI_REQUEST_FACTORY, factory);
+ }
+
+ @Override
+ public boolean isUseXHTTPMethod() {
+ return (Boolean) getProperty(USE_XHTTP_METHOD, false);
+ }
+
+ @Override
+ public void setUseXHTTPMethod(final boolean value) {
+ setProperty(USE_XHTTP_METHOD, value);
+ }
+
+ @Override
+ public boolean isGzipCompression() {
+ return (Boolean) getProperty(GZIP_COMPRESSION, false);
+ }
+
+ @Override
+ public void setGzipCompression(final boolean value) {
+ setProperty(GZIP_COMPRESSION, value);
+ }
+
+ @Override
+ public boolean isUseChuncked() {
+ return (Boolean) getProperty(CHUNKING, true);
+ }
+
+ @Override
+ public void setUseChuncked(final boolean value) {
+ setProperty(CHUNKING, value);
+ }
+
+ @Override
+ public boolean isKeyAsSegment() {
+ return (Boolean) getProperty(KEY_AS_SEGMENT, false);
+ }
+
+ @Override
+ public void setKeyAsSegment(final boolean value) {
+ setProperty(KEY_AS_SEGMENT, value);
+ }
+
+ @Override
++ public boolean isAddressingDerivedTypes() {
++ return (Boolean) getProperty(ADDRESS_DERIVED_TYPE, true);
++ }
++
++ @Override
++ public void setAddressingDerivedTypes(final boolean value) {
++ setProperty(ADDRESS_DERIVED_TYPE, value);
++ }
++
++ @Override
+ public ExecutorService getExecutor() {
+ return executor;
+ }
+
+ @Override
+ public void setExecutor(final ExecutorService executorService) {
+ executor = executorService;
+ }
+}
[2/8] [OLINGO-317] Merged the format ENUMs
Posted by mi...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java
index 6b2bcf7..6a8e8d7 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java
@@ -24,6 +24,7 @@ import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.net.URI;
import java.util.Collection;
+
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.Header;
@@ -38,33 +39,23 @@ import org.apache.olingo.client.api.communication.header.ODataHeaders;
import org.apache.olingo.client.api.communication.request.ODataRequest;
import org.apache.olingo.client.api.communication.request.ODataStreamer;
import org.apache.olingo.client.api.communication.response.ODataResponse;
-import org.apache.olingo.commons.api.format.Format;
import org.apache.olingo.client.api.http.HttpClientException;
import org.apache.olingo.client.api.http.HttpMethod;
-import org.apache.olingo.commons.api.format.ODataMediaFormat;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.format.ODataValueFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
/**
* Abstract representation of an OData request. Get instance by using factories.
*
- * @param <T> Accepted content-type formats by the request in object.
- *
* @see org.apache.olingo.client.api.communication.request.cud.v3.CUDRequestFactory
* @see org.apache.olingo.client.api.communication.request.cud.v4.CUDRequestFactory
* @see org.apache.olingo.client.api.communication.request.batch.v3.BatchRequestFactory
* @see org.apache.olingo.client.api.communication.request.batch.v4.BatchRequestFactory
- * @see org.apache.olingo.client.api.communication.request.invoke.v3.InvokeRequestFactory
- * @see org.apache.olingo.client.api.communication.request.invoke.v4.InvokeRequestFactory
- * @see org.apache.olingo.client.api.communication.request.streamed.v3.StreamedRequestFactory
- * @see org.apache.olingo.client.api.communication.request.streamed.v4.StreamedRequestFactory
+ * @see org.apache.olingo.client.api.communication.request.invoke.InvokeRequestFactory
*/
-public abstract class AbstractODataRequest<T extends Format> extends AbstractRequest implements ODataRequest {
+public abstract class AbstractODataRequest extends AbstractRequest implements ODataRequest {
protected final CommonODataClient<?> odataClient;
- private final Class<T> formatRef;
-
/**
* OData request method.
*/
@@ -93,17 +84,13 @@ public abstract class AbstractODataRequest<T extends Format> extends AbstractReq
/**
* Constructor.
*
- * @param odataClient client instance getting this request
- * @param formatRef reference class for the format being used
- * @param method HTTP request method. If configured X-HTTP-METHOD header will be used.
- * @param uri OData request URI.
+ * @param odataClient client instance getting this request
+ * @param method HTTP request method. If configured X-HTTP-METHOD header will be used.
+ * @param uri OData request URI.
*/
- protected AbstractODataRequest(final CommonODataClient<?> odataClient,
- final Class<T> formatRef, final HttpMethod method, final URI uri) {
+ protected AbstractODataRequest(final CommonODataClient<?> odataClient, final HttpMethod method, final URI uri) {
this.odataClient = odataClient;
-
- this.formatRef = formatRef;
this.method = method;
// initialize default headers
@@ -123,161 +110,98 @@ public abstract class AbstractODataRequest<T extends Format> extends AbstractReq
createHttpUriRequest(this.method, this.uri);
}
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("unchecked")
- public T getDefaultFormat() {
- return (T) (formatRef.equals(ODataPubFormat.class)
- ? odataClient.getConfiguration().getDefaultPubFormat()
- : (formatRef.equals(ODataValueFormat.class)
- ? odataClient.getConfiguration().getDefaultValueFormat()
- : (formatRef.equals(ODataMediaFormat.class)
- ? odataClient.getConfiguration().getDefaultMediaFormat()
- : odataClient.getConfiguration().getDefaultFormat())));
- }
+ public abstract ODataFormat getDefaultFormat();
- /**
- * {@inheritDoc}
- */
@Override
public URI getURI() {
return uri;
}
- /**
- * {@inheritDoc}
- */
@Override
public Collection<String> getHeaderNames() {
return odataHeaders.getHeaderNames();
}
- /**
- * {@inheritDoc}
- */
@Override
public String getHeader(final String name) {
return odataHeaders.getHeader(name);
}
- /**
- * {@inheritDoc}
- */
@Override
public ODataRequest setAccept(final String value) {
odataHeaders.setHeader(HeaderName.accept, value);
return this;
}
- /**
- * {@inheritDoc}
- */
@Override
public ODataRequest setIfMatch(final String value) {
odataHeaders.setHeader(HeaderName.ifMatch, value);
return this;
}
- /**
- * {@inheritDoc}
- */
@Override
public ODataRequest setIfNoneMatch(final String value) {
odataHeaders.setHeader(HeaderName.ifNoneMatch, value);
return this;
}
- /**
- * {@inheritDoc}
- */
@Override
public ODataRequest setPrefer(final String value) {
odataHeaders.setHeader(HeaderName.prefer, value);
return this;
}
- /**
- * {@inheritDoc}
- */
@Override
public ODataRequest setXHTTPMethod(final String value) {
odataHeaders.setHeader(HeaderName.xHttpMethod, value);
return this;
}
- /**
- * {@inheritDoc}
- */
@Override
public ODataRequest setContentType(final String value) {
odataHeaders.setHeader(HeaderName.contentType, value);
return this;
}
- /**
- * {@inheritDoc}
- */
@Override
public ODataRequest setSlug(final String value) {
odataHeaders.setHeader(HeaderName.slug, value);
return this;
}
- /**
- * {@inheritDoc}
- */
@Override
public ODataRequest addCustomHeader(final String name, final String value) {
odataHeaders.setHeader(name, value);
return this;
}
- /**
- * {@inheritDoc}
- */
@Override
public ODataRequest addCustomHeader(final HeaderName name, final String value) {
odataHeaders.setHeader(name, value);
return this;
}
- /**
- * {@inheritDoc}
- */
@Override
public String getAccept() {
final String acceptHead = odataHeaders.getHeader(HeaderName.accept);
return StringUtils.isBlank(acceptHead) ? getDefaultFormat().toString(odataClient.getServiceVersion()) : acceptHead;
}
- /**
- * {@inheritDoc}
- */
@Override
public String getIfMatch() {
return odataHeaders.getHeader(HeaderName.ifMatch);
}
- /**
- * {@inheritDoc}
- */
@Override
public String getIfNoneMatch() {
return odataHeaders.getHeader(HeaderName.ifNoneMatch);
}
- /**
- * {@inheritDoc}
- */
@Override
public String getPrefer() {
return odataHeaders.getHeader(HeaderName.prefer);
}
- /**
- * {@inheritDoc}
- */
@Override
public String getContentType() {
final String contentTypeHead = odataHeaders.getHeader(HeaderName.contentType);
@@ -285,9 +209,6 @@ public abstract class AbstractODataRequest<T extends Format> extends AbstractReq
? getDefaultFormat().toString(odataClient.getServiceVersion()) : contentTypeHead;
}
- /**
- * ${@inheritDoc }
- */
@Override
public HttpMethod getMethod() {
return method;
@@ -302,9 +223,6 @@ public abstract class AbstractODataRequest<T extends Format> extends AbstractReq
return odataHeaders;
}
- /**
- * {@inheritDoc }
- */
@Override
public byte[] toByteArray() {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -341,9 +259,6 @@ public abstract class AbstractODataRequest<T extends Format> extends AbstractReq
}
}
- /**
- * {@inheritDoc }
- */
@Override
public InputStream rawExecute() {
try {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataDeleteRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataDeleteRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataDeleteRequestImpl.java
index 91461b6..174f739 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataDeleteRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataDeleteRequestImpl.java
@@ -20,21 +20,22 @@ package org.apache.olingo.client.core.communication.request.cud;
import java.io.InputStream;
import java.net.URI;
+
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest;
import org.apache.olingo.client.api.communication.response.ODataDeleteResponse;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.client.api.http.HttpMethod;
import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
+import org.apache.olingo.commons.api.format.ODataFormat;
/**
* This class implements an OData delete request.
*/
-public class ODataDeleteRequestImpl extends AbstractODataBasicRequest<ODataDeleteResponse, ODataPubFormat>
- implements ODataDeleteRequest {
+public class ODataDeleteRequestImpl extends AbstractODataBasicRequest<ODataDeleteResponse>
+ implements ODataDeleteRequest {
/**
* Constructor.
@@ -43,13 +44,16 @@ public class ODataDeleteRequestImpl extends AbstractODataBasicRequest<ODataDelet
* @param method HTTP method to be used
* @param uri URI of the entity to be deleted.
*/
- ODataDeleteRequestImpl(final CommonODataClient odataClient, final HttpMethod method, final URI uri) {
- super(odataClient, ODataPubFormat.class, method, uri);
+ ODataDeleteRequestImpl(final CommonODataClient<?> odataClient, final HttpMethod method, final URI uri) {
+ super(odataClient, method, uri);
+ }
+
+ @Override
+ public ODataFormat getDefaultFormat() {
+ return odataClient.getConfiguration().getDefaultPubFormat();
}
/**
- * {@inheritDoc }
- * <p>
* No payload: null will be returned.
*/
@Override
@@ -57,9 +61,6 @@ public class ODataDeleteRequestImpl extends AbstractODataBasicRequest<ODataDelet
return null;
}
- /**
- * {@inheritDoc }
- */
@Override
public ODataDeleteResponse execute() {
return new ODataDeleteResponseImpl(httpClient, doExecute());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java
index fcaf9de..e09236c 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java
@@ -35,7 +35,7 @@ import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.data.Entity;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
import org.apache.olingo.commons.api.serialization.ODataSerializerException;
@@ -45,7 +45,7 @@ import org.apache.olingo.commons.api.serialization.ODataSerializerException;
* @param <E> concrete ODataEntity implementation
*/
public class ODataEntityCreateRequestImpl<E extends CommonODataEntity>
- extends AbstractODataBasicRequest<ODataEntityCreateResponse<E>, ODataPubFormat>
+ extends AbstractODataBasicRequest<ODataEntityCreateResponse<E>>
implements ODataEntityCreateRequest<E> {
/**
@@ -61,25 +61,24 @@ public class ODataEntityCreateRequestImpl<E extends CommonODataEntity>
* @param entity entity to be created.
*/
ODataEntityCreateRequestImpl(final CommonODataClient<?> odataClient, final URI targetURI, final E entity) {
- super(odataClient, ODataPubFormat.class, HttpMethod.POST, targetURI);
+ super(odataClient, HttpMethod.POST, targetURI);
this.entity = entity;
}
- /**
- * {@inheritDoc }
- */
+ @Override
+ public ODataFormat getDefaultFormat() {
+ return odataClient.getConfiguration().getDefaultPubFormat();
+ }
+
@Override
protected InputStream getPayload() {
try {
- return odataClient.getWriter().writeEntity(entity, ODataPubFormat.fromString(getContentType()));
+ return odataClient.getWriter().writeEntity(entity, ODataFormat.fromString(getContentType()));
} catch (final ODataSerializerException e) {
throw new IllegalArgumentException(e);
}
}
- /**
- * {@inheritDoc }
- */
@Override
public ODataEntityCreateResponse<E> execute() {
final InputStream input = getPayload();
@@ -126,7 +125,7 @@ public class ODataEntityCreateRequestImpl<E extends CommonODataEntity>
public E getBody() {
if (entity == null) {
try {
- final ResWrap<Entity> resource = odataClient.getDeserializer(ODataPubFormat.fromString(getAccept()))
+ final ResWrap<Entity> resource = odataClient.getDeserializer(ODataFormat.fromString(getAccept()))
.toEntity(getRawResponse());
entity = (E) odataClient.getBinder().getODataEntity(resource);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityUpdateRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityUpdateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityUpdateRequestImpl.java
index 7ce5788..6acbd2a 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityUpdateRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityUpdateRequestImpl.java
@@ -35,7 +35,7 @@ import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.data.Entity;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
import org.apache.olingo.commons.api.serialization.ODataSerializerException;
@@ -45,7 +45,7 @@ import org.apache.olingo.commons.api.serialization.ODataSerializerException;
* @param <E> concrete ODataEntity implementation
*/
public class ODataEntityUpdateRequestImpl<E extends CommonODataEntity>
- extends AbstractODataBasicRequest<ODataEntityUpdateResponse<E>, ODataPubFormat>
+ extends AbstractODataBasicRequest<ODataEntityUpdateResponse<E>>
implements ODataEntityUpdateRequest<E> {
/**
@@ -64,13 +64,15 @@ public class ODataEntityUpdateRequestImpl<E extends CommonODataEntity>
public ODataEntityUpdateRequestImpl(final CommonODataClient<?> odataClient,
final HttpMethod method, final URI uri, final E changes) {
- super(odataClient, ODataPubFormat.class, method, uri);
+ super(odataClient, method, uri);
this.changes = changes;
}
- /**
- * {@inheritDoc }
- */
+ @Override
+ public ODataFormat getDefaultFormat() {
+ return odataClient.getConfiguration().getDefaultPubFormat();
+ }
+
@Override
public ODataEntityUpdateResponse<E> execute() {
final InputStream input = getPayload();
@@ -86,7 +88,7 @@ public class ODataEntityUpdateRequestImpl<E extends CommonODataEntity>
@Override
protected InputStream getPayload() {
try {
- return odataClient.getWriter().writeEntity(changes, ODataPubFormat.fromString(getContentType()));
+ return odataClient.getWriter().writeEntity(changes, ODataFormat.fromString(getContentType()));
} catch (final ODataSerializerException e) {
throw new IllegalArgumentException(e);
}
@@ -124,7 +126,7 @@ public class ODataEntityUpdateRequestImpl<E extends CommonODataEntity>
public E getBody() {
if (entity == null) {
try {
- final ResWrap<Entity> resource = odataClient.getDeserializer(ODataPubFormat.fromString(getAccept()))
+ final ResWrap<Entity> resource = odataClient.getDeserializer(ODataFormat.fromString(getAccept()))
.toEntity(getRawResponse());
entity = (E) odataClient.getBinder().getODataEntity(resource);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataPropertyUpdateRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataPropertyUpdateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataPropertyUpdateRequestImpl.java
index d23c642..7389128 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataPropertyUpdateRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataPropertyUpdateRequestImpl.java
@@ -42,8 +42,8 @@ import org.apache.olingo.commons.api.serialization.ODataSerializerException;
/**
* This class implements an OData update entity property request.
*/
-public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest<ODataPropertyUpdateResponse, ODataFormat>
- implements ODataPropertyUpdateRequest {
+public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest<ODataPropertyUpdateResponse>
+ implements ODataPropertyUpdateRequest {
/**
* Value to be created.
@@ -61,12 +61,17 @@ public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest<OD
ODataPropertyUpdateRequestImpl(final CommonODataClient<?> odataClient,
final HttpMethod method, final URI targetURI, final CommonODataProperty property) {
- super(odataClient, ODataFormat.class, method, targetURI);
+ super(odataClient, method, targetURI);
// set request body
this.property = property;
}
@Override
+ public ODataFormat getDefaultFormat() {
+ return odataClient.getConfiguration().getDefaultFormat();
+ }
+
+ @Override
public ODataPropertyUpdateResponse execute() {
final InputStream input = getPayload();
((HttpEntityEnclosingRequestBase) request).setEntity(URIUtils.buildInputStreamEntity(odataClient, input));
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataValueUpdateRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataValueUpdateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataValueUpdateRequestImpl.java
index bdddb44..4a46684 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataValueUpdateRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataValueUpdateRequestImpl.java
@@ -20,6 +20,7 @@ package org.apache.olingo.client.core.communication.request.cud;
import java.io.InputStream;
import java.net.URI;
+
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
@@ -27,20 +28,20 @@ import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.client.api.communication.request.cud.ODataValueUpdateRequest;
import org.apache.olingo.client.api.communication.response.ODataValueUpdateResponse;
-import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
-import org.apache.olingo.commons.api.format.ODataValueFormat;
import org.apache.olingo.client.api.http.HttpClientException;
import org.apache.olingo.client.api.http.HttpMethod;
-import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
+import org.apache.olingo.client.core.uri.URIUtils;
+import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.format.ODataFormat;
/**
* This class implements an OData update entity property value request.
*/
-public class ODataValueUpdateRequestImpl extends AbstractODataBasicRequest<ODataValueUpdateResponse, ODataValueFormat>
- implements ODataValueUpdateRequest {
+public class ODataValueUpdateRequestImpl extends AbstractODataBasicRequest<ODataValueUpdateResponse>
+ implements ODataValueUpdateRequest {
/**
* Value to be created.
@@ -55,17 +56,19 @@ public class ODataValueUpdateRequestImpl extends AbstractODataBasicRequest<OData
* @param targetURI entity set or entity or entity property URI.
* @param value value to be created.
*/
- ODataValueUpdateRequestImpl(final CommonODataClient odataClient,
+ ODataValueUpdateRequestImpl(final CommonODataClient<?> odataClient,
final HttpMethod method, final URI targetURI, final ODataPrimitiveValue value) {
- super(odataClient, ODataValueFormat.class, method, targetURI);
+ super(odataClient, method, targetURI);
// set request body
this.value = value;
}
- /**
- * {@inheritDoc }
- */
+ @Override
+ public ODataFormat getDefaultFormat() {
+ return odataClient.getConfiguration().getDefaultValueFormat();
+ }
+
@Override
public ODataValueUpdateResponse execute() {
final InputStream input = getPayload();
@@ -118,11 +121,11 @@ public class ODataValueUpdateRequestImpl extends AbstractODataBasicRequest<OData
@Override
public ODataPrimitiveValue getBody() {
if (value == null) {
- final ODataValueFormat format = ODataValueFormat.fromString(getAccept());
+ final ODataFormat format = ODataFormat.fromString(getAccept());
try {
value = odataClient.getObjectFactory().newPrimitiveValueBuilder().
- setType(format == ODataValueFormat.TEXT
+ setType(format == ODataFormat.TEXT_PLAIN
? EdmPrimitiveTypeKind.String : EdmPrimitiveTypeKind.Stream).
setText(IOUtils.toString(getRawResponse())).
build();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/ODataLinkCreateRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/ODataLinkCreateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/ODataLinkCreateRequestImpl.java
index 2f43812..1de01fd 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/ODataLinkCreateRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/ODataLinkCreateRequestImpl.java
@@ -39,7 +39,7 @@ import org.apache.olingo.commons.api.serialization.ODataSerializerException;
/**
* This class implements an insert link OData request.
*/
-public class ODataLinkCreateRequestImpl extends AbstractODataBasicRequest<ODataLinkOperationResponse, ODataFormat>
+public class ODataLinkCreateRequestImpl extends AbstractODataBasicRequest<ODataLinkOperationResponse>
implements ODataLinkCreateRequest {
/**
@@ -55,14 +55,16 @@ public class ODataLinkCreateRequestImpl extends AbstractODataBasicRequest<ODataL
* @param link entity to be linked.
*/
ODataLinkCreateRequestImpl(final CommonODataClient<?> odataClient, final URI targetURI, final ODataLink link) {
- super(odataClient, ODataFormat.class, HttpMethod.POST, targetURI);
+ super(odataClient, HttpMethod.POST, targetURI);
// set request body
this.link = link;
}
- /**
- * {@inheritDoc}
- */
+ @Override
+ public ODataFormat getDefaultFormat() {
+ return odataClient.getConfiguration().getDefaultFormat();
+ }
+
@Override
public ODataLinkOperationResponse execute() {
final InputStream input = getPayload();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/ODataLinkUpdateRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/ODataLinkUpdateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/ODataLinkUpdateRequestImpl.java
index 59172ec..aa00574 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/ODataLinkUpdateRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/ODataLinkUpdateRequestImpl.java
@@ -39,8 +39,8 @@ import org.apache.olingo.commons.api.serialization.ODataSerializerException;
/**
* This class implements an update link OData request.
*/
-public class ODataLinkUpdateRequestImpl extends AbstractODataBasicRequest<ODataLinkOperationResponse, ODataFormat>
- implements ODataLinkUpdateRequest {
+public class ODataLinkUpdateRequestImpl extends AbstractODataBasicRequest<ODataLinkOperationResponse>
+ implements ODataLinkUpdateRequest {
/**
* Entity to be linked.
@@ -57,13 +57,17 @@ public class ODataLinkUpdateRequestImpl extends AbstractODataBasicRequest<ODataL
*/
ODataLinkUpdateRequestImpl(final CommonODataClient<?> odataClient,
final HttpMethod method, final URI targetURI, final ODataLink link) {
-
- super(odataClient, ODataFormat.class, method, targetURI);
+ super(odataClient, method, targetURI);
// set request body
this.link = link;
}
@Override
+ public ODataFormat getDefaultFormat() {
+ return odataClient.getConfiguration().getDefaultFormat();
+ }
+
+ @Override
public ODataLinkOperationResponse execute() {
final InputStream input = getPayload();
((HttpEntityEnclosingRequestBase) request).setEntity(URIUtils.buildInputStreamEntity(odataClient, input));
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
index b6b476e..714dd5e 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
@@ -46,7 +46,6 @@ import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.domain.ODataInvokeResult;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
import org.apache.olingo.commons.api.serialization.ODataSerializerException;
@@ -54,7 +53,7 @@ import org.apache.olingo.commons.api.serialization.ODataSerializerException;
* This class implements an OData invoke operation request.
*/
public abstract class AbstractODataInvokeRequest<T extends ODataInvokeResult>
- extends AbstractODataBasicRequest<ODataInvokeResponse<T>, ODataPubFormat>
+ extends AbstractODataBasicRequest<ODataInvokeResponse<T>>
implements ODataInvokeRequest<T>, ODataBatchableRequest {
private final Class<T> reference;
@@ -78,15 +77,12 @@ public abstract class AbstractODataInvokeRequest<T extends ODataInvokeResult>
final HttpMethod method,
final URI uri) {
- super(odataClient, ODataPubFormat.class, method, uri);
+ super(odataClient, method, uri);
this.reference = reference;
this.parameters = new LinkedHashMap<String, ODataValue>();
}
- /**
- * {@inheritDoc }
- */
@Override
public void setParameters(final Map<String, ODataValue> parameters) {
this.parameters.clear();
@@ -95,20 +91,25 @@ public abstract class AbstractODataInvokeRequest<T extends ODataInvokeResult>
}
}
- private String getActualFormat(final ODataPubFormat format) {
- return (CommonODataProperty.class.isAssignableFrom(reference) && format == ODataPubFormat.ATOM)
+ @Override
+ public ODataFormat getDefaultFormat() {
+ return odataClient.getConfiguration().getDefaultPubFormat();
+ }
+
+ private String getActualFormat(final ODataFormat format) {
+ return (CommonODataProperty.class.isAssignableFrom(reference) && format == ODataFormat.ATOM)
? ODataFormat.XML.toString(odataClient.getServiceVersion())
: format.toString(odataClient.getServiceVersion());
}
@Override
- public void setFormat(final ODataPubFormat format) {
+ public void setFormat(final ODataFormat format) {
final String _format = getActualFormat(format);
setAccept(_format);
setContentType(_format);
}
- protected abstract ODataPubFormat getPOSTParameterFormat();
+ protected abstract ODataFormat getPOSTParameterFormat();
@Override
protected InputStream getPayload() {
@@ -216,10 +217,10 @@ public abstract class AbstractODataInvokeRequest<T extends ODataInvokeResult>
InputStream responseStream = this.payload == null ? res.getEntity().getContent() : this.payload;
if (CommonODataEntitySet.class.isAssignableFrom(reference)) {
invokeResult = reference.cast(odataClient.getReader().readEntitySet(responseStream,
- ODataPubFormat.fromString(getContentType())));
+ ODataFormat.fromString(getContentType())));
} else if (CommonODataEntity.class.isAssignableFrom(reference)) {
invokeResult = reference.cast(odataClient.getReader().readEntity(responseStream,
- ODataPubFormat.fromString(getContentType())));
+ ODataFormat.fromString(getContentType())));
} else if (CommonODataProperty.class.isAssignableFrom(reference)) {
invokeResult = reference.cast(odataClient.getReader().readProperty(responseStream,
ODataFormat.fromString(getContentType())));
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/ODataInvokeRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/ODataInvokeRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/ODataInvokeRequestImpl.java
index 84a4406..bec9628 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/ODataInvokeRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/ODataInvokeRequestImpl.java
@@ -21,6 +21,7 @@ package org.apache.olingo.client.core.communication.request.invoke.v3;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Map;
+
import org.apache.http.client.utils.URIBuilder;
import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.client.api.http.HttpMethod;
@@ -28,7 +29,7 @@ import org.apache.olingo.client.core.communication.request.invoke.AbstractODataI
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.domain.ODataInvokeResult;
import org.apache.olingo.commons.api.domain.ODataValue;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
public class ODataInvokeRequestImpl<T extends ODataInvokeResult> extends AbstractODataInvokeRequest<T> {
@@ -39,8 +40,8 @@ public class ODataInvokeRequestImpl<T extends ODataInvokeResult> extends Abstrac
}
@Override
- protected ODataPubFormat getPOSTParameterFormat() {
- return ODataPubFormat.JSON;
+ protected ODataFormat getPOSTParameterFormat() {
+ return ODataFormat.JSON;
}
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/ODataInvokeRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/ODataInvokeRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/ODataInvokeRequestImpl.java
index 7860c6b..1aa607b 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/ODataInvokeRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/ODataInvokeRequestImpl.java
@@ -22,6 +22,7 @@ import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URLEncoder;
import java.util.Map;
+
import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.client.api.http.HttpMethod;
import org.apache.olingo.client.core.communication.request.invoke.AbstractODataInvokeRequest;
@@ -29,11 +30,11 @@ import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.Constants;
import org.apache.olingo.commons.api.domain.ODataInvokeResult;
import org.apache.olingo.commons.api.domain.ODataValue;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
public class ODataInvokeRequestImpl<T extends ODataInvokeResult> extends AbstractODataInvokeRequest<T> {
- private ODataPubFormat format;
+ private ODataFormat format;
public ODataInvokeRequestImpl(final CommonODataClient<?> odataClient, final Class<T> reference,
final HttpMethod method, final URI uri) {
@@ -42,13 +43,13 @@ public class ODataInvokeRequestImpl<T extends ODataInvokeResult> extends Abstrac
}
@Override
- public void setFormat(final ODataPubFormat format) {
+ public void setFormat(final ODataFormat format) {
super.setFormat(format);
this.format = format;
}
@Override
- protected ODataPubFormat getPOSTParameterFormat() {
+ protected ODataFormat getPOSTParameterFormat() {
return format == null ? getDefaultFormat() : format;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractMetadataRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractMetadataRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractMetadataRequestImpl.java
index c851b49..e84beb9 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractMetadataRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractMetadataRequestImpl.java
@@ -24,10 +24,10 @@ import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.client.api.communication.request.ODataRequest;
import org.apache.olingo.commons.api.format.ODataFormat;
-public abstract class AbstractMetadataRequestImpl<V> extends AbstractODataRetrieveRequest<V, ODataFormat> {
+public abstract class AbstractMetadataRequestImpl<V> extends AbstractODataRetrieveRequest<V> {
- public AbstractMetadataRequestImpl(final CommonODataClient odataClient, final URI query) {
- super(odataClient, ODataFormat.class, query);
+ public AbstractMetadataRequestImpl(final CommonODataClient<?> odataClient, final URI query) {
+ super(odataClient, query);
super.setAccept(ContentType.APPLICATION_XML.getMimeType());
super.setContentType(ContentType.APPLICATION_XML.getMimeType());
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractODataRetrieveRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractODataRetrieveRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractODataRetrieveRequest.java
index 3fc51e1..1a28a14 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractODataRetrieveRequest.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractODataRetrieveRequest.java
@@ -20,12 +20,12 @@ package org.apache.olingo.client.core.communication.request.retrieve;
import java.io.InputStream;
import java.net.URI;
+
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.client.api.communication.request.retrieve.ODataRetrieveRequest;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
-import org.apache.olingo.commons.api.format.Format;
import org.apache.olingo.client.api.http.HttpMethod;
import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
@@ -33,32 +33,24 @@ import org.apache.olingo.client.core.communication.response.AbstractODataRespons
/**
* This is an abstract representation of an OData retrieve query request returning one or more result item.
*/
-public abstract class AbstractODataRetrieveRequest<V, T extends Format>
- extends AbstractODataBasicRequest<ODataRetrieveResponse<V>, T>
- implements ODataRetrieveRequest<V, T> {
+public abstract class AbstractODataRetrieveRequest<T>
+ extends AbstractODataBasicRequest<ODataRetrieveResponse<T>>
+ implements ODataRetrieveRequest<T> {
/**
* Private constructor.
*
* @param odataClient client instance getting this request
- * @param formatRef reference class for the format being used
* @param query query to be executed.
*/
- public AbstractODataRetrieveRequest(final CommonODataClient<?> odataClient, final Class<T> formatRef,
- final URI query) {
-
- super(odataClient, formatRef, HttpMethod.GET, query);
+ public AbstractODataRetrieveRequest(final CommonODataClient<?> odataClient, final URI query) {
+ super(odataClient, HttpMethod.GET, query);
}
- /**
- * {@inheritDoc }
- */
@Override
- public abstract ODataRetrieveResponse<V> execute();
+ public abstract ODataRetrieveResponse<T> execute();
/**
- * {@inheritDoc }
- * <p>
* This kind of request doesn't have any payload: null will be returned.
*/
@Override
@@ -70,7 +62,7 @@ public abstract class AbstractODataRetrieveRequest<V, T extends Format>
* Response abstract class about an ODataRetrieveRequest.
*/
protected abstract class AbstractODataRetrieveResponse
- extends AbstractODataResponse implements ODataRetrieveResponse<V> {
+ extends AbstractODataResponse implements ODataRetrieveResponse<T> {
/**
* Constructor.
@@ -95,10 +87,7 @@ public abstract class AbstractODataRetrieveRequest<V, T extends Format>
return res;
}
- /**
- * {@inheritDoc }
- */
@Override
- public abstract V getBody();
+ public abstract T getBody();
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntityRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntityRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntityRequestImpl.java
index f75333e..427e5b3 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntityRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntityRequestImpl.java
@@ -28,14 +28,14 @@ import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse
import org.apache.olingo.commons.api.data.Entity;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
/**
* This class implements an OData retrieve query request returning a single entity.
*/
public class ODataEntityRequestImpl<E extends CommonODataEntity>
- extends AbstractODataRetrieveRequest<E, ODataPubFormat> implements ODataEntityRequest<E> {
+ extends AbstractODataRetrieveRequest<E> implements ODataEntityRequest<E> {
/**
* Private constructor.
@@ -44,7 +44,12 @@ public class ODataEntityRequestImpl<E extends CommonODataEntity>
* @param query query to be executed.
*/
public ODataEntityRequestImpl(final CommonODataClient<?> odataClient, final URI query) {
- super(odataClient, ODataPubFormat.class, query);
+ super(odataClient, query);
+ }
+
+ @Override
+ public ODataFormat getDefaultFormat() {
+ return odataClient.getConfiguration().getDefaultPubFormat();
}
@Override
@@ -83,7 +88,7 @@ public class ODataEntityRequestImpl<E extends CommonODataEntity>
public E getBody() {
if (entity == null) {
try {
- final ResWrap<Entity> resource = odataClient.getDeserializer(ODataPubFormat.fromString(getContentType()))
+ final ResWrap<Entity> resource = odataClient.getDeserializer(ODataFormat.fromString(getContentType()))
.toEntity(getRawResponse());
entity = (E) odataClient.getBinder().getODataEntity(resource);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetIteratorRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetIteratorRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetIteratorRequestImpl.java
index cca5053..5cf1377 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetIteratorRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetIteratorRequestImpl.java
@@ -19,6 +19,7 @@
package org.apache.olingo.client.core.communication.request.retrieve;
import java.net.URI;
+
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.olingo.client.api.CommonODataClient;
@@ -27,16 +28,16 @@ import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse
import org.apache.olingo.client.api.domain.ODataEntitySetIterator;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
/**
* This class implements an OData EntitySet query request.
*/
public class ODataEntitySetIteratorRequestImpl<ES extends CommonODataEntitySet, E extends CommonODataEntity>
- extends AbstractODataRetrieveRequest<ODataEntitySetIterator<ES, E>, ODataPubFormat>
+ extends AbstractODataRetrieveRequest<ODataEntitySetIterator<ES, E>>
implements ODataEntitySetIteratorRequest<ES, E> {
- private ODataEntitySetIterator entitySetIterator = null;
+ private ODataEntitySetIterator<ES, E> entitySetIterator = null;
/**
* Private constructor.
@@ -45,12 +46,14 @@ public class ODataEntitySetIteratorRequestImpl<ES extends CommonODataEntitySet,
* @param query query to be executed.
*/
public ODataEntitySetIteratorRequestImpl(final CommonODataClient<?> odataClient, final URI query) {
- super(odataClient, ODataPubFormat.class, query);
+ super(odataClient, query);
+ }
+
+ @Override
+ public ODataFormat getDefaultFormat() {
+ return odataClient.getConfiguration().getDefaultPubFormat();
}
- /**
- * {@inheritDoc }
- */
@Override
public ODataRetrieveResponse<ODataEntitySetIterator<ES, E>> execute() {
final HttpResponse res = doExecute();
@@ -72,15 +75,11 @@ public class ODataEntitySetIteratorRequestImpl<ES extends CommonODataEntitySet,
super(client, res);
}
- /**
- * {@inheritDoc }
- */
@Override
- @SuppressWarnings("unchecked")
public ODataEntitySetIterator<ES, E> getBody() {
if (entitySetIterator == null) {
entitySetIterator = new ODataEntitySetIterator<ES, E>(
- odataClient, getRawResponse(), ODataPubFormat.fromString(getContentType()));
+ odataClient, getRawResponse(), ODataFormat.fromString(getContentType()));
}
return entitySetIterator;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java
index 8013cfd..c560576 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java
@@ -28,7 +28,7 @@ import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse
import org.apache.olingo.commons.api.data.EntitySet;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
/**
@@ -37,7 +37,7 @@ import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
* @param <ES> concrete ODataEntitySet implementation
*/
public class ODataEntitySetRequestImpl<ES extends CommonODataEntitySet>
- extends AbstractODataRetrieveRequest<ES, ODataPubFormat> implements ODataEntitySetRequest<ES> {
+ extends AbstractODataRetrieveRequest<ES> implements ODataEntitySetRequest<ES> {
private ES entitySet = null;
@@ -48,12 +48,14 @@ public class ODataEntitySetRequestImpl<ES extends CommonODataEntitySet>
* @param query query to be executed.
*/
public ODataEntitySetRequestImpl(final CommonODataClient<?> odataClient, final URI query) {
- super(odataClient, ODataPubFormat.class, query);
+ super(odataClient, query);
+ }
+
+ @Override
+ public ODataFormat getDefaultFormat() {
+ return odataClient.getConfiguration().getDefaultPubFormat();
}
- /**
- * {@inheritDoc }
- */
@Override
public ODataRetrieveResponse<ES> execute() {
final HttpResponse res = doExecute();
@@ -84,15 +86,12 @@ public class ODataEntitySetRequestImpl<ES extends CommonODataEntitySet>
super(client, res);
}
- /**
- * {@inheritDoc }
- */
@Override
@SuppressWarnings("unchecked")
public ES getBody() {
if (entitySet == null) {
try {
- final ResWrap<EntitySet> resource = odataClient.getDeserializer(ODataPubFormat.fromString(getContentType()))
+ final ResWrap<EntitySet> resource = odataClient.getDeserializer(ODataFormat.fromString(getContentType()))
.toEntitySet(getRawResponse());
entitySet = (ES) odataClient.getBinder().getODataEntitySet(resource);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataMediaRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataMediaRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataMediaRequestImpl.java
index 527ab2f..ad2263e 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataMediaRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataMediaRequestImpl.java
@@ -21,20 +21,20 @@ package org.apache.olingo.client.core.communication.request.retrieve;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
+
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.client.api.communication.header.HeaderName;
import org.apache.olingo.client.api.communication.request.retrieve.ODataMediaRequest;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
-import org.apache.olingo.commons.api.format.ODataMediaFormat;
import org.apache.olingo.client.api.http.HttpClientException;
+import org.apache.olingo.commons.api.format.ODataFormat;
/**
* This class implements an OData media query request.
*/
-public class ODataMediaRequestImpl extends AbstractODataRetrieveRequest<InputStream, ODataMediaFormat>
- implements ODataMediaRequest {
+public class ODataMediaRequestImpl extends AbstractODataRetrieveRequest<InputStream> implements ODataMediaRequest {
/**
* Private constructor.
@@ -43,19 +43,21 @@ public class ODataMediaRequestImpl extends AbstractODataRetrieveRequest<InputStr
* @param query query to be executed.
*/
ODataMediaRequestImpl(final CommonODataClient<?> odataClient, final URI query) {
- super(odataClient, ODataMediaFormat.class, query);
+ super(odataClient, query);
- setAccept(ODataMediaFormat.APPLICATION_OCTET_STREAM.toString());
- setContentType(ODataMediaFormat.APPLICATION_OCTET_STREAM.toString());
+ setAccept(ODataFormat.APPLICATION_OCTET_STREAM.toString());
+ setContentType(ODataFormat.APPLICATION_OCTET_STREAM.toString());
this.odataHeaders.removeHeader(HeaderName.minDataServiceVersion);
this.odataHeaders.removeHeader(HeaderName.maxDataServiceVersion);
this.odataHeaders.removeHeader(HeaderName.dataServiceVersion);
}
- /**
- * {@inheritDoc }
- */
+ @Override
+ public ODataFormat getDefaultFormat() {
+ return odataClient.getConfiguration().getDefaultMediaFormat();
+ }
+
@Override
public ODataRetrieveResponse<InputStream> execute() {
final HttpResponse res = doExecute();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataPropertyRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataPropertyRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataPropertyRequestImpl.java
index 3d0b64f..f13da7d 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataPropertyRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataPropertyRequestImpl.java
@@ -26,18 +26,18 @@ import org.apache.http.client.HttpClient;
import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
+import org.apache.olingo.client.api.http.HttpClientException;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
-import org.apache.olingo.client.api.http.HttpClientException;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.data.Property;
/**
* This class implements an OData entity property query request.
*/
public class ODataPropertyRequestImpl<T extends CommonODataProperty>
- extends AbstractODataRetrieveRequest<T, ODataFormat> implements ODataPropertyRequest<T> {
+ extends AbstractODataRetrieveRequest<T> implements ODataPropertyRequest<T> {
/**
* Private constructor.
@@ -46,7 +46,12 @@ public class ODataPropertyRequestImpl<T extends CommonODataProperty>
* @param query query to be executed.
*/
public ODataPropertyRequestImpl(final CommonODataClient<?> odataClient, final URI query) {
- super(odataClient, ODataFormat.class, query);
+ super(odataClient, query);
+ }
+
+ @Override
+ public ODataFormat getDefaultFormat() {
+ return odataClient.getConfiguration().getDefaultFormat();
}
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataRawRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataRawRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataRawRequestImpl.java
index 070f59f..e005c8b 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataRawRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataRawRequestImpl.java
@@ -32,14 +32,13 @@ import org.apache.olingo.client.api.http.HttpMethod;
import org.apache.olingo.client.core.communication.request.AbstractODataRequest;
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
/**
* This class implements a generic OData request.
*/
-public class ODataRawRequestImpl extends AbstractODataRequest<ODataPubFormat>
- implements ODataRawRequest {
+public class ODataRawRequestImpl extends AbstractODataRequest implements ODataRawRequest {
/**
* Constructor.
@@ -48,7 +47,12 @@ public class ODataRawRequestImpl extends AbstractODataRequest<ODataPubFormat>
* @param uri request URI.
*/
ODataRawRequestImpl(final CommonODataClient<?> odataClient, final URI uri) {
- super(odataClient, ODataPubFormat.class, HttpMethod.GET, uri);
+ super(odataClient, HttpMethod.GET, uri);
+ }
+
+ @Override
+ public ODataFormat getDefaultFormat() {
+ return odataClient.getConfiguration().getDefaultPubFormat();
}
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataServiceDocumentRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataServiceDocumentRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataServiceDocumentRequestImpl.java
index 6014b5b..d252c6e 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataServiceDocumentRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataServiceDocumentRequestImpl.java
@@ -34,7 +34,7 @@ import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
/**
* This class implements an OData service document request.
*/
-public class ODataServiceDocumentRequestImpl extends AbstractODataRetrieveRequest<ODataServiceDocument, ODataFormat>
+public class ODataServiceDocumentRequestImpl extends AbstractODataRetrieveRequest<ODataServiceDocument>
implements ODataServiceDocumentRequest {
/**
@@ -44,12 +44,14 @@ public class ODataServiceDocumentRequestImpl extends AbstractODataRetrieveReques
* @param uri request URI.
*/
ODataServiceDocumentRequestImpl(final CommonODataClient<?> odataClient, final URI uri) {
- super(odataClient, ODataFormat.class, uri);
+ super(odataClient, uri);
+ }
+
+ @Override
+ public ODataFormat getDefaultFormat() {
+ return odataClient.getConfiguration().getDefaultFormat();
}
- /**
- * {@inheritDoc }
- */
@Override
public ODataRetrieveResponse<ODataServiceDocument> execute() {
final HttpResponse res = doExecute();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataValueRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataValueRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataValueRequestImpl.java
index 7bc9fdf..6e1e466 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataValueRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataValueRequestImpl.java
@@ -19,22 +19,23 @@
package org.apache.olingo.client.core.communication.request.retrieve;
import java.net.URI;
+
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.client.api.communication.request.retrieve.ODataValueRequest;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
-import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
-import org.apache.olingo.commons.api.format.ODataValueFormat;
import org.apache.olingo.client.api.http.HttpClientException;
+import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.format.ODataFormat;
/**
* This class implements an OData entity property value query request.
*/
-public class ODataValueRequestImpl extends AbstractODataRetrieveRequest<ODataPrimitiveValue, ODataValueFormat>
- implements ODataValueRequest {
+public class ODataValueRequestImpl extends AbstractODataRetrieveRequest<ODataPrimitiveValue>
+ implements ODataValueRequest {
/**
* Private constructor.
@@ -43,12 +44,14 @@ public class ODataValueRequestImpl extends AbstractODataRetrieveRequest<ODataPri
* @param query query to be executed.
*/
ODataValueRequestImpl(final CommonODataClient<?> odataClient, final URI query) {
- super(odataClient, ODataValueFormat.class, query);
+ super(odataClient, query);
+ }
+
+ @Override
+ public ODataFormat getDefaultFormat() {
+ return odataClient.getConfiguration().getDefaultValueFormat();
}
- /**
- * {@inheritDoc }
- */
@Override
public ODataRetrieveResponse<ODataPrimitiveValue> execute() {
final HttpResponse res = doExecute();
@@ -87,11 +90,11 @@ public class ODataValueRequestImpl extends AbstractODataRetrieveRequest<ODataPri
@Override
public ODataPrimitiveValue getBody() {
if (value == null) {
- final ODataValueFormat format = ODataValueFormat.fromString(getContentType());
+ final ODataFormat format = ODataFormat.fromString(getContentType());
try {
value = odataClient.getObjectFactory().newPrimitiveValueBuilder().
- setType(format == ODataValueFormat.TEXT
+ setType(format == ODataFormat.TEXT_PLAIN
? EdmPrimitiveTypeKind.String : EdmPrimitiveTypeKind.Stream).
setText(IOUtils.toString(getRawResponse())).
build();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/ODataLinkCollectionRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/ODataLinkCollectionRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/ODataLinkCollectionRequestImpl.java
index 0761aff..bb3ee8b 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/ODataLinkCollectionRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/ODataLinkCollectionRequestImpl.java
@@ -35,8 +35,8 @@ import org.apache.olingo.client.core.communication.request.retrieve.AbstractODat
/**
* This class implements an OData link query request.
*/
-public class ODataLinkCollectionRequestImpl extends AbstractODataRetrieveRequest<ODataLinkCollection, ODataFormat>
- implements ODataLinkCollectionRequest {
+public class ODataLinkCollectionRequestImpl extends AbstractODataRetrieveRequest<ODataLinkCollection>
+ implements ODataLinkCollectionRequest {
/**
* Private constructor.
@@ -46,13 +46,15 @@ public class ODataLinkCollectionRequestImpl extends AbstractODataRetrieveRequest
* @param linkName link name.
*/
ODataLinkCollectionRequestImpl(final ODataClient odataClient, final URI targetURI, final String linkName) {
- super(odataClient, ODataFormat.class,
- odataClient.newURIBuilder(targetURI.toASCIIString()).appendLinksSegment(linkName).build());
+ super(odataClient,
+ odataClient.newURIBuilder(targetURI.toASCIIString()).appendLinksSegment(linkName).build());
+ }
+
+ @Override
+ public ODataFormat getDefaultFormat() {
+ return odataClient.getConfiguration().getDefaultFormat();
}
- /**
- * {@inheritDoc }
- */
@Override
public ODataRetrieveResponse<ODataLinkCollection> execute() {
return new ODataLinkCollectionResponseImpl(httpClient, doExecute());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/ODataDeltaRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/ODataDeltaRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/ODataDeltaRequestImpl.java
index d817dc4..bd32c9e 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/ODataDeltaRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/ODataDeltaRequestImpl.java
@@ -32,14 +32,19 @@ import org.apache.olingo.client.core.communication.request.retrieve.AbstractODat
import org.apache.olingo.commons.api.data.Delta;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.domain.v4.ODataDelta;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
-public class ODataDeltaRequestImpl extends AbstractODataRetrieveRequest<ODataDelta, ODataPubFormat>
+public class ODataDeltaRequestImpl extends AbstractODataRetrieveRequest<ODataDelta>
implements ODataDeltaRequest {
public ODataDeltaRequestImpl(final CommonODataClient<?> odataClient, final URI query) {
- super(odataClient, ODataPubFormat.class, query);
+ super(odataClient, query);
+ }
+
+ @Override
+ public ODataFormat getDefaultFormat() {
+ return odataClient.getConfiguration().getDefaultPubFormat();
}
@Override
@@ -67,7 +72,7 @@ public class ODataDeltaRequestImpl extends AbstractODataRetrieveRequest<ODataDel
if (delta == null) {
try {
final ResWrap<Delta> resource = ((ODataClient) odataClient)
- .getDeserializer(ODataPubFormat.fromString(getContentType()))
+ .getDeserializer(ODataFormat.fromString(getContentType()))
.toDelta(res.getEntity().getContent());
delta = ((ODataClient) odataClient).getBinder().getODataDelta(resource);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedEntityRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedEntityRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedEntityRequest.java
index e04d5d2..edbe31e 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedEntityRequest.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedEntityRequest.java
@@ -19,12 +19,13 @@
package org.apache.olingo.client.core.communication.request.streamed;
import java.net.URI;
+
import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.client.api.communication.request.ODataPayloadManager;
import org.apache.olingo.client.api.communication.request.streamed.ODataStreamedEntityRequest;
import org.apache.olingo.client.api.communication.response.ODataResponse;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.client.api.http.HttpMethod;
+import org.apache.olingo.commons.api.format.ODataFormat;
/**
* Abstract class representing a request concerning a streamed entity.
@@ -36,7 +37,7 @@ public abstract class AbstractODataStreamedEntityRequest<V extends ODataResponse
extends AbstractODataStreamedRequest<V, T>
implements ODataStreamedEntityRequest<V, T> {
- private ODataPubFormat format;
+ private ODataFormat format;
/**
* Constructor.
@@ -52,19 +53,13 @@ public abstract class AbstractODataStreamedEntityRequest<V extends ODataResponse
setAccept(getFormat().toString(odataClient.getServiceVersion()));
}
- /**
- * {@inheritDoc }
- */
@Override
- public final ODataPubFormat getFormat() {
+ public final ODataFormat getFormat() {
return format == null ? odataClient.getConfiguration().getDefaultPubFormat() : format;
}
- /**
- * {@inheritDoc }
- */
@Override
- public final void setFormat(final ODataPubFormat format) {
+ public final void setFormat(final ODataFormat format) {
this.format = format;
setAccept(format.toString(odataClient.getServiceVersion()));
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedRequest.java
index 4f3abe9..0f6a188 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedRequest.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedRequest.java
@@ -23,23 +23,24 @@ import java.io.InputStream;
import java.net.URI;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
+
+import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import org.apache.http.entity.ContentType;
-import org.apache.olingo.client.api.ODataBatchConstants;
import org.apache.olingo.client.api.CommonODataClient;
+import org.apache.olingo.client.api.ODataBatchConstants;
import org.apache.olingo.client.api.communication.request.ODataPayloadManager;
import org.apache.olingo.client.api.communication.request.ODataStreamedRequest;
import org.apache.olingo.client.api.communication.request.ODataStreamer;
import org.apache.olingo.client.api.communication.request.batch.CommonODataBatchRequest;
import org.apache.olingo.client.api.communication.response.ODataResponse;
-import org.apache.olingo.commons.api.format.ODataMediaFormat;
import org.apache.olingo.client.api.http.HttpMethod;
-import org.apache.olingo.client.core.uri.URIUtils;
-import org.apache.olingo.client.core.communication.request.Wrapper;
import org.apache.olingo.client.core.communication.request.AbstractODataRequest;
-import org.apache.commons.io.IOUtils;
+import org.apache.olingo.client.core.communication.request.Wrapper;
+import org.apache.olingo.client.core.uri.URIUtils;
+import org.apache.olingo.commons.api.format.ODataFormat;
/**
* Streamed OData request abstract class.
@@ -48,7 +49,7 @@ import org.apache.commons.io.IOUtils;
* @param <T> OData request payload type corresponding to the request implementation.
*/
public abstract class AbstractODataStreamedRequest<V extends ODataResponse, T extends ODataPayloadManager<V>>
- extends AbstractODataRequest<ODataMediaFormat> implements ODataStreamedRequest<V, T> {
+ extends AbstractODataRequest implements ODataStreamedRequest<V, T> {
/**
* OData payload stream manager.
@@ -71,11 +72,16 @@ public abstract class AbstractODataStreamedRequest<V extends ODataResponse, T ex
public AbstractODataStreamedRequest(final CommonODataClient<?> odataClient,
final HttpMethod method, final URI uri) {
- super(odataClient, ODataMediaFormat.class, method, uri);
+ super(odataClient, method, uri);
setAccept(ContentType.APPLICATION_OCTET_STREAM.getMimeType());
setContentType(ContentType.APPLICATION_OCTET_STREAM.getMimeType());
}
+ @Override
+ public ODataFormat getDefaultFormat() {
+ return odataClient.getConfiguration().getDefaultMediaFormat();
+ }
+
/**
* Gets OData request payload management object.
*
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/v4/AsyncRequestWrapperImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/v4/AsyncRequestWrapperImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/v4/AsyncRequestWrapperImpl.java
index 7aef8a9..2ec51e0 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/v4/AsyncRequestWrapperImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/v4/AsyncRequestWrapperImpl.java
@@ -155,7 +155,7 @@ public class AsyncRequestWrapperImpl<R extends ODataResponse> extends AbstractRe
if (res.getStatusLine().getStatusCode() == 202) {
retrieveMonitorDetails(res);
} else {
- response = (R) ((AbstractODataRequest<?>) odataRequest).getResponseTemplate().initFromHttpResponse(res);
+ response = (R) ((AbstractODataRequest) odataRequest).getResponseTemplate().initFromHttpResponse(res);
}
}
@@ -245,7 +245,7 @@ public class AsyncRequestWrapperImpl<R extends ODataResponse> extends AbstractRe
private R instantiateResponse(final HttpResponse res) {
R odataResponse;
try {
- odataResponse = (R) ((AbstractODataRequest<?>) odataRequest).getResponseTemplate().
+ odataResponse = (R) ((AbstractODataRequest) odataRequest).getResponseTemplate().
initFromEnclosedPart(res.getEntity().getContent());
} catch (Exception e) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AbstractODataDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AbstractODataDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AbstractODataDeserializer.java
index 18850e3..97b858b 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AbstractODataDeserializer.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AbstractODataDeserializer.java
@@ -27,9 +27,7 @@ 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.serialization.ODataDeserializer;
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
import org.apache.olingo.commons.core.serialization.AtomDeserializer;
@@ -51,9 +49,10 @@ public abstract class AbstractODataDeserializer {
protected final ODataServiceVersion version;
protected final ODataDeserializer deserializer;
- public AbstractODataDeserializer(final ODataServiceVersion version, final boolean serverMode, final Format format) {
+ public AbstractODataDeserializer(final ODataServiceVersion version, final boolean serverMode,
+ final ODataFormat format) {
this.version = version;
- if (format == ODataFormat.XML || format == ODataPubFormat.ATOM) {
+ if (format == ODataFormat.XML || format == ODataFormat.ATOM) {
deserializer = new AtomDeserializer(version);
} else {
deserializer = new JsonDeserializer(version, serverMode);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AbstractODataReader.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AbstractODataReader.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AbstractODataReader.java
index 94634d4..fca8273 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AbstractODataReader.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AbstractODataReader.java
@@ -25,27 +25,25 @@ import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.client.api.data.ServiceDocument;
-import org.apache.olingo.commons.api.domain.ODataError;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.domain.CommonODataEntity;
-import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.apache.olingo.client.api.domain.ODataEntitySetIterator;
import org.apache.olingo.client.api.edm.xml.Schema;
-import org.apache.olingo.commons.api.domain.CommonODataProperty;
-import org.apache.olingo.commons.api.domain.ODataServiceDocument;
-import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.client.api.edm.xml.XMLMetadata;
import org.apache.olingo.client.api.serialization.CommonODataReader;
import org.apache.olingo.client.core.edm.EdmClientImpl;
-import org.apache.olingo.commons.api.data.ResWrap;
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.CommonODataEntity;
+import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
+import org.apache.olingo.commons.api.domain.CommonODataProperty;
+import org.apache.olingo.commons.api.domain.ODataError;
+import org.apache.olingo.commons.api.domain.ODataServiceDocument;
+import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.format.ODataValueFormat;
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -96,16 +94,16 @@ public abstract class AbstractODataReader implements CommonODataReader {
(URI) null,
null,
reference.cast(new ODataEntitySetIterator<CommonODataEntitySet, CommonODataEntity>(
- client, src, ODataPubFormat.fromString(format))));
+ client, src, ODataFormat.fromString(format))));
} else if (CommonODataEntitySet.class.isAssignableFrom(reference)) {
- final ResWrap<EntitySet> resource = client.getDeserializer(ODataPubFormat.fromString(format))
+ final ResWrap<EntitySet> resource = client.getDeserializer(ODataFormat.fromString(format))
.toEntitySet(src);
res = new ResWrap<T>(
resource.getContextURL(),
resource.getMetadataETag(),
reference.cast(client.getBinder().getODataEntitySet(resource)));
} else if (CommonODataEntity.class.isAssignableFrom(reference)) {
- final ResWrap<Entity> container = client.getDeserializer(ODataPubFormat.fromString(format)).toEntity(src);
+ final ResWrap<Entity> container = client.getDeserializer(ODataFormat.fromString(format)).toEntity(src);
res = new ResWrap<T>(
container.getContextURL(),
container.getMetadataETag(),
@@ -121,7 +119,7 @@ public abstract class AbstractODataReader implements CommonODataReader {
(URI) null,
null,
reference.cast(client.getObjectFactory().newPrimitiveValueBuilder().
- setType(ODataValueFormat.fromString(format) == ODataValueFormat.TEXT
+ setType(ODataFormat.fromString(format) == ODataFormat.TEXT_PLAIN
? EdmPrimitiveTypeKind.String : EdmPrimitiveTypeKind.Stream).
setText(IOUtils.toString(src)).
build()));
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataWriterImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataWriterImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataWriterImpl.java
index da6c4e4..94cec0b 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataWriterImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataWriterImpl.java
@@ -34,7 +34,6 @@ import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.commons.api.serialization.ODataSerializerException;
public class ODataWriterImpl implements ODataWriter {
@@ -46,7 +45,7 @@ public class ODataWriterImpl implements ODataWriter {
}
@Override
- public InputStream writeEntities(final Collection<CommonODataEntity> entities, final ODataPubFormat format)
+ public InputStream writeEntities(final Collection<CommonODataEntity> entities, final ODataFormat format)
throws ODataSerializerException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
OutputStreamWriter writer;
@@ -67,7 +66,7 @@ public class ODataWriterImpl implements ODataWriter {
}
@Override
- public InputStream writeEntity(final CommonODataEntity entity, final ODataPubFormat format)
+ public InputStream writeEntity(final CommonODataEntity entity, final ODataFormat format)
throws ODataSerializerException {
return writeEntities(Collections.<CommonODataEntity>singleton(entity), format);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v3/ODataDeserializerImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v3/ODataDeserializerImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v3/ODataDeserializerImpl.java
index b99d170..a5cf318 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v3/ODataDeserializerImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v3/ODataDeserializerImpl.java
@@ -33,7 +33,6 @@ import org.apache.olingo.client.core.serialization.AbstractODataDeserializer;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.data.v3.LinkCollection;
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.serialization.ODataDeserializerException;
import org.apache.olingo.commons.core.serialization.AtomDeserializer;
@@ -41,9 +40,9 @@ import org.apache.olingo.commons.core.serialization.JsonLinkCollectionDeserializ
public class ODataDeserializerImpl extends AbstractODataDeserializer implements ODataDeserializer {
- private final Format format;
+ private final ODataFormat format;
- public ODataDeserializerImpl(final ODataServiceVersion version, final boolean serverMode, final Format format) {
+ public ODataDeserializerImpl(final ODataServiceVersion version, final boolean serverMode, final ODataFormat format) {
super(version, serverMode, format);
this.format = format;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v3/ODataReaderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v3/ODataReaderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v3/ODataReaderImpl.java
index 2297d4d..4661e58 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v3/ODataReaderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v3/ODataReaderImpl.java
@@ -21,7 +21,6 @@ package org.apache.olingo.client.core.serialization.v3;
import java.io.InputStream;
import org.apache.olingo.client.api.domain.v3.ODataLinkCollection;
-import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.client.api.serialization.v3.ODataReader;
import org.apache.olingo.client.api.v3.ODataClient;
import org.apache.olingo.client.core.serialization.AbstractODataReader;
@@ -30,7 +29,7 @@ import org.apache.olingo.commons.api.data.v3.LinkCollection;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
import org.apache.olingo.commons.api.domain.v3.ODataProperty;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
public class ODataReaderImpl extends AbstractODataReader implements ODataReader {
@@ -40,13 +39,13 @@ public class ODataReaderImpl extends AbstractODataReader implements ODataReader
}
@Override
- public ODataEntitySet readEntitySet(final InputStream input, final ODataPubFormat format)
+ public ODataEntitySet readEntitySet(final InputStream input, final ODataFormat format)
throws ODataDeserializerException {
return ((ODataClient) client).getBinder().getODataEntitySet(client.getDeserializer(format).toEntitySet(input));
}
@Override
- public ODataEntity readEntity(final InputStream input, final ODataPubFormat format)
+ public ODataEntity readEntity(final InputStream input, final ODataFormat format)
throws ODataDeserializerException {
return ((ODataClient) client).getBinder().getODataEntity(client.getDeserializer(format).toEntity(input));
}
[5/8] git commit: [OLINGO-317] Merged the format ENUMs
Posted by mi...@apache.org.
[OLINGO-317] Merged the format ENUMs
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/37abba5f
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/37abba5f
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/37abba5f
Branch: refs/heads/master
Commit: 37abba5f0e1b3e37c48524800390304657e5444e
Parents: b15439f
Author: Michael Bolz <mi...@sap.com>
Authored: Fri Jun 13 15:16:50 2014 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Fri Jun 13 15:26:16 2014 +0200
----------------------------------------------------------------------
.../ext/proxy/EntityContainerFactory.java | 5 +-
.../commons/AbstractPersistenceManager.java | 9 +-
.../proxy/commons/EntityInvocationHandler.java | 8 +-
.../commons/EntitySetInvocationHandler.java | 6 +-
.../NonTransactionalPersistenceManagerImpl.java | 6 +-
.../olingo/fit/AbstractBaseTestITCase.java | 5 +-
.../olingo/fit/v3/AbstractTestITCase.java | 29 +--
.../apache/olingo/fit/v3/BatchTestITCase.java | 20 +-
.../apache/olingo/fit/v3/CountTestITCase.java | 16 +-
.../olingo/fit/v3/EntityCreateTestITCase.java | 46 ++--
.../olingo/fit/v3/EntityRetrieveTestITCase.java | 41 ++--
.../olingo/fit/v3/EntitySetTestITCase.java | 31 +--
.../olingo/fit/v3/EntityUpdateTestITCase.java | 30 +--
.../apache/olingo/fit/v3/ErrorTestITCase.java | 30 ++-
.../apache/olingo/fit/v3/InvokeTestITCase.java | 27 +--
.../olingo/fit/v3/KeyAsSegmentTestITCase.java | 16 +-
.../olingo/fit/v3/MediaEntityTestITCase.java | 24 +-
.../olingo/fit/v3/OpenTypeTestITCase.java | 17 +-
.../olingo/fit/v3/PrimitiveKeysTestITCase.java | 12 +-
.../olingo/fit/v3/PropertyTestITCase.java | 10 +-
.../olingo/fit/v3/PropertyValueTestITCase.java | 31 ++-
.../olingo/fit/v3/QueryOptionsTestITCase.java | 15 +-
.../olingo/fit/v4/AbstractTestITCase.java | 16 +-
.../apache/olingo/fit/v4/AsyncTestITCase.java | 17 +-
.../olingo/fit/v4/AuthBatchTestITCase.java | 11 +-
.../apache/olingo/fit/v4/BatchTestITCase.java | 29 +--
.../fit/v4/BoundOperationInvokeTestITCase.java | 15 +-
.../olingo/fit/v4/ConformanceTestITCase.java | 35 +--
.../apache/olingo/fit/v4/DeltaTestITCase.java | 8 +-
.../olingo/fit/v4/DerivedTypeTestITCase.java | 14 +-
.../olingo/fit/v4/EntityCreateTestITCase.java | 19 +-
.../olingo/fit/v4/EntityRetrieveTestITCase.java | 69 +++---
.../olingo/fit/v4/EntitySetTestITCase.java | 33 +--
.../olingo/fit/v4/EntityUpdateTestITCase.java | 25 ++-
.../olingo/fit/v4/ErrorResponseTestITCase.java | 5 +-
.../olingo/fit/v4/FilterFactoryTestITCase.java | 5 +-
.../fit/v4/JSONFormatConformanceTestITCase.java | 12 +-
.../olingo/fit/v4/KeyAsSegmentTestITCase.java | 23 +-
.../olingo/fit/v4/MediaEntityTestITCase.java | 23 +-
.../olingo/fit/v4/OpenTypeTestITCase.java | 19 +-
.../fit/v4/OperationImportInvokeTestITCase.java | 22 +-
.../olingo/fit/v4/PropertyValueTestITCase.java | 19 +-
.../olingo/fit/v4/QueryOptionsTestITCase.java | 11 +-
.../olingo/fit/v4/SingletonTestITCase.java | 29 +--
.../olingo/client/api/CommonConfiguration.java | 29 +--
.../olingo/client/api/CommonODataClient.java | 6 +-
.../request/ODataBasicRequest.java | 16 +-
.../request/cud/ODataDeleteRequest.java | 3 +-
.../request/cud/ODataEntityCreateRequest.java | 3 +-
.../request/cud/ODataEntityUpdateRequest.java | 3 +-
.../request/cud/ODataPropertyUpdateRequest.java | 3 +-
.../request/cud/ODataValueUpdateRequest.java | 3 +-
.../request/cud/v3/ODataLinkCreateRequest.java | 3 +-
.../request/cud/v3/ODataLinkUpdateRequest.java | 3 +-
.../request/invoke/ODataInvokeRequest.java | 4 +-
.../request/retrieve/EdmMetadataRequest.java | 3 +-
.../request/retrieve/ODataEntityRequest.java | 3 +-
.../retrieve/ODataEntitySetIteratorRequest.java | 3 +-
.../request/retrieve/ODataEntitySetRequest.java | 4 +-
.../request/retrieve/ODataMediaRequest.java | 3 +-
.../request/retrieve/ODataPropertyRequest.java | 2 +-
.../request/retrieve/ODataRetrieveRequest.java | 5 +-
.../retrieve/ODataServiceDocumentRequest.java | 3 +-
.../request/retrieve/ODataValueRequest.java | 3 +-
.../request/retrieve/XMLMetadataRequest.java | 4 +-
.../retrieve/v3/ODataLinkCollectionRequest.java | 3 +-
.../request/retrieve/v4/ODataDeltaRequest.java | 3 +-
.../streamed/ODataStreamedEntityRequest.java | 10 +-
.../api/domain/ODataEntitySetIterator.java | 16 +-
.../api/serialization/CommonODataReader.java | 5 +-
.../client/api/serialization/ODataWriter.java | 5 +-
.../api/serialization/v3/ODataReader.java | 7 +-
.../api/serialization/v4/ODataReader.java | 5 +-
.../olingo/client/api/v3/Configuration.java | 25 ---
.../olingo/client/api/v3/ODataClient.java | 9 +-
.../olingo/client/api/v4/ODataClient.java | 9 +-
.../client/core/AbstractConfiguration.java | 224 -------------------
.../olingo/client/core/AbstractODataClient.java | 2 -
.../olingo/client/core/Configuration.java | 197 ++++++++++++++++
.../olingo/client/core/ODataClientFactory.java | 7 +-
.../request/AbstractODataBasicRequest.java | 39 ++--
.../request/AbstractODataRequest.java | 103 +--------
.../request/cud/ODataDeleteRequestImpl.java | 21 +-
.../cud/ODataEntityCreateRequestImpl.java | 21 +-
.../cud/ODataEntityUpdateRequestImpl.java | 18 +-
.../cud/ODataPropertyUpdateRequestImpl.java | 11 +-
.../cud/ODataValueUpdateRequestImpl.java | 27 ++-
.../cud/v3/ODataLinkCreateRequestImpl.java | 12 +-
.../cud/v3/ODataLinkUpdateRequestImpl.java | 12 +-
.../invoke/AbstractODataInvokeRequest.java | 25 ++-
.../invoke/v3/ODataInvokeRequestImpl.java | 7 +-
.../invoke/v4/ODataInvokeRequestImpl.java | 9 +-
.../retrieve/AbstractMetadataRequestImpl.java | 6 +-
.../retrieve/AbstractODataRetrieveRequest.java | 29 +--
.../retrieve/ODataEntityRequestImpl.java | 13 +-
.../ODataEntitySetIteratorRequestImpl.java | 23 +-
.../retrieve/ODataEntitySetRequestImpl.java | 19 +-
.../request/retrieve/ODataMediaRequestImpl.java | 20 +-
.../retrieve/ODataPropertyRequestImpl.java | 15 +-
.../request/retrieve/ODataRawRequestImpl.java | 12 +-
.../ODataServiceDocumentRequestImpl.java | 12 +-
.../request/retrieve/ODataValueRequestImpl.java | 23 +-
.../v3/ODataLinkCollectionRequestImpl.java | 16 +-
.../retrieve/v4/ODataDeltaRequestImpl.java | 13 +-
.../AbstractODataStreamedEntityRequest.java | 15 +-
.../streamed/AbstractODataStreamedRequest.java | 20 +-
.../request/v4/AsyncRequestWrapperImpl.java | 4 +-
.../AbstractODataDeserializer.java | 7 +-
.../core/serialization/AbstractODataReader.java | 28 ++-
.../core/serialization/ODataWriterImpl.java | 5 +-
.../serialization/v3/ODataDeserializerImpl.java | 5 +-
.../core/serialization/v3/ODataReaderImpl.java | 7 +-
.../serialization/v4/ODataDeserializerImpl.java | 8 +-
.../core/serialization/v4/ODataReaderImpl.java | 5 +-
.../client/core/uri/v3/URIBuilderImpl.java | 10 +-
.../client/core/uri/v4/URIBuilderImpl.java | 8 +-
.../client/core/v3/ConfigurationImpl.java | 32 ---
.../olingo/client/core/v3/ODataClientImpl.java | 16 +-
.../client/core/v4/ConfigurationImpl.java | 32 ---
.../olingo/client/core/v4/ODataClientImpl.java | 13 +-
.../apache/olingo/client/core/AbstractTest.java | 7 +-
.../apache/olingo/client/core/v3/AtomTest.java | 13 +-
.../olingo/client/core/v3/EntitySetTest.java | 8 +-
.../olingo/client/core/v3/EntityTest.java | 32 +--
.../apache/olingo/client/core/v3/ErrorTest.java | 18 +-
.../apache/olingo/client/core/v3/JSONTest.java | 13 +-
.../apache/olingo/client/core/v4/AtomTest.java | 10 +-
.../olingo/client/core/v4/EntitySetTest.java | 14 +-
.../olingo/client/core/v4/EntityTest.java | 63 +++---
.../apache/olingo/client/core/v4/ErrorTest.java | 12 +-
.../apache/olingo/client/core/v4/JSONTest.java | 21 +-
.../olingo/commons/api/format/ContentType.java | 16 +-
.../olingo/commons/api/format/Format.java | 26 ---
.../olingo/commons/api/format/ODataFormat.java | 64 ++++--
.../commons/api/format/ODataMediaFormat.java | 76 -------
.../commons/api/format/ODataPubFormat.java | 102 ---------
.../commons/api/format/ODataValueFormat.java | 81 -------
.../core/serialization/AtomDeserializer.java | 7 +-
.../org/apache/olingo/server/api/OData.java | 2 +-
.../server/api/processor/DefaultProcessor.java | 2 +-
.../server/api/serializer/ODataFormat.java | 23 --
.../apache/olingo/server/core/ODataImpl.java | 4 +-
.../tecsvc/processor/SampleJsonProcessor.java | 8 +-
.../serializer/json/ServiceDocumentTest.java | 2 +-
.../serializer/xml/MetadataDocumentTest.java | 2 +-
145 files changed, 1193 insertions(+), 1683 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/EntityContainerFactory.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/EntityContainerFactory.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/EntityContainerFactory.java
index c36aa77..84b4995 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/EntityContainerFactory.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/EntityContainerFactory.java
@@ -21,9 +21,10 @@ package org.apache.olingo.ext.proxy;
import java.lang.reflect.Proxy;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+
import org.apache.olingo.client.api.CommonEdmEnabledODataClient;
import org.apache.olingo.client.core.ODataClientFactory;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.ext.proxy.api.PersistenceManager;
import org.apache.olingo.ext.proxy.commons.EntityContainerInvocationHandler;
import org.apache.olingo.ext.proxy.commons.NonTransactionalPersistenceManagerImpl;
@@ -47,7 +48,7 @@ public final class EntityContainerFactory<C extends CommonEdmEnabledODataClient<
final C client, final boolean transactional) {
if (!FACTORY_PER_SERVICEROOT.containsKey(client.getServiceRoot())) {
- client.getConfiguration().setDefaultPubFormat(ODataPubFormat.JSON_FULL_METADATA);
+ client.getConfiguration().setDefaultPubFormat(ODataFormat.JSON_FULL_METADATA);
final EntityContainerFactory<C> instance = new EntityContainerFactory<C>(client, transactional);
FACTORY_PER_SERVICEROOT.put(client.getServiceRoot(), instance);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractPersistenceManager.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractPersistenceManager.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractPersistenceManager.java
index 67369ef..492c751 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractPersistenceManager.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractPersistenceManager.java
@@ -28,6 +28,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+
import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.client.api.communication.header.ODataPreferences;
import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest;
@@ -40,7 +41,7 @@ import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ODataLinkType;
import org.apache.olingo.commons.api.domain.v4.ODataEntity;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.api.format.ODataMediaFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.ext.proxy.EntityContainerFactory;
import org.apache.olingo.ext.proxy.api.PersistenceManager;
import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty;
@@ -150,7 +151,7 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
final Set<EntityInvocationHandler> toBeLinked = new HashSet<EntityInvocationHandler>();
for (Object proxy : type == ODataLinkType.ENTITY_SET_NAVIGATION
- ? (Collection) property.getValue() : Collections.singleton(property.getValue())) {
+ ? (Collection<?>) property.getValue() : Collections.singleton(property.getValue())) {
final EntityInvocationHandler target = (EntityInvocationHandler) Proxy.getInvocationHandler(proxy);
@@ -354,8 +355,8 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
factory.getClient().getCUDRequestFactory().getMediaEntityUpdateRequest(uri, input);
req.setContentType(StringUtils.isBlank(handler.getEntity().getMediaContentType())
- ? ODataMediaFormat.WILDCARD.toString()
- : ODataMediaFormat.fromFormat(handler.getEntity().getMediaContentType()).toString());
+ ? ODataFormat.WILDCARD.toString()
+ : ODataFormat.fromString(handler.getEntity().getMediaContentType()).toString());
if (StringUtils.isNotBlank(handler.getETag())) {
req.setIfMatch(handler.getETag());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java
index 9b52e34..aa81921 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java
@@ -32,17 +32,17 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.client.api.communication.request.retrieve.ODataMediaRequest;
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
-import org.apache.olingo.commons.api.domain.ODataLinked;
import org.apache.olingo.commons.api.domain.v4.ODataAnnotation;
import org.apache.olingo.commons.api.domain.v4.ODataEntity;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.format.ODataMediaFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.ext.proxy.api.AbstractTerm;
import org.apache.olingo.ext.proxy.api.Annotatable;
import org.apache.olingo.ext.proxy.api.annotations.EntityType;
@@ -108,7 +108,7 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler
final Class<?> typeRef,
final EntityContainerInvocationHandler containerHandler) {
- super(typeRef, (ODataLinked) entity, containerHandler);
+ super(typeRef, entity, containerHandler);
this.entityURI = entityURI;
this.internal = entity;
@@ -325,7 +325,7 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler
final ODataMediaRequest retrieveReq = getClient().getRetrieveRequestFactory().
getMediaEntityRequest(contentSource);
- retrieveReq.setFormat(ODataMediaFormat.fromFormat(contentType));
+ retrieveReq.setFormat(ODataFormat.fromString(contentType));
this.stream = retrieveReq.execute().getBody();
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java
index 71d8755..ec00a75 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java
@@ -31,6 +31,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
+
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.tuple.ImmutableTriple;
import org.apache.commons.lang3.tuple.Triple;
@@ -48,7 +49,7 @@ import org.apache.olingo.commons.api.domain.v4.ODataAnnotation;
import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.api.format.ODataValueFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.ext.proxy.api.AbstractEntityCollection;
import org.apache.olingo.ext.proxy.api.AbstractEntitySet;
import org.apache.olingo.ext.proxy.api.AbstractSingleton;
@@ -141,7 +142,6 @@ class EntitySetInvocationHandler<
}
@Override
- @SuppressWarnings("unchecked")
public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
if (isSelfMethod(method, args)) {
return invokeSelfMethod(method, args);
@@ -183,7 +183,7 @@ class EntitySetInvocationHandler<
public Long count() {
final ODataValueRequest req = getClient().getRetrieveRequestFactory().
getValueRequest(getClient().newURIBuilder(this.uri.toASCIIString()).count().build());
- req.setFormat(ODataValueFormat.TEXT);
+ req.setFormat(ODataFormat.TEXT_PLAIN);
return Long.valueOf(req.execute().getBody().asPrimitive().toString());
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/NonTransactionalPersistenceManagerImpl.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/NonTransactionalPersistenceManagerImpl.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/NonTransactionalPersistenceManagerImpl.java
index dedd338..6f36148 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/NonTransactionalPersistenceManagerImpl.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/NonTransactionalPersistenceManagerImpl.java
@@ -43,13 +43,13 @@ public class NonTransactionalPersistenceManagerImpl extends AbstractPersistenceM
protected void doFlush(final PersistenceChanges changes, final TransactionItems items) {
for (Map.Entry<ODataBatchableRequest, EntityInvocationHandler> entry : changes.getChanges().entrySet()) {
try {
- final ODataResponse response = ((ODataBasicRequest<?, ?>) entry.getKey()).execute();
+ final ODataResponse response = ((ODataBasicRequest<?>) entry.getKey()).execute();
if (response instanceof ODataEntityCreateResponse && response.getStatusCode() == 201) {
- entry.getValue().setEntity(((ODataEntityCreateResponse) response).getBody());
+ entry.getValue().setEntity(((ODataEntityCreateResponse<?>) response).getBody());
LOG.debug("Upgrade created object '{}'", entry.getValue());
} else if (response instanceof ODataEntityUpdateResponse && response.getStatusCode() == 200) {
- entry.getValue().setEntity(((ODataEntityUpdateResponse) response).getBody());
+ entry.getValue().setEntity(((ODataEntityUpdateResponse<?>) response).getBody());
LOG.debug("Upgrade updated object '{}'", entry.getValue());
}
} catch (Exception e) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
index cef8d11..f54b5b8 100644
--- a/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
@@ -30,7 +30,6 @@ import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.commons.api.serialization.ODataSerializerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -79,14 +78,14 @@ public abstract class AbstractBaseTestITCase {
if (LOG.isDebugEnabled()) {
StringWriter writer = new StringWriter();
try {
- getClient().getSerializer(ODataPubFormat.ATOM).write(writer, getClient().getBinder().getEntity(entity));
+ getClient().getSerializer(ODataFormat.ATOM).write(writer, getClient().getBinder().getEntity(entity));
} catch (final ODataSerializerException e) {}
writer.flush();
LOG.debug(message + " (Atom)\n{}", writer.toString());
writer = new StringWriter();
try {
- getClient().getSerializer(ODataPubFormat.JSON).write(writer, getClient().getBinder().getEntity(entity));
+ getClient().getSerializer(ODataFormat.JSON).write(writer, getClient().getBinder().getEntity(entity));
} catch (final ODataSerializerException e) {}
writer.flush();
LOG.debug(message + " (JSON)\n{}", writer.toString());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v3/AbstractTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/AbstractTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/AbstractTestITCase.java
index aacecdc..6e694e2 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v3/AbstractTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v3/AbstractTestITCase.java
@@ -34,6 +34,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+
import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.client.api.communication.ODataClientErrorException;
import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest;
@@ -49,7 +50,6 @@ import org.apache.olingo.client.api.http.HttpMethod;
import org.apache.olingo.client.api.uri.v3.URIBuilder;
import org.apache.olingo.client.api.v3.ODataClient;
import org.apache.olingo.client.core.ODataClientFactory;
-import org.apache.olingo.fit.AbstractBaseTestITCase;
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
@@ -64,7 +64,8 @@ import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.domain.v3.ODataProperty;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.fit.AbstractBaseTestITCase;
import org.junit.BeforeClass;
public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
@@ -223,7 +224,7 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
}
}
- protected ODataEntity getSampleCustomerInfo(final int id, final String sampleinfo) {
+ protected ODataEntity getSampleCustomerInfo(final String sampleinfo) {
final ODataEntity entity = getClient().getObjectFactory().newEntity(new FullQualifiedName(
"Microsoft.Test.OData.Services.AstoriaDefaultService.CustomerInfo"));
entity.setMediaEntity(true);
@@ -288,7 +289,7 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
if (withInlineInfo) {
final ODataInlineEntity inlineInfo = getClient().getObjectFactory().newDeepInsertEntity(
"Info",
- getSampleCustomerInfo(id, sampleName + "_Info"));
+ getSampleCustomerInfo(sampleName + "_Info"));
inlineInfo.getEntity().setMediaEntity(true);
entity.addLink(inlineInfo);
}
@@ -306,7 +307,7 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
}
}
- protected ODataEntity read(final ODataPubFormat format, final URI editLink) {
+ protected ODataEntity read(final ODataFormat format, final URI editLink) {
final ODataEntityRequest<ODataEntity> req = getClient().getRetrieveRequestFactory().
getEntityRequest(editLink);
req.setFormat(format);
@@ -316,7 +317,7 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
assertNotNull(entity);
- if (ODataPubFormat.JSON_FULL_METADATA == format || ODataPubFormat.ATOM == format) {
+ if (ODataFormat.JSON_FULL_METADATA == format || ODataFormat.ATOM == format) {
assertEquals(req.getURI(), entity.getEditLink());
}
@@ -325,7 +326,7 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
protected ODataEntity createEntity(
final String serviceRootURL,
- final ODataPubFormat format,
+ final ODataFormat format,
final ODataEntity original,
final String entitySetName) {
@@ -351,7 +352,7 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
}
protected ODataEntity compareEntities(final String serviceRootURL,
- final ODataPubFormat format,
+ final ODataFormat format,
final ODataEntity original,
final int actualObjectId,
final Collection<String> expands) {
@@ -388,7 +389,7 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
}
protected void cleanAfterCreate(
- final ODataPubFormat format,
+ final ODataFormat format,
final ODataEntity created,
final boolean includeInline,
final String baseUri) {
@@ -431,7 +432,7 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
getEntityRequest(link);
// bug that needs to be fixed on the SampleService - cannot get entity not found with header
// Accept: application/json;odata=minimalmetadata
- retrieveReq.setFormat(format == ODataPubFormat.JSON_FULL_METADATA ? ODataPubFormat.JSON : format);
+ retrieveReq.setFormat(format == ODataFormat.JSON_FULL_METADATA ? ODataFormat.JSON : format);
Exception exception = null;
try {
@@ -446,19 +447,19 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
}
protected void updateEntityDescription(
- final ODataPubFormat format, final ODataEntity changes, final UpdateType type) {
+ final ODataFormat format, final ODataEntity changes, final UpdateType type) {
updateEntityDescription(format, changes, type, null);
}
protected void updateEntityDescription(
- final ODataPubFormat format, final ODataEntity changes, final UpdateType type, final String etag) {
+ final ODataFormat format, final ODataEntity changes, final UpdateType type, final String etag) {
updateEntityStringProperty("Description", format, changes, type, etag);
}
protected void updateEntityStringProperty(final String propertyName,
- final ODataPubFormat format, final ODataEntity changes, final UpdateType type, final String etag) {
+ final ODataFormat format, final ODataEntity changes, final UpdateType type, final String etag) {
final URI editLink = changes.getEditLink();
@@ -497,7 +498,7 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
}
protected void update(
- final UpdateType type, final ODataEntity changes, final ODataPubFormat format, final String etag) {
+ final UpdateType type, final ODataEntity changes, final ODataFormat format, final String etag) {
final ODataEntityUpdateRequest<ODataEntity> req =
getClient().getCUDRequestFactory().getEntityUpdateRequest(type, changes);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v3/BatchTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/BatchTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/BatchTestITCase.java
index 18ebaad..88bbfb9 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v3/BatchTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v3/BatchTestITCase.java
@@ -19,8 +19,8 @@
package org.apache.olingo.fit.v3;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException;
@@ -28,6 +28,7 @@ import java.net.URI;
import java.util.Iterator;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
+
import org.apache.http.HttpResponse;
import org.apache.olingo.client.api.ODataBatchConstants;
import org.apache.olingo.client.api.communication.request.ODataPayloadManager;
@@ -56,8 +57,7 @@ import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
-import static org.apache.olingo.fit.v3.AbstractTestITCase.client;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
public class BatchTestITCase extends AbstractTestITCase {
@@ -116,7 +116,7 @@ public class BatchTestITCase extends AbstractTestITCase {
createReq = client.getCUDRequestFactory().getEntityCreateRequest(
targetURI.build(),
getSampleCustomerProfile(100 + i, "Sample customer", false));
- createReq.setFormat(ODataPubFormat.JSON);
+ createReq.setFormat(ODataFormat.JSON);
changeset.addRequest(createReq);
}
@@ -124,7 +124,7 @@ public class BatchTestITCase extends AbstractTestITCase {
createReq = client.getCUDRequestFactory().getEntityCreateRequest(
targetURI.build(),
getSampleCustomerProfile(105, "Sample customer", false));
- createReq.setFormat(ODataPubFormat.JSON);
+ createReq.setFormat(ODataFormat.JSON);
changeset.addRequest(createReq);
targetURI = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customer");
@@ -133,7 +133,7 @@ public class BatchTestITCase extends AbstractTestITCase {
createReq = client.getCUDRequestFactory().getEntityCreateRequest(
targetURI.build(),
getSampleCustomerProfile(100 + i, "Sample customer", false));
- createReq.setFormat(ODataPubFormat.ATOM);
+ createReq.setFormat(ODataFormat.ATOM);
changeset.addRequest(createReq);
}
@@ -318,7 +318,7 @@ public class BatchTestITCase extends AbstractTestITCase {
// create new request
ODataEntityRequest<ODataEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
- queryReq.setFormat(ODataPubFormat.ATOM);
+ queryReq.setFormat(ODataFormat.ATOM);
streamManager.addRequest(queryReq);
// -------------------------------------------
@@ -340,9 +340,9 @@ public class BatchTestITCase extends AbstractTestITCase {
"Description",
client.getObjectFactory().newPrimitiveValueBuilder().buildString("new description from batch")));
- final ODataEntityUpdateRequest changeReq =
+ final ODataEntityUpdateRequest<?> changeReq =
client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.MERGE, merge);
- changeReq.setFormat(ODataPubFormat.JSON_FULL_METADATA);
+ changeReq.setFormat(ODataFormat.JSON_FULL_METADATA);
changeReq.setIfMatch(getETag(editLink));
changeset.addRequest(changeReq);
@@ -352,7 +352,7 @@ public class BatchTestITCase extends AbstractTestITCase {
final ODataEntity original = getSampleCustomerProfile(1000, "Sample customer", false);
final ODataEntityCreateRequest<ODataEntity> createReq =
client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), original);
- createReq.setFormat(ODataPubFormat.ATOM);
+ createReq.setFormat(ODataFormat.ATOM);
changeset.addRequest(createReq);
// Delete customer created above
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v3/CountTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/CountTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/CountTestITCase.java
index 56c7902..673acdf 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v3/CountTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v3/CountTestITCase.java
@@ -18,14 +18,16 @@
*/
package org.apache.olingo.fit.v3;
-import static org.junit.Assert.*;
-import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import org.apache.olingo.client.api.communication.ODataClientErrorException;
import org.apache.olingo.client.api.communication.request.retrieve.ODataValueRequest;
-import org.apache.olingo.commons.api.domain.ODataValue;
-import org.apache.olingo.commons.api.format.ODataValueFormat;
import org.apache.olingo.client.api.uri.CommonURIBuilder;
+import org.apache.olingo.commons.api.domain.ODataValue;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.junit.Test;
public class CountTestITCase extends AbstractTestITCase {
@@ -34,7 +36,7 @@ public class CountTestITCase extends AbstractTestITCase {
CommonURIBuilder<?> uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Customer").count();
final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
- req.setFormat(ODataValueFormat.TEXT);
+ req.setFormat(ODataFormat.TEXT_PLAIN);
try {
final ODataValue value = req.execute().getBody();
assertTrue(10 <= Integer.parseInt(value.toString()));
@@ -48,10 +50,10 @@ public class CountTestITCase extends AbstractTestITCase {
final CommonURIBuilder<?> uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Customer").count();
final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
- req.setFormat(ODataValueFormat.TEXT);
+ req.setFormat(ODataFormat.TEXT_PLAIN);
req.setAccept("application/json;odata=fullmetadata");
try {
- final ODataValue value = req.execute().getBody();
+ req.execute().getBody();
fail();
} catch (ODataClientErrorException e) {
assertEquals(415, e.getStatusLine().getStatusCode());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v3/EntityCreateTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/EntityCreateTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/EntityCreateTestITCase.java
index 0d9730e..04fb6c1 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v3/EntityCreateTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v3/EntityCreateTestITCase.java
@@ -28,6 +28,7 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Set;
+
import org.apache.http.entity.ContentType;
import org.apache.olingo.client.api.communication.header.HeaderName;
import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest;
@@ -48,8 +49,7 @@ import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
import org.apache.olingo.commons.api.domain.v3.ODataProperty;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
-
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
/**
@@ -63,7 +63,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
@Test
public void createAsAtom() {
- final ODataPubFormat format = ODataPubFormat.ATOM;
+ final ODataFormat format = ODataFormat.ATOM;
final int id = 1;
final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
@@ -75,7 +75,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
@Test
public void createAsJSON() {
- final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
+ final ODataFormat format = ODataFormat.JSON_FULL_METADATA;
final int id = 2;
final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
@@ -87,7 +87,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
@Test
public void createWithInlineAsAtom() {
- final ODataPubFormat format = ODataPubFormat.ATOM;
+ final ODataFormat format = ODataFormat.ATOM;
final int id = 3;
final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", true);
@@ -101,7 +101,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
@Test
public void createWithInlineAsJSON() {
// this needs to be full, otherwise there is no mean to recognize links
- final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
+ final ODataFormat format = ODataFormat.JSON_FULL_METADATA;
final int id = 4;
final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", true);
@@ -114,12 +114,12 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
@Test
public void createInlineWithoutLinkAsAtom() {
- final ODataPubFormat format = ODataPubFormat.ATOM;
+ final ODataFormat format = ODataFormat.ATOM;
final int id = 5;
final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
original.addLink(client.getObjectFactory().newDeepInsertEntity(
- "Info", getSampleCustomerInfo(id, "Sample Customer_Info")));
+ "Info", getSampleCustomerInfo("Sample Customer_Info")));
createEntity(getServiceRoot(), format, original, "Customer");
final ODataEntity actual =
@@ -141,12 +141,12 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
@Test
public void createInlineWithoutLinkAsJSON() {
- final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
+ final ODataFormat format = ODataFormat.JSON_FULL_METADATA;
final int id = 6;
final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
original.addLink(client.getObjectFactory().newDeepInsertEntity(
- "Info", getSampleCustomerInfo(id, "Sample Customer_Info")));
+ "Info", getSampleCustomerInfo("Sample Customer_Info")));
createEntity(getServiceRoot(), format, original, "Customer");
final ODataEntity actual =
@@ -168,7 +168,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
@Test
public void createWithNavigationAsAtom() {
- final ODataPubFormat format = ODataPubFormat.ATOM;
+ final ODataFormat format = ODataFormat.ATOM;
final ODataEntity actual = createWithNavigationLink(format, 5);
cleanAfterCreate(format, actual, false, getServiceRoot());
}
@@ -176,14 +176,14 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
@Test
public void createWithNavigationAsJSON() {
// this needs to be full, otherwise there is no mean to recognize links
- final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
+ final ODataFormat format = ODataFormat.JSON_FULL_METADATA;
final ODataEntity actual = createWithNavigationLink(format, 6);
cleanAfterCreate(format, actual, false, getServiceRoot());
}
@Test
public void createWithFeedNavigationAsAtom() throws EdmPrimitiveTypeException {
- final ODataPubFormat format = ODataPubFormat.ATOM;
+ final ODataFormat format = ODataFormat.ATOM;
final ODataEntity actual = createWithFeedNavigationLink(format, 7);
cleanAfterCreate(format, actual, false, getServiceRoot());
}
@@ -191,14 +191,14 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
@Test
public void createWithFeedNavigationAsJSON() throws EdmPrimitiveTypeException {
// this needs to be full, otherwise there is no mean to recognize links
- final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
+ final ODataFormat format = ODataFormat.JSON_FULL_METADATA;
final ODataEntity actual = createWithFeedNavigationLink(format, 8);
cleanAfterCreate(format, actual, false, getServiceRoot());
}
@Test
public void createWithBackNavigationAsAtom() throws EdmPrimitiveTypeException {
- final ODataPubFormat format = ODataPubFormat.ATOM;
+ final ODataFormat format = ODataFormat.ATOM;
final ODataEntity actual = createWithBackNavigationLink(format, 9);
cleanAfterCreate(format, actual, true, getServiceRoot());
}
@@ -206,19 +206,19 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
@Test
public void createWithBackNavigationAsJSON() throws EdmPrimitiveTypeException {
// this needs to be full, otherwise there is no mean to recognize links
- final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
+ final ODataFormat format = ODataFormat.JSON_FULL_METADATA;
final ODataEntity actual = createWithBackNavigationLink(format, 10);
cleanAfterCreate(format, actual, true, getServiceRoot());
}
@Test
public void multiKeyAsAtom() {
- multiKey(ODataPubFormat.ATOM);
+ multiKey(ODataFormat.ATOM);
}
@Test
public void multiKeyAsJSON() {
- multiKey(ODataPubFormat.JSON);
+ multiKey(ODataFormat.JSON);
}
@Test
@@ -256,7 +256,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
final URIBuilder uriBuilder = client.newURIBuilder(getServiceRoot()).appendEntitySetSegment("Customer");
final ODataEntityCreateRequest<ODataEntity> createReq =
client.getCUDRequestFactory().getEntityCreateRequest(uriBuilder.build(), original);
- createReq.setFormat(ODataPubFormat.JSON_FULL_METADATA);
+ createReq.setFormat(ODataFormat.JSON_FULL_METADATA);
createReq.setContentType(ContentType.APPLICATION_ATOM_XML.getMimeType());
createReq.setPrefer(client.newPreferences().returnContent());
@@ -274,7 +274,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
}
}
- private ODataEntity createWithFeedNavigationLink(final ODataPubFormat format, final int id)
+ private ODataEntity createWithFeedNavigationLink(final ODataFormat format, final int id)
throws EdmPrimitiveTypeException {
final String sampleName = "Sample customer";
@@ -337,7 +337,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
return actual;
}
- private ODataEntity createWithNavigationLink(final ODataPubFormat format, final int id) {
+ private ODataEntity createWithNavigationLink(final ODataFormat format, final int id) {
final String sampleName = "Sample customer";
final ODataEntity original = getSampleCustomerProfile(id, sampleName, false);
@@ -374,7 +374,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
return actual;
}
- private ODataEntity createWithBackNavigationLink(final ODataPubFormat format, final int id)
+ private ODataEntity createWithBackNavigationLink(final ODataFormat format, final int id)
throws EdmPrimitiveTypeException {
final String sampleName = "Sample customer";
@@ -440,7 +440,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
return customer;
}
- private void multiKey(final ODataPubFormat format) {
+ private void multiKey(final ODataFormat format) {
final ODataEntity message = client.getObjectFactory().newEntity(new FullQualifiedName(
"Microsoft.Test.OData.Services.AstoriaDefaultService.Message"));
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v3/EntityRetrieveTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/EntityRetrieveTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/EntityRetrieveTestITCase.java
index 043e547..832b538 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v3/EntityRetrieveTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v3/EntityRetrieveTestITCase.java
@@ -25,6 +25,7 @@ import static org.junit.Assert.assertTrue;
import java.util.LinkedHashMap;
import java.util.List;
+
import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataRawRequest;
@@ -42,7 +43,7 @@ import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
/**
@@ -54,7 +55,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
return testStaticServiceRootURL;
}
- private void withInlineEntry(final ODataPubFormat format) {
+ private void withInlineEntry(final ODataFormat format) {
final CommonURIBuilder<?> uriBuilder = client.newURIBuilder(getServiceRoot()).
appendEntitySetSegment("Customer").appendKeySegment(-10).expand("Info");
@@ -97,16 +98,16 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
@Test
public void withInlineEntryFromAtom() {
- withInlineEntry(ODataPubFormat.ATOM);
+ withInlineEntry(ODataFormat.ATOM);
}
@Test
public void withInlineEntryFromJSON() {
// this needs to be full, otherwise there is no mean to recognize links
- withInlineEntry(ODataPubFormat.JSON_FULL_METADATA);
+ withInlineEntry(ODataFormat.JSON_FULL_METADATA);
}
- private void withInlineFeed(final ODataPubFormat format) {
+ private void withInlineFeed(final ODataFormat format) {
final CommonURIBuilder<?> uriBuilder = client.newURIBuilder(getServiceRoot()).
appendEntitySetSegment("Customer").appendKeySegment(-10).expand("Orders");
@@ -135,16 +136,16 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
@Test
public void withInlineFeedFromAtom() {
- withInlineFeed(ODataPubFormat.ATOM);
+ withInlineFeed(ODataFormat.ATOM);
}
@Test
public void withInlineFeedFromJSON() {
// this needs to be full, otherwise there is no mean to recognize links
- withInlineFeed(ODataPubFormat.JSON_FULL_METADATA);
+ withInlineFeed(ODataFormat.JSON_FULL_METADATA);
}
- private void rawRequest(final ODataPubFormat format) {
+ private void rawRequest(final ODataFormat format) {
final CommonURIBuilder<?> uriBuilder = client.newURIBuilder(getServiceRoot()).
appendEntitySetSegment("Car").appendKeySegment(16);
@@ -163,16 +164,16 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
@Test
public void rawRequestAsAtom() {
- rawRequest(ODataPubFormat.ATOM);
+ rawRequest(ODataFormat.ATOM);
}
@Test
public void rawRequestAsJSON() {
// this needs to be full, otherwise actions will not be provided
- rawRequest(ODataPubFormat.JSON_FULL_METADATA);
+ rawRequest(ODataFormat.JSON_FULL_METADATA);
}
- private void multiKey(final ODataPubFormat format) throws EdmPrimitiveTypeException {
+ private void multiKey(final ODataFormat format) throws EdmPrimitiveTypeException {
final LinkedHashMap<String, Object> multiKey = new LinkedHashMap<String, Object>();
multiKey.put("FromUsername", "1");
multiKey.put("MessageId", -10);
@@ -191,25 +192,25 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
@Test
public void multiKeyAsAtom() throws EdmPrimitiveTypeException {
- multiKey(ODataPubFormat.ATOM);
+ multiKey(ODataFormat.ATOM);
}
@Test
public void multiKeyAsJSON() throws EdmPrimitiveTypeException {
- multiKey(ODataPubFormat.JSON_FULL_METADATA);
+ multiKey(ODataFormat.JSON_FULL_METADATA);
}
@Test
public void checkForETagAsAtom() {
- checkForETag(ODataPubFormat.ATOM);
+ checkForETag(ODataFormat.ATOM);
}
@Test
public void checkForETagAsJSON() {
- checkForETag(ODataPubFormat.JSON_FULL_METADATA);
+ checkForETag(ODataFormat.JSON_FULL_METADATA);
}
- private void checkForETag(final ODataPubFormat format) {
+ private void checkForETag(final ODataFormat format) {
final CommonURIBuilder<?> uriBuilder =
client.newURIBuilder(getServiceRoot()).appendEntitySetSegment("Product").appendKeySegment(-10);
@@ -231,14 +232,14 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
final CommonURIBuilder<?> uriBuilder = client.newURIBuilder(getServiceRoot()).appendEntitySetSegment("Car");
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- req.setFormat(ODataPubFormat.JSON);
+ req.setFormat(ODataFormat.JSON);
// this statement should cause an IllegalArgumentException bearing JsonParseException
// since we are attempting to parse an EntitySet as if it was an Entity
req.execute().getBody();
}
- private void geospatial(final ODataPubFormat format) {
+ private void geospatial(final ODataFormat format) {
final URIBuilder uriBuilder = client.newURIBuilder(getServiceRoot()).
appendEntitySetSegment("AllGeoTypesSet").appendKeySegment(-10);
@@ -251,11 +252,11 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
@Test
public void geospatialAsJSON() {
- geospatial(ODataPubFormat.JSON_FULL_METADATA);
+ geospatial(ODataFormat.JSON_FULL_METADATA);
}
@Test
public void geospatialAsAtom() {
- geospatial(ODataPubFormat.ATOM);
+ geospatial(ODataFormat.ATOM);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v3/EntitySetTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/EntitySetTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/EntitySetTestITCase.java
index 0f8649c..61acf0a 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v3/EntitySetTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v3/EntitySetTestITCase.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.net.URI;
+
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetIteratorRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataRawRequest;
@@ -35,7 +36,7 @@ import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
/**
@@ -49,55 +50,55 @@ public class EntitySetTestITCase extends AbstractTestITCase {
@Test
public void rawRequestAsAtom() throws IOException {
- rawRequest(ODataPubFormat.ATOM);
+ rawRequest(ODataFormat.ATOM);
}
@Test
public void rawRequestAsJSON() throws IOException {
- rawRequest(ODataPubFormat.JSON);
+ rawRequest(ODataFormat.JSON);
}
@Test
public void readWithInlineCountAsJSON() throws IOException {
- readWithInlineCount(ODataPubFormat.JSON);
+ readWithInlineCount(ODataFormat.JSON);
}
@Test
public void readWithInlineCountAsAtom() throws IOException {
- readWithInlineCount(ODataPubFormat.ATOM);
+ readWithInlineCount(ODataFormat.ATOM);
}
@Test
public void readODataEntitySetIteratorFromAtom() {
- readODataEntitySetIterator(ODataPubFormat.ATOM);
+ readODataEntitySetIterator(ODataFormat.ATOM);
}
@Test
public void readODataEntitySetIteratorFromJSON() {
- readODataEntitySetIterator(ODataPubFormat.JSON);
+ readODataEntitySetIterator(ODataFormat.JSON);
}
@Test
public void readODataEntitySetIteratorFromJSONFullMeta() {
- readODataEntitySetIterator(ODataPubFormat.JSON_FULL_METADATA);
+ readODataEntitySetIterator(ODataFormat.JSON_FULL_METADATA);
}
@Test
public void readODataEntitySetIteratorFromJSONNoMeta() {
- readODataEntitySetIterator(ODataPubFormat.JSON_NO_METADATA);
+ readODataEntitySetIterator(ODataFormat.JSON_NO_METADATA);
}
@Test
public void readODataEntitySetWithNextFromAtom() {
- readEntitySetWithNextLink(ODataPubFormat.ATOM);
+ readEntitySetWithNextLink(ODataFormat.ATOM);
}
@Test
public void readODataEntitySetWithNextFromJSON() {
- readEntitySetWithNextLink(ODataPubFormat.JSON_FULL_METADATA);
+ readEntitySetWithNextLink(ODataFormat.JSON_FULL_METADATA);
}
- private void readEntitySetWithNextLink(final ODataPubFormat format) {
+ private void readEntitySetWithNextLink(final ODataFormat format) {
final URIBuilder uriBuilder = client.newURIBuilder(getServiceRoot());
uriBuilder.appendEntitySetSegment("Customer");
@@ -121,7 +122,7 @@ public class EntitySetTestITCase extends AbstractTestITCase {
assertEquals(expected, found);
}
- private void readODataEntitySetIterator(final ODataPubFormat format) {
+ private void readODataEntitySetIterator(final ODataFormat format) {
final URIBuilder uriBuilder = client.newURIBuilder(getServiceRoot());
uriBuilder.appendEntitySetSegment("Customer");
@@ -144,7 +145,7 @@ public class EntitySetTestITCase extends AbstractTestITCase {
assertTrue(feedIterator.getNext().toASCIIString().endsWith("Customer?$skiptoken=-9"));
}
- private void readWithInlineCount(final ODataPubFormat format) {
+ private void readWithInlineCount(final ODataFormat format) {
final URIBuilder uriBuilder = client.newURIBuilder(getServiceRoot());
uriBuilder.appendEntitySetSegment("Product").inlineCount(URIBuilder.InlineCount.allpages);
@@ -158,7 +159,7 @@ public class EntitySetTestITCase extends AbstractTestITCase {
assertEquals(10, entitySet.getPayload().getCount());
}
- private void rawRequest(final ODataPubFormat format) {
+ private void rawRequest(final ODataFormat format) {
final URIBuilder uriBuilder = client.newURIBuilder(getServiceRoot());
uriBuilder.appendEntitySetSegment("Car");
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v3/EntityUpdateTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/EntityUpdateTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/EntityUpdateTestITCase.java
index 413dae8..72f4ed7 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v3/EntityUpdateTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v3/EntityUpdateTestITCase.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.fail;
import java.net.URI;
import java.util.LinkedHashMap;
+
import org.apache.olingo.client.api.communication.ODataClientErrorException;
import org.apache.olingo.client.api.communication.header.HeaderName;
import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
@@ -33,8 +34,7 @@ import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResp
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
-
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
/**
@@ -48,7 +48,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
@Test
public void mergeAsAtom() {
- final ODataPubFormat format = ODataPubFormat.ATOM;
+ final ODataFormat format = ODataFormat.ATOM;
final URI uri = client.newURIBuilder(getServiceRoot()).
appendEntitySetSegment("Product").appendKeySegment(-10).build();
final String etag = getETag(uri);
@@ -59,7 +59,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
@Test
public void mergeAsJSON() {
- final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
+ final ODataFormat format = ODataFormat.JSON_FULL_METADATA;
final URI uri = client.newURIBuilder(getServiceRoot()).
appendEntitySetSegment("Product").appendKeySegment(-10).build();
final String etag = getETag(uri);
@@ -70,7 +70,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
@Test
public void patchAsAtom() {
- final ODataPubFormat format = ODataPubFormat.ATOM;
+ final ODataFormat format = ODataFormat.ATOM;
final URI uri = client.newURIBuilder(getServiceRoot()).
appendEntitySetSegment("Product").appendKeySegment(-10).build();
final String etag = getETag(uri);
@@ -81,7 +81,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
@Test
public void patchAsJSON() {
- final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
+ final ODataFormat format = ODataFormat.JSON_FULL_METADATA;
final URI uri = client.newURIBuilder(getServiceRoot()).
appendEntitySetSegment("Product").appendKeySegment(-10).build();
final String etag = getETag(uri);
@@ -92,7 +92,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
@Test
public void replaceAsAtom() {
- final ODataPubFormat format = ODataPubFormat.ATOM;
+ final ODataFormat format = ODataFormat.ATOM;
final ODataEntity changes = read(format, client.newURIBuilder(getServiceRoot()).
appendEntitySetSegment("Car").appendKeySegment(14).build());
updateEntityDescription(format, changes, UpdateType.REPLACE);
@@ -100,7 +100,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
@Test
public void replaceAsJSON() {
- final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
+ final ODataFormat format = ODataFormat.JSON_FULL_METADATA;
final ODataEntity changes = read(format, client.newURIBuilder(getServiceRoot()).
appendEntitySetSegment("Car").appendKeySegment(14).build());
updateEntityDescription(format, changes, UpdateType.REPLACE);
@@ -108,15 +108,15 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
@Test
public void patchLinkAsAtom() throws EdmPrimitiveTypeException {
- patchLink(ODataPubFormat.ATOM);
+ patchLink(ODataFormat.ATOM);
}
@Test
public void patchLinkAsJSON() throws EdmPrimitiveTypeException {
- patchLink(ODataPubFormat.JSON_FULL_METADATA);
+ patchLink(ODataFormat.JSON_FULL_METADATA);
}
- public void patchLink(final ODataPubFormat format) throws EdmPrimitiveTypeException {
+ public void patchLink(final ODataFormat format) throws EdmPrimitiveTypeException {
final URI uri = client.newURIBuilder(getServiceRoot()).
appendEntitySetSegment("Customer").appendKeySegment(-10).build();
@@ -172,7 +172,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
// ---------------------------------------
}
- private ODataEntityUpdateRequest<ODataEntity> buildMultiKeyUpdateReq(final ODataPubFormat format)
+ private ODataEntityUpdateRequest<ODataEntity> buildMultiKeyUpdateReq(final ODataFormat format)
throws EdmPrimitiveTypeException {
final LinkedHashMap<String, Object> multiKey = new LinkedHashMap<String, Object>();
@@ -192,19 +192,19 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
return client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.MERGE, message);
}
- private void mergeMultiKey(final ODataPubFormat format) throws EdmPrimitiveTypeException {
+ private void mergeMultiKey(final ODataFormat format) throws EdmPrimitiveTypeException {
final ODataEntityUpdateResponse<ODataEntity> res = buildMultiKeyUpdateReq(format).execute();
assertEquals(204, res.getStatusCode());
}
@Test
public void mergeMultiKeyAsAtom() throws EdmPrimitiveTypeException {
- mergeMultiKey(ODataPubFormat.ATOM);
+ mergeMultiKey(ODataFormat.ATOM);
}
@Test
public void mergeMultiKeyAsJSON() throws EdmPrimitiveTypeException {
- mergeMultiKey(ODataPubFormat.JSON_FULL_METADATA);
+ mergeMultiKey(ODataFormat.JSON_FULL_METADATA);
}
@Test
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v3/ErrorTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/ErrorTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/ErrorTestITCase.java
index fe8ef61..3781734 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v3/ErrorTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v3/ErrorTestITCase.java
@@ -26,6 +26,7 @@ import static org.junit.Assert.fail;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.net.URI;
+
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.olingo.client.api.communication.ODataClientErrorException;
@@ -41,7 +42,7 @@ import org.apache.olingo.client.core.communication.response.AbstractODataRespons
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
/**
@@ -50,10 +51,15 @@ import org.junit.Test;
public class ErrorTestITCase extends AbstractTestITCase {
private class ErrorGeneratingRequest
- extends AbstractODataBasicRequest<ODataEntityCreateResponse<ODataEntity>, ODataPubFormat> {
+ extends AbstractODataBasicRequest<ODataEntityCreateResponse<ODataEntity>> {
public ErrorGeneratingRequest(final HttpMethod method, final URI uri) {
- super(client, ODataPubFormat.class, method, uri);
+ super(client, method, uri);
+ }
+
+ @Override
+ public ODataFormat getDefaultFormat() {
+ return odataClient.getConfiguration().getDefaultPubFormat();
}
@Override
@@ -83,7 +89,7 @@ public class ErrorTestITCase extends AbstractTestITCase {
}
}
- private void stacktraceError(final ODataPubFormat format) {
+ private void stacktraceError(final ODataFormat format) {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL);
uriBuilder.appendEntitySetSegment("Customer");
@@ -102,15 +108,15 @@ public class ErrorTestITCase extends AbstractTestITCase {
@Test
public void xmlStacktraceError() {
- stacktraceError(ODataPubFormat.ATOM);
+ stacktraceError(ODataFormat.ATOM);
}
@Test
public void jsonStacktraceError() {
- stacktraceError(ODataPubFormat.JSON);
+ stacktraceError(ODataFormat.JSON);
}
- private void notfoundError(final ODataPubFormat format) {
+ private void notfoundError(final ODataFormat format) {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL);
uriBuilder.appendEntitySetSegment("Customer(154)");
@@ -130,15 +136,15 @@ public class ErrorTestITCase extends AbstractTestITCase {
@Test
public void xmlNotfoundError() {
- notfoundError(ODataPubFormat.ATOM);
+ notfoundError(ODataFormat.ATOM);
}
@Test
public void jsonNotfoundError() {
- notfoundError(ODataPubFormat.JSON);
+ notfoundError(ODataFormat.JSON);
}
- private void instreamError(final ODataPubFormat format) {
+ private void instreamError(final ODataFormat format) {
final URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).
appendOperationCallSegment("InStreamErrorGetCustomer");
final ODataInvokeRequest<ODataEntitySet> req =
@@ -152,11 +158,11 @@ public class ErrorTestITCase extends AbstractTestITCase {
@Test(expected = IllegalArgumentException.class)
public void atomInstreamError() {
- instreamError(ODataPubFormat.ATOM);
+ instreamError(ODataFormat.ATOM);
}
@Test(expected = IllegalArgumentException.class)
public void jsonInstreamError() {
- instreamError(ODataPubFormat.JSON);
+ instreamError(ODataFormat.JSON);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v3/InvokeTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/InvokeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/InvokeTestITCase.java
index 6b8742f..d2edbbe 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v3/InvokeTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v3/InvokeTestITCase.java
@@ -29,6 +29,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+
import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest;
import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
@@ -46,12 +47,12 @@ import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
import org.apache.olingo.commons.api.domain.v3.ODataProperty;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
public class InvokeTestITCase extends AbstractTestITCase {
- private void getWithNoParams(final ODataPubFormat format) {
+ private void getWithNoParams(final ODataFormat format) {
// 1. get primitive value property
URIBuilder builder = getClient().newURIBuilder(testStaticServiceRootURL).
appendOperationCallSegment("GetPrimitiveString");
@@ -83,15 +84,15 @@ public class InvokeTestITCase extends AbstractTestITCase {
@Test
public void getWithNoParamsAsAtom() {
- getWithNoParams(ODataPubFormat.ATOM);
+ getWithNoParams(ODataFormat.ATOM);
}
@Test
public void getWithNoParamsAsJSON() {
- getWithNoParams(ODataPubFormat.JSON);
+ getWithNoParams(ODataFormat.JSON);
}
- private void getWithParams(final ODataPubFormat format) throws EdmPrimitiveTypeException {
+ private void getWithParams(final ODataFormat format) throws EdmPrimitiveTypeException {
// 1. primitive result
URIBuilder builder = getClient().newURIBuilder(testStaticServiceRootURL).
appendOperationCallSegment("GetArgumentPlusOne");
@@ -133,15 +134,15 @@ public class InvokeTestITCase extends AbstractTestITCase {
@Test
public void getWithParamsAsAtom() throws EdmPrimitiveTypeException {
- getWithParams(ODataPubFormat.ATOM);
+ getWithParams(ODataFormat.ATOM);
}
@Test
public void getWithParamsAsJSON() throws EdmPrimitiveTypeException {
- getWithParams(ODataPubFormat.JSON);
+ getWithParams(ODataFormat.JSON);
}
- private ODataEntity createEmployee(final ODataPubFormat format) {
+ private ODataEntity createEmployee(final ODataFormat format) {
final ODataEntity employee = getClient().getObjectFactory().newEntity(new FullQualifiedName(
"Microsoft.Test.OData.Services.AstoriaDefaultService.Employee"));
@@ -169,7 +170,7 @@ public class InvokeTestITCase extends AbstractTestITCase {
return req.execute().getBody();
}
- private void deleteEmployee(final ODataPubFormat format, final Integer id) {
+ private void deleteEmployee(final ODataFormat format, final Integer id) {
final URIBuilder uriBuilder = getClient().newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Person").appendKeySegment(id);
@@ -182,7 +183,7 @@ public class InvokeTestITCase extends AbstractTestITCase {
@Test
public void boundPost() throws EdmPrimitiveTypeException {
// 0. create an employee
- final ODataEntity created = createEmployee(ODataPubFormat.JSON_FULL_METADATA);
+ final ODataEntity created = createEmployee(ODataFormat.JSON_FULL_METADATA);
assertNotNull(created);
final Integer createdId = created.getProperty("PersonId").getPrimitiveValue().toCastValue(Integer.class);
assertNotNull(createdId);
@@ -192,7 +193,7 @@ public class InvokeTestITCase extends AbstractTestITCase {
final ODataInvokeRequest<ODataNoContent> req = getClient().getInvokeRequestFactory().
getActionInvokeRequest(operation.getTarget(), ODataNoContent.class);
- req.setFormat(ODataPubFormat.JSON_FULL_METADATA);
+ req.setFormat(ODataFormat.JSON_FULL_METADATA);
final ODataInvokeResponse<ODataNoContent> res = req.execute();
assertNotNull(res);
assertEquals(204, res.getStatusCode());
@@ -202,13 +203,13 @@ public class InvokeTestITCase extends AbstractTestITCase {
appendEntitySetSegment("Person").appendKeySegment(createdId);
final ODataEntityRequest<ODataEntity> retrieveRes =
getClient().getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- retrieveRes.setFormat(ODataPubFormat.JSON_FULL_METADATA);
+ retrieveRes.setFormat(ODataFormat.JSON_FULL_METADATA);
final ODataEntity read = retrieveRes.execute().getBody();
assertEquals("0", read.getProperty("Salary").getPrimitiveValue().toString());
assertTrue(read.getProperty("Title").getPrimitiveValue().toString().endsWith("[Sacked]"));
// 3. remove the test employee
- deleteEmployee(ODataPubFormat.JSON_FULL_METADATA, createdId);
+ deleteEmployee(ODataFormat.JSON_FULL_METADATA, createdId);
}
@Test
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v3/KeyAsSegmentTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/KeyAsSegmentTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/KeyAsSegmentTestITCase.java
index 30c2d99..569ea4f 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v3/KeyAsSegmentTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v3/KeyAsSegmentTestITCase.java
@@ -26,7 +26,7 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRe
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.api.uri.v3.URIBuilder;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -38,7 +38,7 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
client.getConfiguration().setKeyAsSegment(true);
}
- private void read(final ODataPubFormat format) {
+ private void read(final ODataFormat format) {
final URIBuilder uriBuilder = client.newURIBuilder(testKeyAsSegmentServiceRootURL).
appendEntitySetSegment("Customer").appendKeySegment(-10);
@@ -55,17 +55,17 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
@Test
public void fromAtom() {
- read(ODataPubFormat.ATOM);
+ read(ODataFormat.ATOM);
}
@Test
public void fromJSON() {
- read(ODataPubFormat.JSON_FULL_METADATA);
+ read(ODataFormat.JSON_FULL_METADATA);
}
@Test
public void createODataEntityAsAtom() {
- final ODataPubFormat format = ODataPubFormat.ATOM;
+ final ODataFormat format = ODataFormat.ATOM;
final int id = 1;
final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
@@ -77,7 +77,7 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
@Test
public void createODataEntityAsJSON() {
- final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
+ final ODataFormat format = ODataFormat.JSON_FULL_METADATA;
final int id = 2;
final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
@@ -89,7 +89,7 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
@Test
public void replaceODataEntityAsAtom() {
- final ODataPubFormat format = ODataPubFormat.ATOM;
+ final ODataFormat format = ODataFormat.ATOM;
final ODataEntity changes = read(format, client.newURIBuilder(testKeyAsSegmentServiceRootURL).
appendEntitySetSegment("Car").appendKeySegment(14).build());
updateEntityDescription(format, changes, UpdateType.REPLACE);
@@ -97,7 +97,7 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
@Test
public void replaceODataEntityAsJSON() {
- final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
+ final ODataFormat format = ODataFormat.JSON_FULL_METADATA;
final ODataEntity changes = read(format, client.newURIBuilder(testKeyAsSegmentServiceRootURL).
appendEntitySetSegment("Car").appendKeySegment(14).build());
updateEntityDescription(format, changes, UpdateType.REPLACE);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v3/MediaEntityTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/MediaEntityTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/MediaEntityTestITCase.java
index 7383c1b..a29c10f 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v3/MediaEntityTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v3/MediaEntityTestITCase.java
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertNotNull;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
+
import org.apache.commons.io.IOUtils;
import org.apache.olingo.client.api.communication.ODataClientErrorException;
import org.apache.olingo.client.api.communication.request.retrieve.ODataMediaRequest;
@@ -39,8 +40,7 @@ import org.apache.olingo.client.api.communication.response.ODataStreamUpdateResp
import org.apache.olingo.client.api.uri.v3.URIBuilder;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.domain.v3.ODataProperty;
-import org.apache.olingo.commons.api.format.ODataMediaFormat;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
public class MediaEntityTestITCase extends AbstractTestITCase {
@@ -51,7 +51,7 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
appendEntitySetSegment("Car").appendKeySegment(12);
final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaEntityRequest(builder.build());
- retrieveReq.setFormat(ODataMediaFormat.WILDCARD);
+ retrieveReq.setFormat(ODataFormat.WILDCARD);
final ODataRetrieveResponse<InputStream> retrieveRes = retrieveReq.execute();
assertEquals(200, retrieveRes.getStatusCode());
@@ -66,7 +66,7 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Car").appendKeySegment(12);
final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaEntityRequest(builder.build());
- retrieveReq.setFormat(ODataMediaFormat.APPLICATION_XML);
+ retrieveReq.setFormat(ODataFormat.APPLICATION_XML);
retrieveReq.execute();
}
@@ -77,12 +77,12 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Car").appendKeySegment(12);
final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaEntityRequest(builder.build());
- retrieveReq.setFormat(ODataMediaFormat.APPLICATION_JSON);
+ retrieveReq.setFormat(ODataFormat.APPLICATION_JSON);
retrieveReq.execute();
}
- private void updateMediaEntity(final ODataPubFormat format, final int id) throws Exception {
+ private void updateMediaEntity(final ODataFormat format, final int id) throws Exception {
final URIBuilder builder =
client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Car").appendKeySegment(id);
@@ -106,15 +106,15 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
@Test
public void updateMediaEntityAsAtom() throws Exception {
- updateMediaEntity(ODataPubFormat.ATOM, 14);
+ updateMediaEntity(ODataFormat.ATOM, 14);
}
@Test
public void updateMediaEntityAsJson() throws Exception {
- updateMediaEntity(ODataPubFormat.JSON, 15);
+ updateMediaEntity(ODataFormat.JSON, 15);
}
- private void createMediaEntity(final ODataPubFormat format, final InputStream input) throws Exception {
+ private void createMediaEntity(final ODataFormat format, final InputStream input) throws Exception {
final URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Car");
final ODataMediaEntityCreateRequest<ODataEntity> createReq =
@@ -148,17 +148,17 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
@Test
public void createMediaEntityAsAtom() throws Exception {
- createMediaEntity(ODataPubFormat.ATOM, IOUtils.toInputStream("buffered stream sample"));
+ createMediaEntity(ODataFormat.ATOM, IOUtils.toInputStream("buffered stream sample"));
}
@Test
public void createMediaEntityAsJson() throws Exception {
- createMediaEntity(ODataPubFormat.JSON, IOUtils.toInputStream("buffered stream sample"));
+ createMediaEntity(ODataFormat.JSON, IOUtils.toInputStream("buffered stream sample"));
}
@Test
public void issue137() throws Exception {
- createMediaEntity(ODataPubFormat.JSON, this.getClass().getResourceAsStream("/sample.png"));
+ createMediaEntity(ODataFormat.JSON, this.getClass().getResourceAsStream("/sample.png"));
}
@Test
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v3/OpenTypeTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/OpenTypeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/OpenTypeTestITCase.java
index 05d8a07..b6b4d53 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v3/OpenTypeTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v3/OpenTypeTestITCase.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertTrue;
import java.util.Calendar;
import java.util.UUID;
+
import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
import org.apache.olingo.client.api.communication.response.ODataDeleteResponse;
import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
@@ -35,7 +36,7 @@ import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.EdmSchema;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
public class OpenTypeTestITCase extends AbstractTestITCase {
@@ -52,13 +53,13 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
assertTrue(metadata.getEntityType(new FullQualifiedName(schema.getNamespace(), "RowIndex")).isOpenType());
}
- private ODataEntity readRow(final ODataPubFormat format, final String uuid) {
+ private ODataEntity readRow(final ODataFormat format, final String uuid) {
final URIBuilder builder = getClient().newURIBuilder(testOpenTypeServiceRootURL).
appendEntitySetSegment("Row").appendKeySegment(UUID.fromString(uuid));
return read(format, builder.build());
}
- private void read(final ODataPubFormat format) {
+ private void read(final ODataFormat format) {
ODataEntity row = readRow(format, "71f7d0dc-ede4-45eb-b421-555a2aa1e58f");
assertEquals(EdmPrimitiveTypeKind.Double, row.getProperty("Double").getPrimitiveValue().getTypeKind());
assertEquals(EdmPrimitiveTypeKind.Guid, row.getProperty("Id").getPrimitiveValue().getTypeKind());
@@ -69,15 +70,15 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
@Test
public void readAsAtom() {
- read(ODataPubFormat.ATOM);
+ read(ODataFormat.ATOM);
}
@Test
public void readAsJSON() {
- read(ODataPubFormat.JSON_FULL_METADATA);
+ read(ODataFormat.JSON_FULL_METADATA);
}
- private void cud(final ODataPubFormat format) {
+ private void cud(final ODataFormat format) {
final Integer id = 1426;
ODataEntity rowIndex = getClient().getObjectFactory().newEntity(
@@ -172,11 +173,11 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
@Test
public void cudAsAtom() {
- cud(ODataPubFormat.ATOM);
+ cud(ODataFormat.ATOM);
}
@Test
public void cudAsJSON() {
- cud(ODataPubFormat.JSON_FULL_METADATA);
+ cud(ODataFormat.JSON_FULL_METADATA);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v3/PrimitiveKeysTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/PrimitiveKeysTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/PrimitiveKeysTestITCase.java
index 73c7d9d..2b2ec75 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v3/PrimitiveKeysTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v3/PrimitiveKeysTestITCase.java
@@ -23,16 +23,16 @@ import static org.junit.Assert.assertNotNull;
import java.math.BigDecimal;
import java.util.UUID;
+
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
-
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
public class PrimitiveKeysTestITCase extends AbstractTestITCase {
- private void readEntity(final String entityType, final Object key, final ODataPubFormat format) {
+ private void readEntity(final String entityType, final Object key, final ODataFormat format) {
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(
client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment(entityType).
appendKeySegment(key).
@@ -45,7 +45,7 @@ public class PrimitiveKeysTestITCase extends AbstractTestITCase {
assertNotNull(entity.getProperty("Id"));
}
- private void readPrimitiveKeys(final ODataPubFormat format) {
+ private void readPrimitiveKeys(final ODataFormat format) {
readEntity("EdmBooleanSet", Boolean.TRUE, format);
readEntity("EdmByteSet", 255, format);
readEntity("EdmDecimalSet", new BigDecimal("79228162514264337593543950335"), format);
@@ -60,11 +60,11 @@ public class PrimitiveKeysTestITCase extends AbstractTestITCase {
@Test
public void readEntityAsAtom() {
- readPrimitiveKeys(ODataPubFormat.ATOM);
+ readPrimitiveKeys(ODataFormat.ATOM);
}
@Test
public void readEntityAsJSON() {
- readPrimitiveKeys(ODataPubFormat.JSON_FULL_METADATA);
+ readPrimitiveKeys(ODataFormat.JSON_FULL_METADATA);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v3/PropertyTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/PropertyTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/PropertyTestITCase.java
index e1fa1d4..6866a06 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v3/PropertyTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v3/PropertyTestITCase.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
+
import org.apache.olingo.client.api.communication.ODataClientErrorException;
import org.apache.olingo.client.api.communication.request.cud.ODataPropertyUpdateRequest;
import org.apache.olingo.client.api.communication.request.cud.ODataValueUpdateRequest;
@@ -45,7 +46,6 @@ import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.domain.v3.ODataProperty;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.format.ODataValueFormat;
import org.junit.Test;
/**
@@ -59,7 +59,7 @@ public class PropertyTestITCase extends AbstractTestITCase {
@Test
public void replacePropertyValue() throws Exception {
- updatePropertyValue(ODataValueFormat.TEXT, UpdateType.REPLACE);
+ updatePropertyValue(ODataFormat.TEXT_PLAIN, UpdateType.REPLACE);
}
@Test
@@ -128,7 +128,7 @@ public class PropertyTestITCase extends AbstractTestITCase {
uriBuilder.appendEntitySetSegment("Customer").count();
final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
- req.setFormat(ODataValueFormat.TEXT);
+ req.setFormat(ODataFormat.TEXT_PLAIN);
final ODataRetrieveResponse<ODataPrimitiveValue> res = req.execute();
assertEquals(200, res.getStatusCode());
@@ -159,8 +159,8 @@ public class PropertyTestITCase extends AbstractTestITCase {
execute();
}
- private void updatePropertyValue(final ODataValueFormat format, final UpdateType type)
- throws IOException, EdmPrimitiveTypeException {
+ private void updatePropertyValue(final ODataFormat format, final UpdateType type)
+ throws IOException, EdmPrimitiveTypeException {
final URIBuilder uriBuilder = client.newURIBuilder(getServiceRoot()).
appendEntitySetSegment("Customer").appendKeySegment(-9).
[4/8] [OLINGO-317] Merged the format ENUMs
Posted by mi...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v3/PropertyValueTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/PropertyValueTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/PropertyValueTestITCase.java
index 2c8c9d9..b27461e 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v3/PropertyValueTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v3/PropertyValueTestITCase.java
@@ -18,7 +18,11 @@
*/
package org.apache.olingo.fit.v3;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import java.io.IOException;
+
import org.apache.olingo.client.api.communication.ODataClientErrorException;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataValueRequest;
@@ -26,8 +30,7 @@ import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse
import org.apache.olingo.client.api.uri.CommonURIBuilder;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
-import org.apache.olingo.commons.api.format.ODataValueFormat;
-import static org.junit.Assert.*;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
public class PropertyValueTestITCase extends AbstractTestITCase {
@@ -37,7 +40,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
CommonURIBuilder<?> uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Product").appendKeySegment(-10).appendPropertySegment("ProductId");
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
- req.setFormat(ODataValueFormat.TEXT);
+ req.setFormat(ODataFormat.TEXT_PLAIN);
final ODataValue value = req.execute().getBody();
assertNotNull(value);
assertEquals(-10, Integer.parseInt(value.toString()));
@@ -48,7 +51,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
CommonURIBuilder<?> uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Product").appendKeySegment(-10).appendPropertySegment("ProductId");
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
- req.setFormat(ODataValueFormat.TEXT);
+ req.setFormat(ODataFormat.TEXT_PLAIN);
final ODataValue value = req.execute().getBody();
assertNotNull(value);
assertEquals(-10, Integer.parseInt(value.toString()));
@@ -59,7 +62,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
CommonURIBuilder<?> uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Product").appendKeySegment(-6).appendPropertySegment("Description");
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
- req.setFormat(ODataValueFormat.TEXT);
+ req.setFormat(ODataFormat.TEXT_PLAIN);
final ODataValue value = req.execute().getBody();
assertNotNull(value);
assertEquals("expdybhclurfobuyvzmhkgrnrajhamqmkhqpmiypittnp", value.toString());
@@ -71,7 +74,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
appendEntitySetSegment("Product").appendKeySegment(-7).appendPropertySegment(
"NestedComplexConcurrency/ModifiedDate");
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
- req.setFormat(ODataValueFormat.TEXT);
+ req.setFormat(ODataFormat.TEXT_PLAIN);
final ODataValue value = req.execute().getBody();
assertNotNull(value);
assertEquals("7866-11-16T22:25:52.747755+01:00", value.toString());
@@ -82,7 +85,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
CommonURIBuilder<?> uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Product").appendKeySegment(-6).appendPropertySegment("Dimensions/Height");
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
- req.setFormat(ODataValueFormat.TEXT);
+ req.setFormat(ODataFormat.TEXT_PLAIN);
final ODataValue value = req.execute().getBody();
assertNotNull(value);
assertEquals("-79228162514264337593543950335", value.toString());
@@ -111,11 +114,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
req.setAccept("application/atom+xml");
ODataRetrieveResponse<ODataEntity> res = req.execute();
assertEquals(200, res.getStatusCode());
- ODataEntity entitySet = res.getBody();
- assertNotNull(entitySet);
- assertEquals("fi653p3+MklA/LdoBlhWgnMTUUEo8tEgtbMXnF0a3CUNL9BZxXpSRiD9ebTnmNR0zWPjJ"
- + "VIDx4tdmCnq55XrJh+RW9aI/b34wAogK3kcORw=",
- entitySet.getProperties().get(0).getValue().toString());
+ res.getBody();
}
@Test(expected = IllegalArgumentException.class)
@@ -126,11 +125,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
req.setAccept("application/xml");
ODataRetrieveResponse<ODataEntity> res = req.execute();
assertEquals(200, res.getStatusCode());
- ODataEntity entitySet = res.getBody();
- assertNotNull(entitySet);
- assertEquals("fi653p3+MklA/LdoBlhWgnMTUUEo8tEgtbMXnF0a3CUNL9BZxXpSRiD9ebTnmNR0zWPjJ"
- + "VIDx4tdmCnq55XrJh+RW9aI/b34wAogK3kcORw=",
- entitySet.getProperties().get(0).getValue().toString());
+ res.getBody();
}
@Test
@@ -139,7 +134,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
appendEntitySetSegment("Product").appendKeySegment(-7).appendPropertySegment(
"ComplexConcurrency/QueriedDateTime");
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
- req.setFormat(ODataValueFormat.TEXT);
+ req.setFormat(ODataFormat.TEXT_PLAIN);
final ODataValue value = req.execute().getBody();
if (value.isPrimitive()) {
assertNotNull(value);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v3/QueryOptionsTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/QueryOptionsTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/QueryOptionsTestITCase.java
index 1b15c3f..940aa74 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v3/QueryOptionsTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v3/QueryOptionsTestITCase.java
@@ -25,6 +25,7 @@ import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
@@ -34,7 +35,7 @@ import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
/**
@@ -44,8 +45,6 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
/**
* Test <tt>$expand</tt>.
- *
- * @see EntityRetrieveTest#readODataEntityWithInline(org.apache.olingo.commons.api.format.ODataPubFormat)
*/
public void expand() {
// empty
@@ -102,18 +101,16 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
appendEntitySetSegment("Customer").appendKeySegment(-10).format("json");
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- req.setFormat(ODataPubFormat.ATOM);
+ req.setFormat(ODataFormat.ATOM);
final ODataRetrieveResponse<ODataEntity> res = req.execute();
assertNotNull(res);
assertTrue(res.getContentType().replaceAll(" ", "").
- startsWith(ODataPubFormat.JSON.toString(client.getServiceVersion())));
+ startsWith(ODataFormat.JSON.toString(client.getServiceVersion())));
}
/**
* Test <tt>$skip</tt>.
- *
- * @see FeedTest#readFeedWithNextLink(org.apache.olingo.commons.api.format.ODataPubFormat)
*/
public void skip() {
// empty
@@ -121,8 +118,6 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
/**
* Test <tt>$top</tt>.
- *
- * @see FeedTest#readFeed(org.apache.olingo.commons.api.format.ODataPubFormat)
*/
public void top() {
// empty
@@ -157,7 +152,7 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().
getEntitySetRequest(uriBuilder.build());
- req.setFormat(ODataPubFormat.ATOM);
+ req.setFormat(ODataFormat.ATOM);
final ODataEntitySet feed = req.execute().getBody();
assertNotNull(feed);
assertEquals(feed.getEntities().size(), feed.getCount());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v4/AbstractTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/AbstractTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/AbstractTestITCase.java
index 31619e3..5ba1c26 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/AbstractTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/AbstractTestITCase.java
@@ -18,8 +18,12 @@
*/
package org.apache.olingo.fit.v4;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import java.io.IOException;
import java.net.URI;
+
import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest;
import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
@@ -28,7 +32,6 @@ import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse
import org.apache.olingo.client.api.v4.EdmEnabledODataClient;
import org.apache.olingo.client.api.v4.ODataClient;
import org.apache.olingo.client.core.ODataClientFactory;
-import org.apache.olingo.fit.AbstractBaseTestITCase;
import org.apache.olingo.commons.api.domain.ODataCollectionValue;
import org.apache.olingo.commons.api.domain.v4.ODataEntity;
import org.apache.olingo.commons.api.domain.v4.ODataProperty;
@@ -36,10 +39,9 @@ import org.apache.olingo.commons.api.domain.v4.ODataValue;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.core.domain.v4.ODataEntityImpl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import org.apache.olingo.fit.AbstractBaseTestITCase;
import org.junit.BeforeClass;
public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
@@ -86,7 +88,7 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
return client;
}
- protected ODataEntity read(final ODataPubFormat format, final URI editLink) {
+ protected ODataEntity read(final ODataFormat format, final URI editLink) {
final ODataEntityRequest<ODataEntity> req = getClient().getRetrieveRequestFactory().getEntityRequest(editLink);
req.setFormat(format);
@@ -95,14 +97,14 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
assertNotNull(entity);
- if (ODataPubFormat.JSON_FULL_METADATA == format || ODataPubFormat.ATOM == format) {
+ if (ODataFormat.JSON_FULL_METADATA == format || ODataFormat.ATOM == format) {
assertEquals(req.getURI(), entity.getEditLink());
}
return entity;
}
- protected void createAndDeleteOrder(final ODataPubFormat format, final int id) {
+ protected void createAndDeleteOrder(final ODataFormat format, final int id) {
final ODataEntity order = new ODataEntityImpl(
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Order"));
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v4/AsyncTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/AsyncTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/AsyncTestITCase.java
index edeeae5..bcc8313 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/AsyncTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/AsyncTestITCase.java
@@ -27,6 +27,7 @@ import java.net.URI;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
+
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
import org.apache.olingo.client.api.communication.request.v4.AsyncRequestWrapper;
@@ -39,7 +40,7 @@ import org.apache.olingo.commons.api.domain.ODataInlineEntity;
import org.apache.olingo.commons.api.domain.ODataLink;
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.format.ODataFormat;
import org.junit.Test;
public class AsyncTestITCase extends AbstractTestITCase {
@@ -62,7 +63,7 @@ public class AsyncTestITCase extends AbstractTestITCase {
assertFalse(res.getBody().getEntities().isEmpty());
}
- private void withInlineEntry(final ODataPubFormat format) {
+ private void withInlineEntry(final ODataFormat format) {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Customers").appendKeySegment(1).expand("Company");
@@ -85,7 +86,7 @@ public class AsyncTestITCase extends AbstractTestITCase {
assertEquals(3, entity.getNavigationLinks().size());
- if (ODataPubFormat.ATOM == format) {
+ if (ODataFormat.ATOM == format) {
assertTrue(entity.getAssociationLinks().isEmpty());
// In JSON, association links for each $ref link will exist.
}
@@ -120,16 +121,16 @@ public class AsyncTestITCase extends AbstractTestITCase {
@Test
public void withInlineEntryAsAtom() {
- withInlineEntry(ODataPubFormat.ATOM);
+ withInlineEntry(ODataFormat.ATOM);
}
@Test
public void withInlineEntryAsJSON() {
// this needs to be full, otherwise there is no mean to recognize links
- withInlineEntry(ODataPubFormat.JSON_FULL_METADATA);
+ withInlineEntry(ODataFormat.JSON_FULL_METADATA);
}
- private void asyncOrders(final ODataPubFormat format) {
+ private void asyncOrders(final ODataFormat format) {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("async").appendEntitySetSegment("Orders");
@@ -154,11 +155,11 @@ public class AsyncTestITCase extends AbstractTestITCase {
@Test
public void asyncOrdersAsAtom() {
- asyncOrders(ODataPubFormat.ATOM);
+ asyncOrders(ODataFormat.ATOM);
}
@Test
public void asyncOrdersAsJSON() {
- asyncOrders(ODataPubFormat.JSON);
+ asyncOrders(ODataFormat.JSON);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v4/AuthBatchTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/AuthBatchTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/AuthBatchTestITCase.java
index 2b3faea..73f1578 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/AuthBatchTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/AuthBatchTestITCase.java
@@ -17,10 +17,9 @@ package org.apache.olingo.fit.v4;
import static org.junit.Assert.assertEquals;
-import org.junit.Test;
import java.net.URI;
-import org.apache.olingo.client.api.communication.header.HeaderName;
+import org.apache.olingo.client.api.communication.header.HeaderName;
import org.apache.olingo.client.api.communication.request.batch.BatchManager;
import org.apache.olingo.client.api.communication.request.batch.ODataChangeset;
import org.apache.olingo.client.api.communication.request.batch.v4.ODataBatchRequest;
@@ -37,7 +36,8 @@ import org.apache.olingo.commons.api.domain.v4.ODataEntity;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.junit.Test;
public class AuthBatchTestITCase extends AbstractTestITCase {
@@ -63,7 +63,6 @@ public class AuthBatchTestITCase extends AbstractTestITCase {
batchRequest(unauthclient, testAuthServiceRootURL);
}
- @SuppressWarnings({"unchecked"})
private void batchRequest(final ODataClient client, final String baseURL) throws EdmPrimitiveTypeException {
// create your request
final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(baseURL);
@@ -82,7 +81,7 @@ public class AuthBatchTestITCase extends AbstractTestITCase {
// create new request
ODataEntityRequest<ODataEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
- queryReq.setFormat(ODataPubFormat.JSON);
+ queryReq.setFormat(ODataFormat.JSON);
streamManager.addRequest(queryReq);
// -------------------------------------------
@@ -106,7 +105,7 @@ public class AuthBatchTestITCase extends AbstractTestITCase {
final ODataEntityUpdateRequest<ODataEntity> changeReq =
client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.PATCH, patch);
- changeReq.setFormat(ODataPubFormat.JSON_FULL_METADATA);
+ changeReq.setFormat(ODataFormat.JSON_FULL_METADATA);
changeset.addRequest(changeReq);
// -------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v4/BatchTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/BatchTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/BatchTestITCase.java
index daf4ed2..c4bac40 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/BatchTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/BatchTestITCase.java
@@ -18,10 +18,10 @@
*/
package org.apache.olingo.fit.v4;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.fail;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.IOException;
import java.net.URI;
@@ -31,6 +31,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
+
import org.apache.http.HttpResponse;
import org.apache.olingo.client.api.ODataBatchConstants;
import org.apache.olingo.client.api.communication.header.HeaderName;
@@ -65,7 +66,7 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
public class BatchTestITCase extends AbstractTestITCase {
@@ -126,20 +127,20 @@ public class BatchTestITCase extends AbstractTestITCase {
for (int i = 1; i <= 2; i++) {
// Create Customer into the changeset
createReq = client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), newOrder(100 + i));
- createReq.setFormat(ODataPubFormat.JSON);
+ createReq.setFormat(ODataFormat.JSON);
changeset.addRequest(createReq);
}
targetURI = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("WrongEntitySet");
createReq = client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), newOrder(105));
- createReq.setFormat(ODataPubFormat.JSON);
+ createReq.setFormat(ODataFormat.JSON);
changeset.addRequest(createReq);
targetURI = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders");
for (int i = 3; i <= 4; i++) {
// Create Customer into the changeset
createReq = client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), newOrder(100 + i));
- createReq.setFormat(ODataPubFormat.JSON);
+ createReq.setFormat(ODataFormat.JSON);
changeset.addRequest(createReq);
}
@@ -189,7 +190,7 @@ public class BatchTestITCase extends AbstractTestITCase {
// create new request
ODataEntityRequest<ODataEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
- queryReq.setFormat(ODataPubFormat.JSON);
+ queryReq.setFormat(ODataFormat.JSON);
streamManager.addRequest(queryReq);
// -------------------------------------------
@@ -334,7 +335,7 @@ public class BatchTestITCase extends AbstractTestITCase {
// create new request
ODataEntityRequest<ODataEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
- queryReq.setFormat(ODataPubFormat.JSON);
+ queryReq.setFormat(ODataFormat.JSON);
streamManager.addRequest(queryReq);
// -------------------------------------------
@@ -347,7 +348,7 @@ public class BatchTestITCase extends AbstractTestITCase {
final ODataEntity original = newOrder(2000);
final ODataEntityCreateRequest<ODataEntity> createReq =
client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), original);
- createReq.setFormat(ODataPubFormat.JSON);
+ createReq.setFormat(ODataFormat.JSON);
streamManager.addRequest(createReq);
// -------------------------------------------
@@ -401,7 +402,7 @@ public class BatchTestITCase extends AbstractTestITCase {
// create new request
ODataEntityRequest<ODataEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
- queryReq.setFormat(ODataPubFormat.JSON);
+ queryReq.setFormat(ODataFormat.JSON);
streamManager.addRequest(queryReq);
// -------------------------------------------
@@ -425,7 +426,7 @@ public class BatchTestITCase extends AbstractTestITCase {
final ODataEntityUpdateRequest<ODataEntity> changeReq =
client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.PATCH, patch);
- changeReq.setFormat(ODataPubFormat.JSON_FULL_METADATA);
+ changeReq.setFormat(ODataFormat.JSON_FULL_METADATA);
changeset.addRequest(changeReq);
@@ -434,7 +435,7 @@ public class BatchTestITCase extends AbstractTestITCase {
final ODataEntity original = newOrder(1000);
final ODataEntityCreateRequest<ODataEntity> createReq =
client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), original);
- createReq.setFormat(ODataPubFormat.JSON);
+ createReq.setFormat(ODataFormat.JSON);
changeset.addRequest(createReq);
// -------------------------------------------
@@ -490,7 +491,7 @@ public class BatchTestITCase extends AbstractTestITCase {
entity = createres.getBody();
assertEquals(new Integer(1000), entity.getProperty("OrderID").getPrimitiveValue().toCastValue(Integer.class));
- // retrive the third item (ODataRetrieve)
+ // retrieve the third item (ODataRetrieve)
item = iter.next();
assertTrue(item instanceof ODataSingleResponseItem);
@@ -525,7 +526,7 @@ public class BatchTestITCase extends AbstractTestITCase {
// create new request
ODataEntityRequest<ODataEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
- queryReq.setFormat(ODataPubFormat.JSON);
+ queryReq.setFormat(ODataFormat.JSON);
async.addRetrieve(queryReq);
// -------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v4/BoundOperationInvokeTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/BoundOperationInvokeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/BoundOperationInvokeTestITCase.java
index e2bf9f2..a009aea 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/BoundOperationInvokeTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/BoundOperationInvokeTestITCase.java
@@ -26,6 +26,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
+
import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
import org.apache.olingo.client.api.uri.v4.URIBuilder;
@@ -42,12 +43,12 @@ import org.apache.olingo.commons.api.domain.v4.ODataSingleton;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
- private void functions(final ODataPubFormat format) throws EdmPrimitiveTypeException {
+ private void functions(final ODataFormat format) throws EdmPrimitiveTypeException {
// GetEmployeesCount
URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company");
final ODataEntityRequest<ODataSingleton> singletonReq =
@@ -167,12 +168,12 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
@Test
public void atomFunctions() throws EdmPrimitiveTypeException {
- functions(ODataPubFormat.ATOM);
+ functions(ODataFormat.ATOM);
}
@Test
public void jsonFunctions() throws EdmPrimitiveTypeException {
- functions(ODataPubFormat.JSON_FULL_METADATA);
+ functions(ODataFormat.JSON_FULL_METADATA);
}
@Test
@@ -261,7 +262,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
assertEquals(41.79, getActualAmountRes.getPrimitiveValue().toCastValue(Double.class), 0);
}
- private void actions(final ODataPubFormat format) throws EdmPrimitiveTypeException {
+ private void actions(final ODataFormat format) throws EdmPrimitiveTypeException {
// IncreaseRevenue
URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company");
ODataEntityRequest<ODataEntity> entityReq =
@@ -365,12 +366,12 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
@Test
public void atomActions() throws EdmPrimitiveTypeException {
- actions(ODataPubFormat.ATOM);
+ actions(ODataFormat.ATOM);
}
@Test
public void jsonActions() throws EdmPrimitiveTypeException {
- actions(ODataPubFormat.JSON_FULL_METADATA);
+ actions(ODataFormat.JSON_FULL_METADATA);
}
@Test
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v4/ConformanceTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/ConformanceTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/ConformanceTestITCase.java
index 8f67cdf..d2303b2 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/ConformanceTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/ConformanceTestITCase.java
@@ -19,12 +19,12 @@
package org.apache.olingo.fit.v4;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
-import org.junit.Test;
import java.net.URI;
+
import org.apache.olingo.client.api.communication.header.HeaderName;
import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest;
import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
@@ -53,8 +53,9 @@ import org.apache.olingo.commons.api.domain.v4.ODataValue;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.core.domain.v4.ODataEntityImpl;
+import org.junit.Test;
/**
* 13.2 Interoperable OData Clients
@@ -115,7 +116,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
final ODataEntityCreateRequest<ODataEntity> req = getClient().getCUDRequestFactory().getEntityCreateRequest(
getClient().newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Orders").build(), order);
- req.setFormat(ODataPubFormat.JSON_FULL_METADATA);
+ req.setFormat(ODataFormat.JSON_FULL_METADATA);
// check for OData-Version
assertEquals("4.0", req.getHeader("OData-Version"));
@@ -123,13 +124,13 @@ public class ConformanceTestITCase extends AbstractTestITCase {
// check for Content-Type
assertEquals(
- ODataPubFormat.JSON_FULL_METADATA.toString(ODataServiceVersion.V40),
+ ODataFormat.JSON_FULL_METADATA.toString(ODataServiceVersion.V40),
req.getHeader("Content-Type"));
assertEquals(
- ODataPubFormat.JSON_FULL_METADATA.toString(ODataServiceVersion.V40),
+ ODataFormat.JSON_FULL_METADATA.toString(ODataServiceVersion.V40),
req.getHeader(HeaderName.contentType.toString()));
assertEquals(
- ODataPubFormat.JSON_FULL_METADATA.toString(ODataServiceVersion.V40),
+ ODataFormat.JSON_FULL_METADATA.toString(ODataServiceVersion.V40),
req.getContentType());
final ODataEntity created = req.execute().getBody();
@@ -176,7 +177,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().
getEntitySetRequest(uriBuilder.build());
- req.setFormat(ODataPubFormat.JSON_FULL_METADATA);
+ req.setFormat(ODataFormat.JSON_FULL_METADATA);
req.setPrefer(client.newPreferences().maxPageSize(5));
ODataRetrieveResponse<ODataEntitySet> res = req.execute();
@@ -193,7 +194,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
assertEquals(expected, found);
req = client.getRetrieveRequestFactory().getEntitySetRequest(found);
- req.setFormat(ODataPubFormat.JSON_FULL_METADATA);
+ req.setFormat(ODataFormat.JSON_FULL_METADATA);
res = req.execute();
feed = res.getBody();
@@ -233,7 +234,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
final URIBuilder builder = getClient().newURIBuilder(testOpenTypeServiceRootURL).
appendEntitySetSegment("RowIndex").appendKeySegment(id);
- rowIndex = read(ODataPubFormat.JSON_FULL_METADATA, builder.build());
+ rowIndex = read(ODataFormat.JSON_FULL_METADATA, builder.build());
assertNotNull(rowIndex);
assertEquals(EdmPrimitiveTypeKind.Int32, rowIndex.getProperty("Id").getPrimitiveValue().getTypeKind());
assertEquals(EdmPrimitiveTypeKind.String, rowIndex.getProperty("aString").getPrimitiveValue().getTypeKind());
@@ -266,7 +267,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
final ODataEntityUpdateResponse<ODataEntity> res = req.execute();
assertEquals(204, res.getStatusCode());
- final ODataEntity actual = read(ODataPubFormat.JSON, uri);
+ final ODataEntity actual = read(ODataFormat.JSON, uri);
assertEquals(newname, actual.getProperty("FirstName").getPrimitiveValue().toString());
}
@@ -284,7 +285,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
appendEntitySetSegment("Customers").appendKeySegment(1).expand("Company");
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- req.setFormat(ODataPubFormat.JSON_FULL_METADATA);
+ req.setFormat(ODataFormat.JSON_FULL_METADATA);
assertNotNull(req.execute().getBody());
@@ -301,7 +302,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
appendRefSegment();
ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- req.setFormat(ODataPubFormat.JSON_FULL_METADATA);
+ req.setFormat(ODataFormat.JSON_FULL_METADATA);
ODataRetrieveResponse<ODataEntity> res = req.execute();
assertNotNull(res);
@@ -314,7 +315,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
appendEntityIdSegment(entity.getId().toASCIIString()).build();
req = client.getRetrieveRequestFactory().getEntityRequest(referenceURI);
- req.setFormat(ODataPubFormat.JSON_FULL_METADATA);
+ req.setFormat(ODataFormat.JSON_FULL_METADATA);
res = req.execute();
assertNotNull(res);
@@ -335,7 +336,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
assertNotNull(customers.getDeltaLink());
final ODataDeltaRequest deltaReq = client.getRetrieveRequestFactory().getDeltaRequest(customers.getDeltaLink());
- deltaReq.setFormat(ODataPubFormat.JSON_FULL_METADATA);
+ deltaReq.setFormat(ODataFormat.JSON_FULL_METADATA);
final ODataDelta delta = deltaReq.execute().getBody();
assertNotNull(delta);
@@ -377,7 +378,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
final ODataEntitySetRequest<ODataEntitySet> req =
client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
- req.setFormat(ODataPubFormat.JSON_FULL_METADATA);
+ req.setFormat(ODataFormat.JSON_FULL_METADATA);
final AsyncRequestWrapper<ODataRetrieveResponse<ODataEntitySet>> async =
client.getAsyncRequestFactory().<ODataRetrieveResponse<ODataEntitySet>>getAsyncRequestWrapper(req);
@@ -404,7 +405,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
final ODataEntityRequest<ODataEntity> req =
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- req.setFormat(ODataPubFormat.JSON);
+ req.setFormat(ODataFormat.JSON);
assertEquals("application/json;odata.metadata=minimal", req.getHeader("Accept"));
assertEquals("application/json;odata.metadata=minimal", req.getHeader(HeaderName.accept.toString()));
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v4/DeltaTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/DeltaTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/DeltaTestITCase.java
index 77c55a0..6c76793 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/DeltaTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/DeltaTestITCase.java
@@ -27,12 +27,12 @@ import org.apache.olingo.client.api.communication.request.retrieve.v4.ODataDelta
import org.apache.olingo.commons.api.domain.v4.ODataDelta;
import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
import org.apache.olingo.commons.api.domain.v4.ODataProperty;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
public class DeltaTestITCase extends AbstractTestITCase {
- private void parse(final ODataPubFormat format) {
+ private void parse(final ODataFormat format) {
final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().getEntitySetRequest(
client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customers").build());
req.setPrefer(client.newPreferences().trackChanges());
@@ -76,11 +76,11 @@ public class DeltaTestITCase extends AbstractTestITCase {
@Test
public void atomParse() {
- parse(ODataPubFormat.ATOM);
+ parse(ODataFormat.ATOM);
}
@Test
public void jsonParse() {
- parse(ODataPubFormat.JSON);
+ parse(ODataFormat.JSON);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v4/DerivedTypeTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/DerivedTypeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/DerivedTypeTestITCase.java
index bb1bcff..929f453 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/DerivedTypeTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/DerivedTypeTestITCase.java
@@ -33,12 +33,12 @@ import org.apache.olingo.commons.api.domain.v4.ODataProperty;
import org.apache.olingo.commons.api.domain.v4.ODataValuable;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
public class DerivedTypeTestITCase extends AbstractTestITCase {
- private void read(final ODataPubFormat format) {
+ private void read(final ODataFormat format) {
// 1. entity set
URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("People").
@@ -66,15 +66,15 @@ public class DerivedTypeTestITCase extends AbstractTestITCase {
@Test
public void readfromAtom() {
- read(ODataPubFormat.ATOM);
+ read(ODataFormat.ATOM);
}
@Test
public void readfromJSON() {
- read(ODataPubFormat.JSON_FULL_METADATA);
+ read(ODataFormat.JSON_FULL_METADATA);
}
- private void createDelete(final ODataPubFormat format) {
+ private void createDelete(final ODataFormat format) {
final ODataEntity customer = client.getObjectFactory().
newEntity(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer"));
@@ -135,11 +135,11 @@ public class DerivedTypeTestITCase extends AbstractTestITCase {
@Test
public void createDeleteAsAtom() {
- createDelete(ODataPubFormat.ATOM);
+ createDelete(ODataFormat.ATOM);
}
@Test
public void createDeleteAsJSON() {
- createDelete(ODataPubFormat.JSON_FULL_METADATA);
+ createDelete(ODataFormat.JSON_FULL_METADATA);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v4/EntityCreateTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/EntityCreateTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/EntityCreateTestITCase.java
index 8203513..a6a8721 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/EntityCreateTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/EntityCreateTestITCase.java
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertNotNull;
import java.net.URI;
import java.util.Calendar;
+
import org.apache.commons.lang3.RandomUtils;
import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
import org.apache.olingo.client.api.communication.response.ODataDeleteResponse;
@@ -34,22 +35,22 @@ import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
public class EntityCreateTestITCase extends AbstractTestITCase {
@Test
public void atomCreateAndDelete() {
- createAndDeleteOrder(ODataPubFormat.ATOM, 1000);
+ createAndDeleteOrder(ODataFormat.ATOM, 1000);
}
@Test
public void jsonCreateAndDelete() {
- createAndDeleteOrder(ODataPubFormat.JSON, 1001);
+ createAndDeleteOrder(ODataFormat.JSON, 1001);
}
- private void onContained(final ODataPubFormat format) {
+ private void onContained(final ODataFormat format) {
final URI uri = getClient().newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Accounts").
appendKeySegment(101).appendNavigationSegment("MyPaymentInstruments").build();
@@ -99,15 +100,15 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
@Test
public void atomOnContained() {
- onContained(ODataPubFormat.ATOM);
+ onContained(ODataFormat.ATOM);
}
@Test
public void jsonOnContained() {
- onContained(ODataPubFormat.JSON);
+ onContained(ODataFormat.JSON);
}
- private void deepInsert(final ODataPubFormat format, final int productId, final int productDetailId)
+ private void deepInsert(final ODataFormat format, final int productId, final int productDetailId)
throws EdmPrimitiveTypeException {
final ODataEntity product = getClient().getObjectFactory().
@@ -178,11 +179,11 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
@Test
public void atomDeepInsert() throws EdmPrimitiveTypeException {
- deepInsert(ODataPubFormat.ATOM, 10, 10);
+ deepInsert(ODataFormat.ATOM, 10, 10);
}
@Test
public void jsonDeepInsert() throws EdmPrimitiveTypeException {
- deepInsert(ODataPubFormat.JSON_FULL_METADATA, 11, 11);
+ deepInsert(ODataFormat.JSON_FULL_METADATA, 11, 11);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v4/EntityRetrieveTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/EntityRetrieveTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/EntityRetrieveTestITCase.java
index 4e8afaa..79b73e9 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/EntityRetrieveTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/EntityRetrieveTestITCase.java
@@ -26,6 +26,7 @@ import static org.junit.Assert.assertTrue;
import java.net.URI;
import java.util.LinkedHashMap;
import java.util.List;
+
import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataRawRequest;
@@ -45,7 +46,7 @@ import org.apache.olingo.commons.api.domain.ODataLinkType;
import org.apache.olingo.commons.api.domain.v4.ODataEntity;
import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
/**
@@ -53,7 +54,7 @@ import org.junit.Test;
*/
public class EntityRetrieveTestITCase extends AbstractTestITCase {
- private void withInlineEntity(final ODataClient client, final ODataPubFormat format) {
+ private void withInlineEntity(final ODataClient client, final ODataFormat format) {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Customers").appendKeySegment(1).expand("Company");
@@ -70,11 +71,11 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
assertEquals("Edm.GeographyPoint", entity.getProperty("Home").getPrimitiveValue().getTypeName());
// In JSON with minimal metadata, links are not provided
- if (format == ODataPubFormat.ATOM || format == ODataPubFormat.JSON_FULL_METADATA) {
+ if (format == ODataFormat.ATOM || format == ODataFormat.JSON_FULL_METADATA) {
assertEquals(testStaticServiceRootURL + "/Customers(1)", entity.getEditLink().toASCIIString());
assertEquals(3, entity.getNavigationLinks().size());
- if (ODataPubFormat.ATOM == format) {
+ if (ODataFormat.ATOM == format) {
assertTrue(entity.getAssociationLinks().isEmpty());
// In JSON, association links for each $ref link will exist.
}
@@ -110,20 +111,20 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
@Test
public void withInlineEntityFromAtom() {
- withInlineEntity(client, ODataPubFormat.ATOM);
+ withInlineEntity(client, ODataFormat.ATOM);
}
@Test
public void withInlineEntityFromFullJSON() {
- withInlineEntity(client, ODataPubFormat.JSON_FULL_METADATA);
+ withInlineEntity(client, ODataFormat.JSON_FULL_METADATA);
}
@Test
public void withInlineEntityFromJSON() {
- withInlineEntity(edmClient, ODataPubFormat.JSON);
+ withInlineEntity(edmClient, ODataFormat.JSON);
}
- private void withInlineEntitySet(final ODataClient client, final ODataPubFormat format) {
+ private void withInlineEntitySet(final ODataClient client, final ODataFormat format) {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Customers").appendKeySegment(1).expand("Orders");
@@ -137,7 +138,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString());
// In JSON with minimal metadata, links are not provided
- if (format == ODataPubFormat.ATOM || format == ODataPubFormat.JSON_FULL_METADATA) {
+ if (format == ODataFormat.ATOM || format == ODataFormat.JSON_FULL_METADATA) {
boolean found = false;
for (ODataLink link : entity.getNavigationLinks()) {
if (link instanceof ODataInlineEntitySet) {
@@ -153,20 +154,20 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
@Test
public void withInlineEntitySetFromAtom() {
- withInlineEntitySet(client, ODataPubFormat.ATOM);
+ withInlineEntitySet(client, ODataFormat.ATOM);
}
@Test
public void withInlineEntitySetFromFullJSON() {
- withInlineEntitySet(client, ODataPubFormat.JSON_FULL_METADATA);
+ withInlineEntitySet(client, ODataFormat.JSON_FULL_METADATA);
}
@Test
public void withInlineEntitySetFromJSON() {
- withInlineEntitySet(edmClient, ODataPubFormat.JSON);
+ withInlineEntitySet(edmClient, ODataFormat.JSON);
}
- private void rawRequest(final ODataPubFormat format) {
+ private void rawRequest(final ODataFormat format) {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("People").appendKeySegment(5);
@@ -185,16 +186,16 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
@Test
public void rawRequestAsAtom() {
- rawRequest(ODataPubFormat.ATOM);
+ rawRequest(ODataFormat.ATOM);
}
@Test
public void rawRequestAsJSON() {
// this needs to be full, otherwise reference will not be provided
- rawRequest(ODataPubFormat.JSON_FULL_METADATA);
+ rawRequest(ODataFormat.JSON_FULL_METADATA);
}
- private void multiKey(final ODataPubFormat format) throws EdmPrimitiveTypeException {
+ private void multiKey(final ODataFormat format) throws EdmPrimitiveTypeException {
final LinkedHashMap<String, Object> multiKey = new LinkedHashMap<String, Object>();
multiKey.put("ProductID", "6");
multiKey.put("ProductDetailID", 1);
@@ -214,15 +215,15 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
@Test
public void multiKeyAsAtom() throws EdmPrimitiveTypeException {
- multiKey(ODataPubFormat.ATOM);
+ multiKey(ODataFormat.ATOM);
}
@Test
public void multiKeyAsJSON() throws EdmPrimitiveTypeException {
- multiKey(ODataPubFormat.JSON_FULL_METADATA);
+ multiKey(ODataFormat.JSON_FULL_METADATA);
}
- private void checkForETag(final ODataClient client, final ODataPubFormat format) {
+ private void checkForETag(final ODataClient client, final ODataFormat format) {
final URIBuilder uriBuilder =
client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders").appendKeySegment(8);
@@ -246,17 +247,17 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
@Test
public void checkForETagAsAtom() {
- checkForETag(client, ODataPubFormat.ATOM);
+ checkForETag(client, ODataFormat.ATOM);
}
@Test
public void checkForETagAsFullJSON() {
- checkForETag(client, ODataPubFormat.JSON_FULL_METADATA);
+ checkForETag(client, ODataFormat.JSON_FULL_METADATA);
}
@Test
public void checkForETagAsJSON() {
- checkForETag(edmClient, ODataPubFormat.JSON);
+ checkForETag(edmClient, ODataFormat.JSON);
}
@Test(expected = IllegalArgumentException.class)
@@ -264,14 +265,14 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders");
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- req.setFormat(ODataPubFormat.JSON);
+ req.setFormat(ODataFormat.JSON);
// this statement should cause an IllegalArgumentException bearing JsonParseException
// since we are attempting to parse an EntitySet as if it was an Entity
req.execute().getBody();
}
- private void reference(final ODataPubFormat format) {
+ private void reference(final ODataFormat format) {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Orders").appendKeySegment(8).appendNavigationSegment("CustomerForOrder").
appendRefSegment();
@@ -299,15 +300,15 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
@Test
public void atomReference() {
- reference(ODataPubFormat.ATOM);
+ reference(ODataFormat.ATOM);
}
@Test
public void jsonReference() {
- reference(ODataPubFormat.JSON_FULL_METADATA);
+ reference(ODataFormat.JSON_FULL_METADATA);
}
- private void contained(final ODataClient client, final ODataPubFormat format) throws EdmPrimitiveTypeException {
+ private void contained(final ODataClient client, final ODataFormat format) throws EdmPrimitiveTypeException {
final URI uri = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Accounts").appendKeySegment(101).
appendNavigationSegment("MyPaymentInstruments").appendKeySegment(101902).build();
@@ -324,20 +325,20 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
@Test
public void containedFromAtom() throws EdmPrimitiveTypeException {
- contained(client, ODataPubFormat.ATOM);
+ contained(client, ODataFormat.ATOM);
}
@Test
public void containedFromFullJSON() throws EdmPrimitiveTypeException {
- contained(client, ODataPubFormat.JSON_FULL_METADATA);
+ contained(client, ODataFormat.JSON_FULL_METADATA);
}
@Test
public void containedFromJSON() throws EdmPrimitiveTypeException {
- contained(edmClient, ODataPubFormat.JSON);
+ contained(edmClient, ODataFormat.JSON);
}
- private void entitySetNavigationLink(final ODataClient client, final ODataPubFormat format) {
+ private void entitySetNavigationLink(final ODataClient client, final ODataFormat format) {
final URI uri = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Accounts").appendKeySegment(101).build();
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uri);
@@ -347,7 +348,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
assertNotNull(entity);
// With JSON, entity set navigation links are only recognizable via Edm
- if (format == ODataPubFormat.ATOM || client instanceof EdmEnabledODataClient) {
+ if (format == ODataFormat.ATOM || client instanceof EdmEnabledODataClient) {
assertEquals(ODataLinkType.ENTITY_SET_NAVIGATION, entity.getNavigationLink("MyPaymentInstruments").getType());
assertEquals(ODataLinkType.ENTITY_SET_NAVIGATION, entity.getNavigationLink("ActiveSubscriptions").getType());
}
@@ -355,13 +356,13 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
@Test
public void entitySetNavigationLinkFromAtom() {
- entitySetNavigationLink(client, ODataPubFormat.ATOM);
+ entitySetNavigationLink(client, ODataFormat.ATOM);
}
@Test
public void entitySetNavigationLinkFromJSON() {
// only JSON_FULL_METADATA has links, only Edm can recognize entity set navigation
- entitySetNavigationLink(edmClient, ODataPubFormat.JSON_FULL_METADATA);
+ entitySetNavigationLink(edmClient, ODataFormat.JSON_FULL_METADATA);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v4/EntitySetTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/EntitySetTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/EntitySetTestITCase.java
index e2a8bde..a428d3d 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/EntitySetTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/EntitySetTestITCase.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.net.URI;
+
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetIteratorRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataRawRequest;
@@ -36,7 +37,7 @@ import org.apache.olingo.client.core.uri.URIUtils;
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.format.ODataFormat;
import org.junit.Test;
/**
@@ -44,7 +45,7 @@ import org.junit.Test;
*/
public class EntitySetTestITCase extends AbstractTestITCase {
- private void rawRequest(final ODataPubFormat format) {
+ private void rawRequest(final ODataFormat format) {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People");
final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
@@ -60,15 +61,15 @@ public class EntitySetTestITCase extends AbstractTestITCase {
@Test
public void rawRequestAsAtom() throws IOException {
- rawRequest(ODataPubFormat.ATOM);
+ rawRequest(ODataFormat.ATOM);
}
@Test
public void rawRequestAsJSON() throws IOException {
- rawRequest(ODataPubFormat.JSON);
+ rawRequest(ODataFormat.JSON);
}
- private void readWithInlineCount(final ODataClient client, final ODataPubFormat format) {
+ private void readWithInlineCount(final ODataClient client, final ODataFormat format) {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("People").count(true);
@@ -87,20 +88,20 @@ public class EntitySetTestITCase extends AbstractTestITCase {
@Test
public void readWithInlineCountAsJSON() throws IOException {
- readWithInlineCount(edmClient, ODataPubFormat.JSON);
+ readWithInlineCount(edmClient, ODataFormat.JSON);
}
@Test
public void readWithInlineCountAsFullJSON() throws IOException {
- readWithInlineCount(client, ODataPubFormat.JSON_FULL_METADATA);
+ readWithInlineCount(client, ODataFormat.JSON_FULL_METADATA);
}
@Test
public void readWithInlineCountAsAtom() throws IOException {
- readWithInlineCount(client, ODataPubFormat.ATOM);
+ readWithInlineCount(client, ODataFormat.ATOM);
}
- private void readODataEntitySetIterator(final ODataPubFormat format) {
+ private void readODataEntitySetIterator(final ODataFormat format) {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People");
final ODataEntitySetIteratorRequest<ODataEntitySet, ODataEntity> req =
@@ -124,25 +125,25 @@ public class EntitySetTestITCase extends AbstractTestITCase {
@Test
public void readODataEntitySetIteratorFromAtom() {
- readODataEntitySetIterator(ODataPubFormat.ATOM);
+ readODataEntitySetIterator(ODataFormat.ATOM);
}
@Test
public void readODataEntitySetIteratorFromJSON() {
- readODataEntitySetIterator(ODataPubFormat.JSON);
+ readODataEntitySetIterator(ODataFormat.JSON);
}
@Test
public void readODataEntitySetIteratorFromJSONFull() {
- readODataEntitySetIterator(ODataPubFormat.JSON_FULL_METADATA);
+ readODataEntitySetIterator(ODataFormat.JSON_FULL_METADATA);
}
@Test
public void readODataEntitySetIteratorFromJSONNo() {
- readODataEntitySetIterator(ODataPubFormat.JSON_NO_METADATA);
+ readODataEntitySetIterator(ODataFormat.JSON_NO_METADATA);
}
- private void readWithNext(final ODataPubFormat format) {
+ private void readWithNext(final ODataFormat format) {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People");
final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().
@@ -166,12 +167,12 @@ public class EntitySetTestITCase extends AbstractTestITCase {
@Test
public void readWithNextFromAtom() {
- readWithNext(ODataPubFormat.ATOM);
+ readWithNext(ODataFormat.ATOM);
}
@Test
public void readWithNextFromJSON() {
- readWithNext(ODataPubFormat.JSON_FULL_METADATA);
+ readWithNext(ODataFormat.JSON_FULL_METADATA);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v4/EntityUpdateTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/EntityUpdateTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/EntityUpdateTestITCase.java
index a51dd62..a81376c 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/EntityUpdateTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/EntityUpdateTestITCase.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertNotNull;
import java.net.URI;
import java.util.Calendar;
import java.util.UUID;
+
import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
import org.apache.olingo.client.api.communication.request.cud.v4.UpdateType;
import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
@@ -32,12 +33,12 @@ import org.apache.olingo.commons.api.domain.v4.ODataEntity;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
public class EntityUpdateTestITCase extends AbstractTestITCase {
- private void upsert(final UpdateType updateType, final ODataPubFormat format) {
+ private void upsert(final UpdateType updateType, final ODataFormat format) {
final ODataEntity order = getClient().getObjectFactory().
newEntity(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Order"));
@@ -72,17 +73,17 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
@Test
public void atomUpsert() {
- upsert(UpdateType.PATCH, ODataPubFormat.ATOM);
- upsert(UpdateType.REPLACE, ODataPubFormat.ATOM);
+ upsert(UpdateType.PATCH, ODataFormat.ATOM);
+ upsert(UpdateType.REPLACE, ODataFormat.ATOM);
}
@Test
public void jsonUpsert() {
- upsert(UpdateType.PATCH, ODataPubFormat.JSON);
- upsert(UpdateType.REPLACE, ODataPubFormat.JSON);
+ upsert(UpdateType.PATCH, ODataFormat.JSON);
+ upsert(UpdateType.REPLACE, ODataFormat.JSON);
}
- private void onContained(final ODataPubFormat format) {
+ private void onContained(final ODataFormat format) {
final String newName = UUID.randomUUID().toString();
final ODataEntity changes = getClient().getObjectFactory().newEntity(
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument"));
@@ -106,15 +107,15 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
@Test
public void atomOnContained() {
- onContained(ODataPubFormat.ATOM);
+ onContained(ODataFormat.ATOM);
}
@Test
public void jsonOnContained() {
- onContained(ODataPubFormat.JSON);
+ onContained(ODataFormat.JSON);
}
- private void bindOperation(final ODataPubFormat format) throws EdmPrimitiveTypeException {
+ private void bindOperation(final ODataFormat format) throws EdmPrimitiveTypeException {
final ODataEntity changes = getClient().getObjectFactory().newEntity(
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer"));
final ODataLink parent = getClient().getObjectFactory().newEntityNavigationLink("Parent",
@@ -144,11 +145,11 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
@Test
public void atomBindOperation() throws EdmPrimitiveTypeException {
- bindOperation(ODataPubFormat.ATOM);
+ bindOperation(ODataFormat.ATOM);
}
@Test
public void jsonBindOperation() throws EdmPrimitiveTypeException {
- bindOperation(ODataPubFormat.JSON);
+ bindOperation(ODataFormat.JSON);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v4/ErrorResponseTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/ErrorResponseTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/ErrorResponseTestITCase.java
index 7805691..54f6f74 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/ErrorResponseTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/ErrorResponseTestITCase.java
@@ -23,10 +23,11 @@ import static org.junit.Assert.fail;
import java.net.URI;
import java.util.Map;
+
import org.apache.olingo.client.api.communication.ODataClientErrorException;
import org.apache.olingo.commons.api.domain.ODataError;
import org.apache.olingo.commons.api.domain.ODataErrorDetail;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
public class ErrorResponseTestITCase extends AbstractTestITCase {
@@ -38,7 +39,7 @@ public class ErrorResponseTestITCase extends AbstractTestITCase {
build();
try {
- read(ODataPubFormat.JSON, readURI);
+ read(ODataFormat.JSON, readURI);
fail("should have got exception");
} catch (Exception ex) {
final ODataError err = ((ODataClientErrorException) ex).getODataError();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v4/FilterFactoryTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/FilterFactoryTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/FilterFactoryTestITCase.java
index 2bb3851..737f355 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/FilterFactoryTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/FilterFactoryTestITCase.java
@@ -19,7 +19,6 @@
package org.apache.olingo.fit.v4;
import static org.junit.Assert.assertEquals;
-import static org.apache.olingo.fit.v4.AbstractTestITCase.client;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
import org.apache.olingo.client.api.uri.URIFilter;
@@ -28,7 +27,7 @@ import org.apache.olingo.client.api.uri.v4.FilterFactory;
import org.apache.olingo.client.api.uri.v4.URIBuilder;
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.format.ODataFormat;
import org.junit.Test;
public class FilterFactoryTestITCase extends AbstractTestITCase {
@@ -51,7 +50,7 @@ public class FilterFactoryTestITCase extends AbstractTestITCase {
final ODataEntitySetRequest<ODataEntitySet> req =
client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
- req.setFormat(ODataPubFormat.JSON_FULL_METADATA);
+ req.setFormat(ODataFormat.JSON_FULL_METADATA);
final ODataEntitySet feed = req.execute().getBody();
assertEquals(3, feed.getEntities().size());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v4/JSONFormatConformanceTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/JSONFormatConformanceTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/JSONFormatConformanceTestITCase.java
index 7d48860..04651b3 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/JSONFormatConformanceTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/JSONFormatConformanceTestITCase.java
@@ -40,7 +40,7 @@ import org.apache.olingo.commons.api.domain.v4.ODataLink;
import org.apache.olingo.commons.api.domain.v4.ODataProperty;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
/**
@@ -91,7 +91,7 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
final URI uri = edmClient.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Accounts").appendKeySegment(102).build();
final ODataEntityRequest<ODataEntity> req = edmClient.getRetrieveRequestFactory().getEntityRequest(uri);
- req.setFormat(ODataPubFormat.JSON_FULL_METADATA);
+ req.setFormat(ODataFormat.JSON_FULL_METADATA);
// request format (via Accept header) is set to full metadata
assertEquals("application/json;odata.metadata=full", req.getAccept());
@@ -148,7 +148,7 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
+ "\"GeographyPoint\": {\"type\": \"Point\",\"coordinates\":[142.1,64.1]}"
+ "}";
- final ODataEntity entity = client.getReader().readEntity(IOUtils.toInputStream(fromSection71), ODataPubFormat.JSON);
+ final ODataEntity entity = client.getReader().readEntity(IOUtils.toInputStream(fromSection71), ODataFormat.JSON);
assertTrue(entity.getProperty("NullValue").hasNullValue());
@@ -219,7 +219,7 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
+ "}";
final ResWrap<Entity> entity =
- client.getDeserializer(ODataPubFormat.JSON).toEntity(IOUtils.toInputStream(fromSection45_1));
+ client.getDeserializer(ODataFormat.JSON).toEntity(IOUtils.toInputStream(fromSection45_1));
assertEquals("http://host/service/$metadata#Customers/$entity", entity.getContextURL().getURI().toASCIIString());
assertEquals("W/\"A1FF3E230954908F\"", entity.getMetadataETag());
@@ -241,7 +241,7 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
+ "}";
final ResWrap<EntitySet> entitySet =
- client.getDeserializer(ODataPubFormat.JSON).toEntitySet(IOUtils.toInputStream(fromSection45_2));
+ client.getDeserializer(ODataFormat.JSON).toEntitySet(IOUtils.toInputStream(fromSection45_2));
assertEquals(5, entitySet.getPayload().getCount(), 0);
assertEquals("Customers?$expand=Orders&$skipToken=5", entitySet.getPayload().getNext().toASCIIString());
@@ -271,7 +271,7 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
+ "}";
final ODataEntitySet entitySet = client.getReader().
- readEntitySet(IOUtils.toInputStream(sample), ODataPubFormat.JSON);
+ readEntitySet(IOUtils.toInputStream(sample), ODataFormat.JSON);
assertEquals(2, entitySet.getAnnotations().size());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v4/KeyAsSegmentTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/KeyAsSegmentTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/KeyAsSegmentTestITCase.java
index c6eca38..612619f 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/KeyAsSegmentTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/KeyAsSegmentTestITCase.java
@@ -18,11 +18,12 @@
*/
package org.apache.olingo.fit.v4;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import java.net.URI;
+
import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
import org.apache.olingo.client.api.communication.request.cud.v4.UpdateType;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
@@ -32,7 +33,7 @@ import org.apache.olingo.client.api.uri.v4.URIBuilder;
import org.apache.olingo.commons.api.domain.v4.ODataEntity;
import org.apache.olingo.commons.api.domain.v4.ODataProperty;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -49,7 +50,7 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
client.getConfiguration().setKeyAsSegment(false);
}
- private void read(final ODataPubFormat format) {
+ private void read(final ODataFormat format) {
final URIBuilder uriBuilder = client.newURIBuilder(testKeyAsSegmentServiceRootURL).
appendEntitySetSegment("Accounts").appendKeySegment(101);
@@ -61,7 +62,7 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
assertNotNull(entity);
// In JSON with minimal metadata, links are not provided
- if (format == ODataPubFormat.ATOM || format == ODataPubFormat.JSON_FULL_METADATA) {
+ if (format == ODataFormat.ATOM || format == ODataFormat.JSON_FULL_METADATA) {
assertFalse(entity.getEditLink().toASCIIString().contains("("));
assertFalse(entity.getEditLink().toASCIIString().contains(")"));
}
@@ -69,25 +70,25 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
@Test
public void atomRead() {
- read(ODataPubFormat.ATOM);
+ read(ODataFormat.ATOM);
}
@Test
public void jsonRead() {
- read(ODataPubFormat.JSON);
+ read(ODataFormat.JSON);
}
@Test
public void atomCreateAndDelete() {
- createAndDeleteOrder(ODataPubFormat.ATOM, 1000);
+ createAndDeleteOrder(ODataFormat.ATOM, 1000);
}
@Test
public void jsonCreateAndDelete() {
- createAndDeleteOrder(ODataPubFormat.JSON_FULL_METADATA, 1001);
+ createAndDeleteOrder(ODataFormat.JSON_FULL_METADATA, 1001);
}
- private void update(final ODataPubFormat format) {
+ private void update(final ODataFormat format) {
final ODataEntity changes = getClient().getObjectFactory().newEntity(
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer"));
final ODataProperty middleName = getClient().getObjectFactory().newPrimitiveProperty("MiddleName",
@@ -115,11 +116,11 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
@Test
public void atomUpdate() {
- update(ODataPubFormat.ATOM);
+ update(ODataFormat.ATOM);
}
@Test
public void jsonUpdate() {
- update(ODataPubFormat.JSON);
+ update(ODataFormat.JSON);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v4/MediaEntityTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/MediaEntityTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/MediaEntityTestITCase.java
index 5d0806b..b82f22c 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/MediaEntityTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/MediaEntityTestITCase.java
@@ -28,6 +28,7 @@ import java.net.URI;
import java.util.Calendar;
import java.util.Collection;
import java.util.UUID;
+
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.olingo.client.api.communication.header.HeaderName;
@@ -51,12 +52,12 @@ import org.apache.olingo.commons.api.domain.v4.ODataValuable;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
public class MediaEntityTestITCase extends AbstractTestITCase {
- private void read(final ODataClient client, final ODataPubFormat format) throws IOException {
+ private void read(final ODataClient client, final ODataFormat format) throws IOException {
final URIBuilder builder = client.newURIBuilder(testDemoServiceRootURL).
appendEntitySetSegment("Advertisements").
appendKeySegment(UUID.fromString("f89dee73-af9f-4cd4-b330-db93c25ff3c7"));
@@ -82,20 +83,20 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
@Test
public void readAsAtom() throws IOException {
- read(client, ODataPubFormat.ATOM);
+ read(client, ODataFormat.ATOM);
}
@Test
public void readAsJSON() throws IOException {
- read(ODataClientFactory.getEdmEnabledV4(testDemoServiceRootURL), ODataPubFormat.JSON);
+ read(ODataClientFactory.getEdmEnabledV4(testDemoServiceRootURL), ODataFormat.JSON);
}
@Test
public void readAsJSONFull() throws IOException {
- read(client, ODataPubFormat.JSON_FULL_METADATA);
+ read(client, ODataFormat.JSON_FULL_METADATA);
}
- private void create(final ODataPubFormat format) throws IOException {
+ private void create(final ODataFormat format) throws IOException {
final String random = RandomStringUtils.random(110);
final InputStream input = IOUtils.toInputStream(random);
@@ -136,15 +137,15 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
@Test
public void createAsAtom() throws IOException {
- create(ODataPubFormat.ATOM);
+ create(ODataFormat.ATOM);
}
@Test
public void createAsJSON() throws IOException {
- create(ODataPubFormat.JSON);
+ create(ODataFormat.JSON);
}
- private void update(final ODataPubFormat format) throws IOException, EdmPrimitiveTypeException {
+ private void update(final ODataFormat format) throws IOException, EdmPrimitiveTypeException {
final URI uri = client.newURIBuilder(testDemoServiceRootURL).
appendEntitySetSegment("Advertisements").
appendKeySegment(UUID.fromString("f89dee73-af9f-4cd4-b330-db93c25ff3c7")).build();
@@ -172,11 +173,11 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
@Test
public void updateAsAtom() throws IOException, EdmPrimitiveTypeException {
- update(ODataPubFormat.ATOM);
+ update(ODataFormat.ATOM);
}
@Test
public void updateAsJSON() throws IOException, EdmPrimitiveTypeException {
- update(ODataPubFormat.JSON);
+ update(ODataFormat.JSON);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v4/OpenTypeTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/OpenTypeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/OpenTypeTestITCase.java
index 495b9d0..6ce43c6 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/OpenTypeTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/OpenTypeTestITCase.java
@@ -24,18 +24,19 @@ import static org.junit.Assert.assertTrue;
import java.util.Calendar;
import java.util.UUID;
+
import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
import org.apache.olingo.client.api.communication.response.ODataDeleteResponse;
import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
import org.apache.olingo.client.api.uri.v4.URIBuilder;
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.ODataEntity;
+import org.apache.olingo.commons.api.domain.v4.ODataProperty;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.EdmSchema;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
public class OpenTypeTestITCase extends AbstractTestITCase {
@@ -52,13 +53,13 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
assertTrue(metadata.getEntityType(new FullQualifiedName(schema.getNamespace(), "RowIndex")).isOpenType());
}
- private ODataEntity readRow(final ODataPubFormat format, final String uuid) {
+ private ODataEntity readRow(final ODataFormat format, final String uuid) {
final URIBuilder builder = getClient().newURIBuilder(testOpenTypeServiceRootURL).
appendEntitySetSegment("Row").appendKeySegment(UUID.fromString(uuid));
return read(format, builder.build());
}
- private void read(final ODataPubFormat format) {
+ private void read(final ODataFormat format) {
ODataEntity row = readRow(format, "71f7d0dc-ede4-45eb-b421-555a2aa1e58f");
assertEquals(EdmPrimitiveTypeKind.Double, row.getProperty("Double").getPrimitiveValue().getTypeKind());
assertEquals(EdmPrimitiveTypeKind.Guid, row.getProperty("Id").getPrimitiveValue().getTypeKind());
@@ -69,15 +70,15 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
@Test
public void readAsAtom() {
- read(ODataPubFormat.ATOM);
+ read(ODataFormat.ATOM);
}
@Test
public void readAsJSON() {
- read(ODataPubFormat.JSON_FULL_METADATA);
+ read(ODataFormat.JSON_FULL_METADATA);
}
- private void cud(final ODataPubFormat format) {
+ private void cud(final ODataFormat format) {
final Integer id = 1426;
ODataEntity rowIndex = getClient().getObjectFactory().newEntity(
@@ -173,12 +174,12 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
@Test
public void cudAsAtom() {
- cud(ODataPubFormat.ATOM);
+ cud(ODataFormat.ATOM);
}
@Test
public void cudAsJSON() {
- cud(ODataPubFormat.JSON_FULL_METADATA);
+ cud(ODataFormat.JSON_FULL_METADATA);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v4/OperationImportInvokeTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/OperationImportInvokeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/OperationImportInvokeTestITCase.java
index 17b9921..972db5d 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/OperationImportInvokeTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/OperationImportInvokeTestITCase.java
@@ -25,6 +25,7 @@ import static org.junit.Assert.assertTrue;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
+
import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest;
import org.apache.olingo.client.api.communication.request.invoke.ODataNoContent;
import org.apache.olingo.commons.api.domain.ODataCollectionValue;
@@ -36,13 +37,12 @@ import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
import org.apache.olingo.commons.api.domain.v4.ODataEnumValue;
import org.apache.olingo.commons.api.domain.v4.ODataProperty;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
-
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
public class OperationImportInvokeTestITCase extends AbstractTestITCase {
- private void functionImports(final ODataPubFormat format) throws EdmPrimitiveTypeException {
+ private void functionImports(final ODataFormat format) throws EdmPrimitiveTypeException {
// GetDefaultColor
final ODataInvokeRequest<ODataProperty> defaultColorReq = getClient().getInvokeRequestFactory().
getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
@@ -113,12 +113,12 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
@Test
public void atomFunctionImports() throws EdmPrimitiveTypeException {
- functionImports(ODataPubFormat.ATOM);
+ functionImports(ODataFormat.ATOM);
}
@Test
public void jsonFunctionImports() throws EdmPrimitiveTypeException {
- functionImports(ODataPubFormat.JSON_FULL_METADATA);
+ functionImports(ODataFormat.JSON_FULL_METADATA);
}
@Test
@@ -182,7 +182,7 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
assertTrue(prodByAL.getCollectionValue().asJavaCollection().contains("Car"));
}
- private void actionImports(final ODataPubFormat format) {
+ private void actionImports(final ODataFormat format) {
// Discount
final ODataPrimitiveValue percentage = getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(22);
final ODataInvokeRequest<ODataNoContent> discountReq = getClient().getInvokeRequestFactory().
@@ -215,12 +215,12 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
@Test
public void atomActionImports() {
- actionImports(ODataPubFormat.ATOM);
+ actionImports(ODataFormat.ATOM);
}
@Test
public void jsonActionImports() {
- actionImports(ODataPubFormat.JSON_FULL_METADATA);
+ actionImports(ODataFormat.JSON_FULL_METADATA);
}
@Test
@@ -251,7 +251,7 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
assertEquals(address.getTypeName(), resetBossAddress.getComplexValue().getTypeName());
}
- private void bossEmails(final ODataPubFormat format) {
+ private void bossEmails(final ODataFormat format) {
// ResetBossEmail
final ODataCollectionValue<org.apache.olingo.commons.api.domain.v4.ODataValue> emails =
getClient().getObjectFactory().newCollectionValue("Collection(Edm.String)");
@@ -284,11 +284,11 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
@Test
public void atomBossEmails() throws EdmPrimitiveTypeException {
- bossEmails(ODataPubFormat.ATOM);
+ bossEmails(ODataFormat.ATOM);
}
@Test
public void jsonBossEmails() throws EdmPrimitiveTypeException {
- bossEmails(ODataPubFormat.JSON_FULL_METADATA);
+ bossEmails(ODataFormat.JSON_FULL_METADATA);
}
}
[3/8] [OLINGO-317] Merged the format ENUMs
Posted by mi...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v4/PropertyValueTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/PropertyValueTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/PropertyValueTestITCase.java
index 1d99bb3..14866d0 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/PropertyValueTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/PropertyValueTestITCase.java
@@ -22,6 +22,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
+
import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.client.api.communication.ODataClientErrorException;
import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
@@ -33,8 +34,6 @@ import org.apache.olingo.commons.api.domain.v4.ODataValuable;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.format.ODataValueFormat;
import org.junit.Test;
public class PropertyValueTestITCase extends AbstractTestITCase {
@@ -44,7 +43,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PersonID");
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
- req.setFormat(ODataValueFormat.TEXT);
+ req.setFormat(ODataFormat.TEXT_PLAIN);
assertEquals("5", req.execute().getBody().toString());
}
@@ -53,7 +52,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("IsRegistered");
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
- req.setFormat(ODataValueFormat.TEXT);
+ req.setFormat(ODataFormat.TEXT_PLAIN);
assertEquals("true", req.execute().getBody().toString());
}
@@ -62,7 +61,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("FirstName");
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
- req.setFormat(ODataValueFormat.TEXT);
+ req.setFormat(ODataFormat.TEXT_PLAIN);
assertEquals("Peter", req.execute().getBody().toString());
}
@@ -71,7 +70,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Orders").appendKeySegment(8).appendPropertySegment("OrderDate");
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
- req.setFormat(ODataValueFormat.TEXT);
+ req.setFormat(ODataFormat.TEXT_PLAIN);
final ODataPrimitiveValue property = req.execute().getBody();
assertEquals("2011-03-04T16:03:57Z", property.toString());
}
@@ -81,7 +80,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("Height");
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
- req.setFormat(ODataValueFormat.TEXT);
+ req.setFormat(ODataFormat.TEXT_PLAIN);
final ODataPrimitiveValue property = req.execute().getBody();
assertEquals("179", property.toString());
}
@@ -91,7 +90,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC");
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
- req.setFormat(ODataValueFormat.TEXT);
+ req.setFormat(ODataFormat.TEXT_PLAIN);
final ODataPrimitiveValue property = req.execute().getBody();
assertEquals("fi653p3+MklA/LdoBlhWgnMTUUEo8tEgtbMXnF0a3CUNL9BZxXpSRiD9ebTnmNR0zWPjJ"
+ "VIDx4tdmCnq55XrJh+RW9aI/b34wAogK3kcORw=", property.toString());
@@ -102,7 +101,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC");
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
- req.setAccept(ODataPubFormat.ATOM.toString(ODataServiceVersion.V40));
+ req.setAccept(ODataFormat.ATOM.toString(ODataServiceVersion.V40));
req.execute().getBody();
}
@@ -133,7 +132,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("HomeAddress");
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
- req.setFormat(ODataValueFormat.TEXT);
+ req.setFormat(ODataFormat.TEXT_PLAIN);
final ODataPrimitiveValue property = req.execute().getBody();
assertTrue(StringUtils.isBlank(property.toString()));
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v4/QueryOptionsTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/QueryOptionsTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/QueryOptionsTestITCase.java
index 207cbd0..19221e9 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/QueryOptionsTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/QueryOptionsTestITCase.java
@@ -19,23 +19,24 @@
package org.apache.olingo.fit.v4;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
-import org.apache.olingo.client.api.uri.v4.URIBuilder;
import org.apache.olingo.client.api.uri.QueryOption;
+import org.apache.olingo.client.api.uri.v4.URIBuilder;
import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
import org.apache.olingo.commons.api.domain.v4.ODataEntity;
import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
/**
@@ -124,12 +125,12 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
appendEntitySetSegment("Customers").appendKeySegment(1).format("json");
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- req.setFormat(ODataPubFormat.ATOM);
+ req.setFormat(ODataFormat.ATOM);
final ODataRetrieveResponse<ODataEntity> res = req.execute();
assertNotNull(res);
assertTrue(res.getContentType().replaceAll(" ", "").
- startsWith(ODataPubFormat.JSON.toString(client.getServiceVersion())));
+ startsWith(ODataFormat.JSON.toString(client.getServiceVersion())));
}
/**
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/fit/src/test/java/org/apache/olingo/fit/v4/SingletonTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/SingletonTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/SingletonTestITCase.java
index bebd927..03621cc 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/SingletonTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/SingletonTestITCase.java
@@ -19,11 +19,12 @@
package org.apache.olingo.fit.v4;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.net.URI;
+
import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
import org.apache.olingo.client.api.communication.request.cud.v4.UpdateType;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
@@ -31,16 +32,16 @@ import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResp
import org.apache.olingo.client.api.uri.v4.URIBuilder;
import org.apache.olingo.client.api.v4.ODataClient;
import org.apache.olingo.commons.api.domain.v4.ODataAnnotation;
-import org.apache.olingo.commons.api.domain.v4.ODataValuable;
import org.apache.olingo.commons.api.domain.v4.ODataSingleton;
+import org.apache.olingo.commons.api.domain.v4.ODataValuable;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
public class SingletonTestITCase extends AbstractTestITCase {
- private void read(final ODataClient client, final ODataPubFormat format) throws EdmPrimitiveTypeException {
+ private void read(final ODataClient client, final ODataFormat format) throws EdmPrimitiveTypeException {
final URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company");
final ODataEntityRequest<ODataSingleton> singleton =
client.getRetrieveRequestFactory().getSingletonRequest(builder.build());
@@ -57,20 +58,20 @@ public class SingletonTestITCase extends AbstractTestITCase {
@Test
public void readFromAtom() throws EdmPrimitiveTypeException {
- read(client, ODataPubFormat.ATOM);
+ read(client, ODataFormat.ATOM);
}
@Test
public void readFromJSON() throws EdmPrimitiveTypeException {
- read(edmClient, ODataPubFormat.JSON);
+ read(edmClient, ODataFormat.JSON);
}
@Test
public void readfromJSONFull() throws EdmPrimitiveTypeException {
- read(client, ODataPubFormat.JSON_FULL_METADATA);
+ read(client, ODataFormat.JSON_FULL_METADATA);
}
- private void readWithAnnotations(final ODataClient client, final ODataPubFormat format)
+ private void readWithAnnotations(final ODataClient client, final ODataFormat format)
throws EdmPrimitiveTypeException {
final URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Boss");
@@ -88,20 +89,20 @@ public class SingletonTestITCase extends AbstractTestITCase {
@Test
public void readWithAnnotationsFromAtom() throws EdmPrimitiveTypeException {
- readWithAnnotations(client, ODataPubFormat.ATOM);
+ readWithAnnotations(client, ODataFormat.ATOM);
}
@Test
public void readWithAnnotationsFromJSON() throws EdmPrimitiveTypeException {
- readWithAnnotations(edmClient, ODataPubFormat.JSON);
+ readWithAnnotations(edmClient, ODataFormat.JSON);
}
@Test
public void readWithAnnotationsFromJSONFull() throws EdmPrimitiveTypeException {
- readWithAnnotations(client, ODataPubFormat.JSON_FULL_METADATA);
+ readWithAnnotations(client, ODataFormat.JSON_FULL_METADATA);
}
- private void update(final ODataPubFormat format) throws EdmPrimitiveTypeException {
+ private void update(final ODataFormat format) throws EdmPrimitiveTypeException {
final ODataSingleton changes = getClient().getObjectFactory().newSingleton(
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Company"));
changes.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("Revenue",
@@ -122,12 +123,12 @@ public class SingletonTestITCase extends AbstractTestITCase {
@Test
public void atomUpdate() throws EdmPrimitiveTypeException {
- update(ODataPubFormat.ATOM);
+ update(ODataFormat.ATOM);
}
@Test
public void jsonUpdate() throws EdmPrimitiveTypeException {
- update(ODataPubFormat.JSON);
+ update(ODataFormat.JSON);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonConfiguration.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonConfiguration.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonConfiguration.java
index 2e3a0d8..756d28f 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonConfiguration.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonConfiguration.java
@@ -18,20 +18,16 @@
*/
package org.apache.olingo.client.api;
+import java.util.concurrent.ExecutorService;
+
import org.apache.olingo.client.api.http.HttpClientFactory;
import org.apache.olingo.client.api.http.HttpUriRequestFactory;
-
-import java.io.Serializable;
-import java.util.concurrent.ExecutorService;
import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.format.ODataMediaFormat;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.format.ODataValueFormat;
/**
* Configuration wrapper.
*/
-public interface CommonConfiguration extends Serializable {
+public interface CommonConfiguration {
/**
* Gets the configured default <tt>Accept</tt> header value format for a batch request.
@@ -50,16 +46,16 @@ public interface CommonConfiguration extends Serializable {
* JSON_FULL_METADATA format will be used as default.
*
* @return configured OData format for AtomPub if specified; JSON_FULL_METADATA format otherwise.
- * @see ODataPubFormat#JSON_FULL_METADATA
+ * @see ODataFormat#JSON_FULL_METADATA
*/
- ODataPubFormat getDefaultPubFormat();
+ ODataFormat getDefaultPubFormat();
/**
* Sets the default OData format for AtomPub exchanges.
*
* @param format default format.
*/
- void setDefaultPubFormat(ODataPubFormat format);
+ void setDefaultPubFormat(ODataFormat format);
/**
* Gets the configured OData format. This value depends on what is returned from <tt>getDefaultPubFormat()</tt>.
@@ -74,38 +70,36 @@ public interface CommonConfiguration extends Serializable {
* as default.
*
* @return configured OData value format if specified; TEXT format otherwise.
- * @see ODataValueFormat#TEXT
+ * @see ODataFormat#TEXT
*/
- ODataValueFormat getDefaultValueFormat();
+ ODataFormat getDefaultValueFormat();
/**
* Sets the default OData value format.
*
* @param format default format.
*/
- void setDefaultValueFormat(ODataValueFormat format);
+ void setDefaultValueFormat(ODataFormat format);
/**
* Gets the configured OData media format. If this configuration parameter doesn't exist the APPLICATION_OCTET_STREAM
* format will be used as default.
*
* @return configured OData media format if specified; APPLICATION_OCTET_STREAM format otherwise.
- * @see ODataMediaFormat#WILDCARD
*/
- ODataMediaFormat getDefaultMediaFormat();
+ ODataFormat getDefaultMediaFormat();
/**
* Sets the default OData media format.
*
* @param format default format.
*/
- void setDefaultMediaFormat(ODataMediaFormat format);
+ void setDefaultMediaFormat(ODataFormat format);
/**
* Gets the HttpClient factory to be used for executing requests.
*
* @return provided implementation (if configured via <tt>setHttpClientFactory</tt> or default.
- * @see DefaultHttpClientFactory
*/
HttpClientFactory getHttpClientFactory();
@@ -121,7 +115,6 @@ public interface CommonConfiguration extends Serializable {
* Gets the HttpUriRequest factory for generating requests to be executed.
*
* @return provided implementation (if configured via <tt>setHttpUriRequestFactory</tt> or default.
- * @see DefaultHttpUriRequestFactory
*/
HttpUriRequestFactory getHttpUriRequestFactory();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java
index d3c929a..136f07a 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java
@@ -33,7 +33,7 @@ import org.apache.olingo.client.api.uri.CommonFilterFactory;
import org.apache.olingo.client.api.uri.CommonURIBuilder;
import org.apache.olingo.commons.api.domain.CommonODataObjectFactory;
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.serialization.ODataSerializer;
/**
@@ -55,9 +55,9 @@ public interface CommonODataClient<UT extends CommonUpdateType> {
CommonFilterFactory getFilterFactory();
- ODataSerializer getSerializer(Format format);
+ ODataSerializer getSerializer(ODataFormat format);
- ClientODataDeserializer getDeserializer(Format format);
+ ClientODataDeserializer getDeserializer(ODataFormat format);
CommonODataReader getReader();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/ODataBasicRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/ODataBasicRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/ODataBasicRequest.java
index 1d97bcc..6bcb3b8 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/ODataBasicRequest.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/ODataBasicRequest.java
@@ -19,37 +19,35 @@
package org.apache.olingo.client.api.communication.request;
import java.util.concurrent.Future;
+
import org.apache.olingo.client.api.communication.response.ODataResponse;
-import org.apache.olingo.commons.api.format.Format;
+import org.apache.olingo.commons.api.format.ODataFormat;
/**
* Basic OData request.
*
- * @param <V> OData response type corresponding to the request implementation.
- * @param <T> Accepted content-type formats by the request in object.
+ * @param <T> OData response type corresponding to the request implementation.
*/
-public interface ODataBasicRequest<V extends ODataResponse, T extends Format> extends ODataRequest {
+public interface ODataBasicRequest<T extends ODataResponse> extends ODataRequest {
/**
* Request execute.
*
* @return return an OData response.
*/
- V execute();
+ T execute();
/**
* Async request execute.
*
* @return <code>Future<ODataResponse></code> about the executed request.
*/
- Future<V> asyncExecute();
+ Future<T> asyncExecute();
/**
* Override configured request format.
*
* @param format request format.
- * @see com.msopentech.odatajclient.engine.format.ODataFormat
- * @see com.msopentech.odatajclient.engine.format.ODataPubFormat
*/
- void setFormat(T format);
+ void setFormat(ODataFormat format);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataDeleteRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataDeleteRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataDeleteRequest.java
index 9ac5e95..883e860 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataDeleteRequest.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataDeleteRequest.java
@@ -21,11 +21,10 @@ package org.apache.olingo.client.api.communication.request.cud;
import org.apache.olingo.client.api.communication.request.ODataBasicRequest;
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
import org.apache.olingo.client.api.communication.response.ODataDeleteResponse;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
/**
* This class implements an OData delete request.
*/
public interface ODataDeleteRequest
- extends ODataBasicRequest<ODataDeleteResponse, ODataPubFormat>, ODataBatchableRequest {
+ extends ODataBasicRequest<ODataDeleteResponse>, ODataBatchableRequest {
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataEntityCreateRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataEntityCreateRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataEntityCreateRequest.java
index ddd5975..d13254a 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataEntityCreateRequest.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataEntityCreateRequest.java
@@ -22,7 +22,6 @@ import org.apache.olingo.client.api.communication.request.ODataBasicRequest;
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
/**
* This interface describes an OData create request.
@@ -30,5 +29,5 @@ import org.apache.olingo.commons.api.format.ODataPubFormat;
* @param <E> concrete ODataEntity implementation
*/
public interface ODataEntityCreateRequest<E extends CommonODataEntity>
- extends ODataBasicRequest<ODataEntityCreateResponse<E>, ODataPubFormat>, ODataBatchableRequest {
+ extends ODataBasicRequest<ODataEntityCreateResponse<E>>, ODataBatchableRequest {
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataEntityUpdateRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataEntityUpdateRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataEntityUpdateRequest.java
index 341028e..d2c48a9 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataEntityUpdateRequest.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataEntityUpdateRequest.java
@@ -22,7 +22,6 @@ import org.apache.olingo.client.api.communication.request.ODataBasicRequest;
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
/**
* This class implements an OData update request.
@@ -30,5 +29,5 @@ import org.apache.olingo.commons.api.format.ODataPubFormat;
* @param <E> concrete ODataEntity implementation
*/
public interface ODataEntityUpdateRequest<E extends CommonODataEntity>
- extends ODataBasicRequest<ODataEntityUpdateResponse<E>, ODataPubFormat>, ODataBatchableRequest {
+ extends ODataBasicRequest<ODataEntityUpdateResponse<E>>, ODataBatchableRequest {
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataPropertyUpdateRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataPropertyUpdateRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataPropertyUpdateRequest.java
index 25ece1a..c77a915 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataPropertyUpdateRequest.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataPropertyUpdateRequest.java
@@ -21,11 +21,10 @@ package org.apache.olingo.client.api.communication.request.cud;
import org.apache.olingo.client.api.communication.request.ODataBasicRequest;
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
import org.apache.olingo.client.api.communication.response.ODataPropertyUpdateResponse;
-import org.apache.olingo.commons.api.format.ODataFormat;
/**
* This class implements an OData update entity property request.
*/
public interface ODataPropertyUpdateRequest
- extends ODataBasicRequest<ODataPropertyUpdateResponse, ODataFormat>, ODataBatchableRequest {
+ extends ODataBasicRequest<ODataPropertyUpdateResponse>, ODataBatchableRequest {
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataValueUpdateRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataValueUpdateRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataValueUpdateRequest.java
index ced8c03..63ee311 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataValueUpdateRequest.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataValueUpdateRequest.java
@@ -21,11 +21,10 @@ package org.apache.olingo.client.api.communication.request.cud;
import org.apache.olingo.client.api.communication.request.ODataBasicRequest;
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
import org.apache.olingo.client.api.communication.response.ODataValueUpdateResponse;
-import org.apache.olingo.commons.api.format.ODataValueFormat;
/**
* This class implements an OData update entity property value request.
*/
public interface ODataValueUpdateRequest
- extends ODataBasicRequest<ODataValueUpdateResponse, ODataValueFormat>, ODataBatchableRequest {
+ extends ODataBasicRequest<ODataValueUpdateResponse>, ODataBatchableRequest {
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v3/ODataLinkCreateRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v3/ODataLinkCreateRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v3/ODataLinkCreateRequest.java
index b35a76f..3d52790 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v3/ODataLinkCreateRequest.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v3/ODataLinkCreateRequest.java
@@ -21,11 +21,10 @@ package org.apache.olingo.client.api.communication.request.cud.v3;
import org.apache.olingo.client.api.communication.request.ODataBasicRequest;
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
import org.apache.olingo.client.api.communication.response.ODataLinkOperationResponse;
-import org.apache.olingo.commons.api.format.ODataFormat;
/**
* This class implements an insert link OData request.
*/
public interface ODataLinkCreateRequest
- extends ODataBasicRequest<ODataLinkOperationResponse, ODataFormat>, ODataBatchableRequest {
+ extends ODataBasicRequest<ODataLinkOperationResponse>, ODataBatchableRequest {
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v3/ODataLinkUpdateRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v3/ODataLinkUpdateRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v3/ODataLinkUpdateRequest.java
index 765594e..b140647 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v3/ODataLinkUpdateRequest.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v3/ODataLinkUpdateRequest.java
@@ -21,11 +21,10 @@ package org.apache.olingo.client.api.communication.request.cud.v3;
import org.apache.olingo.client.api.communication.request.ODataBasicRequest;
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
import org.apache.olingo.client.api.communication.response.ODataLinkOperationResponse;
-import org.apache.olingo.commons.api.format.ODataFormat;
/**
* This class implements an update link OData request.
*/
public interface ODataLinkUpdateRequest
- extends ODataBasicRequest<ODataLinkOperationResponse, ODataFormat>, ODataBatchableRequest {
+ extends ODataBasicRequest<ODataLinkOperationResponse>, ODataBatchableRequest {
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/invoke/ODataInvokeRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/invoke/ODataInvokeRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/invoke/ODataInvokeRequest.java
index 733008a..696ff23 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/invoke/ODataInvokeRequest.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/invoke/ODataInvokeRequest.java
@@ -19,11 +19,11 @@
package org.apache.olingo.client.api.communication.request.invoke;
import java.util.Map;
+
import org.apache.olingo.client.api.communication.request.ODataBasicRequest;
import org.apache.olingo.client.api.communication.response.ODataInvokeResponse;
import org.apache.olingo.commons.api.domain.ODataInvokeResult;
import org.apache.olingo.commons.api.domain.ODataValue;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
/**
* This class implements an OData invoke operation request.
@@ -31,7 +31,7 @@ import org.apache.olingo.commons.api.format.ODataPubFormat;
* @param <T> the actual invoke result
*/
public interface ODataInvokeRequest<T extends ODataInvokeResult>
- extends ODataBasicRequest<ODataInvokeResponse<T>, ODataPubFormat> {
+ extends ODataBasicRequest<ODataInvokeResponse<T>> {
/**
* Sets operation parameters.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/EdmMetadataRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/EdmMetadataRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/EdmMetadataRequest.java
index d4ea45b..e220eca 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/EdmMetadataRequest.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/EdmMetadataRequest.java
@@ -19,10 +19,9 @@
package org.apache.olingo.client.api.communication.request.retrieve;
import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.format.ODataFormat;
/**
* This class implements a metadata query request.
*/
-public interface EdmMetadataRequest extends ODataRetrieveRequest<Edm, ODataFormat> {
+public interface EdmMetadataRequest extends ODataRetrieveRequest<Edm> {
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataEntityRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataEntityRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataEntityRequest.java
index 1e65ae8..239fbed 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataEntityRequest.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataEntityRequest.java
@@ -19,10 +19,9 @@
package org.apache.olingo.client.api.communication.request.retrieve;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
/**
* Describes an OData retrieve query request returning a single entity.
*/
-public interface ODataEntityRequest<E extends CommonODataEntity> extends ODataRetrieveRequest<E, ODataPubFormat> {
+public interface ODataEntityRequest<E extends CommonODataEntity> extends ODataRetrieveRequest<E> {
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataEntitySetIteratorRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataEntitySetIteratorRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataEntitySetIteratorRequest.java
index 724b644..0b442a5 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataEntitySetIteratorRequest.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataEntitySetIteratorRequest.java
@@ -21,11 +21,10 @@ package org.apache.olingo.client.api.communication.request.retrieve;
import org.apache.olingo.client.api.domain.ODataEntitySetIterator;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
/**
* This class implements an OData EntitySet query request.
*/
public interface ODataEntitySetIteratorRequest<ES extends CommonODataEntitySet, E extends CommonODataEntity>
- extends ODataRetrieveRequest<ODataEntitySetIterator<ES, E>, ODataPubFormat> {
+ extends ODataRetrieveRequest<ODataEntitySetIterator<ES, E>> {
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataEntitySetRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataEntitySetRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataEntitySetRequest.java
index c7e1964..766b6d0 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataEntitySetRequest.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataEntitySetRequest.java
@@ -19,13 +19,11 @@
package org.apache.olingo.client.api.communication.request.retrieve;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
/**
* This interface describes an OData EntitySet query request.
*
* @param <ES> concrete ODataEntitySet implementation
*/
-public interface ODataEntitySetRequest<ES extends CommonODataEntitySet>
- extends ODataRetrieveRequest<ES, ODataPubFormat> {
+public interface ODataEntitySetRequest<ES extends CommonODataEntitySet> extends ODataRetrieveRequest<ES> {
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataMediaRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataMediaRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataMediaRequest.java
index a4bbf3c..3528681 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataMediaRequest.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataMediaRequest.java
@@ -19,10 +19,9 @@
package org.apache.olingo.client.api.communication.request.retrieve;
import java.io.InputStream;
-import org.apache.olingo.commons.api.format.ODataMediaFormat;
/**
* This class implements an OData media query request.
*/
-public interface ODataMediaRequest extends ODataRetrieveRequest<InputStream, ODataMediaFormat> {
+public interface ODataMediaRequest extends ODataRetrieveRequest<InputStream> {
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataPropertyRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataPropertyRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataPropertyRequest.java
index f61783b..69e85bf 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataPropertyRequest.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataPropertyRequest.java
@@ -24,5 +24,5 @@ import org.apache.olingo.commons.api.format.ODataFormat;
/**
* This class implements an OData entity property query request.
*/
-public interface ODataPropertyRequest<T extends CommonODataProperty> extends ODataRetrieveRequest<T, ODataFormat> {
+public interface ODataPropertyRequest<T extends CommonODataProperty> extends ODataRetrieveRequest<T> {
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataRetrieveRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataRetrieveRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataRetrieveRequest.java
index 61e505c..3b0404a 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataRetrieveRequest.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataRetrieveRequest.java
@@ -21,11 +21,10 @@ package org.apache.olingo.client.api.communication.request.retrieve;
import org.apache.olingo.client.api.communication.request.ODataBasicRequest;
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
-import org.apache.olingo.commons.api.format.Format;
/**
* This is an abstract representation of an OData retrieve query request returning one or more result item.
*/
-public interface ODataRetrieveRequest<V, T extends Format>
- extends ODataBasicRequest<ODataRetrieveResponse<V>, T>, ODataBatchableRequest {
+public interface ODataRetrieveRequest<T>
+ extends ODataBasicRequest<ODataRetrieveResponse<T>>, ODataBatchableRequest {
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataServiceDocumentRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataServiceDocumentRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataServiceDocumentRequest.java
index 580798c..494066a 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataServiceDocumentRequest.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataServiceDocumentRequest.java
@@ -19,10 +19,9 @@
package org.apache.olingo.client.api.communication.request.retrieve;
import org.apache.olingo.commons.api.domain.ODataServiceDocument;
-import org.apache.olingo.commons.api.format.ODataFormat;
/**
* This class implements an OData service document request.
*/
-public interface ODataServiceDocumentRequest extends ODataRetrieveRequest<ODataServiceDocument, ODataFormat> {
+public interface ODataServiceDocumentRequest extends ODataRetrieveRequest<ODataServiceDocument> {
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataValueRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataValueRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataValueRequest.java
index e78067a..7121ba2 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataValueRequest.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataValueRequest.java
@@ -19,10 +19,9 @@
package org.apache.olingo.client.api.communication.request.retrieve;
import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
-import org.apache.olingo.commons.api.format.ODataValueFormat;
/**
* This class implements an OData entity property value query request.
*/
-public interface ODataValueRequest extends ODataRetrieveRequest<ODataPrimitiveValue, ODataValueFormat> {
+public interface ODataValueRequest extends ODataRetrieveRequest<ODataPrimitiveValue> {
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/XMLMetadataRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/XMLMetadataRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/XMLMetadataRequest.java
index 619aa04..626d0f9 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/XMLMetadataRequest.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/XMLMetadataRequest.java
@@ -19,11 +19,11 @@
package org.apache.olingo.client.api.communication.request.retrieve;
import java.util.Map;
+
import org.apache.olingo.client.api.edm.xml.Schema;
-import org.apache.olingo.commons.api.format.ODataFormat;
/**
* This class implements an XML metadata request.
*/
-public interface XMLMetadataRequest extends ODataRetrieveRequest<Map<String, Schema>, ODataFormat> {
+public interface XMLMetadataRequest extends ODataRetrieveRequest<Map<String, Schema>> {
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v3/ODataLinkCollectionRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v3/ODataLinkCollectionRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v3/ODataLinkCollectionRequest.java
index 1494aea..90cbb46 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v3/ODataLinkCollectionRequest.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v3/ODataLinkCollectionRequest.java
@@ -20,10 +20,9 @@ package org.apache.olingo.client.api.communication.request.retrieve.v3;
import org.apache.olingo.client.api.communication.request.retrieve.ODataRetrieveRequest;
import org.apache.olingo.client.api.domain.v3.ODataLinkCollection;
-import org.apache.olingo.commons.api.format.ODataFormat;
/**
* This class implements an OData link query request.
*/
-public interface ODataLinkCollectionRequest extends ODataRetrieveRequest<ODataLinkCollection, ODataFormat> {
+public interface ODataLinkCollectionRequest extends ODataRetrieveRequest<ODataLinkCollection> {
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v4/ODataDeltaRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v4/ODataDeltaRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v4/ODataDeltaRequest.java
index 6f75d62..d10713a 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v4/ODataDeltaRequest.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v4/ODataDeltaRequest.java
@@ -20,10 +20,9 @@ package org.apache.olingo.client.api.communication.request.retrieve.v4;
import org.apache.olingo.client.api.communication.request.retrieve.ODataRetrieveRequest;
import org.apache.olingo.commons.api.domain.v4.ODataDelta;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
/**
* Describes an OData retrieve request returning a delta object.
*/
-public interface ODataDeltaRequest extends ODataRetrieveRequest<ODataDelta, ODataPubFormat> {
+public interface ODataDeltaRequest extends ODataRetrieveRequest<ODataDelta> {
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/ODataStreamedEntityRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/ODataStreamedEntityRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/ODataStreamedEntityRequest.java
index 1af787e..843bd84 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/ODataStreamedEntityRequest.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/ODataStreamedEntityRequest.java
@@ -21,7 +21,7 @@ package org.apache.olingo.client.api.communication.request.streamed;
import org.apache.olingo.client.api.communication.request.ODataPayloadManager;
import org.apache.olingo.client.api.communication.request.ODataStreamedRequest;
import org.apache.olingo.client.api.communication.response.ODataResponse;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
/**
* Abstract class representing a request concerning a streamed entity.
@@ -36,15 +36,15 @@ public interface ODataStreamedEntityRequest<V extends ODataResponse, T extends O
* Returns resource representation format.
*
* @return the configured format (or default if not specified).
- * @see org.apache.olingo.client.api.Configuration#getDefaultPubFormat()
+ * @see org.apache.olingo.client.api.CommonConfiguration#getDefaultPubFormat()
*/
- ODataPubFormat getFormat();
+ ODataFormat getFormat();
/**
* Override configured request format.
*
* @param format request format.
- * @see org.apache.olingo.client.api.format.ODataFormat
+ * @see ODataFormat
*/
- void setFormat(final ODataPubFormat format);
+ void setFormat(final ODataFormat format);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataEntitySetIterator.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataEntitySetIterator.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataEntitySetIterator.java
index 3525518..966214e 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataEntitySetIterator.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataEntitySetIterator.java
@@ -35,7 +35,7 @@ import org.apache.olingo.commons.api.data.Entity;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -56,11 +56,11 @@ public class ODataEntitySetIterator<ES extends CommonODataEntitySet, E extends C
*/
private static final Logger LOG = LoggerFactory.getLogger(ODataEntitySetIterator.class);
- private final CommonODataClient odataClient;
+ private final CommonODataClient<?> odataClient;
private final InputStream stream;
- private final ODataPubFormat format;
+ private final ODataFormat format;
private ResWrap<Entity> cached;
@@ -80,14 +80,14 @@ public class ODataEntitySetIterator<ES extends CommonODataEntitySet, E extends C
* @param format OData format.
*/
public ODataEntitySetIterator(final CommonODataClient<?> odataClient, final InputStream stream,
- final ODataPubFormat format) {
+ final ODataFormat format) {
this.odataClient = odataClient;
this.stream = stream;
this.format = format;
this.osEntitySet = new ByteArrayOutputStream();
- if (format == ODataPubFormat.ATOM) {
+ if (format == ODataFormat.ATOM) {
namespaces = getAllElementAttributes(stream, "feed", osEntitySet);
} else {
namespaces = null;
@@ -112,7 +112,7 @@ public class ODataEntitySetIterator<ES extends CommonODataEntitySet, E extends C
@SuppressWarnings("unchecked")
public boolean hasNext() {
if (available && cached == null) {
- if (format == ODataPubFormat.ATOM) {
+ if (format == ODataFormat.ATOM) {
cached = nextAtomEntityFromEntitySet(stream, osEntitySet, namespaces);
} else {
cached = nextJSONEntityFromEntitySet(stream, osEntitySet);
@@ -213,7 +213,7 @@ public class ODataEntitySetIterator<ES extends CommonODataEntitySet, E extends C
}
if (c >= 0) {
- jsonEntity = odataClient.getDeserializer(ODataPubFormat.JSON).toEntity(
+ jsonEntity = odataClient.getDeserializer(ODataFormat.JSON).toEntity(
new ByteArrayInputStream(entity.toByteArray()));
}
} else {
@@ -242,7 +242,7 @@ public class ODataEntitySetIterator<ES extends CommonODataEntitySet, E extends C
entity.write(">".getBytes(Constants.UTF8));
if (consume(input, "</entry>", entity, true) >= 0) {
- atomEntity = odataClient.getDeserializer(ODataPubFormat.ATOM).
+ atomEntity = odataClient.getDeserializer(ODataFormat.ATOM).
toEntity(new ByteArrayInputStream(entity.toByteArray()));
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/CommonODataReader.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/CommonODataReader.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/CommonODataReader.java
index e41d0bd..c678d2b 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/CommonODataReader.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/CommonODataReader.java
@@ -30,7 +30,6 @@ import org.apache.olingo.commons.api.domain.ODataError;
import org.apache.olingo.commons.api.domain.ODataServiceDocument;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
/**
@@ -77,7 +76,7 @@ public interface CommonODataReader {
* @return de-serialized entity set.
* @throws ODataDeserializerException
*/
- CommonODataEntitySet readEntitySet(InputStream input, ODataPubFormat format) throws ODataDeserializerException;
+ CommonODataEntitySet readEntitySet(InputStream input, ODataFormat format) throws ODataDeserializerException;
/**
* Parses a stream taking care to de-serializes the first OData entity found.
@@ -87,7 +86,7 @@ public interface CommonODataReader {
* @return entity de-serialized.
* @throws ODataDeserializerException
*/
- CommonODataEntity readEntity(InputStream input, ODataPubFormat format) throws ODataDeserializerException;
+ CommonODataEntity readEntity(InputStream input, ODataFormat format) throws ODataDeserializerException;
/**
* Parses a stream taking care to de-serialize the first OData entity property found.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataWriter.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataWriter.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataWriter.java
index 07a2fcd..8711487 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataWriter.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataWriter.java
@@ -25,7 +25,6 @@ import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.commons.api.serialization.ODataSerializerException;
/**
@@ -45,7 +44,7 @@ public interface ODataWriter {
* @return stream of serialized objects.
* @throws ODataSerializerException
*/
- InputStream writeEntities(Collection<CommonODataEntity> entities, ODataPubFormat format)
+ InputStream writeEntities(Collection<CommonODataEntity> entities, ODataFormat format)
throws ODataSerializerException;
/**
@@ -56,7 +55,7 @@ public interface ODataWriter {
* @return stream of serialized object.
* @throws ODataSerializerException
*/
- InputStream writeEntity(CommonODataEntity entity, ODataPubFormat format)
+ InputStream writeEntity(CommonODataEntity entity, ODataFormat format)
throws ODataSerializerException;
/**
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v3/ODataReader.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v3/ODataReader.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v3/ODataReader.java
index 082bf46..b618e0e 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v3/ODataReader.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v3/ODataReader.java
@@ -21,21 +21,20 @@ package org.apache.olingo.client.api.serialization.v3;
import java.io.InputStream;
import org.apache.olingo.client.api.domain.v3.ODataLinkCollection;
-import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.client.api.serialization.CommonODataReader;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
import org.apache.olingo.commons.api.domain.v3.ODataProperty;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
public interface ODataReader extends CommonODataReader {
@Override
- ODataEntitySet readEntitySet(InputStream input, ODataPubFormat format) throws ODataDeserializerException;
+ ODataEntitySet readEntitySet(InputStream input, ODataFormat format) throws ODataDeserializerException;
@Override
- ODataEntity readEntity(InputStream input, ODataPubFormat format) throws ODataDeserializerException;
+ ODataEntity readEntity(InputStream input, ODataFormat format) throws ODataDeserializerException;
@Override
ODataProperty readProperty(InputStream input, ODataFormat format) throws ODataDeserializerException;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v4/ODataReader.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v4/ODataReader.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v4/ODataReader.java
index 31d4969..993034c 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v4/ODataReader.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/v4/ODataReader.java
@@ -25,16 +25,15 @@ import org.apache.olingo.commons.api.domain.v4.ODataEntity;
import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
import org.apache.olingo.commons.api.domain.v4.ODataProperty;
import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
public interface ODataReader extends CommonODataReader {
@Override
- ODataEntitySet readEntitySet(InputStream input, ODataPubFormat format) throws ODataDeserializerException;
+ ODataEntitySet readEntitySet(InputStream input, ODataFormat format) throws ODataDeserializerException;
@Override
- ODataEntity readEntity(InputStream input, ODataPubFormat format) throws ODataDeserializerException;
+ ODataEntity readEntity(InputStream input, ODataFormat format) throws ODataDeserializerException;
@Override
ODataProperty readProperty(InputStream input, ODataFormat format) throws ODataDeserializerException;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/Configuration.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/Configuration.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/Configuration.java
deleted file mode 100644
index 87dff2f..0000000
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/Configuration.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.client.api.v3;
-
-import org.apache.olingo.client.api.CommonConfiguration;
-
-public interface Configuration extends CommonConfiguration {
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java
index 6360f0a..71d5ffd 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java
@@ -18,6 +18,7 @@
*/
package org.apache.olingo.client.api.v3;
+import org.apache.olingo.client.api.CommonConfiguration;
import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.client.api.communication.request.batch.v3.BatchRequestFactory;
import org.apache.olingo.client.api.communication.request.cud.v3.CUDRequestFactory;
@@ -26,18 +27,18 @@ import org.apache.olingo.client.api.communication.request.retrieve.v3.RetrieveRe
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.URIBuilder;
import org.apache.olingo.client.api.uri.v3.FilterFactory;
+import org.apache.olingo.client.api.uri.v3.URIBuilder;
import org.apache.olingo.commons.api.domain.v3.ODataObjectFactory;
-import org.apache.olingo.commons.api.format.Format;
+import org.apache.olingo.commons.api.format.ODataFormat;
public interface ODataClient extends CommonODataClient<UpdateType> {
@Override
- Configuration getConfiguration();
+ CommonConfiguration getConfiguration();
@Override
- ODataDeserializer getDeserializer(Format format);
+ ODataDeserializer getDeserializer(ODataFormat format);
@Override
ODataReader getReader();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java
index fa923aa..ee1fe97 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java
@@ -18,6 +18,7 @@
*/
package org.apache.olingo.client.api.v4;
+import org.apache.olingo.client.api.CommonConfiguration;
import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.client.api.communication.request.batch.v4.BatchRequestFactory;
import org.apache.olingo.client.api.communication.request.cud.v4.CUDRequestFactory;
@@ -27,19 +28,19 @@ import org.apache.olingo.client.api.communication.request.v4.AsyncRequestFactory
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.URIBuilder;
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;
import org.apache.olingo.commons.api.domain.v4.ODataObjectFactory;
-import org.apache.olingo.commons.api.format.Format;
+import org.apache.olingo.commons.api.format.ODataFormat;
public interface ODataClient extends CommonODataClient<UpdateType> {
@Override
- Configuration getConfiguration();
+ CommonConfiguration getConfiguration();
@Override
- ODataDeserializer getDeserializer(Format format);
+ ODataDeserializer getDeserializer(ODataFormat format);
@Override
ODataReader getReader();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractConfiguration.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractConfiguration.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractConfiguration.java
deleted file mode 100644
index dc9ee6c..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractConfiguration.java
+++ /dev/null
@@ -1,224 +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.client.core;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import org.apache.olingo.client.api.CommonConfiguration;
-import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.format.ODataMediaFormat;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.format.ODataValueFormat;
-import org.apache.olingo.client.api.http.HttpClientFactory;
-import org.apache.olingo.client.api.http.HttpUriRequestFactory;
-import org.apache.olingo.client.core.http.DefaultHttpClientFactory;
-import org.apache.olingo.client.core.http.DefaultHttpUriRequestFactory;
-import org.apache.olingo.commons.api.format.ContentType;
-
-public abstract class AbstractConfiguration implements CommonConfiguration {
-
- private static final String DEFAULT_PUB_FORMAT = "pubFormat";
-
- private static final String DEFAULT_VALUE_FORMAT = "valueFormat";
-
- private static final String DEFAULT_BATCH_ACCEPT_FORMAT = "batchAcceptFormat";
-
- private static final String DEFAULT_MEDIA_FORMAT = "valueFormat";
-
- private static final String HTTP_CLIENT_FACTORY = "httpClientFactory";
-
- private static final String HTTP_URI_REQUEST_FACTORY = "httpUriRequestFactory";
-
- private static final String USE_XHTTP_METHOD = "useHTTPMethod";
-
- private static final String KEY_AS_SEGMENT = "keyAsSegment";
-
- private static final String GZIP_COMPRESSION = "gzipCompression";
-
- private static final String CHUNKING = "chunking";
-
- private static final long serialVersionUID = 1L;
-
- private final Map<String, Object> CONF = new HashMap<String, Object>();
-
- private transient ExecutorService executor = Executors.newFixedThreadPool(10);
-
- /**
- * Gets given configuration property.
- *
- * @param key key value of the property to be retrieved.
- * @param defaultValue default value to be used in case of the given key doesn't exist.
- * @return property value if exists; default value if does not exist.
- */
- protected Object getProperty(final String key, final Object defaultValue) {
- return CONF.containsKey(key) ? CONF.get(key) : defaultValue;
- }
-
- /**
- * Sets new configuration property.
- *
- * @param key configuration property key.
- * @param value configuration property value.
- * @return given value.
- */
- protected Object setProperty(final String key, final Object value) {
- return CONF.put(key, value);
- }
-
- @Override
- public String getDefaultBatchAcceptFormat() {
- return getProperty(DEFAULT_BATCH_ACCEPT_FORMAT, ContentType.MULTIPART_MIXED).toString();
- }
-
- @Override
- public void setDefaultBatchAcceptFormat(final String contentType) {
- setProperty(DEFAULT_BATCH_ACCEPT_FORMAT, contentType);
- }
-
- @Override
- public ODataPubFormat getDefaultPubFormat() {
- return ODataPubFormat.valueOf(
- getProperty(DEFAULT_PUB_FORMAT, ODataPubFormat.JSON_FULL_METADATA.name()).toString());
- }
-
- @Override
- public void setDefaultPubFormat(final ODataPubFormat format) {
- setProperty(DEFAULT_PUB_FORMAT, format.name());
- }
-
- @Override
- public ODataFormat getDefaultFormat() {
- ODataFormat format;
-
- switch (getDefaultPubFormat()) {
- case ATOM:
- format = ODataFormat.XML;
- break;
-
- case JSON_FULL_METADATA:
- format = ODataFormat.JSON_FULL_METADATA;
- break;
-
- case JSON_NO_METADATA:
- format = ODataFormat.JSON_NO_METADATA;
- break;
-
- case JSON:
- default:
- format = ODataFormat.JSON;
- }
-
- return format;
- }
-
- @Override
- public ODataValueFormat getDefaultValueFormat() {
- return ODataValueFormat.valueOf(
- getProperty(DEFAULT_VALUE_FORMAT, ODataValueFormat.TEXT.name()).toString());
- }
-
- @Override
- public void setDefaultValueFormat(final ODataValueFormat format) {
- setProperty(DEFAULT_VALUE_FORMAT, format.name());
- }
-
- @Override
- public ODataMediaFormat getDefaultMediaFormat() {
- return ODataMediaFormat.valueOf(
- getProperty(DEFAULT_VALUE_FORMAT, ODataMediaFormat.APPLICATION_OCTET_STREAM.name()).toString());
- }
-
- @Override
- public void setDefaultMediaFormat(final ODataMediaFormat format) {
- setProperty(DEFAULT_MEDIA_FORMAT, format.name());
- }
-
- @Override
- public HttpClientFactory getHttpClientFactory() {
- return (HttpClientFactory) getProperty(HTTP_CLIENT_FACTORY, new DefaultHttpClientFactory());
- }
-
- @Override
- public void setHttpClientFactory(final HttpClientFactory factory) {
- setProperty(HTTP_CLIENT_FACTORY, factory);
- }
-
- @Override
- public HttpUriRequestFactory getHttpUriRequestFactory() {
- return (HttpUriRequestFactory) getProperty(HTTP_URI_REQUEST_FACTORY, new DefaultHttpUriRequestFactory());
- }
-
- @Override
- public void setHttpUriRequestFactory(final HttpUriRequestFactory factory) {
- setProperty(HTTP_URI_REQUEST_FACTORY, factory);
- }
-
- @Override
- public boolean isUseXHTTPMethod() {
- return (Boolean) getProperty(USE_XHTTP_METHOD, false);
- }
-
- @Override
- public void setUseXHTTPMethod(final boolean value) {
- setProperty(USE_XHTTP_METHOD, value);
- }
-
- @Override
- public boolean isGzipCompression() {
- return (Boolean) getProperty(GZIP_COMPRESSION, false);
- }
-
- @Override
- public void setGzipCompression(final boolean value) {
- setProperty(GZIP_COMPRESSION, value);
- }
-
- @Override
- public boolean isUseChuncked() {
- return (Boolean) getProperty(CHUNKING, true);
- }
-
- @Override
- public void setUseChuncked(final boolean value) {
- setProperty(CHUNKING, value);
- }
-
- @Override
- public boolean isKeyAsSegment() {
- return (Boolean) getProperty(KEY_AS_SEGMENT, false);
- }
-
- @Override
- public void setKeyAsSegment(final boolean value) {
- setProperty(KEY_AS_SEGMENT, value);
- }
-
- @Override
- public ExecutorService getExecutor() {
- return executor;
- }
-
- @Override
- public void setExecutor(final ExecutorService executorService) {
- executor = executorService;
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractODataClient.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractODataClient.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractODataClient.java
index 71c60c4..2f6e860 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractODataClient.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractODataClient.java
@@ -26,8 +26,6 @@ import org.apache.olingo.client.core.serialization.ODataWriterImpl;
public abstract class AbstractODataClient<UT extends CommonUpdateType> implements CommonODataClient<UT> {
- private static final long serialVersionUID = 7269096702397630265L;
-
private final ODataWriter writer = new ODataWriterImpl(this);
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/Configuration.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/Configuration.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/Configuration.java
new file mode 100644
index 0000000..1bad32f
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/Configuration.java
@@ -0,0 +1,197 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.core;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import org.apache.olingo.client.api.CommonConfiguration;
+import org.apache.olingo.client.api.http.HttpClientFactory;
+import org.apache.olingo.client.api.http.HttpUriRequestFactory;
+import org.apache.olingo.client.core.http.DefaultHttpClientFactory;
+import org.apache.olingo.client.core.http.DefaultHttpUriRequestFactory;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.commons.api.format.ODataFormat;
+
+public class Configuration implements CommonConfiguration {
+
+ private static final String DEFAULT_PUB_FORMAT = "pubFormat";
+
+ private static final String DEFAULT_VALUE_FORMAT = "valueFormat";
+
+ private static final String DEFAULT_BATCH_ACCEPT_FORMAT = "batchAcceptFormat";
+
+ private static final String DEFAULT_MEDIA_FORMAT = "valueFormat";
+
+ private static final String HTTP_CLIENT_FACTORY = "httpClientFactory";
+
+ private static final String HTTP_URI_REQUEST_FACTORY = "httpUriRequestFactory";
+
+ private static final String USE_XHTTP_METHOD = "useHTTPMethod";
+
+ private static final String KEY_AS_SEGMENT = "keyAsSegment";
+
+ private static final String GZIP_COMPRESSION = "gzipCompression";
+
+ private static final String CHUNKING = "chunking";
+
+ private final Map<String, Object> CONF = new HashMap<String, Object>();
+
+ private transient ExecutorService executor = Executors.newFixedThreadPool(10);
+
+ /**
+ * Gets given configuration property.
+ *
+ * @param key key value of the property to be retrieved.
+ * @param defaultValue default value to be used in case of the given key doesn't exist.
+ * @return property value if exists; default value if does not exist.
+ */
+ protected Object getProperty(final String key, final Object defaultValue) {
+ return CONF.containsKey(key) ? CONF.get(key) : defaultValue;
+ }
+
+ /**
+ * Sets new configuration property.
+ *
+ * @param key configuration property key.
+ * @param value configuration property value.
+ * @return given value.
+ */
+ protected Object setProperty(final String key, final Object value) {
+ return CONF.put(key, value);
+ }
+
+ @Override
+ public String getDefaultBatchAcceptFormat() {
+ return getProperty(DEFAULT_BATCH_ACCEPT_FORMAT, ContentType.MULTIPART_MIXED).toString();
+ }
+
+ @Override
+ public void setDefaultBatchAcceptFormat(final String contentType) {
+ setProperty(DEFAULT_BATCH_ACCEPT_FORMAT, contentType);
+ }
+
+ @Override
+ public ODataFormat getDefaultPubFormat() {
+ return (ODataFormat) getProperty(DEFAULT_PUB_FORMAT, ODataFormat.JSON_FULL_METADATA);
+ }
+
+ @Override
+ public void setDefaultPubFormat(final ODataFormat format) {
+ setProperty(DEFAULT_PUB_FORMAT, format);
+ }
+
+ @Override
+ public ODataFormat getDefaultFormat() {
+ ODataFormat format = getDefaultPubFormat();
+ return format == ODataFormat.ATOM ? ODataFormat.XML : format;
+ }
+
+ @Override
+ public ODataFormat getDefaultValueFormat() {
+ return (ODataFormat) getProperty(DEFAULT_VALUE_FORMAT, ODataFormat.TEXT_PLAIN);
+ }
+
+ @Override
+ public void setDefaultValueFormat(final ODataFormat format) {
+ setProperty(DEFAULT_VALUE_FORMAT, format);
+ }
+
+ @Override
+ public ODataFormat getDefaultMediaFormat() {
+ return (ODataFormat) getProperty(DEFAULT_VALUE_FORMAT, ODataFormat.APPLICATION_OCTET_STREAM);
+ }
+
+ @Override
+ public void setDefaultMediaFormat(final ODataFormat format) {
+ setProperty(DEFAULT_MEDIA_FORMAT, format);
+ }
+
+ @Override
+ public HttpClientFactory getHttpClientFactory() {
+ return (HttpClientFactory) getProperty(HTTP_CLIENT_FACTORY, new DefaultHttpClientFactory());
+ }
+
+ @Override
+ public void setHttpClientFactory(final HttpClientFactory factory) {
+ setProperty(HTTP_CLIENT_FACTORY, factory);
+ }
+
+ @Override
+ public HttpUriRequestFactory getHttpUriRequestFactory() {
+ return (HttpUriRequestFactory) getProperty(HTTP_URI_REQUEST_FACTORY, new DefaultHttpUriRequestFactory());
+ }
+
+ @Override
+ public void setHttpUriRequestFactory(final HttpUriRequestFactory factory) {
+ setProperty(HTTP_URI_REQUEST_FACTORY, factory);
+ }
+
+ @Override
+ public boolean isUseXHTTPMethod() {
+ return (Boolean) getProperty(USE_XHTTP_METHOD, false);
+ }
+
+ @Override
+ public void setUseXHTTPMethod(final boolean value) {
+ setProperty(USE_XHTTP_METHOD, value);
+ }
+
+ @Override
+ public boolean isGzipCompression() {
+ return (Boolean) getProperty(GZIP_COMPRESSION, false);
+ }
+
+ @Override
+ public void setGzipCompression(final boolean value) {
+ setProperty(GZIP_COMPRESSION, value);
+ }
+
+ @Override
+ public boolean isUseChuncked() {
+ return (Boolean) getProperty(CHUNKING, true);
+ }
+
+ @Override
+ public void setUseChuncked(final boolean value) {
+ setProperty(CHUNKING, value);
+ }
+
+ @Override
+ public boolean isKeyAsSegment() {
+ return (Boolean) getProperty(KEY_AS_SEGMENT, false);
+ }
+
+ @Override
+ public void setKeyAsSegment(final boolean value) {
+ setProperty(KEY_AS_SEGMENT, value);
+ }
+
+ @Override
+ public ExecutorService getExecutor() {
+ return executor;
+ }
+
+ @Override
+ public void setExecutor(final ExecutorService executorService) {
+ executor = executorService;
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/ODataClientFactory.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/ODataClientFactory.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/ODataClientFactory.java
index a9c87ed..fd462ff 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/ODataClientFactory.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/ODataClientFactory.java
@@ -18,7 +18,8 @@
*/
package org.apache.olingo.client.core;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
+
public final class ODataClientFactory {
@@ -29,7 +30,7 @@ public final class ODataClientFactory {
public static org.apache.olingo.client.api.v3.EdmEnabledODataClient getEdmEnabledV3(final String serviceRoot) {
final org.apache.olingo.client.api.v3.EdmEnabledODataClient instance =
new org.apache.olingo.client.core.v3.EdmEnabledODataClientImpl(serviceRoot);
- instance.getConfiguration().setDefaultPubFormat(ODataPubFormat.JSON);
+ instance.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
return instance;
}
@@ -40,7 +41,7 @@ public final class ODataClientFactory {
public static org.apache.olingo.client.api.v4.EdmEnabledODataClient getEdmEnabledV4(final String serviceRoot) {
final org.apache.olingo.client.api.v4.EdmEnabledODataClient instance =
new org.apache.olingo.client.core.v4.EdmEnabledODataClientImpl(serviceRoot);
- instance.getConfiguration().setDefaultPubFormat(ODataPubFormat.JSON);
+ instance.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
return instance;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/37abba5f/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataBasicRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataBasicRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataBasicRequest.java
index c08b426..cfb1112 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataBasicRequest.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataBasicRequest.java
@@ -23,60 +23,51 @@ import java.io.InputStream;
import java.net.URI;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
+
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.client.api.ODataBatchConstants;
import org.apache.olingo.client.api.CommonODataClient;
+import org.apache.olingo.client.api.ODataBatchConstants;
import org.apache.olingo.client.api.communication.request.ODataBasicRequest;
import org.apache.olingo.client.api.communication.request.ODataStreamer;
import org.apache.olingo.client.api.communication.request.batch.CommonODataBatchRequest;
import org.apache.olingo.client.api.communication.response.ODataResponse;
-import org.apache.olingo.commons.api.format.Format;
import org.apache.olingo.client.api.http.HttpMethod;
+import org.apache.olingo.commons.api.format.ODataFormat;
/**
* Basic request abstract implementation.
*
- * @param <V> OData response type corresponding to the request implementation.
- * @param <T> OData format being used.
+ * @param <T> OData response type corresponding to the request implementation.
*/
-public abstract class AbstractODataBasicRequest<V extends ODataResponse, T extends Format>
- extends AbstractODataRequest<T>
- implements ODataBasicRequest<V, T> {
+public abstract class AbstractODataBasicRequest<T extends ODataResponse>
+ extends AbstractODataRequest implements ODataBasicRequest<T> {
/**
* Constructor.
*
* @param odataClient client instance getting this request
- * @param formatRef reference class for the format being used
* @param method request method.
* @param uri OData request URI.
*/
- public AbstractODataBasicRequest(final CommonODataClient<?> odataClient,
- final Class<T> formatRef, final HttpMethod method, final URI uri) {
-
- super(odataClient, formatRef, method, uri);
+ public AbstractODataBasicRequest(final CommonODataClient<?> odataClient, final HttpMethod method, final URI uri) {
+ super(odataClient, method, uri);
}
- /**
- * {@inheritDoc}
- */
@Override
- public void setFormat(final T format) {
+ public void setFormat(final ODataFormat format) {
if (format != null) {
- setAccept(format.toString(odataClient.getServiceVersion()));
- setContentType(format.toString(odataClient.getServiceVersion()));
+ final String formatString = format.toString(odataClient.getServiceVersion());
+ setAccept(formatString);
+ setContentType(formatString);
}
}
- /**
- * {@inheritDoc}
- */
@Override
- public final Future<V> asyncExecute() {
- return odataClient.getConfiguration().getExecutor().submit(new Callable<V>() {
+ public final Future<T> asyncExecute() {
+ return odataClient.getConfiguration().getExecutor().submit(new Callable<T>() {
@Override
- public V call() throws Exception {
+ public T call() throws Exception {
return execute();
}
});
[7/8] git commit: [OLINGO-317] Refactored ContentType
Posted by mi...@apache.org.
[OLINGO-317] Refactored ContentType
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/ab6fd5e2
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/ab6fd5e2
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/ab6fd5e2
Branch: refs/heads/master
Commit: ab6fd5e2b8b2b01731c2ba771763e6b126baa28b
Parents: 176bee4
Author: Michael Bolz <mi...@sap.com>
Authored: Tue Jun 17 14:53:44 2014 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Tue Jun 17 14:53:44 2014 +0200
----------------------------------------------------------------------
.../commons/AbstractPersistenceManager.java | 6 +-
.../proxy/commons/EntityInvocationHandler.java | 12 +-
.../TransactionalPersistenceManagerImpl.java | 3 +-
.../org/apache/olingo/fit/AbstractServices.java | 8 +-
.../olingo/fit/v3/EntityRetrieveTestITCase.java | 2 +-
.../olingo/fit/v3/EntitySetTestITCase.java | 4 +-
.../olingo/fit/v3/MediaEntityTestITCase.java | 2 +-
.../olingo/fit/v3/PropertyTestITCase.java | 2 +-
.../olingo/fit/v3/QueryOptionsTestITCase.java | 2 +-
.../olingo/fit/v4/AuthBatchTestITCase.java | 6 +-
.../apache/olingo/fit/v4/BatchTestITCase.java | 2 +-
.../olingo/fit/v4/ConformanceTestITCase.java | 6 +-
.../olingo/fit/v4/EntityRetrieveTestITCase.java | 2 +-
.../olingo/fit/v4/EntitySetTestITCase.java | 4 +-
.../olingo/fit/v4/PropertyValueTestITCase.java | 4 +-
.../olingo/fit/v4/QueryOptionsTestITCase.java | 2 +-
.../olingo/client/api/CommonConfiguration.java | 9 +-
.../olingo/client/core/Configuration.java | 6 +-
.../request/AbstractODataBasicRequest.java | 2 +-
.../request/AbstractODataRequest.java | 9 +-
.../request/batch/ODataBatchUtilities.java | 6 +-
.../request/batch/v3/ODataBatchRequestImpl.java | 2 +-
.../request/batch/v4/ODataBatchRequestImpl.java | 2 +-
.../invoke/AbstractODataInvokeRequest.java | 6 +-
.../AbstractODataStreamedEntityRequest.java | 4 +-
.../commons/api/domain/ODataLinkType.java | 8 +-
.../olingo/commons/api/format/ContentType.java | 707 ++++++++++++++++++-
.../olingo/commons/api/format/ODataFormat.java | 137 ++--
.../core/serialization/AtomSerializer.java | 2 +-
.../tecsvc/processor/SampleJsonProcessor.java | 4 +-
30 files changed, 832 insertions(+), 139 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ab6fd5e2/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractPersistenceManager.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractPersistenceManager.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractPersistenceManager.java
index 492c751..d53e68e 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractPersistenceManager.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractPersistenceManager.java
@@ -354,9 +354,9 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
final ODataMediaEntityUpdateRequest<?> req =
factory.getClient().getCUDRequestFactory().getMediaEntityUpdateRequest(uri, input);
- req.setContentType(StringUtils.isBlank(handler.getEntity().getMediaContentType())
- ? ODataFormat.WILDCARD.toString()
- : ODataFormat.fromString(handler.getEntity().getMediaContentType()).toString());
+ if (StringUtils.isNotBlank(handler.getEntity().getMediaContentType())) {
+ req.setContentType(ODataFormat.fromString(handler.getEntity().getMediaContentType()).toString());
+ }
if (StringUtils.isNotBlank(handler.getETag())) {
req.setIfMatch(handler.getETag());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ab6fd5e2/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java
index aa81921..531353c 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java
@@ -320,13 +320,11 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler
&& typeRef.getAnnotation(EntityType.class).hasStream()
&& contentSource != null) {
- final String contentType =
- StringUtils.isBlank(getEntity().getMediaContentType()) ? "*/*" : getEntity().getMediaContentType();
-
- final ODataMediaRequest retrieveReq = getClient().getRetrieveRequestFactory().
- getMediaEntityRequest(contentSource);
- retrieveReq.setFormat(ODataFormat.fromString(contentType));
-
+ final ODataMediaRequest retrieveReq = getClient().getRetrieveRequestFactory()
+ .getMediaEntityRequest(contentSource);
+ if (StringUtils.isNotBlank(getEntity().getMediaContentType())) {
+ retrieveReq.setFormat(ODataFormat.fromString(getEntity().getMediaContentType()));
+ }
this.stream = retrieveReq.execute().getBody();
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ab6fd5e2/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/TransactionalPersistenceManagerImpl.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/TransactionalPersistenceManagerImpl.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/TransactionalPersistenceManagerImpl.java
index 73a3f29..1165830 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/TransactionalPersistenceManagerImpl.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/TransactionalPersistenceManagerImpl.java
@@ -54,7 +54,8 @@ public class TransactionalPersistenceManagerImpl extends AbstractPersistenceMana
protected void doFlush(final PersistenceChanges changes, final TransactionItems items) {
final CommonODataBatchRequest request =
factory.getClient().getBatchRequestFactory().getBatchRequest(factory.getClient().getServiceRoot());
- ((ODataRequest) request).setAccept(factory.getClient().getConfiguration().getDefaultBatchAcceptFormat());
+ String accept = factory.getClient().getConfiguration().getDefaultBatchAcceptFormat().toContentTypeString();
+ ((ODataRequest) request).setAccept(accept);
final BatchManager streamManager = (BatchManager) ((ODataStreamedRequest) request).payloadManager();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ab6fd5e2/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
index f701b2a..4db7659 100644
--- a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
+++ b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
@@ -123,6 +123,8 @@ public abstract class AbstractServices {
private static final Pattern REF_PATTERN = Pattern.compile("([$]\\d+)");
protected static final String BOUNDARY = "batch_243234_25424_ef_892u748";
+ protected static final String MULTIPART_MIXED = "multipart/mixed";//ContentType.MULTIPART_MIXED.toContentTypeString();
+ protected static final String APPLICATION_OCTET_STREAM = "application/octet-stream";
protected final ODataServiceVersion version;
protected final Metadata metadata;
@@ -194,8 +196,8 @@ public abstract class AbstractServices {
@POST
@Path("/$batch")
- @Consumes(ContentType.MULTIPART_MIXED)
- @Produces(ContentType.APPLICATION_OCTET_STREAM + ";boundary=" + BOUNDARY)
+ @Consumes(MULTIPART_MIXED)
+ @Produces(APPLICATION_OCTET_STREAM + ";boundary=" + BOUNDARY)
public Response batch(
@HeaderParam("Authorization") @DefaultValue(StringUtils.EMPTY) String authorization,
@HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) String prefer,
@@ -611,7 +613,7 @@ public abstract class AbstractServices {
final String entityKey;
if (xml.isMediaContent(entitySetName)) {
entry = new EntityImpl();
- entry.setMediaContentType(ContentType.WILDCARD);
+ entry.setMediaContentType(ContentType.APPLICATION_OCTET_STREAM.toContentTypeString());
entry.setType(entitySet.getType());
entityKey = xml.getDefaultEntryKey(entitySetName, entry);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ab6fd5e2/fit/src/test/java/org/apache/olingo/fit/v3/EntityRetrieveTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/EntityRetrieveTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/EntityRetrieveTestITCase.java
index 832b538..39fc464 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v3/EntityRetrieveTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v3/EntityRetrieveTestITCase.java
@@ -150,7 +150,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
appendEntitySetSegment("Car").appendKeySegment(16);
final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
- req.setFormat(format.toString(client.getServiceVersion()));
+ req.setFormat(format.getContentType(client.getServiceVersion()).toContentTypeString());
final ODataRawResponse res = req.execute();
assertNotNull(res);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ab6fd5e2/fit/src/test/java/org/apache/olingo/fit/v3/EntitySetTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/EntitySetTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/EntitySetTestITCase.java
index 61acf0a..83a0a5a 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v3/EntitySetTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v3/EntitySetTestITCase.java
@@ -150,7 +150,7 @@ public class EntitySetTestITCase extends AbstractTestITCase {
uriBuilder.appendEntitySetSegment("Product").inlineCount(URIBuilder.InlineCount.allpages);
final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
- req.setFormat(format.toString(client.getServiceVersion()));
+ req.setFormat(format.getContentType(client.getServiceVersion()).toContentTypeString());
final ODataRawResponse res = req.execute();
assertNotNull(res);
@@ -164,7 +164,7 @@ public class EntitySetTestITCase extends AbstractTestITCase {
uriBuilder.appendEntitySetSegment("Car");
final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
- req.setFormat(format.toString(client.getServiceVersion()));
+ req.setFormat(format.getContentType(client.getServiceVersion()).toContentTypeString());
final ODataRawResponse res = req.execute();
assertNotNull(res);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ab6fd5e2/fit/src/test/java/org/apache/olingo/fit/v3/MediaEntityTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/MediaEntityTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/MediaEntityTestITCase.java
index a29c10f..26f1b29 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v3/MediaEntityTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v3/MediaEntityTestITCase.java
@@ -51,7 +51,7 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
appendEntitySetSegment("Car").appendKeySegment(12);
final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaEntityRequest(builder.build());
- retrieveReq.setFormat(ODataFormat.WILDCARD);
+ retrieveReq.setAccept("*/*");
final ODataRetrieveResponse<InputStream> retrieveRes = retrieveReq.execute();
assertEquals(200, retrieveRes.getStatusCode());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ab6fd5e2/fit/src/test/java/org/apache/olingo/fit/v3/PropertyTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/PropertyTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/PropertyTestITCase.java
index 6866a06..107fec7 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v3/PropertyTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v3/PropertyTestITCase.java
@@ -348,7 +348,7 @@ public class PropertyTestITCase extends AbstractTestITCase {
appendEntitySetSegment("Customer").appendKeySegment(-10).appendPropertySegment("BackupContactInfo");
final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
- req.setFormat(format.toString(client.getServiceVersion()));
+ req.setFormat(format.getContentType(client.getServiceVersion()).toContentTypeString());
final ODataRawResponse res = req.execute();
assertNotNull(res);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ab6fd5e2/fit/src/test/java/org/apache/olingo/fit/v3/QueryOptionsTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/QueryOptionsTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/QueryOptionsTestITCase.java
index 940aa74..09f4a33 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v3/QueryOptionsTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v3/QueryOptionsTestITCase.java
@@ -106,7 +106,7 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
final ODataRetrieveResponse<ODataEntity> res = req.execute();
assertNotNull(res);
assertTrue(res.getContentType().replaceAll(" ", "").
- startsWith(ODataFormat.JSON.toString(client.getServiceVersion())));
+ startsWith(ODataFormat.JSON.getContentType(client.getServiceVersion()).toContentTypeString()));
}
/**
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ab6fd5e2/fit/src/test/java/org/apache/olingo/fit/v4/AuthBatchTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/AuthBatchTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/AuthBatchTestITCase.java
index 73f1578..d09db86 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/AuthBatchTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/AuthBatchTestITCase.java
@@ -41,7 +41,7 @@ import org.junit.Test;
public class AuthBatchTestITCase extends AbstractTestITCase {
- private final static String ACCEPT = ContentType.APPLICATION_OCTET_STREAM;
+ private final static ContentType ACCEPT = ContentType.APPLICATION_OCTET_STREAM;
@Test
public void clean() throws EdmPrimitiveTypeException {
@@ -66,8 +66,8 @@ public class AuthBatchTestITCase extends AbstractTestITCase {
private void batchRequest(final ODataClient client, final String baseURL) throws EdmPrimitiveTypeException {
// create your request
final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(baseURL);
- request.setAccept(ACCEPT);
- request.addCustomHeader("User-Agent", "Microsoft ADO.NET Data Client xxx");
+ request.setAccept(ACCEPT.toContentTypeString());
+ request.addCustomHeader("User-Agent", "Apache Olingo OData Client");
request.addCustomHeader(HeaderName.acceptCharset, "UTF-8");
final BatchManager streamManager = request.payloadManager();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ab6fd5e2/fit/src/test/java/org/apache/olingo/fit/v4/BatchTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/BatchTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/BatchTestITCase.java
index c4bac40..a491418 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/BatchTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/BatchTestITCase.java
@@ -77,7 +77,7 @@ public class BatchTestITCase extends AbstractTestITCase {
private static final int MAX = 10000;
- private final static String ACCEPT = ContentType.APPLICATION_OCTET_STREAM;
+ private final static String ACCEPT = ContentType.APPLICATION_OCTET_STREAM.toContentTypeString();
@Test
public void stringStreaming() {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ab6fd5e2/fit/src/test/java/org/apache/olingo/fit/v4/ConformanceTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/ConformanceTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/ConformanceTestITCase.java
index d2303b2..fc1c2e3 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/ConformanceTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/ConformanceTestITCase.java
@@ -124,13 +124,13 @@ public class ConformanceTestITCase extends AbstractTestITCase {
// check for Content-Type
assertEquals(
- ODataFormat.JSON_FULL_METADATA.toString(ODataServiceVersion.V40),
+ ODataFormat.JSON_FULL_METADATA.getContentType(ODataServiceVersion.V40).toContentTypeString(),
req.getHeader("Content-Type"));
assertEquals(
- ODataFormat.JSON_FULL_METADATA.toString(ODataServiceVersion.V40),
+ ODataFormat.JSON_FULL_METADATA.getContentType(ODataServiceVersion.V40).toContentTypeString(),
req.getHeader(HeaderName.contentType.toString()));
assertEquals(
- ODataFormat.JSON_FULL_METADATA.toString(ODataServiceVersion.V40),
+ ODataFormat.JSON_FULL_METADATA.getContentType(ODataServiceVersion.V40).toContentTypeString(),
req.getContentType());
final ODataEntity created = req.execute().getBody();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ab6fd5e2/fit/src/test/java/org/apache/olingo/fit/v4/EntityRetrieveTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/EntityRetrieveTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/EntityRetrieveTestITCase.java
index 79b73e9..4937d7a 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/EntityRetrieveTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/EntityRetrieveTestITCase.java
@@ -172,7 +172,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
appendEntitySetSegment("People").appendKeySegment(5);
final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
- req.setFormat(format.toString(client.getServiceVersion()));
+ req.setFormat(format.getContentType(client.getServiceVersion()).toContentTypeString());
final ODataRawResponse res = req.execute();
assertNotNull(res);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ab6fd5e2/fit/src/test/java/org/apache/olingo/fit/v4/EntitySetTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/EntitySetTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/EntitySetTestITCase.java
index a428d3d..0b87fbe 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/EntitySetTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/EntitySetTestITCase.java
@@ -49,7 +49,7 @@ public class EntitySetTestITCase extends AbstractTestITCase {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People");
final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
- req.setFormat(format.toString(client.getServiceVersion()));
+ req.setFormat(format.getContentType(client.getServiceVersion()).toContentTypeString());
final ODataRawResponse res = req.execute();
assertNotNull(res);
@@ -74,7 +74,7 @@ public class EntitySetTestITCase extends AbstractTestITCase {
appendEntitySetSegment("People").count(true);
final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
- req.setFormat(format.toString(client.getServiceVersion()));
+ req.setFormat(format.getContentType(client.getServiceVersion()).toContentTypeString());
final ODataRawResponse res = req.execute();
assertNotNull(res);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ab6fd5e2/fit/src/test/java/org/apache/olingo/fit/v4/PropertyValueTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/PropertyValueTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/PropertyValueTestITCase.java
index 14866d0..ed9c3ad 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/PropertyValueTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/PropertyValueTestITCase.java
@@ -101,7 +101,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC");
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
- req.setAccept(ODataFormat.ATOM.toString(ODataServiceVersion.V40));
+ req.setAccept(ODataFormat.ATOM.getContentType(ODataServiceVersion.V40).toContentTypeString());
req.execute().getBody();
}
@@ -110,7 +110,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC");
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
- req.setAccept(ODataFormat.XML.toString(client.getServiceVersion()));
+ req.setAccept(ODataFormat.XML.getContentType(client.getServiceVersion()).toContentTypeString());
req.execute().getBody();
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ab6fd5e2/fit/src/test/java/org/apache/olingo/fit/v4/QueryOptionsTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/QueryOptionsTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/QueryOptionsTestITCase.java
index 19221e9..b55f4ef 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/QueryOptionsTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/QueryOptionsTestITCase.java
@@ -130,7 +130,7 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
final ODataRetrieveResponse<ODataEntity> res = req.execute();
assertNotNull(res);
assertTrue(res.getContentType().replaceAll(" ", "").
- startsWith(ODataFormat.JSON.toString(client.getServiceVersion())));
+ startsWith(ODataFormat.JSON.getContentType(client.getServiceVersion()).toContentTypeString()));
}
/**
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ab6fd5e2/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonConfiguration.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonConfiguration.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonConfiguration.java
index 62708eb..95319f9 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonConfiguration.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonConfiguration.java
@@ -22,6 +22,7 @@ import java.util.concurrent.ExecutorService;
import org.apache.olingo.client.api.http.HttpClientFactory;
import org.apache.olingo.client.api.http.HttpUriRequestFactory;
+import org.apache.olingo.commons.api.format.ContentType;
import org.apache.olingo.commons.api.format.ODataFormat;
/**
@@ -33,13 +34,13 @@ public interface CommonConfiguration {
* Gets the configured default <tt>Accept</tt> header value format for a batch request.
* @return configured default <tt>Accept</tt> header value for a batch request.
*/
- String getDefaultBatchAcceptFormat();
+ ContentType getDefaultBatchAcceptFormat();
/**
* Set the default <tt>Accept</tt> header value format for a batch request.
* @param contentType default <tt>Accept</tt> header value.
*/
- void setDefaultBatchAcceptFormat(String contentType);
+ void setDefaultBatchAcceptFormat(ContentType contentType);
/**
* Gets the configured OData format for AtomPub exchanges. If this configuration parameter doesn't exist the
@@ -69,8 +70,8 @@ public interface CommonConfiguration {
* Gets the configured OData value format. If this configuration parameter doesn't exist the TEXT format will be used
* as default.
*
- * @return configured OData value format if specified; TEXT format otherwise.
- * @see ODataFormat#TEXT
+ * @return configured OData value format if specified; TEXT_PLAIN format otherwise.
+ * @see ODataFormat#TEXT_PLAIN
*/
ODataFormat getDefaultValueFormat();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ab6fd5e2/lib/client-core/src/main/java/org/apache/olingo/client/core/Configuration.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/Configuration.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/Configuration.java
index a67bc11..2dc1993 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/Configuration.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/Configuration.java
@@ -82,12 +82,12 @@ public class Configuration implements CommonConfiguration {
}
@Override
- public String getDefaultBatchAcceptFormat() {
- return getProperty(DEFAULT_BATCH_ACCEPT_FORMAT, ContentType.MULTIPART_MIXED).toString();
+ public ContentType getDefaultBatchAcceptFormat() {
+ return (ContentType) getProperty(DEFAULT_BATCH_ACCEPT_FORMAT, ContentType.MULTIPART_MIXED);
}
@Override
- public void setDefaultBatchAcceptFormat(final String contentType) {
+ public void setDefaultBatchAcceptFormat(final ContentType contentType) {
setProperty(DEFAULT_BATCH_ACCEPT_FORMAT, contentType);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ab6fd5e2/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataBasicRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataBasicRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataBasicRequest.java
index cfb1112..cb72202 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataBasicRequest.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataBasicRequest.java
@@ -57,7 +57,7 @@ public abstract class AbstractODataBasicRequest<T extends ODataResponse>
@Override
public void setFormat(final ODataFormat format) {
if (format != null) {
- final String formatString = format.toString(odataClient.getServiceVersion());
+ final String formatString = format.getContentType(odataClient.getServiceVersion()).toContentTypeString();
setAccept(formatString);
setContentType(formatString);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ab6fd5e2/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java
index 6a8e8d7..58412fc 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java
@@ -184,7 +184,9 @@ public abstract class AbstractODataRequest extends AbstractRequest implements OD
@Override
public String getAccept() {
final String acceptHead = odataHeaders.getHeader(HeaderName.accept);
- return StringUtils.isBlank(acceptHead) ? getDefaultFormat().toString(odataClient.getServiceVersion()) : acceptHead;
+ return StringUtils.isBlank(acceptHead) ?
+ getDefaultFormat().getContentType(odataClient.getServiceVersion()).toContentTypeString() :
+ acceptHead;
}
@Override
@@ -205,8 +207,9 @@ public abstract class AbstractODataRequest extends AbstractRequest implements OD
@Override
public String getContentType() {
final String contentTypeHead = odataHeaders.getHeader(HeaderName.contentType);
- return StringUtils.isBlank(contentTypeHead)
- ? getDefaultFormat().toString(odataClient.getServiceVersion()) : contentTypeHead;
+ return StringUtils.isBlank(contentTypeHead) ?
+ getDefaultFormat().getContentType(odataClient.getServiceVersion()).toContentTypeString() :
+ contentTypeHead;
}
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ab6fd5e2/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataBatchUtilities.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataBatchUtilities.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataBatchUtilities.java
index da46d82..b0429ac 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataBatchUtilities.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataBatchUtilities.java
@@ -95,7 +95,7 @@ public class ODataBatchUtilities {
* <p>
* Usually used to read an entire batch part.
*
- * @param batchController batch controller.
+ * @param controller batch controller.
* @param os destination stream of batch part (null to discard).
* @param checkCurrent if 'TRUE' the current line will be included into the delimiter verification.
* @return latest read line.
@@ -111,7 +111,7 @@ public class ODataBatchUtilities {
* <p>
* Usually used to read an entire batch part.
*
- * @param batchController batch controller.
+ * @param controller batch controller.
* @param os destination stream of batch part (null to discard).
* @param count number of batch line to be read.
* @param checkCurrent if 'TRUE' the current line will be included into the delimiter verification.
@@ -302,7 +302,7 @@ public class ODataBatchUtilities {
final String contentType = headers.containsKey(HeaderName.contentType.toString())
? headers.get(HeaderName.contentType.toString()).toString() : StringUtils.EMPTY;
- if (contentType.contains(ContentType.MULTIPART_MIXED)) {
+ if (contentType.contains(ContentType.MULTIPART_MIXED.toContentTypeString())) {
nextItemType = BatchItemType.CHANGESET;
} else if (contentType.contains(ODataBatchConstants.ITEM_CONTENT_TYPE)) {
nextItemType = BatchItemType.RETRIEVE;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ab6fd5e2/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v3/ODataBatchRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v3/ODataBatchRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v3/ODataBatchRequestImpl.java
index 3fbfddb..93821da 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v3/ODataBatchRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v3/ODataBatchRequestImpl.java
@@ -49,7 +49,7 @@ public class ODataBatchRequestImpl
public ODataBatchRequestImpl(final ODataClient odataClient, final URI uri) {
super(odataClient, uri);
- setAccept(odataClient.getConfiguration().getDefaultBatchAcceptFormat());
+ setAccept(odataClient.getConfiguration().getDefaultBatchAcceptFormat().toContentTypeString());
}
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ab6fd5e2/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/ODataBatchRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/ODataBatchRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/ODataBatchRequestImpl.java
index 0c43549..8fea8ce 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/ODataBatchRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/ODataBatchRequestImpl.java
@@ -48,7 +48,7 @@ public class ODataBatchRequestImpl
public ODataBatchRequestImpl(final ODataClient odataClient, final URI uri) {
super(odataClient, uri);
- setAccept(odataClient.getConfiguration().getDefaultBatchAcceptFormat());
+ setAccept(odataClient.getConfiguration().getDefaultBatchAcceptFormat().toContentTypeString());
}
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ab6fd5e2/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
index 714dd5e..5546778 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
@@ -97,9 +97,9 @@ public abstract class AbstractODataInvokeRequest<T extends ODataInvokeResult>
}
private String getActualFormat(final ODataFormat format) {
- return (CommonODataProperty.class.isAssignableFrom(reference) && format == ODataFormat.ATOM)
- ? ODataFormat.XML.toString(odataClient.getServiceVersion())
- : format.toString(odataClient.getServiceVersion());
+ return ((CommonODataProperty.class.isAssignableFrom(reference) && format == ODataFormat.ATOM)
+ ? ODataFormat.XML : format)
+ .getContentType(odataClient.getServiceVersion()).toContentTypeString();
}
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ab6fd5e2/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedEntityRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedEntityRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedEntityRequest.java
index edbe31e..506270a 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedEntityRequest.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedEntityRequest.java
@@ -50,7 +50,7 @@ public abstract class AbstractODataStreamedEntityRequest<V extends ODataResponse
final URI uri) {
super(odataClient, method, uri);
- setAccept(getFormat().toString(odataClient.getServiceVersion()));
+ setAccept(getFormat().getContentType(odataClient.getServiceVersion()).toContentTypeString());
}
@Override
@@ -61,6 +61,6 @@ public abstract class AbstractODataStreamedEntityRequest<V extends ODataResponse
@Override
public final void setFormat(final ODataFormat format) {
this.format = format;
- setAccept(format.toString(odataClient.getServiceVersion()));
+ setAccept(format.getContentType(odataClient.getServiceVersion()).toContentTypeString());
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ab6fd5e2/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinkType.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinkType.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinkType.java
index 28727ea..c7662a3 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinkType.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinkType.java
@@ -30,11 +30,11 @@ public enum ODataLinkType {
/**
* Entity navigation link.
*/
- ENTITY_NAVIGATION(ContentType.APPLICATION_ATOM_XML + ";type=entry"),
+ ENTITY_NAVIGATION(ContentType.APPLICATION_ATOM_XML_ENTRY),
/**
* Entity set navigation link.
*/
- ENTITY_SET_NAVIGATION(ContentType.APPLICATION_ATOM_XML + ";type=feed"),
+ ENTITY_SET_NAVIGATION(ContentType.APPLICATION_ATOM_XML_FEED),
/**
* Association link.
*/
@@ -50,6 +50,10 @@ public enum ODataLinkType {
this.type = type;
}
+ private ODataLinkType(ContentType contentType) {
+ this(contentType.toContentTypeString());
+ }
+
private ODataLinkType setType(final String type) {
this.type = type;
return this;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ab6fd5e2/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java
index c37131c..12a3152 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java
@@ -1,70 +1,705 @@
-/*
+/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ ******************************************************************************/
package org.apache.olingo.commons.api.format;
-import java.util.EnumMap;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
import java.util.Map;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import java.util.Map.Entry;
+import java.util.TreeMap;
+import java.util.regex.Pattern;
+
+/**
+ * Internally used {@link ContentType} for OData library.
+ *
+ * For more details on format and content of a {@link ContentType} see
+ * <em>Media Type</em> format as defined in
+ * <a href="http://www.ietf.org/rfc/rfc7231.txt">RFC 7231</a>, chapter 3.1.1.1.
+ * <pre>
+ * media-type = type "/" subtype *( OWS ";" OWS parameter )
+ * type = token
+ * subtype = token
+ * OWS = *( SP / HTAB ) ; optional whitespace
+ * </pre>
+ *
+ * Especially for <code>Accept</code> Header as defined in
+ * RFC 7231, chapter 5.3.2:
+ * <pre>
+ * Accept = #( media-range [ accept-params ] )
+ * media-range = ( "*/*"
+ * / ( type "/" "*" )
+ * / ( type "/" subtype )
+ * ) *( OWS ";" OWS parameter )
+ * accept-params = weight *( accept-ext )
+ * accept-ext = OWS ";" OWS token [ "=" ( token / quoted-string ) ]
+ * weight = OWS ";" OWS "q=" qvalue
+ * qvalue = ( "0" [ "." 0*3DIGIT ] ) / ( "1" [ "." 0*3("0") ] )
+ * </pre>
+ *
+ * Once created a {@link ContentType} is <b>IMMUTABLE</b>.
+ */
+public class ContentType {
+
+ private static final Comparator<String> Q_PARAMETER_COMPARATOR = new Comparator<String>() {
+ @Override
+ public int compare(final String o1, final String o2) {
+ Float f1 = parseQParameterValue(o1);
+ Float f2 = parseQParameterValue(o2);
+ return f2.compareTo(f1);
+ }
+ };
+
+ private static final char WHITESPACE_CHAR = ' ';
+ private static final String PARAMETER_SEPARATOR = ";";
+ private static final String PARAMETER_KEY_VALUE_SEPARATOR = "=";
+ private static final String TYPE_SUBTYPE_SEPARATOR = "/";
+ private static final String MEDIA_TYPE_WILDCARD = "*";
+
+ public static final String PARAMETER_Q = "q";
+ public static final String PARAMETER_TYPE = "type";
+ public static final String PARAMETER_CHARSET = "charset";
+ public static final String CHARSET_UTF_8 = "UTF-8";
+
+ private static final Pattern Q_PARAMETER_VALUE_PATTERN = Pattern.compile("1|0|1\\.0{1,3}|0\\.\\d{1,3}");
+
+ public static final ContentType WILDCARD = create(MEDIA_TYPE_WILDCARD, MEDIA_TYPE_WILDCARD);
+
+ public static final ContentType APPLICATION_XHTML_XML = create("application", "xhtml+xml");
+ public static final ContentType APPLICATION_SVG_XML = create("application", "svg+xml");
+ public static final ContentType APPLICATION_FORM_URLENCODED = create("application", "x-www-form-urlencoded");
+ public static final ContentType MULTIPART_FORM_DATA = create("multipart", "form-data");
+ public static final ContentType TEXT_XML = create("text", "xml");
+ public static final ContentType TEXT_HTML = create("text", "html");
+
+ public static final ContentType APPLICATION_XML = create("application", "xml");
+ public static final ContentType APPLICATION_XML_CS_UTF_8 = create(APPLICATION_XML, PARAMETER_CHARSET,
+ CHARSET_UTF_8);
+ public static final ContentType APPLICATION_ATOM_XML = create("application", "atom+xml");
+ public static final ContentType APPLICATION_ATOM_XML_CS_UTF_8 = create(APPLICATION_ATOM_XML,
+ PARAMETER_CHARSET, CHARSET_UTF_8);
+ public static final ContentType APPLICATION_ATOM_XML_ENTRY = create(APPLICATION_ATOM_XML, PARAMETER_TYPE, "entry");
+ public static final ContentType APPLICATION_ATOM_XML_ENTRY_CS_UTF_8 = create(APPLICATION_ATOM_XML_ENTRY,
+ PARAMETER_CHARSET, CHARSET_UTF_8);
+ public static final ContentType APPLICATION_ATOM_XML_FEED = create(APPLICATION_ATOM_XML, PARAMETER_TYPE, "feed");
+ public static final ContentType APPLICATION_ATOM_XML_FEED_CS_UTF_8 = ContentType.create(APPLICATION_ATOM_XML_FEED,
+ PARAMETER_CHARSET, CHARSET_UTF_8);
+ public static final ContentType APPLICATION_ATOM_SVC = create("application", "atomsvc+xml");
+ public static final ContentType APPLICATION_ATOM_SVC_CS_UTF_8 = create(APPLICATION_ATOM_SVC,
+ PARAMETER_CHARSET, CHARSET_UTF_8);
+ public static final ContentType APPLICATION_JSON = create("application", "json");
+ public static final ContentType APPLICATION_JSON_CS_UTF_8 = create(APPLICATION_JSON,
+ PARAMETER_CHARSET, CHARSET_UTF_8);
+ public static final ContentType APPLICATION_OCTET_STREAM = create("application", "octet-stream");
+ public static final ContentType TEXT_PLAIN = create("text", "plain");
+ public static final ContentType TEXT_PLAIN_CS_UTF_8 = ContentType
+ .create(TEXT_PLAIN, PARAMETER_CHARSET, CHARSET_UTF_8);
+ public static final ContentType MULTIPART_MIXED = create("multipart", "mixed");
+
+ private final String type;
+ private final String subtype;
+ private final Map<String, String> parameters;
+
+ private ContentType(final String type) {
+ if (type == null) {
+ throw new IllegalArgumentException("Type parameter MUST NOT be null.");
+ }
+ this.type = validateType(type);
+ subtype = null;
+ parameters = Collections.emptyMap();
+ }
+
+ /**
+ * Creates a content type from type, subtype, and parameters.
+ * @param type
+ * @param subtype
+ * @param parameters
+ */
+ private ContentType(final String type, final String subtype, final Map<String, String> parameters) {
+ if ((type == null || MEDIA_TYPE_WILDCARD.equals(type)) && !MEDIA_TYPE_WILDCARD.equals(subtype)) {
+ throw new IllegalArgumentException("Illegal combination of WILDCARD type with NONE WILDCARD subtype.");
+ }
+ this.type = validateType(type);
+ this.subtype = validateType(subtype);
+
+ if (parameters == null) {
+ this.parameters = Collections.emptyMap();
+ } else {
+ this.parameters = new TreeMap<String, String>(new Comparator<String>() {
+ @Override
+ public int compare(final String o1, final String o2) {
+ return o1.compareToIgnoreCase(o2);
+ }
+ });
+ this.parameters.putAll(parameters);
+ this.parameters.remove(PARAMETER_Q);
+ }
+ }
-public abstract class ContentType {
+ private String validateType(final String type) {
+ if (type == null || type.isEmpty()) {
+ return MEDIA_TYPE_WILDCARD;
+ }
+ int len = type.length();
+ for (int i = 0; i < len; i++) {
+ if (type.charAt(i) == WHITESPACE_CHAR) {
+ throw new IllegalArgumentException("Illegal whitespace found for type '" + type + "'.");
+ }
+ }
+ return type;
+ }
- public static final String APPLICATION_ATOM_XML = "application/atom+xml";
+ /**
+ * Validates if given <code>format</code> is parseable and can be used as input for {@link #create(String)} method.
+ * @param format to be validated string
+ * @return <code>true</code> if format is parseable otherwise <code>false</code>
+ */
+ public static boolean isParseable(final String format) {
+ try {
+ return ContentType.create(format) != null;
+ } catch (IllegalArgumentException e) {
+ return false;
+ }
+ }
- public static final String APPLICATION_FORM_URLENCODED = "application/x-www-form-urlencoded";
+ /**
+ * Creates a content type from type and subtype.
+ * @param type
+ * @param subtype
+ * @return a new <code>ContentType</code> object
+ */
+ public static ContentType create(final String type, final String subtype) {
+ return new ContentType(type, subtype, null);
+ }
- public static final String APPLICATION_JSON = "application/json";
+ /**
+ *
+ * @param contentType
+ * @param parameterKey
+ * @param parameterValue
+ * @return a new <code>ContentType</code> object
+ */
+ public static ContentType create(final ContentType contentType,
+ final String parameterKey, final String parameterValue) {
+ ContentType ct = new ContentType(contentType.type, contentType.subtype, contentType.parameters);
+ ct.parameters.put(parameterKey, parameterValue);
+ return ct;
+ }
- public static final String APPLICATION_OCTET_STREAM = "application/octet-stream";
+ /**
+ * Create a {@link ContentType} based on given input string (<code>format</code>).
+ * Supported format is <code>Media Type</code> format as defined in RFC 7231, chapter 3.1.1.1.
+ * @param format a string in format as defined in RFC 7231, chapter 3.1.1.1
+ * @return a new <code>ContentType</code> object
+ * @throws IllegalArgumentException if input string is not parseable
+ */
+ public static ContentType create(final String format) {
+ if (format == null) {
+ throw new IllegalArgumentException("Parameter format MUST NOT be NULL.");
+ }
- public static final String MULTIPART_MIXED = "multipart/mixed";
+ // split 'types' and 'parameters'
+ String[] typesAndParameters = format.split(PARAMETER_SEPARATOR, 2);
+ String types = typesAndParameters[0];
+ String parameters = (typesAndParameters.length > 1 ? typesAndParameters[1] : null);
+ //
+ Map<String, String> parametersMap = parseParameters(parameters);
+ //
+ if (types.contains(TYPE_SUBTYPE_SEPARATOR)) {
+ String[] tokens = types.split(TYPE_SUBTYPE_SEPARATOR);
+ if (tokens.length == 2) {
+ if (tokens[0] == null || tokens[0].isEmpty()) {
+ throw new IllegalArgumentException("No type found in format '" + format + "'.");
+ } else if (tokens[1] == null || tokens[1].isEmpty()) {
+ throw new IllegalArgumentException("No subtype found in format '" + format + "'.");
+ } else {
+ return new ContentType(tokens[0], tokens[1], parametersMap);
+ }
+ } else {
+ throw new IllegalArgumentException("Too many '" + TYPE_SUBTYPE_SEPARATOR + "' in format '" + format + "'.");
+ }
+ } else if (MEDIA_TYPE_WILDCARD.equals(types)) {
+ return ContentType.WILDCARD;
+ } else {
+ throw new IllegalArgumentException("No separator '" + TYPE_SUBTYPE_SEPARATOR + "' was found in format '" + format
+ + "'.");
+ }
+ }
- public static final String APPLICATION_SVG_XML = "application/svg+xml";
+ /**
+ * Create a list of {@link ContentType} based on given input strings (<code>contentTypes</code>).
+ *
+ * Supported format is <code>Media Type</code> format as defined in RFC 7231, chapter 3.1.1.1.
+ * If one of the given strings can not be parsed an exception is thrown (hence no list is returned with the parseable
+ * strings).
+ * @param contentTypeStrings a list of strings in format as defined in <code>RFC 2616 section 3.7</code>
+ * @return a list of new <code>ContentType</code> object
+ * @throws IllegalArgumentException if one of the given input string is not parseable this exceptions is thrown
+ */
+ public static List<ContentType> create(final List<String> contentTypeStrings) {
+ List<ContentType> contentTypes = new ArrayList<ContentType>(contentTypeStrings.size());
+ for (String contentTypeString : contentTypeStrings) {
+ contentTypes.add(create(contentTypeString));
+ }
+ return contentTypes;
+ }
- public static final String APPLICATION_XHTML_XML = "application/xhtml+xml";
+ /**
+ * Parses the given input string (<code>format</code>) and returns created {@link ContentType} if input was valid or
+ * return <code>NULL</code> if input was not parseable.
+ *
+ * For the definition of the supported format see {@link #create(String)}.
+ *
+ * @param format a string in format as defined in RFC 7231, chapter 3.1.1.1
+ * @return a new <code>ContentType</code> object
+ */
+ public static ContentType parse(final String format) {
+ try {
+ return ContentType.create(format);
+ } catch (IllegalArgumentException e) {
+ return null;
+ }
+ }
- public static final String APPLICATION_XML = "application/xml";
+ /**
+ * Sort given list (which must contains content-type formatted string) for their {@value #PARAMETER_Q} value
+ * as defined in RFC 7231, chapter 3.1.1.1, and RFC 7231, chapter 5.3.1.
+ *
+ * <b>Attention:</b> For invalid values a {@value #PARAMETER_Q} value from <code>-1</code> is used for sorting.
+ *
+ * @param toSort list which is sorted and hence re-arranged
+ */
+ public static void sortForQParameter(final List<String> toSort) {
+ Collections.sort(toSort, ContentType.Q_PARAMETER_COMPARATOR);
+ }
- public static final String MULTIPART_FORM_DATA = "multipart/form-data";
+ /**
+ * Valid input are <code>;</code> separated <code>key=value</code> pairs
+ * without spaces between key and value.
+ * <b>Attention:</b> <code>q</code> parameter is validated but not added to result map
+ *
+ * <p>
+ * See RFC 7231:
+ * The type, subtype, and parameter name tokens are case-insensitive.
+ * Parameter values might or might not be case-sensitive, depending on
+ * the semantics of the parameter name. The presence or absence of a
+ * parameter might be significant to the processing of a media-type,
+ * depending on its definition within the media type registry.
+ * </p>
+ *
+ * @param parameters
+ * @return Map with keys mapped to values
+ */
+ private static Map<String, String> parseParameters(final String parameters) {
+ Map<String, String> parameterMap = new HashMap<String, String>();
+ if (parameters != null) {
+ String[] splittedParameters = parameters.split(PARAMETER_SEPARATOR);
+ for (String parameter : splittedParameters) {
+ String[] keyValue = parameter.split(PARAMETER_KEY_VALUE_SEPARATOR);
+ String key = keyValue[0].trim().toLowerCase(Locale.ENGLISH);
+ String value = keyValue.length > 1 ? keyValue[1] : null;
+ if (value != null && Character.isWhitespace(value.charAt(0))) {
+ throw new IllegalArgumentException("Value of parameter '" + key + "' starts with whitespace ('" + parameters
+ + "').");
+ }
+ if (PARAMETER_Q.equals(key.toLowerCase(Locale.ENGLISH))) {
+ // q parameter is only validated but not added
+ if (!Q_PARAMETER_VALUE_PATTERN.matcher(value).matches()) {
+ throw new IllegalArgumentException("Value of 'q' parameter is not valid (q='" + value + "').");
+ }
+ } else {
+ parameterMap.put(key, value);
+ }
+ }
+ }
+ return parameterMap;
+ }
- public static final String TEXT_HTML = "text/html";
+ /**
+ * Parse value of {@value #PARAMETER_Q} <code>parameter</code> out of content type/parameters.
+ * If no {@value #PARAMETER_Q} <code>parameter</code> is in <code>content type/parameters</code> parameter found
+ * <code>1</code> is returned.
+ * If {@value #PARAMETER_Q} <code>parameter</code> is invalid <code>-1</code> is returned.
+ *
+ * @param contentType parameter which is parsed for {@value #PARAMETER_Q} <code>parameter</code> value
+ * @return value of {@value #PARAMETER_Q} <code>parameter</code> or <code>1</code> or <code>-1</code>
+ */
+ private static Float parseQParameterValue(final String contentType) {
+ if (contentType != null) {
+ String[] splittedParameters = contentType.split(PARAMETER_SEPARATOR);
+ for (String parameter : splittedParameters) {
+ String[] keyValue = parameter.split(PARAMETER_KEY_VALUE_SEPARATOR);
+ String key = keyValue[0].trim().toLowerCase(Locale.ENGLISH);
+ if (PARAMETER_Q.equalsIgnoreCase(key)) {
+ String value = keyValue.length > 1 ? keyValue[1] : null;
+ if (Q_PARAMETER_VALUE_PATTERN.matcher(value).matches()) {
+ return Float.valueOf(value);
+ }
+ return Float.valueOf(-1);
+ }
+ }
+ }
+ return Float.valueOf(1);
+ }
- public static final String TEXT_PLAIN = "text/plain";
+ /**
+ * Check if parameter with key value is an allowed parameter.
+ * @param key
+ * @return
+ */
+ private static boolean isParameterAllowed(final String key) {
+ return key != null && !PARAMETER_Q.equals(key.toLowerCase(Locale.ENGLISH));
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public String getSubtype() {
+ return subtype;
+ }
+
+ /**
+ *
+ * @return parameters of this {@link ContentType} as unmodifiable map.
+ */
+ public Map<String, String> getParameters() {
+ return Collections.unmodifiableMap(parameters);
+ }
+
+ @Override
+ public int hashCode() {
+ return 1;
+ }
- public static final String TEXT_XML = "text/xml";
+ /**
+ * {@link ContentType}s are equal
+ * <ul>
+ * <li>if <code>type</code>, <code>subtype</code> and all <code>parameters</code> have the same value.</li>
+ * <li>if <code>type</code> and/or <code>subtype</code> is set to "*" (in such a case the <code>parameters</code> are
+ * ignored).</li>
+ * </ul>
+ *
+ * @return <code>true</code> if both instances are equal (see definition above), otherwise <code>false</code>.
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ // NULL validation is done in method 'isEqualWithoutParameters(obj)'
+ Boolean compatible = isEqualWithoutParameters(obj);
- public static final String WILDCARD = "*/*";
+ if (compatible == null) {
+ ContentType other = (ContentType) obj;
- public static final EnumMap<ODataServiceVersion, Map<String, String>> formatPerVersion =
- new EnumMap<ODataServiceVersion, Map<String, String>>(ODataServiceVersion.class);
+ // parameter checks
+ if (parameters == null) {
+ if (other.parameters != null) {
+ return false;
+ }
+ } else if (parameters.size() == other.parameters.size()) {
+ Iterator<Entry<String, String>> entries = parameters.entrySet().iterator();
+ Iterator<Entry<String, String>> otherEntries = other.parameters.entrySet().iterator();
+ while (entries.hasNext()) {
+ Entry<String, String> e = entries.next();
+ Entry<String, String> oe = otherEntries.next();
+
+ if (!areEqual(e.getKey(), oe.getKey())) {
+ return false;
+ }
+ if (!areEqual(e.getValue(), oe.getValue())) {
+ return false;
+ }
+ }
+ } else {
+ return false;
+ }
+ return true;
+ } else {
+ // all tests run
+ return compatible.booleanValue();
+ }
+ }
+
+ /**
+ * {@link ContentType}s are <b>compatible</b>
+ * <ul>
+ * <li>if <code>type</code>, <code>subtype</code> have the same value.</li>
+ * <li>if <code>type</code> and/or <code>subtype</code> is set to "*"</li>
+ * </ul>
+ * The set <code>parameters</code> are <b>always</b> ignored (for compare with parameters see {@link #equals(Object)}
+ * ).
+ *
+ * @return <code>true</code> if both instances are equal (see definition above), otherwise <code>false</code>.
+ */
+ public boolean isCompatible(final ContentType obj) {
+ Boolean compatible = isEqualWithoutParameters(obj);
+ if (compatible == null) {
+ return true;
+ }
+ return compatible.booleanValue();
+ }
+
+ /**
+ * Check equal without parameters.
+ * It is possible that no decision about <code>equal/none equal</code> can be determined a <code>NULL</code> is
+ * returned.
+ *
+ * @param obj to checked object
+ * @return <code>true</code> if both instances are equal (see definition above), otherwise <code>false</code>
+ * or <code>NULL</code> if no decision about <code>equal/none equal</code> could be determined.
+ */
+ private Boolean isEqualWithoutParameters(final Object obj) {
+ // basic checks
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+
+ ContentType other = (ContentType) obj;
+
+ // subtype checks
+ if (subtype == null) {
+ if (other.subtype != null) {
+ return false;
+ }
+ } else if (!subtype.equals(other.subtype)) {
+ if (other.subtype == null) {
+ return false;
+ } else if (!subtype.equals(MEDIA_TYPE_WILDCARD) && !other.subtype.equals(MEDIA_TYPE_WILDCARD)) {
+ return false;
+ }
+ }
+
+ // type checks
+ if (type == null) {
+ if (other.type != null) {
+ return false;
+ }
+ } else if (!type.equals(other.type)) {
+ if (!type.equals(MEDIA_TYPE_WILDCARD) && !other.type.equals(MEDIA_TYPE_WILDCARD)) {
+ return false;
+ }
+ }
+
+ // if wildcards are set, content types are defined as 'equal'
+ if (countWildcards() > 0 || other.countWildcards() > 0) {
+ return true;
+ }
+
+ return null;
+ }
+
+ /**
+ * Check whether both string are equal ignoring the case of the strings.
+ *
+ * @param first first string
+ * @param second second string
+ * @return <code>true</code> if both strings are equal (by ignoring the case), otherwise <code>false</code> is
+ * returned
+ */
+ private static boolean areEqual(final String first, final String second) {
+ if (first == null) {
+ if (second != null) {
+ return false;
+ }
+ } else if (!first.equalsIgnoreCase(second)) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Get {@link ContentType} as string as defined in RFC 7231 (http://www.ietf.org/rfc/rfc7231.txt, chapter 3.1.1.1:
+ * Media Type)
+ * @return string representation of <code>ContentType</code> object
+ */
+ public String toContentTypeString() {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append(type).append(TYPE_SUBTYPE_SEPARATOR).append(subtype);
+
+ for (String key : parameters.keySet()) {
+ if (isParameterAllowed(key)) {
+ String value = parameters.get(key);
+ sb.append(";").append(key).append("=").append(value);
+ }
+ }
+ return sb.toString();
+ }
+
+ @Override
+ public String toString() {
+ return toContentTypeString();
+ }
+
+ /**
+ * Find best match between this {@link ContentType} and the {@link ContentType} in the list.
+ * If a match (this {@link ContentType} is equal to a {@link ContentType} in list) is found either this or the
+ * {@link ContentType} from the list is returned based on which {@link ContentType} has less "**" characters set
+ * (checked with {@link #compareWildcardCounts(ContentType)}.
+ * If no match (none {@link ContentType} in list is equal to this {@link ContentType}) is found <code>NULL</code> is
+ * returned.
+ *
+ * @param toMatchContentTypes list of {@link ContentType}s which are matches against this {@link ContentType}
+ * @return best matched content type in list or <code>NULL</code> if none content type match to this content type
+ * instance
+ */
+ public ContentType match(final List<ContentType> toMatchContentTypes) {
+ for (ContentType supportedContentType : toMatchContentTypes) {
+ if (equals(supportedContentType)) {
+ if (compareWildcardCounts(supportedContentType) < 0) {
+ return this;
+ } else {
+ return supportedContentType;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Find best match between this {@link ContentType} and the {@link ContentType} in the list ignoring all set
+ * parameters.
+ * If a match (this {@link ContentType} is equal to a {@link ContentType} in list) is found either this or the
+ * {@link ContentType} from the list is returned based on which {@link ContentType} has less "**" characters set
+ * (checked with {@link #compareWildcardCounts(ContentType)}.
+ * If no match (none {@link ContentType} in list is equal to this {@link ContentType}) is found <code>NULL</code> is
+ * returned.
+ *
+ * @param toMatchContentTypes list of {@link ContentType}s which are matches against this {@link ContentType}
+ * @return best matched content type in list or <code>NULL</code> if none content type match to this content type
+ * instance
+ */
+ public ContentType matchCompatible(final List<ContentType> toMatchContentTypes) {
+ for (ContentType supportedContentType : toMatchContentTypes) {
+ if (isCompatible(supportedContentType)) {
+ if (compareWildcardCounts(supportedContentType) < 0) {
+ return this;
+ } else {
+ return supportedContentType;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Check if a valid compatible match for this {@link ContentType} exists in given list.
+ * Compatible in this case means that <b>all set parameters are ignored</b>.
+ * For more detail what a valid match is see {@link #matchCompatible(List)}.
+ *
+ * @param toMatchContentTypes list of {@link ContentType}s which are matches against this {@link ContentType}
+ * @return <code>true</code> if a compatible content type was found in given list
+ * or <code>false</code> if none compatible content type match was found
+ */
+ public boolean hasCompatible(final List<ContentType> toMatchContentTypes) {
+ return matchCompatible(toMatchContentTypes) != null;
+ }
+
+ /**
+ * Check if a valid match for this {@link ContentType} exists in given list.
+ * For more detail what a valid match is see {@link #match(List)}.
+ *
+ * @param toMatchContentTypes list of {@link ContentType}s which are matches against this {@link ContentType}
+ * @return <code>true</code> if a matching content type was found in given list
+ * or <code>false</code> if none matching content type match was found
+ */
+ public boolean hasMatch(final List<ContentType> toMatchContentTypes) {
+ return match(toMatchContentTypes) != null;
+ }
+
+ /**
+ * Compare wildcards counts/weights of both {@link ContentType}.
+ *
+ * The smaller {@link ContentType} has lesser weighted wildcards then the bigger {@link ContentType}.
+ * As result this method returns this object weighted wildcards minus the given parameter object weighted wildcards.
+ *
+ * A type wildcard is weighted with <code>2</code> and a subtype wildcard is weighted with <code>1</code>.
+ *
+ * @param otherContentType {@link ContentType} to be compared to
+ * @return this object weighted wildcards minus the given parameter object weighted wildcards.
+ */
+ public int compareWildcardCounts(final ContentType otherContentType) {
+ return countWildcards() - otherContentType.countWildcards();
+ }
+
+ private int countWildcards() {
+ int count = 0;
+ if (MEDIA_TYPE_WILDCARD.equals(type)) {
+ count += 2;
+ }
+ if (MEDIA_TYPE_WILDCARD.equals(subtype)) {
+ count++;
+ }
+ return count;
+ }
+
+ /**
+ *
+ * @return <code>true</code> if <code>type</code> or <code>subtype</code> of this instance is a "*".
+ */
+ public boolean hasWildcard() {
+ return (MEDIA_TYPE_WILDCARD.equals(type) || MEDIA_TYPE_WILDCARD.equals(subtype));
+ }
+
+ /**
+ *
+ * @return <code>true</code> if both <code>type</code> and <code>subtype</code> of this instance are a "*".
+ */
+ public boolean isWildcard() {
+ return (MEDIA_TYPE_WILDCARD.equals(type) && MEDIA_TYPE_WILDCARD.equals(subtype));
+ }
+
+ public static List<ContentType> convert(final List<String> types) {
+ List<ContentType> results = new ArrayList<ContentType>();
+ for (String contentType : types) {
+ results.add(ContentType.create(contentType));
+ }
+ return results;
+ }
- static {
- final Map<String, String> v3 = new HashMap<String, String>();
- v3.put(ODataFormat.JSON_NO_METADATA.name(), ContentType.APPLICATION_JSON + ";odata=nometadata");
- v3.put(ODataFormat.JSON.name(), ContentType.APPLICATION_JSON + ";odata=minimalmetadata");
- v3.put(ODataFormat.JSON_FULL_METADATA.name(), ContentType.APPLICATION_JSON + ";odata=fullmetadata");
- formatPerVersion.put(ODataServiceVersion.V30, v3);
+ /**
+ * Check if a valid match for given content type formated string (<code>toMatch</code>) exists in given list.
+ * Therefore the given content type formated string (<code>toMatch</code>) is converted into a {@link ContentType}
+ * with a simple {@link #create(String)} call (during which an exception can occur).
+ *
+ * For more detail in general see {@link #hasMatch(List)} and for what a valid match is see {@link #match(List)}.
+ *
+ * @param toMatch content type formated string (<code>toMatch</code>) for which is checked if a match exists in given
+ * list
+ * @param matchExamples list of {@link ContentType}s which are matches against content type formated string
+ * (<code>toMatch</code>)
+ * @return <code>true</code> if a matching content type was found in given list
+ * or <code>false</code> if none matching content type match was found
+ */
+ public static boolean match(final String toMatch, final ContentType... matchExamples) {
+ ContentType toMatchContentType = ContentType.create(toMatch);
- final Map<String, String> v4 = new HashMap<String, String>();
- v4.put(ODataFormat.JSON_NO_METADATA.name(), ContentType.APPLICATION_JSON + ";odata.metadata=none");
- v4.put(ODataFormat.JSON.name(), ContentType.APPLICATION_JSON + ";odata.metadata=minimal");
- v4.put(ODataFormat.JSON_FULL_METADATA.name(), ContentType.APPLICATION_JSON + ";odata.metadata=full");
- formatPerVersion.put(ODataServiceVersion.V40, v4);
+ return toMatchContentType.hasMatch(Arrays.asList(matchExamples));
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ab6fd5e2/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataFormat.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataFormat.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataFormat.java
index 37d0731..bc122e2 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataFormat.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataFormat.java
@@ -20,6 +20,9 @@ package org.apache.olingo.commons.api.format;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* Available formats to be used in various contexts.
*/
@@ -38,8 +41,6 @@ public enum ODataFormat {
ATOM(ContentType.APPLICATION_ATOM_XML),
// media formats
- MEDIA_TYPE_WILDCARD("*"),
- WILDCARD(ContentType.WILDCARD),
APPLICATION_XML(ContentType.APPLICATION_XML),
APPLICATION_ATOM_XML(ContentType.APPLICATION_ATOM_XML),
APPLICATION_XHTML_XML(ContentType.APPLICATION_XHTML_XML),
@@ -52,79 +53,127 @@ public enum ODataFormat {
TEXT_XML(ContentType.TEXT_XML),
TEXT_HTML(ContentType.TEXT_HTML);
- private final String format;
+ private static final String JSON_METADATA_PARAMETER_V3 = "odata";
+ private static final String JSON_METADATA_PARAMETER_V4 = "odata.metadata";
+
+ private static final Map<ODataServiceVersion, Map<ODataFormat, ContentType>> FORMAT_PER_VERSION = new
+ HashMap<ODataServiceVersion, Map<ODataFormat, ContentType>>();
+
+ static {
+ final Map<ODataFormat, ContentType> v3 = new HashMap<ODataFormat, ContentType>();
+ v3.put(ODataFormat.JSON_NO_METADATA, ContentType.create(
+ ContentType.APPLICATION_JSON, JSON_METADATA_PARAMETER_V3, "nometadata"));
+ v3.put(ODataFormat.JSON, ContentType.create(
+ ContentType.APPLICATION_JSON, JSON_METADATA_PARAMETER_V3, "minimalmetadata"));
+ v3.put(ODataFormat.JSON_FULL_METADATA, ContentType.create(
+ ContentType.APPLICATION_JSON, JSON_METADATA_PARAMETER_V3, "fullmetadata"));
+ FORMAT_PER_VERSION.put(ODataServiceVersion.V30, v3);
+
+ final Map<ODataFormat, ContentType> v4 = new HashMap<ODataFormat, ContentType>();
+ v4.put(ODataFormat.JSON_NO_METADATA, ContentType.create(
+ ContentType.APPLICATION_JSON, JSON_METADATA_PARAMETER_V4, "none"));
+ v4.put(ODataFormat.JSON, ContentType.create(
+ ContentType.APPLICATION_JSON, JSON_METADATA_PARAMETER_V4, "minimal"));
+ v4.put(ODataFormat.JSON_FULL_METADATA, ContentType.create(
+ ContentType.APPLICATION_JSON, JSON_METADATA_PARAMETER_V4, "full"));
+ FORMAT_PER_VERSION.put(ODataServiceVersion.V40, v4);
+ }
+
+ private final ContentType contentType;
- ODataFormat() {
- this.format = null;
+ ODataFormat(final ContentType contentType) {
+ this.contentType = contentType;
}
- ODataFormat(final String format) {
- this.format = format;
+ ODataFormat() {
+ this.contentType = null;
}
/**
- * Gets format as a string.
- *
+ * Gets format as {@link ContentType}.
* @param version OData service version.
- * @return format as a string.
+ * @return format as ContentType.
*/
- public String toString(final ODataServiceVersion version) {
+ public ContentType getContentType(final ODataServiceVersion version) {
if (version.ordinal() < ODataServiceVersion.V30.ordinal()) {
throw new IllegalArgumentException("Unsupported version " + version);
}
- return format == null ? ContentType.formatPerVersion.get(version).get(this.name()) : format;
+ return contentType == null ? FORMAT_PER_VERSION.get(version).get(this) : contentType;
}
@Override
public String toString() {
- if (format == null) {
+ if (contentType == null) {
throw new UnsupportedOperationException();
} else {
- return format;
+ return contentType.toContentTypeString();
}
}
/**
- * Gets OData format from its string representation.
+ * Gets OData format from a content type.
*
- * @param format string representation of the format.
+ * @param contentType content type
* @return OData format.
*/
- public static ODataFormat fromString(final String format) {
- ODataFormat result = null;
-
- final StringBuffer _format = new StringBuffer();
-
- final String[] parts = format.split(";");
- _format.append(parts[0].trim());
- if (ContentType.APPLICATION_JSON.equals(parts[0].trim())) {
- if (parts.length > 1) {
- if (parts[1].trim().equalsIgnoreCase("charset=UTF-8")) {
- result = ODataFormat.JSON;
- } else {
- _format.append(';').append(parts[1].trim());
- }
- } else {
- result = ODataFormat.JSON;
- }
+ public static ODataFormat fromContentType(final ContentType contentType) {
+ if (contentType == null) {
+ return null;
+ }
+ if (contentType.hasWildcard()) {
+ throw new IllegalArgumentException("Content Type must be fully specified!");
}
- if (result == null) {
- final String candidate = _format.toString();
- for (ODataFormat value : values()) {
- if (candidate.equals(value.toString(ODataServiceVersion.V30))
- || candidate.equals(value.toString(ODataServiceVersion.V40))) {
- result = value;
- break;
+ if (contentType.isCompatible(ContentType.APPLICATION_ATOM_XML)
+ || contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC)) {
+ return ATOM;
+ } else if (contentType.isCompatible(ContentType.APPLICATION_XML)) {
+ return XML;
+ } else if (contentType.isCompatible(ContentType.APPLICATION_JSON)) {
+ String jsonVariant = contentType.getParameters().get(JSON_METADATA_PARAMETER_V3);
+ if (jsonVariant != null) {
+ for (ODataFormat candidate : FORMAT_PER_VERSION.get(ODataServiceVersion.V30).keySet()) {
+ if (FORMAT_PER_VERSION.get(ODataServiceVersion.V30).get(candidate).getParameters()
+ .get(JSON_METADATA_PARAMETER_V3)
+ .equals(jsonVariant)) {
+ return candidate;
+ }
+ }
+ }
+ jsonVariant = contentType.getParameters().get(JSON_METADATA_PARAMETER_V4);
+ if (jsonVariant != null) {
+ for (ODataFormat candidate : FORMAT_PER_VERSION.get(ODataServiceVersion.V40).keySet()) {
+ if (FORMAT_PER_VERSION.get(ODataServiceVersion.V40).get(candidate).getParameters()
+ .get(JSON_METADATA_PARAMETER_V4)
+ .equals(jsonVariant)) {
+ return candidate;
+ }
}
}
+ return JSON;
+ } else if (contentType.isCompatible(ContentType.APPLICATION_OCTET_STREAM)) {
+ return APPLICATION_OCTET_STREAM;
+ } else if (contentType.isCompatible(ContentType.TEXT_PLAIN)) {
+ return TEXT_PLAIN;
+ } else if (contentType.isCompatible(ContentType.APPLICATION_XHTML_XML)) {
+ return APPLICATION_XHTML_XML;
+ } else if (contentType.isCompatible(ContentType.APPLICATION_SVG_XML)) {
+ return APPLICATION_SVG_XML;
+ } else if (contentType.isCompatible(ContentType.APPLICATION_FORM_URLENCODED)) {
+ return APPLICATION_FORM_URLENCODED;
+ } else if (contentType.isCompatible(ContentType.MULTIPART_FORM_DATA)) {
+ return MULTIPART_FORM_DATA;
+ } else if (contentType.isCompatible(ContentType.TEXT_XML)) {
+ return TEXT_XML;
+ } else if (contentType.isCompatible(ContentType.TEXT_HTML)) {
+ return TEXT_HTML;
}
- if (result == null) {
- throw new IllegalArgumentException("Unsupported format: " + format);
- }
+ throw new IllegalArgumentException("Unsupported content Type: " + contentType);
+ }
- return result;
+ public static ODataFormat fromString(final String contentType) {
+ return contentType == null ? null : fromContentType(ContentType.parse(contentType));
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ab6fd5e2/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java
index fb2a041..74a76ad 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java
@@ -319,7 +319,7 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
writer.writeStartElement(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.PROPERTIES);
properties(writer, entity.getProperties());
} else {
- writer.writeAttribute(Constants.ATTR_TYPE, ContentType.APPLICATION_XML);
+ writer.writeAttribute(Constants.ATTR_TYPE, ContentType.APPLICATION_XML.toContentTypeString());
writer.writeStartElement(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.PROPERTIES);
properties(writer, entity.getProperties());
writer.writeEndElement();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ab6fd5e2/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
index 7e56c55..5c6c636 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
@@ -72,7 +72,7 @@ public class SampleJsonProcessor implements EntitySetProcessor, EntityProcessor
LOG.info("Finished in " + (System.nanoTime() - time) / 1000 + " microseconds");
response.setStatusCode(200);
- response.setHeader("Content-Type", ContentType.APPLICATION_JSON);
+ response.setHeader("Content-Type", ContentType.APPLICATION_JSON.toContentTypeString());
}
@Override
@@ -91,7 +91,7 @@ public class SampleJsonProcessor implements EntitySetProcessor, EntityProcessor
LOG.info("Finished in " + (System.nanoTime() - time) / 1000 + " microseconds");
response.setStatusCode(200);
- response.setHeader("Content-Type", ContentType.APPLICATION_JSON);
+ response.setHeader("Content-Type", ContentType.APPLICATION_JSON.toContentTypeString());
}
protected Entity createEntity() {
[8/8] git commit: [OLINGO-317] Minor ContentType refactoring
Posted by mi...@apache.org.
[OLINGO-317] Minor ContentType refactoring
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/ce359852
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/ce359852
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/ce359852
Branch: refs/heads/master
Commit: ce3598521da0b4b6576067ea82278a8b22823bde
Parents: ab6fd5e
Author: Michael Bolz <mi...@sap.com>
Authored: Mon Jun 23 15:19:23 2014 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Mon Jun 23 15:19:23 2014 +0200
----------------------------------------------------------------------
.../apache/olingo/commons/api/data/Value.java | 2 -
.../olingo/commons/api/format/AcceptType.java | 259 ++++++++++++
.../olingo/commons/api/format/ContentType.java | 407 +++----------------
.../olingo/commons/api/format/ODataFormat.java | 27 +-
.../olingo/commons/core/data/AbstractValue.java | 5 -
5 files changed, 332 insertions(+), 368 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce359852/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Value.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Value.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Value.java
index 08a420d..268a026 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Value.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Value.java
@@ -36,8 +36,6 @@ public interface Value {
Object get();
- NullValue asNull();
-
PrimitiveValue asPrimitive();
EnumValue asEnum();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce359852/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/AcceptType.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/AcceptType.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/AcceptType.java
new file mode 100644
index 0000000..07a5452
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/AcceptType.java
@@ -0,0 +1,259 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.commons.api.format;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.regex.Pattern;
+
+/**
+ * Internally used {@link AcceptType} for OData library.
+ *
+ * See RFC 7231, chapter 5.3.2:
+ * <pre>
+ * Accept = #( media-range [ accept-params ] )
+ * media-range = ( "*/*"
+ * / ( type "/" "*" )
+ * / ( type "/" subtype )
+ * ) *( OWS ";" OWS parameter )
+ * accept-params = weight *( accept-ext )
+ * accept-ext = OWS ";" OWS token [ "=" ( token / quoted-string ) ]
+ * weight = OWS ";" OWS "q=" qvalue
+ * qvalue = ( "0" [ "." 0*3DIGIT ] ) / ( "1" [ "." 0*3("0") ] )
+ * </pre>
+ *
+ * Once created a {@link AcceptType} is <b>IMMUTABLE</b>.
+ */
+public class AcceptType {
+
+ private static final String MEDIA_TYPE_WILDCARD = "*";
+ private static final String PARAMETER_Q = "q";
+ private static final Pattern Q_PARAMETER_VALUE_PATTERN = Pattern.compile("1|0|1\\.0{1,3}|0\\.\\d{1,3}");
+
+ public static final AcceptType WILDCARD = create(MEDIA_TYPE_WILDCARD, MEDIA_TYPE_WILDCARD, null, 1F);
+
+ private final String type;
+ private final String subtype;
+ private final Map<String, String> parameters;
+ private final Float quality;
+
+ private AcceptType(final String type, final String subtype, final Map<String, String> parameters,
+ final Float quality) {
+ this.type = type;
+ this.subtype = subtype;
+ this.parameters = createParameterMap();
+ this.parameters.putAll(parameters);
+ this.quality = quality;
+ }
+
+ private TreeMap<String, String> createParameterMap() {
+ return new TreeMap<String, String>(new Comparator<String>() {
+ @Override
+ public int compare(final String o1, final String o2) {
+ return o1.compareToIgnoreCase(o2);
+ }
+ });
+ }
+
+ private AcceptType(final String type) {
+ if (type == null) {
+ throw new IllegalArgumentException("Type parameter MUST NOT be null.");
+ }
+ List<String> typeSubtype = new ArrayList<String>();
+ this.parameters = createParameterMap();
+ ContentType.parse(type, typeSubtype, parameters);
+ this.type = typeSubtype.get(0);
+ this.subtype = typeSubtype.get(1);
+ if (MEDIA_TYPE_WILDCARD.equals(this.type) && !MEDIA_TYPE_WILDCARD.equals(this.subtype)) {
+ throw new IllegalArgumentException("Illegal combination of WILDCARD type with NONE WILDCARD subtype.");
+ }
+ final String q = parameters.get(PARAMETER_Q);
+ if (q == null) {
+ quality = 1F;
+ } else {
+ if (Q_PARAMETER_VALUE_PATTERN.matcher(q).matches()) {
+ quality = Float.valueOf(q);
+ } else {
+ throw new IllegalArgumentException("Illegal quality parameter.");
+ }
+ parameters.remove(PARAMETER_Q);
+ }
+ }
+
+ /**
+ * Creates an accept type.
+ * @param type
+ * @param subtype
+ * @param parameters
+ * @param quality
+ * @return a new <code>AcceptType</code> object
+ */
+ public static AcceptType create(final String type, final String subtype, final Map<String, String> parameters,
+ final Float quality) {
+ return new AcceptType(type, subtype, parameters, quality);
+ }
+
+ public static AcceptType create(final ContentType contentType) {
+ return create(contentType.getType(), contentType.getSubtype(), contentType.getParameters(), 1F);
+ }
+
+ /**
+ * Create an {@link AcceptType} based on given input string (<code>format</code>).
+ * @param format
+ * @return a new <code>AcceptType</code> object
+ * @throws IllegalArgumentException if input string is not parseable
+ */
+ public static AcceptType create(final String format) {
+ if (format == null) {
+ throw new IllegalArgumentException("Parameter format MUST NOT be NULL.");
+ }
+ return new AcceptType(format);
+ }
+
+ /**
+ * Parses the given input string (<code>format</code>) and returns created {@link AcceptType} if input was valid or
+ * return <code>NULL</code> if input was not parseable.
+ * @param format
+ * @return a new <code>ContentType</code> object
+ */
+ public static AcceptType parse(final String format) {
+ try {
+ return AcceptType.create(format);
+ } catch (IllegalArgumentException e) {
+ return null;
+ }
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public String getSubtype() {
+ return subtype;
+ }
+
+ public Map<String, String> getParameters() {
+ return parameters;
+ }
+
+ public Float getQuality() {
+ return quality;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder result = new StringBuilder();
+ result.append(type).append('/').append(subtype);
+ for (final String key : parameters.keySet()) {
+ result.append(';').append(key).append('=').append(parameters.get(key));
+ }
+ if (quality < 1F) {
+ result.append(';').append(PARAMETER_Q).append('=').append(quality);
+ }
+ return result.toString();
+ }
+
+ /**
+ * <p>Determines whether this accept type matches a given content type.</p>
+ * <p>A match is defined as fulfilling all of the following conditions:
+ * <ul>
+ * <li>the type must be '*' or equal to the content-type's type,</li>
+ * <li>the subtype must be '*' or equal to the content-type's subtype,</li>
+ * <li>all parameters must have the same value as in the content-type's parameter map.</li>
+ * </ul></p>
+ * @param contentType
+ * @return whether this accept type matches the given content type
+ */
+ public boolean matches(final ContentType contentType) {
+ if (type.equals(MEDIA_TYPE_WILDCARD)) {
+ return true;
+ }
+ if (!type.equalsIgnoreCase(contentType.getType())) {
+ return false;
+ }
+ if (subtype.equals(MEDIA_TYPE_WILDCARD)) {
+ return true;
+ }
+ if (!subtype.equalsIgnoreCase(contentType.getSubtype())) {
+ return false;
+ }
+ Map<String, String> compareParameters = contentType.getParameters();
+ for (final String key : parameters.keySet()) {
+ if (compareParameters.containsKey(key)) {
+ if (!parameters.get(key).equalsIgnoreCase(compareParameters.get(key))) {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Create a list of {@link AcceptType} based on given input strings (<code>contentTypes</code>).
+ *
+ * If one of the given strings can not be parsed an exception is thrown (hence no list is returned with the parseable
+ * strings).
+ * @param acceptTypeStrings a list of strings
+ * @return a list of new <code>AcceptType</code> objects
+ * @throws IllegalArgumentException if one of the given input string is not parseable this exceptions is thrown
+ */
+ public static List<AcceptType> create(final List<String> acceptTypeStrings) {
+ List<AcceptType> acceptTypes = new ArrayList<AcceptType>(acceptTypeStrings.size());
+ for (String contentTypeString : acceptTypeStrings) {
+ acceptTypes.add(create(contentTypeString));
+ }
+ return acceptTypes;
+ }
+
+ /**
+ * Sort given list of Accept types
+ * according to their quality-parameter values and their specificity
+ * as defined in RFC 7231, chapters 3.1.1.1, 5.3.1, and 5.3.2.
+ * @param toSort list which is sorted and hence re-arranged
+ */
+ public static void sort(List<AcceptType> toSort) {
+ Collections.sort(toSort,
+ new Comparator<AcceptType>() {
+ @Override
+ public int compare(final AcceptType a1, final AcceptType a2) {
+ int compare = a1.getQuality().compareTo(a2.getQuality());
+ if (compare != 0) {
+ return compare;
+ }
+ compare = (a1.getType().equals(MEDIA_TYPE_WILDCARD) ? 1 : 0)
+ - (a2.getType().equals(MEDIA_TYPE_WILDCARD) ? 1 : 0);
+ if (compare != 0) {
+ return compare;
+ }
+ compare = (a1.getSubtype().equals(MEDIA_TYPE_WILDCARD) ? 1 : 0)
+ - (a2.getSubtype().equals(MEDIA_TYPE_WILDCARD) ? 1 : 0);
+ if (compare != 0) {
+ return compare;
+ }
+ return a2.getParameters().size() - a1.getParameters().size();
+ }
+ });
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce359852/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java
index 12a3152..2ff67bb 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java
@@ -19,7 +19,6 @@
package org.apache.olingo.commons.api.format;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
@@ -29,7 +28,6 @@ import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
-import java.util.regex.Pattern;
/**
* Internally used {@link ContentType} for OData library.
@@ -44,55 +42,19 @@ import java.util.regex.Pattern;
* OWS = *( SP / HTAB ) ; optional whitespace
* </pre>
*
- * Especially for <code>Accept</code> Header as defined in
- * RFC 7231, chapter 5.3.2:
- * <pre>
- * Accept = #( media-range [ accept-params ] )
- * media-range = ( "*/*"
- * / ( type "/" "*" )
- * / ( type "/" subtype )
- * ) *( OWS ";" OWS parameter )
- * accept-params = weight *( accept-ext )
- * accept-ext = OWS ";" OWS token [ "=" ( token / quoted-string ) ]
- * weight = OWS ";" OWS "q=" qvalue
- * qvalue = ( "0" [ "." 0*3DIGIT ] ) / ( "1" [ "." 0*3("0") ] )
- * </pre>
- *
* Once created a {@link ContentType} is <b>IMMUTABLE</b>.
*/
public class ContentType {
- private static final Comparator<String> Q_PARAMETER_COMPARATOR = new Comparator<String>() {
- @Override
- public int compare(final String o1, final String o2) {
- Float f1 = parseQParameterValue(o1);
- Float f2 = parseQParameterValue(o2);
- return f2.compareTo(f1);
- }
- };
-
private static final char WHITESPACE_CHAR = ' ';
private static final String PARAMETER_SEPARATOR = ";";
private static final String PARAMETER_KEY_VALUE_SEPARATOR = "=";
private static final String TYPE_SUBTYPE_SEPARATOR = "/";
- private static final String MEDIA_TYPE_WILDCARD = "*";
- public static final String PARAMETER_Q = "q";
public static final String PARAMETER_TYPE = "type";
public static final String PARAMETER_CHARSET = "charset";
public static final String CHARSET_UTF_8 = "UTF-8";
- private static final Pattern Q_PARAMETER_VALUE_PATTERN = Pattern.compile("1|0|1\\.0{1,3}|0\\.\\d{1,3}");
-
- public static final ContentType WILDCARD = create(MEDIA_TYPE_WILDCARD, MEDIA_TYPE_WILDCARD);
-
- public static final ContentType APPLICATION_XHTML_XML = create("application", "xhtml+xml");
- public static final ContentType APPLICATION_SVG_XML = create("application", "svg+xml");
- public static final ContentType APPLICATION_FORM_URLENCODED = create("application", "x-www-form-urlencoded");
- public static final ContentType MULTIPART_FORM_DATA = create("multipart", "form-data");
- public static final ContentType TEXT_XML = create("text", "xml");
- public static final ContentType TEXT_HTML = create("text", "html");
-
public static final ContentType APPLICATION_XML = create("application", "xml");
public static final ContentType APPLICATION_XML_CS_UTF_8 = create(APPLICATION_XML, PARAMETER_CHARSET,
CHARSET_UTF_8);
@@ -103,43 +65,37 @@ public class ContentType {
public static final ContentType APPLICATION_ATOM_XML_ENTRY_CS_UTF_8 = create(APPLICATION_ATOM_XML_ENTRY,
PARAMETER_CHARSET, CHARSET_UTF_8);
public static final ContentType APPLICATION_ATOM_XML_FEED = create(APPLICATION_ATOM_XML, PARAMETER_TYPE, "feed");
- public static final ContentType APPLICATION_ATOM_XML_FEED_CS_UTF_8 = ContentType.create(APPLICATION_ATOM_XML_FEED,
+ public static final ContentType APPLICATION_ATOM_XML_FEED_CS_UTF_8 = create(APPLICATION_ATOM_XML_FEED,
PARAMETER_CHARSET, CHARSET_UTF_8);
public static final ContentType APPLICATION_ATOM_SVC = create("application", "atomsvc+xml");
public static final ContentType APPLICATION_ATOM_SVC_CS_UTF_8 = create(APPLICATION_ATOM_SVC,
PARAMETER_CHARSET, CHARSET_UTF_8);
public static final ContentType APPLICATION_JSON = create("application", "json");
public static final ContentType APPLICATION_JSON_CS_UTF_8 = create(APPLICATION_JSON,
- PARAMETER_CHARSET, CHARSET_UTF_8);
+ PARAMETER_CHARSET, CHARSET_UTF_8);
public static final ContentType APPLICATION_OCTET_STREAM = create("application", "octet-stream");
public static final ContentType TEXT_PLAIN = create("text", "plain");
- public static final ContentType TEXT_PLAIN_CS_UTF_8 = ContentType
- .create(TEXT_PLAIN, PARAMETER_CHARSET, CHARSET_UTF_8);
+ public static final ContentType TEXT_PLAIN_CS_UTF_8 = create(TEXT_PLAIN, PARAMETER_CHARSET, CHARSET_UTF_8);
public static final ContentType MULTIPART_MIXED = create("multipart", "mixed");
+ public static final ContentType APPLICATION_XHTML_XML = create("application", "xhtml+xml");
+ public static final ContentType APPLICATION_SVG_XML = create("application", "svg+xml");
+ public static final ContentType APPLICATION_FORM_URLENCODED = create("application", "x-www-form-urlencoded");
+ public static final ContentType MULTIPART_FORM_DATA = create("multipart", "form-data");
+ public static final ContentType TEXT_XML = create("text", "xml");
+ public static final ContentType TEXT_HTML = create("text", "html");
+
private final String type;
private final String subtype;
private final Map<String, String> parameters;
- private ContentType(final String type) {
- if (type == null) {
- throw new IllegalArgumentException("Type parameter MUST NOT be null.");
- }
- this.type = validateType(type);
- subtype = null;
- parameters = Collections.emptyMap();
- }
-
/**
* Creates a content type from type, subtype, and parameters.
- * @param type
- * @param subtype
- * @param parameters
- */
+ * @param type
+ * @param subtype
+ * @param parameters
+ */
private ContentType(final String type, final String subtype, final Map<String, String> parameters) {
- if ((type == null || MEDIA_TYPE_WILDCARD.equals(type)) && !MEDIA_TYPE_WILDCARD.equals(subtype)) {
- throw new IllegalArgumentException("Illegal combination of WILDCARD type with NONE WILDCARD subtype.");
- }
this.type = validateType(type);
this.subtype = validateType(subtype);
@@ -153,13 +109,12 @@ public class ContentType {
}
});
this.parameters.putAll(parameters);
- this.parameters.remove(PARAMETER_Q);
}
}
private String validateType(final String type) {
- if (type == null || type.isEmpty()) {
- return MEDIA_TYPE_WILDCARD;
+ if (type == null || type.isEmpty() || "*".equals(type)) {
+ throw new IllegalArgumentException("Illegal type '" + type + "'.");
}
int len = type.length();
for (int i = 0; i < len; i++) {
@@ -201,14 +156,14 @@ public class ContentType {
* @return a new <code>ContentType</code> object
*/
public static ContentType create(final ContentType contentType,
- final String parameterKey, final String parameterValue) {
- ContentType ct = new ContentType(contentType.type, contentType.subtype, contentType.parameters);
- ct.parameters.put(parameterKey, parameterValue);
- return ct;
+ final String parameterKey, final String parameterValue) {
+ ContentType newContentType = new ContentType(contentType.type, contentType.subtype, contentType.parameters);
+ newContentType.parameters.put(parameterKey, parameterValue);
+ return newContentType;
}
/**
- * Create a {@link ContentType} based on given input string (<code>format</code>).
+ * Creates a {@link ContentType} based on given input string (<code>format</code>).
* Supported format is <code>Media Type</code> format as defined in RFC 7231, chapter 3.1.1.1.
* @param format a string in format as defined in RFC 7231, chapter 3.1.1.1
* @return a new <code>ContentType</code> object
@@ -218,51 +173,10 @@ public class ContentType {
if (format == null) {
throw new IllegalArgumentException("Parameter format MUST NOT be NULL.");
}
-
- // split 'types' and 'parameters'
- String[] typesAndParameters = format.split(PARAMETER_SEPARATOR, 2);
- String types = typesAndParameters[0];
- String parameters = (typesAndParameters.length > 1 ? typesAndParameters[1] : null);
- //
- Map<String, String> parametersMap = parseParameters(parameters);
- //
- if (types.contains(TYPE_SUBTYPE_SEPARATOR)) {
- String[] tokens = types.split(TYPE_SUBTYPE_SEPARATOR);
- if (tokens.length == 2) {
- if (tokens[0] == null || tokens[0].isEmpty()) {
- throw new IllegalArgumentException("No type found in format '" + format + "'.");
- } else if (tokens[1] == null || tokens[1].isEmpty()) {
- throw new IllegalArgumentException("No subtype found in format '" + format + "'.");
- } else {
- return new ContentType(tokens[0], tokens[1], parametersMap);
- }
- } else {
- throw new IllegalArgumentException("Too many '" + TYPE_SUBTYPE_SEPARATOR + "' in format '" + format + "'.");
- }
- } else if (MEDIA_TYPE_WILDCARD.equals(types)) {
- return ContentType.WILDCARD;
- } else {
- throw new IllegalArgumentException("No separator '" + TYPE_SUBTYPE_SEPARATOR + "' was found in format '" + format
- + "'.");
- }
- }
-
- /**
- * Create a list of {@link ContentType} based on given input strings (<code>contentTypes</code>).
- *
- * Supported format is <code>Media Type</code> format as defined in RFC 7231, chapter 3.1.1.1.
- * If one of the given strings can not be parsed an exception is thrown (hence no list is returned with the parseable
- * strings).
- * @param contentTypeStrings a list of strings in format as defined in <code>RFC 2616 section 3.7</code>
- * @return a list of new <code>ContentType</code> object
- * @throws IllegalArgumentException if one of the given input string is not parseable this exceptions is thrown
- */
- public static List<ContentType> create(final List<String> contentTypeStrings) {
- List<ContentType> contentTypes = new ArrayList<ContentType>(contentTypeStrings.size());
- for (String contentTypeString : contentTypeStrings) {
- contentTypes.add(create(contentTypeString));
- }
- return contentTypes;
+ List<String> typeSubtype = new ArrayList<String>();
+ Map<String, String> parameters = new HashMap<String, String>();
+ parse(format, typeSubtype, parameters);
+ return new ContentType(typeSubtype.get(0), typeSubtype.get(1), parameters);
}
/**
@@ -282,23 +196,36 @@ public class ContentType {
}
}
- /**
- * Sort given list (which must contains content-type formatted string) for their {@value #PARAMETER_Q} value
- * as defined in RFC 7231, chapter 3.1.1.1, and RFC 7231, chapter 5.3.1.
- *
- * <b>Attention:</b> For invalid values a {@value #PARAMETER_Q} value from <code>-1</code> is used for sorting.
- *
- * @param toSort list which is sorted and hence re-arranged
- */
- public static void sortForQParameter(final List<String> toSort) {
- Collections.sort(toSort, ContentType.Q_PARAMETER_COMPARATOR);
+ protected static void parse(final String format, List<String> typeSubtype, Map<String, String> parameters) {
+ final String[] typesAndParameters = format.split(PARAMETER_SEPARATOR, 2);
+ final String types = typesAndParameters[0];
+ final String params = (typesAndParameters.length > 1 ? typesAndParameters[1] : null);
+
+ if (types.contains(TYPE_SUBTYPE_SEPARATOR)) {
+ String[] tokens = types.split(TYPE_SUBTYPE_SEPARATOR);
+ if (tokens.length == 2) {
+ if (tokens[0] == null || tokens[0].isEmpty()) {
+ throw new IllegalArgumentException("No type found in format '" + format + "'.");
+ } else if (tokens[1] == null || tokens[1].isEmpty()) {
+ throw new IllegalArgumentException("No subtype found in format '" + format + "'.");
+ } else {
+ typeSubtype.add(tokens[0]);
+ typeSubtype.add(tokens[1]);
+ }
+ } else {
+ throw new IllegalArgumentException("Too many '" + TYPE_SUBTYPE_SEPARATOR + "' in format '" + format + "'.");
+ }
+ } else {
+ throw new IllegalArgumentException("No separator '" + TYPE_SUBTYPE_SEPARATOR
+ + "' was found in format '" + format + "'.");
+ }
+
+ parseParameters(params, parameters);
}
/**
* Valid input are <code>;</code> separated <code>key=value</code> pairs
* without spaces between key and value.
- * <b>Attention:</b> <code>q</code> parameter is validated but not added to result map
- *
* <p>
* See RFC 7231:
* The type, subtype, and parameter name tokens are case-insensitive.
@@ -309,10 +236,9 @@ public class ContentType {
* </p>
*
* @param parameters
- * @return Map with keys mapped to values
+ * @param parameterMap
*/
- private static Map<String, String> parseParameters(final String parameters) {
- Map<String, String> parameterMap = new HashMap<String, String>();
+ private static void parseParameters(final String parameters, Map<String, String> parameterMap) {
if (parameters != null) {
String[] splittedParameters = parameters.split(PARAMETER_SEPARATOR);
for (String parameter : splittedParameters) {
@@ -320,56 +246,12 @@ public class ContentType {
String key = keyValue[0].trim().toLowerCase(Locale.ENGLISH);
String value = keyValue.length > 1 ? keyValue[1] : null;
if (value != null && Character.isWhitespace(value.charAt(0))) {
- throw new IllegalArgumentException("Value of parameter '" + key + "' starts with whitespace ('" + parameters
- + "').");
- }
- if (PARAMETER_Q.equals(key.toLowerCase(Locale.ENGLISH))) {
- // q parameter is only validated but not added
- if (!Q_PARAMETER_VALUE_PATTERN.matcher(value).matches()) {
- throw new IllegalArgumentException("Value of 'q' parameter is not valid (q='" + value + "').");
- }
- } else {
- parameterMap.put(key, value);
- }
- }
- }
- return parameterMap;
- }
-
- /**
- * Parse value of {@value #PARAMETER_Q} <code>parameter</code> out of content type/parameters.
- * If no {@value #PARAMETER_Q} <code>parameter</code> is in <code>content type/parameters</code> parameter found
- * <code>1</code> is returned.
- * If {@value #PARAMETER_Q} <code>parameter</code> is invalid <code>-1</code> is returned.
- *
- * @param contentType parameter which is parsed for {@value #PARAMETER_Q} <code>parameter</code> value
- * @return value of {@value #PARAMETER_Q} <code>parameter</code> or <code>1</code> or <code>-1</code>
- */
- private static Float parseQParameterValue(final String contentType) {
- if (contentType != null) {
- String[] splittedParameters = contentType.split(PARAMETER_SEPARATOR);
- for (String parameter : splittedParameters) {
- String[] keyValue = parameter.split(PARAMETER_KEY_VALUE_SEPARATOR);
- String key = keyValue[0].trim().toLowerCase(Locale.ENGLISH);
- if (PARAMETER_Q.equalsIgnoreCase(key)) {
- String value = keyValue.length > 1 ? keyValue[1] : null;
- if (Q_PARAMETER_VALUE_PATTERN.matcher(value).matches()) {
- return Float.valueOf(value);
- }
- return Float.valueOf(-1);
+ throw new IllegalArgumentException(
+ "Value of parameter '" + key + "' starts with whitespace ('" + parameters + "').");
}
+ parameterMap.put(key, value);
}
}
- return Float.valueOf(1);
- }
-
- /**
- * Check if parameter with key value is an allowed parameter.
- * @param key
- * @return
- */
- private static boolean isParameterAllowed(final String key) {
- return key != null && !PARAMETER_Q.equals(key.toLowerCase(Locale.ENGLISH));
}
public String getType() {
@@ -488,11 +370,7 @@ public class ContentType {
return false;
}
} else if (!subtype.equals(other.subtype)) {
- if (other.subtype == null) {
- return false;
- } else if (!subtype.equals(MEDIA_TYPE_WILDCARD) && !other.subtype.equals(MEDIA_TYPE_WILDCARD)) {
- return false;
- }
+ return false;
}
// type checks
@@ -501,14 +379,7 @@ public class ContentType {
return false;
}
} else if (!type.equals(other.type)) {
- if (!type.equals(MEDIA_TYPE_WILDCARD) && !other.type.equals(MEDIA_TYPE_WILDCARD)) {
- return false;
- }
- }
-
- // if wildcards are set, content types are defined as 'equal'
- if (countWildcards() > 0 || other.countWildcards() > 0) {
- return true;
+ return false;
}
return null;
@@ -523,19 +394,12 @@ public class ContentType {
* returned
*/
private static boolean areEqual(final String first, final String second) {
- if (first == null) {
- if (second != null) {
- return false;
- }
- } else if (!first.equalsIgnoreCase(second)) {
- return false;
- }
- return true;
+ return first == null && second == null || first.equalsIgnoreCase(second);
}
/**
- * Get {@link ContentType} as string as defined in RFC 7231 (http://www.ietf.org/rfc/rfc7231.txt, chapter 3.1.1.1:
- * Media Type)
+ * Get {@link ContentType} as string as defined in RFC 7231
+ * (http://www.ietf.org/rfc/rfc7231.txt, chapter 3.1.1.1: Media Type)
* @return string representation of <code>ContentType</code> object
*/
public String toContentTypeString() {
@@ -544,10 +408,7 @@ public class ContentType {
sb.append(type).append(TYPE_SUBTYPE_SEPARATOR).append(subtype);
for (String key : parameters.keySet()) {
- if (isParameterAllowed(key)) {
- String value = parameters.get(key);
- sb.append(";").append(key).append("=").append(value);
- }
+ sb.append(";").append(key).append("=").append(parameters.get(key));
}
return sb.toString();
}
@@ -556,150 +417,4 @@ public class ContentType {
public String toString() {
return toContentTypeString();
}
-
- /**
- * Find best match between this {@link ContentType} and the {@link ContentType} in the list.
- * If a match (this {@link ContentType} is equal to a {@link ContentType} in list) is found either this or the
- * {@link ContentType} from the list is returned based on which {@link ContentType} has less "**" characters set
- * (checked with {@link #compareWildcardCounts(ContentType)}.
- * If no match (none {@link ContentType} in list is equal to this {@link ContentType}) is found <code>NULL</code> is
- * returned.
- *
- * @param toMatchContentTypes list of {@link ContentType}s which are matches against this {@link ContentType}
- * @return best matched content type in list or <code>NULL</code> if none content type match to this content type
- * instance
- */
- public ContentType match(final List<ContentType> toMatchContentTypes) {
- for (ContentType supportedContentType : toMatchContentTypes) {
- if (equals(supportedContentType)) {
- if (compareWildcardCounts(supportedContentType) < 0) {
- return this;
- } else {
- return supportedContentType;
- }
- }
- }
- return null;
- }
-
- /**
- * Find best match between this {@link ContentType} and the {@link ContentType} in the list ignoring all set
- * parameters.
- * If a match (this {@link ContentType} is equal to a {@link ContentType} in list) is found either this or the
- * {@link ContentType} from the list is returned based on which {@link ContentType} has less "**" characters set
- * (checked with {@link #compareWildcardCounts(ContentType)}.
- * If no match (none {@link ContentType} in list is equal to this {@link ContentType}) is found <code>NULL</code> is
- * returned.
- *
- * @param toMatchContentTypes list of {@link ContentType}s which are matches against this {@link ContentType}
- * @return best matched content type in list or <code>NULL</code> if none content type match to this content type
- * instance
- */
- public ContentType matchCompatible(final List<ContentType> toMatchContentTypes) {
- for (ContentType supportedContentType : toMatchContentTypes) {
- if (isCompatible(supportedContentType)) {
- if (compareWildcardCounts(supportedContentType) < 0) {
- return this;
- } else {
- return supportedContentType;
- }
- }
- }
- return null;
- }
-
- /**
- * Check if a valid compatible match for this {@link ContentType} exists in given list.
- * Compatible in this case means that <b>all set parameters are ignored</b>.
- * For more detail what a valid match is see {@link #matchCompatible(List)}.
- *
- * @param toMatchContentTypes list of {@link ContentType}s which are matches against this {@link ContentType}
- * @return <code>true</code> if a compatible content type was found in given list
- * or <code>false</code> if none compatible content type match was found
- */
- public boolean hasCompatible(final List<ContentType> toMatchContentTypes) {
- return matchCompatible(toMatchContentTypes) != null;
- }
-
- /**
- * Check if a valid match for this {@link ContentType} exists in given list.
- * For more detail what a valid match is see {@link #match(List)}.
- *
- * @param toMatchContentTypes list of {@link ContentType}s which are matches against this {@link ContentType}
- * @return <code>true</code> if a matching content type was found in given list
- * or <code>false</code> if none matching content type match was found
- */
- public boolean hasMatch(final List<ContentType> toMatchContentTypes) {
- return match(toMatchContentTypes) != null;
- }
-
- /**
- * Compare wildcards counts/weights of both {@link ContentType}.
- *
- * The smaller {@link ContentType} has lesser weighted wildcards then the bigger {@link ContentType}.
- * As result this method returns this object weighted wildcards minus the given parameter object weighted wildcards.
- *
- * A type wildcard is weighted with <code>2</code> and a subtype wildcard is weighted with <code>1</code>.
- *
- * @param otherContentType {@link ContentType} to be compared to
- * @return this object weighted wildcards minus the given parameter object weighted wildcards.
- */
- public int compareWildcardCounts(final ContentType otherContentType) {
- return countWildcards() - otherContentType.countWildcards();
- }
-
- private int countWildcards() {
- int count = 0;
- if (MEDIA_TYPE_WILDCARD.equals(type)) {
- count += 2;
- }
- if (MEDIA_TYPE_WILDCARD.equals(subtype)) {
- count++;
- }
- return count;
- }
-
- /**
- *
- * @return <code>true</code> if <code>type</code> or <code>subtype</code> of this instance is a "*".
- */
- public boolean hasWildcard() {
- return (MEDIA_TYPE_WILDCARD.equals(type) || MEDIA_TYPE_WILDCARD.equals(subtype));
- }
-
- /**
- *
- * @return <code>true</code> if both <code>type</code> and <code>subtype</code> of this instance are a "*".
- */
- public boolean isWildcard() {
- return (MEDIA_TYPE_WILDCARD.equals(type) && MEDIA_TYPE_WILDCARD.equals(subtype));
- }
-
- public static List<ContentType> convert(final List<String> types) {
- List<ContentType> results = new ArrayList<ContentType>();
- for (String contentType : types) {
- results.add(ContentType.create(contentType));
- }
- return results;
- }
-
- /**
- * Check if a valid match for given content type formated string (<code>toMatch</code>) exists in given list.
- * Therefore the given content type formated string (<code>toMatch</code>) is converted into a {@link ContentType}
- * with a simple {@link #create(String)} call (during which an exception can occur).
- *
- * For more detail in general see {@link #hasMatch(List)} and for what a valid match is see {@link #match(List)}.
- *
- * @param toMatch content type formated string (<code>toMatch</code>) for which is checked if a match exists in given
- * list
- * @param matchExamples list of {@link ContentType}s which are matches against content type formated string
- * (<code>toMatch</code>)
- * @return <code>true</code> if a matching content type was found in given list
- * or <code>false</code> if none matching content type match was found
- */
- public static boolean match(final String toMatch, final ContentType... matchExamples) {
- ContentType toMatchContentType = ContentType.create(toMatch);
-
- return toMatchContentType.hasMatch(Arrays.asList(matchExamples));
- }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce359852/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataFormat.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataFormat.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataFormat.java
index bc122e2..d1e3cc1 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataFormat.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataFormat.java
@@ -57,25 +57,25 @@ public enum ODataFormat {
private static final String JSON_METADATA_PARAMETER_V4 = "odata.metadata";
private static final Map<ODataServiceVersion, Map<ODataFormat, ContentType>> FORMAT_PER_VERSION = new
- HashMap<ODataServiceVersion, Map<ODataFormat, ContentType>>();
+ HashMap<ODataServiceVersion, Map<ODataFormat, ContentType>>();
static {
final Map<ODataFormat, ContentType> v3 = new HashMap<ODataFormat, ContentType>();
v3.put(ODataFormat.JSON_NO_METADATA, ContentType.create(
- ContentType.APPLICATION_JSON, JSON_METADATA_PARAMETER_V3, "nometadata"));
+ ContentType.APPLICATION_JSON, JSON_METADATA_PARAMETER_V3, "nometadata"));
v3.put(ODataFormat.JSON, ContentType.create(
- ContentType.APPLICATION_JSON, JSON_METADATA_PARAMETER_V3, "minimalmetadata"));
+ ContentType.APPLICATION_JSON, JSON_METADATA_PARAMETER_V3, "minimalmetadata"));
v3.put(ODataFormat.JSON_FULL_METADATA, ContentType.create(
- ContentType.APPLICATION_JSON, JSON_METADATA_PARAMETER_V3, "fullmetadata"));
+ ContentType.APPLICATION_JSON, JSON_METADATA_PARAMETER_V3, "fullmetadata"));
FORMAT_PER_VERSION.put(ODataServiceVersion.V30, v3);
final Map<ODataFormat, ContentType> v4 = new HashMap<ODataFormat, ContentType>();
v4.put(ODataFormat.JSON_NO_METADATA, ContentType.create(
- ContentType.APPLICATION_JSON, JSON_METADATA_PARAMETER_V4, "none"));
+ ContentType.APPLICATION_JSON, JSON_METADATA_PARAMETER_V4, "none"));
v4.put(ODataFormat.JSON, ContentType.create(
- ContentType.APPLICATION_JSON, JSON_METADATA_PARAMETER_V4, "minimal"));
+ ContentType.APPLICATION_JSON, JSON_METADATA_PARAMETER_V4, "minimal"));
v4.put(ODataFormat.JSON_FULL_METADATA, ContentType.create(
- ContentType.APPLICATION_JSON, JSON_METADATA_PARAMETER_V4, "full"));
+ ContentType.APPLICATION_JSON, JSON_METADATA_PARAMETER_V4, "full"));
FORMAT_PER_VERSION.put(ODataServiceVersion.V40, v4);
}
@@ -121,12 +121,9 @@ public enum ODataFormat {
if (contentType == null) {
return null;
}
- if (contentType.hasWildcard()) {
- throw new IllegalArgumentException("Content Type must be fully specified!");
- }
if (contentType.isCompatible(ContentType.APPLICATION_ATOM_XML)
- || contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC)) {
+ || contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC)) {
return ATOM;
} else if (contentType.isCompatible(ContentType.APPLICATION_XML)) {
return XML;
@@ -135,8 +132,8 @@ public enum ODataFormat {
if (jsonVariant != null) {
for (ODataFormat candidate : FORMAT_PER_VERSION.get(ODataServiceVersion.V30).keySet()) {
if (FORMAT_PER_VERSION.get(ODataServiceVersion.V30).get(candidate).getParameters()
- .get(JSON_METADATA_PARAMETER_V3)
- .equals(jsonVariant)) {
+ .get(JSON_METADATA_PARAMETER_V3)
+ .equals(jsonVariant)) {
return candidate;
}
}
@@ -145,8 +142,8 @@ public enum ODataFormat {
if (jsonVariant != null) {
for (ODataFormat candidate : FORMAT_PER_VERSION.get(ODataServiceVersion.V40).keySet()) {
if (FORMAT_PER_VERSION.get(ODataServiceVersion.V40).get(candidate).getParameters()
- .get(JSON_METADATA_PARAMETER_V4)
- .equals(jsonVariant)) {
+ .get(JSON_METADATA_PARAMETER_V4)
+ .equals(jsonVariant)) {
return candidate;
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ce359852/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValue.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValue.java
index 2d91ffd..79566bb 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValue.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValue.java
@@ -69,11 +69,6 @@ public abstract class AbstractValue implements Value {
}
@Override
- public NullValue asNull() {
- return isNull() ? (NullValue) this : null;
- }
-
- @Override
public PrimitiveValue asPrimitive() {
return isPrimitive() ? (PrimitiveValue) this : null;
}