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 aee96026e..6fc7b090c 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 @@ -24,5 +24,5 @@ import org.apache.olingo.commons.api.format.ODataPubFormat; /** * This class implements an OData retrieve query request returning a single entity. */ -public interface ODataEntityRequest extends ODataRetrieveRequest { +public interface ODataEntityRequest extends ODataRetrieveRequest { } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/ODataRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/ODataRequestImpl.java index 9719e2249..d45902a1e 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/ODataRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/ODataRequestImpl.java @@ -38,7 +38,6 @@ import org.apache.olingo.client.api.communication.ODataClientErrorException; import org.apache.olingo.client.api.communication.ODataServerErrorException; 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.header.ODataPreferences; 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; 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 f1ae24b3f..3fc51e11c 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 @@ -44,7 +44,9 @@ public abstract class AbstractODataRetrieveRequest * @param formatRef reference class for the format being used * @param query query to be executed. */ - public AbstractODataRetrieveRequest(final CommonODataClient odataClient, final Class formatRef, final URI query) { + public AbstractODataRetrieveRequest(final CommonODataClient odataClient, final Class formatRef, + final URI query) { + super(odataClient, formatRef, HttpMethod.GET, query); } @@ -67,14 +69,15 @@ public abstract class AbstractODataRetrieveRequest /** * Response abstract class about an ODataRetrieveRequest. */ - protected abstract class ODataRetrieveResponseImpl extends AbstractODataResponse implements ODataRetrieveResponse { + protected abstract class AbstractODataRetrieveResponse + extends AbstractODataResponse implements ODataRetrieveResponse { /** * Constructor. *

* Just to create response templates to be initialized from batch. */ - protected ODataRetrieveResponseImpl() { + protected AbstractODataRetrieveResponse() { super(); } @@ -84,7 +87,7 @@ public abstract class AbstractODataRetrieveRequest * @param client HTTP client. * @param res HTTP response. */ - protected ODataRetrieveResponseImpl(final HttpClient client, final HttpResponse res) { + protected AbstractODataRetrieveResponse(final HttpClient client, final HttpResponse res) { super(client, res); } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/EdmMetadataRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/EdmMetadataRequestImpl.java index 96df2d6fa..00f9cb4b6 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/EdmMetadataRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/EdmMetadataRequestImpl.java @@ -49,7 +49,7 @@ class EdmMetadataRequestImpl extends AbstractMetadataRequestImpl implements final ODataRetrieveResponse> xmlMetadataResponse = odataClient.getRetrieveRequestFactory().getXMLMetadataRequest(serviceRoot).execute(); - return new ODataRetrieveResponseImpl() { + return new AbstractODataRetrieveResponse() { private Edm metadata = null; @Override 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 141b82e0c..3c01148e6 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 @@ -32,8 +32,8 @@ import org.apache.olingo.commons.api.format.ODataPubFormat; /** * This class implements an OData retrieve query request returning a single entity. */ -public class ODataEntityRequestImpl - extends AbstractODataRetrieveRequest implements ODataEntityRequest { +public class ODataEntityRequestImpl + extends AbstractODataRetrieveRequest implements ODataEntityRequest { /** * Private constructor. @@ -41,31 +41,29 @@ public class ODataEntityRequestImpl * @param odataClient client instance getting this request * @param query query to be executed. */ - public ODataEntityRequestImpl(final CommonODataClient odataClient, final URI query) { + public ODataEntityRequestImpl(final CommonODataClient odataClient, final URI query) { super(odataClient, ODataPubFormat.class, query); } - /** - * {@inheritDoc } - */ @Override - public ODataRetrieveResponse execute() { + public ODataRetrieveResponse execute() { return new ODataEntityResponseImpl(httpClient, doExecute()); } /** * Response class about an ODataEntityRequest. */ - public class ODataEntityResponseImpl extends ODataRetrieveResponseImpl { + public class ODataEntityResponseImpl extends AbstractODataRetrieveResponse { - private T entity = null; + private E entity = null; /** * Constructor. - *

+ *
* Just to create response templates to be initialized from batch. */ private ODataEntityResponseImpl() { + super(); } /** @@ -78,18 +76,15 @@ public class ODataEntityRequestImpl super(client, res); } - /** - * {@inheritDoc } - */ @Override @SuppressWarnings("unchecked") - public T getBody() { + public E getBody() { if (entity == null) { try { final Container container = odataClient.getDeserializer().toEntry(getRawResponse(), ODataPubFormat.fromString(getContentType())); - entity = (T) odataClient.getBinder().getODataEntity(extractFromContainer(container)); + entity = (E) odataClient.getBinder().getODataEntity(extractFromContainer(container)); } finally { this.close(); } 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 a1e9a8bed..b2e3b5777 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 @@ -60,7 +60,7 @@ public class ODataEntitySetIteratorRequestImpl /** * Response class about an ODataEntitySetRequest. */ - protected class ODataEntitySetResponseImpl extends ODataRetrieveResponseImpl { + protected class ODataEntitySetResponseImpl extends AbstractODataRetrieveResponse { /** * Constructor. 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 4460be309..8159281c8 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 @@ -65,7 +65,7 @@ public class ODataMediaRequestImpl extends AbstractODataRetrieveRequest return new ODataPropertyResponseImpl(httpClient, res); } - protected class ODataPropertyResponseImpl extends ODataRetrieveResponseImpl { + protected class ODataPropertyResponseImpl extends AbstractODataRetrieveResponse { private T property = null; 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 bf37a3225..2b9f347ae 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 @@ -57,7 +57,7 @@ public class ODataServiceDocumentRequestImpl extends AbstractODataRetrieveReques /** * Response class about an ODataServiceDocumentRequest. */ - protected class ODataServiceResponseImpl extends ODataRetrieveResponseImpl { + protected class ODataServiceResponseImpl extends AbstractODataRetrieveResponse { private ODataServiceDocument serviceDocument = null; 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 cd8ca18fb..460b695bc 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 @@ -58,7 +58,7 @@ public class ODataValueRequestImpl extends AbstractODataRetrieveRequest execute() { - return new ODataRetrieveResponseImpl(httpClient, doExecute()) { + return new AbstractODataRetrieveResponse(httpClient, doExecute()) { @Override public XMLMetadata getBody() { @@ -91,7 +91,7 @@ public class XMLMetadataRequestImpl extends AbstractMetadataRequestImpl schemas = new ArrayList(); diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/BatchTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/BatchTestITCase.java index b154363f8..2e4e0df83 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/BatchTestITCase.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/BatchTestITCase.java @@ -60,11 +60,11 @@ import org.junit.Test; public class BatchTestITCase extends AbstractTestITCase { - private static String PREFIX = "!!PREFIX!!"; + private static final String PREFIX = "!!PREFIX!!"; - private static String SUFFIX = "!!SUFFIX!!"; + private static final String SUFFIX = "!!SUFFIX!!"; - private static int MAX = 10000; + private static final int MAX = 10000; @Test public void stringStreaming() { @@ -78,7 +78,7 @@ public class BatchTestITCase extends AbstractTestITCase { streaming.addObject((i + ") send info\n").getBytes()); } - streaming.addObject((SUFFIX).getBytes()); + streaming.addObject(SUFFIX.getBytes()); streaming.finalizeBody(); } @@ -304,7 +304,7 @@ public class BatchTestITCase extends AbstractTestITCase { assertEquals(202, response.getStatusCode()); assertEquals("Accepted", response.getStatusMessage()); final Iterator iter = response.getBody(); - + // retrive the first item (ODataRetrieve) ODataBatchResponseItem item = iter.next(); assertTrue(item instanceof ODataRetrieveResponseItem); @@ -315,10 +315,11 @@ public class BatchTestITCase extends AbstractTestITCase { assertEquals(200, res.getStatusCode()); assertEquals("OK", res.getStatusMessage()); - ODataEntityResponseImpl entres = (ODataEntityResponseImpl) res; - ODataEntity entity = (ODataEntity)entres.getBody(); - - assertEquals(new Integer(-10), entity.getProperty("CustomerId").getPrimitiveValue().toCastValue(Integer.class)); + ODataEntityRequestImpl.ODataEntityResponseImpl entres = + (ODataEntityRequestImpl.ODataEntityResponseImpl) res; + + ODataEntity entity = entres.getBody(); + assertEquals(-10, entity.getProperty("CustomerId").getPrimitiveValue().toCastValue(Integer.class), 0); // retrieve the second item (ODataChangeset) item = iter.next(); @@ -349,8 +350,8 @@ public class BatchTestITCase extends AbstractTestITCase { assertEquals(200, res.getStatusCode()); assertEquals("OK", res.getStatusMessage()); - entres = (ODataEntityResponseImpl) res; - entity = (ODataEntity)entres.getBody(); + entres = (ODataEntityRequestImpl.ODataEntityResponseImpl) res; + entity = entres.getBody(); assertEquals("new description from batch", entity.getProperty("Description").getPrimitiveValue().toCastValue(String.class)); diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityCreateTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityCreateTestITCase.java index 0a62eccc2..2329aae03 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityCreateTestITCase.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityCreateTestITCase.java @@ -30,7 +30,6 @@ 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.header.ODataPreferences; 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.cud.v3.UpdateType; diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityUpdateTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityUpdateTestITCase.java index 10b3891e8..750709c56 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityUpdateTestITCase.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityUpdateTestITCase.java @@ -26,7 +26,6 @@ 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.header.ODataPreferences; import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest; import org.apache.olingo.client.api.communication.request.cud.v3.UpdateType; import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest; diff --git a/pom.xml b/pom.xml index 108276959..a2fb86966 100644 --- a/pom.xml +++ b/pom.xml @@ -70,7 +70,7 @@ 1.1.3 2.0 4.3 - 3.1.0 + 3.0.1 2.7.11 4.0.3.RELEASE