[OLINGO-712] HeaderName is redundant (there is HttpHeader)
Signed-off-by: Christian Amend <christian.amend@sap.com>
This commit is contained in:
parent
a3fbf39f53
commit
d54b071198
|
@ -33,7 +33,6 @@ import java.util.TimeZone;
|
||||||
|
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.client.api.communication.ODataClientErrorException;
|
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.invoke.ODataInvokeRequest;
|
import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest;
|
||||||
import org.apache.olingo.client.api.communication.response.ODataInvokeResponse;
|
import org.apache.olingo.client.api.communication.response.ODataInvokeResponse;
|
||||||
import org.apache.olingo.client.api.domain.ClientCollectionValue;
|
import org.apache.olingo.client.api.domain.ClientCollectionValue;
|
||||||
|
@ -45,6 +44,7 @@ import org.apache.olingo.client.api.domain.ClientValue;
|
||||||
import org.apache.olingo.client.core.ODataClientFactory;
|
import org.apache.olingo.client.core.ODataClientFactory;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||||
|
import org.apache.olingo.commons.api.http.HttpHeader;
|
||||||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||||
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
||||||
|
@ -80,7 +80,7 @@ public class ActionImportITCase extends AbstractBaseTestITCase {
|
||||||
request.setPrefer(getClient().newPreferences().returnMinimal());
|
request.setPrefer(getClient().newPreferences().returnMinimal());
|
||||||
final ODataInvokeResponse<ClientProperty> response = request.execute();
|
final ODataInvokeResponse<ClientProperty> response = request.execute();
|
||||||
assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
|
assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
|
||||||
assertEquals("return=minimal", response.getHeader(HeaderName.preferenceApplied).iterator().next());
|
assertEquals("return=minimal", response.getHeader(HttpHeader.PREFERENCE_APPLIED).iterator().next());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -37,7 +37,6 @@ import java.util.List;
|
||||||
import org.apache.olingo.client.api.EdmEnabledODataClient;
|
import org.apache.olingo.client.api.EdmEnabledODataClient;
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.client.api.communication.ODataClientErrorException;
|
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.ODataDeleteRequest;
|
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.ODataEntityCreateRequest;
|
||||||
import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
|
import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
|
||||||
|
@ -415,7 +414,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
||||||
|
|
||||||
final ODataEntityCreateResponse<ClientEntity> response = request.execute();
|
final ODataEntityCreateResponse<ClientEntity> response = request.execute();
|
||||||
assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
|
assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
|
||||||
assertEquals("return=minimal", response.getHeader(HeaderName.preferenceApplied).iterator().next());
|
assertEquals("return=minimal", response.getHeader(HttpHeader.PREFERENCE_APPLIED).iterator().next());
|
||||||
assertEquals(SERVICE_URI + "/ESTwoPrim(1)", response.getHeader(HttpHeader.LOCATION).iterator().next());
|
assertEquals(SERVICE_URI + "/ESTwoPrim(1)", response.getHeader(HttpHeader.LOCATION).iterator().next());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -696,7 +695,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
||||||
final ODataEntityUpdateResponse<ClientEntity> response = request.execute();
|
final ODataEntityUpdateResponse<ClientEntity> response = request.execute();
|
||||||
|
|
||||||
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
|
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
|
||||||
assertEquals("return=representation", response.getHeader(HeaderName.preferenceApplied).iterator().next());
|
assertEquals("return=representation", response.getHeader(HttpHeader.PREFERENCE_APPLIED).iterator().next());
|
||||||
assertTrue(response.getBody().getProperty("PropertyString").hasNullValue());
|
assertTrue(response.getBody().getProperty("PropertyString").hasNullValue());
|
||||||
assertEquals(34, response.getBody().getProperty("PropertyDecimal").getPrimitiveValue().toValue());
|
assertEquals(34, response.getBody().getProperty("PropertyDecimal").getPrimitiveValue().toValue());
|
||||||
}
|
}
|
||||||
|
@ -843,7 +842,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
||||||
request.setPrefer(getClient().newPreferences().returnMinimal());
|
request.setPrefer(getClient().newPreferences().returnMinimal());
|
||||||
final ODataEntityUpdateResponse<ClientEntity> response = request.execute();
|
final ODataEntityUpdateResponse<ClientEntity> response = request.execute();
|
||||||
assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
|
assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
|
||||||
assertEquals("return=minimal", response.getHeader(HeaderName.preferenceApplied).iterator().next());
|
assertEquals("return=minimal", response.getHeader(HttpHeader.PREFERENCE_APPLIED).iterator().next());
|
||||||
final String cookie = response.getHeader(HttpHeader.SET_COOKIE).iterator().next();
|
final String cookie = response.getHeader(HttpHeader.SET_COOKIE).iterator().next();
|
||||||
|
|
||||||
final ODataEntityRequest<ClientEntity> entityRequest = client.getRetrieveRequestFactory()
|
final ODataEntityRequest<ClientEntity> entityRequest = client.getRetrieveRequestFactory()
|
||||||
|
|
|
@ -33,7 +33,6 @@ import java.util.Iterator;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.client.api.communication.ODataClientErrorException;
|
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.ODataDeleteRequest;
|
import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest;
|
||||||
import org.apache.olingo.client.api.communication.request.cud.ODataPropertyUpdateRequest;
|
import org.apache.olingo.client.api.communication.request.cud.ODataPropertyUpdateRequest;
|
||||||
import org.apache.olingo.client.api.communication.request.cud.ODataValueUpdateRequest;
|
import org.apache.olingo.client.api.communication.request.cud.ODataValueUpdateRequest;
|
||||||
|
@ -380,7 +379,7 @@ public class PrimitiveComplexITCase extends AbstractBaseTestITCase {
|
||||||
|
|
||||||
final ODataValueUpdateResponse response = request.execute();
|
final ODataValueUpdateResponse response = request.execute();
|
||||||
assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
|
assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
|
||||||
assertEquals("return=minimal", response.getHeader(HeaderName.preferenceApplied).iterator().next());
|
assertEquals("return=minimal", response.getHeader(HttpHeader.PREFERENCE_APPLIED).iterator().next());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -25,13 +25,13 @@ import java.net.URI;
|
||||||
|
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.client.api.communication.ODataClientErrorException;
|
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.retrieve.ODataEntitySetRequest;
|
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.communication.response.ODataRetrieveResponse;
|
||||||
import org.apache.olingo.client.api.domain.ClientEntity;
|
import org.apache.olingo.client.api.domain.ClientEntity;
|
||||||
import org.apache.olingo.client.api.domain.ClientEntitySet;
|
import org.apache.olingo.client.api.domain.ClientEntitySet;
|
||||||
import org.apache.olingo.client.core.ODataClientFactory;
|
import org.apache.olingo.client.core.ODataClientFactory;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||||
|
import org.apache.olingo.commons.api.http.HttpHeader;
|
||||||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||||
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
||||||
|
@ -268,7 +268,7 @@ public class SystemQueryOptionITCase extends AbstractBaseTestITCase {
|
||||||
request.setPrefer(getClient().newPreferences().maxPageSize(7));
|
request.setPrefer(getClient().newPreferences().maxPageSize(7));
|
||||||
|
|
||||||
final ODataRetrieveResponse<ClientEntitySet> response = request.execute();
|
final ODataRetrieveResponse<ClientEntitySet> response = request.execute();
|
||||||
assertEquals("odata.maxpagesize=7", response.getHeader(HeaderName.preferenceApplied).iterator().next());
|
assertEquals("odata.maxpagesize=7", response.getHeader(HttpHeader.PREFERENCE_APPLIED).iterator().next());
|
||||||
assertEquals(SERVICE_URI + '/' + ES_SERVER_SIDE_PAGING + "?%24skiptoken=1%2A" + 7,
|
assertEquals(SERVICE_URI + '/' + ES_SERVER_SIDE_PAGING + "?%24skiptoken=1%2A" + 7,
|
||||||
response.getBody().getNext().toASCIIString());
|
response.getBody().getNext().toASCIIString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ import static org.junit.Assert.assertEquals;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
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.BatchManager;
|
||||||
import org.apache.olingo.client.api.communication.request.batch.ODataBatchRequest;
|
import org.apache.olingo.client.api.communication.request.batch.ODataBatchRequest;
|
||||||
import org.apache.olingo.client.api.communication.request.batch.ODataChangeset;
|
import org.apache.olingo.client.api.communication.request.batch.ODataChangeset;
|
||||||
|
@ -40,6 +39,7 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
import org.apache.olingo.commons.api.format.ContentType;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||||
|
import org.apache.olingo.commons.api.http.HttpHeader;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class AuthBatchTestITCase extends AbstractTestITCase {
|
public class AuthBatchTestITCase extends AbstractTestITCase {
|
||||||
|
@ -71,7 +71,7 @@ public class AuthBatchTestITCase extends AbstractTestITCase {
|
||||||
final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(baseURL);
|
final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(baseURL);
|
||||||
request.setAccept(ACCEPT.toContentTypeString());
|
request.setAccept(ACCEPT.toContentTypeString());
|
||||||
request.addCustomHeader("User-Agent", "Apache Olingo OData Client");
|
request.addCustomHeader("User-Agent", "Apache Olingo OData Client");
|
||||||
request.addCustomHeader(HeaderName.acceptCharset, "UTF-8");
|
request.addCustomHeader(HttpHeader.ACCEPT_CHARSET, "UTF-8");
|
||||||
|
|
||||||
final BatchManager streamManager = request.payloadManager();
|
final BatchManager streamManager = request.payloadManager();
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,6 @@ import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
import org.apache.olingo.client.api.ODataBatchConstants;
|
import org.apache.olingo.client.api.ODataBatchConstants;
|
||||||
import org.apache.olingo.client.api.communication.header.HeaderName;
|
|
||||||
import org.apache.olingo.client.api.communication.request.AsyncBatchRequestWrapper;
|
import org.apache.olingo.client.api.communication.request.AsyncBatchRequestWrapper;
|
||||||
import org.apache.olingo.client.api.communication.request.ODataPayloadManager;
|
import org.apache.olingo.client.api.communication.request.ODataPayloadManager;
|
||||||
import org.apache.olingo.client.api.communication.request.batch.BatchManager;
|
import org.apache.olingo.client.api.communication.request.batch.BatchManager;
|
||||||
|
@ -68,6 +67,7 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
import org.apache.olingo.commons.api.format.ContentType;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||||
|
import org.apache.olingo.commons.api.http.HttpHeader;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class BatchTestITCase extends AbstractTestITCase {
|
public class BatchTestITCase extends AbstractTestITCase {
|
||||||
|
@ -570,7 +570,7 @@ public class BatchTestITCase extends AbstractTestITCase {
|
||||||
assertEquals(202, res.getStatusCode());
|
assertEquals(202, res.getStatusCode());
|
||||||
assertEquals("Accepted", res.getStatusMessage());
|
assertEquals("Accepted", res.getStatusMessage());
|
||||||
|
|
||||||
final Collection<String> newMonitorLocation = res.getHeader(HeaderName.location);
|
final Collection<String> newMonitorLocation = res.getHeader(HttpHeader.LOCATION);
|
||||||
if (newMonitorLocation != null && !newMonitorLocation.isEmpty()) {
|
if (newMonitorLocation != null && !newMonitorLocation.isEmpty()) {
|
||||||
responseWrapper.forceNextMonitorCheck(URI.create(newMonitorLocation.iterator().next()));
|
responseWrapper.forceNextMonitorCheck(URI.create(newMonitorLocation.iterator().next()));
|
||||||
// .... now you can start again with isDone() and getODataResponse().
|
// .... now you can start again with isDone() and getODataResponse().
|
||||||
|
|
|
@ -28,7 +28,6 @@ import java.net.URI;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import org.apache.olingo.client.api.communication.header.HeaderName;
|
|
||||||
import org.apache.olingo.client.api.communication.request.AsyncRequestWrapper;
|
import org.apache.olingo.client.api.communication.request.AsyncRequestWrapper;
|
||||||
import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest;
|
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.ODataEntityCreateRequest;
|
||||||
|
@ -55,6 +54,7 @@ import org.apache.olingo.client.core.uri.URIUtils;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||||
|
import org.apache.olingo.commons.api.http.HttpHeader;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,8 +75,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
||||||
final ODataEntityRequest<ClientEntity> req =
|
final ODataEntityRequest<ClientEntity> req =
|
||||||
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
||||||
|
|
||||||
assertEquals("4.0", req.getHeader("OData-MaxVersion"));
|
assertEquals("4.0", req.getHeader(HttpHeader.ODATA_MAX_VERSION));
|
||||||
assertEquals("4.0", req.getHeader(HeaderName.odataMaxVersion.toString()));
|
|
||||||
|
|
||||||
assertNotNull(req.execute().getBody());
|
assertNotNull(req.execute().getBody());
|
||||||
}
|
}
|
||||||
|
@ -121,16 +120,12 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
||||||
req.setFormat(ODataFormat.JSON_FULL_METADATA);
|
req.setFormat(ODataFormat.JSON_FULL_METADATA);
|
||||||
|
|
||||||
// check for OData-Version
|
// check for OData-Version
|
||||||
assertEquals("4.0", req.getHeader("OData-Version"));
|
assertEquals("4.0", req.getHeader(HttpHeader.ODATA_VERSION));
|
||||||
assertEquals("4.0", req.getHeader(HeaderName.odataVersion.toString()));
|
|
||||||
|
|
||||||
// check for Content-Type
|
// check for Content-Type
|
||||||
assertEquals(
|
assertEquals(
|
||||||
ODataFormat.JSON_FULL_METADATA.getContentType().toContentTypeString(),
|
ODataFormat.JSON_FULL_METADATA.getContentType().toContentTypeString(),
|
||||||
req.getHeader("Content-Type"));
|
req.getHeader(HttpHeader.CONTENT_TYPE));
|
||||||
assertEquals(
|
|
||||||
ODataFormat.JSON_FULL_METADATA.getContentType().toContentTypeString(),
|
|
||||||
req.getHeader(HeaderName.contentType.toString()));
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
ODataFormat.JSON_FULL_METADATA.getContentType().toContentTypeString(),
|
ODataFormat.JSON_FULL_METADATA.getContentType().toContentTypeString(),
|
||||||
req.getContentType());
|
req.getContentType());
|
||||||
|
@ -158,8 +153,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
||||||
final ODataEntityRequest<ClientEntity> req =
|
final ODataEntityRequest<ClientEntity> req =
|
||||||
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
||||||
|
|
||||||
assertEquals("4.0", req.getHeader("OData-MaxVersion"));
|
assertEquals("4.0", req.getHeader(HttpHeader.ODATA_MAX_VERSION));
|
||||||
assertEquals("4.0", req.getHeader(HeaderName.odataMaxVersion.toString()));
|
|
||||||
|
|
||||||
final ODataRetrieveResponse<ClientEntity> res = req.execute();
|
final ODataRetrieveResponse<ClientEntity> res = req.execute();
|
||||||
final ClientEntity entity = res.getBody();
|
final ClientEntity entity = res.getBody();
|
||||||
|
@ -411,7 +405,6 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
||||||
req.setFormat(ODataFormat.JSON);
|
req.setFormat(ODataFormat.JSON);
|
||||||
|
|
||||||
assertEquals("application/json;odata.metadata=minimal", req.getHeader("Accept"));
|
assertEquals("application/json;odata.metadata=minimal", req.getHeader("Accept"));
|
||||||
assertEquals("application/json;odata.metadata=minimal", req.getHeader(HeaderName.accept.toString()));
|
|
||||||
assertEquals("application/json;odata.metadata=minimal", req.getAccept());
|
assertEquals("application/json;odata.metadata=minimal", req.getAccept());
|
||||||
|
|
||||||
final ODataRetrieveResponse<ClientEntity> res = req.execute();
|
final ODataRetrieveResponse<ClientEntity> res = req.execute();
|
||||||
|
|
|
@ -32,7 +32,6 @@ import java.util.UUID;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.lang3.RandomStringUtils;
|
import org.apache.commons.lang3.RandomStringUtils;
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.client.api.communication.header.HeaderName;
|
|
||||||
import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
|
import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
|
||||||
import org.apache.olingo.client.api.communication.request.cud.UpdateType;
|
import org.apache.olingo.client.api.communication.request.cud.UpdateType;
|
||||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
|
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
|
||||||
|
@ -53,6 +52,7 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||||
|
import org.apache.olingo.commons.api.http.HttpHeader;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class MediaEntityTestITCase extends AbstractTestITCase {
|
public class MediaEntityTestITCase extends AbstractTestITCase {
|
||||||
|
@ -108,7 +108,7 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
|
||||||
final ODataMediaEntityCreateResponse<ClientEntity> createRes = streamManager.getResponse();
|
final ODataMediaEntityCreateResponse<ClientEntity> createRes = streamManager.getResponse();
|
||||||
assertEquals(201, createRes.getStatusCode());
|
assertEquals(201, createRes.getStatusCode());
|
||||||
|
|
||||||
final Collection<String> location = createRes.getHeader(HeaderName.location);
|
final Collection<String> location = createRes.getHeader(HttpHeader.LOCATION);
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
final URI createdLocation = URI.create(location.iterator().next());
|
final URI createdLocation = URI.create(location.iterator().next());
|
||||||
|
|
||||||
|
|
|
@ -1,194 +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.communication.header;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Major OData request/response header names.
|
|
||||||
*/
|
|
||||||
public enum HeaderName {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The OData protocol uses the Accept request-header field, as specified in [RFC2616].
|
|
||||||
*/
|
|
||||||
accept("Accept"),
|
|
||||||
/**
|
|
||||||
* As specified in [RFC2616], the client MAY specify the set of accepted character sets with the Accept-Charset
|
|
||||||
* header.
|
|
||||||
*/
|
|
||||||
acceptCharset("Accept-Charset"),
|
|
||||||
/**
|
|
||||||
* As specified in [RFC2616], the client MAY specify the set of accepted natural languages with the Accept-Language
|
|
||||||
* header.
|
|
||||||
*/
|
|
||||||
acceptLanguage("Accept-Language"),
|
|
||||||
/**
|
|
||||||
* The Content-Type header is used as specified in [RFC2616].
|
|
||||||
* <br/>
|
|
||||||
* OData request/response supports the following types:
|
|
||||||
* <ul>
|
|
||||||
* <li>application/atom+xml</li>
|
|
||||||
* <li>application/atom+xml;type=entry</li>
|
|
||||||
* <li>application/atom+xml;type=feed</li>
|
|
||||||
* <li>application/json; odata.metadata=full</li>
|
|
||||||
* <li>application/json; odata.metadata=minimal</li>
|
|
||||||
* <li>application/json; odata.metadata=none</li>
|
|
||||||
* <li>application/json</li>
|
|
||||||
* <li>application/xml</li>
|
|
||||||
* <li>text/plain</li>
|
|
||||||
* <li>text/xml</li>
|
|
||||||
* <li>octet/stream</li>
|
|
||||||
* <li>multipart/mixed</li>
|
|
||||||
* </ul>
|
|
||||||
*/
|
|
||||||
contentType("Content-Type"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This header is a custom HTTP header defined for protocol versioning purposes. This header MAY be present on any
|
|
||||||
* request or response message.
|
|
||||||
*/
|
|
||||||
odataVersion("OData-Version"),
|
|
||||||
/**
|
|
||||||
* A response to a create operation that returns 204 No Content MUST include an OData-EntityId response header. The
|
|
||||||
* value of the header is the entity-id of the entity that was acted on by the request. The syntax of the
|
|
||||||
* OData-EntityId preference is specified in [OData-ABNF].
|
|
||||||
*/
|
|
||||||
odataEntityId("OData-EntityId"),
|
|
||||||
/**
|
|
||||||
* An ETag (entity tag) is an HTTP response header returned by an HTTP/1.1 compliant web server used to determine
|
|
||||||
* change in content of a resource at a given URL. The value of the header is an opaque string representing the state
|
|
||||||
* of the resource at the time the response was generated.
|
|
||||||
*/
|
|
||||||
etag("ETag"),
|
|
||||||
/**
|
|
||||||
* The If-Match request-header field is used with a method to make it conditional. As specified in [RFC2616], "the
|
|
||||||
* purpose of this feature is to allow efficient updates of cached information with a minimum amount of transaction
|
|
||||||
* overhead. It is also used, on updating requests, to prevent inadvertent modification of the wrong version of a
|
|
||||||
* resource".
|
|
||||||
*/
|
|
||||||
ifMatch("If-Match"),
|
|
||||||
/**
|
|
||||||
* The If-None-Match request header is used with a method to make it conditional. As specified in [RFC2616], "The
|
|
||||||
* purpose of this feature is to allow efficient updates of cached information with a minimum amount of transaction
|
|
||||||
* overhead. It is also used to prevent a method (for example, PUT) from inadvertently modifying an existing resource
|
|
||||||
* when the client believes that the resource does not exist."
|
|
||||||
*/
|
|
||||||
ifNoneMatch("If-None-Match"),
|
|
||||||
/**
|
|
||||||
* Clients SHOULD specify an OData-MaxVersion request header.
|
|
||||||
* <br />
|
|
||||||
* If specified the service MUST generate a response with an OData-Version less than or equal to the specified
|
|
||||||
* OData-MaxVersion.
|
|
||||||
* <br />
|
|
||||||
* If OData-MaxVersion is not specified, then the service SHOULD interpret the request as having an OData-MaxVersion
|
|
||||||
* equal to the maximum version supported by the service.
|
|
||||||
*/
|
|
||||||
odataMaxVersion("OData-MaxVersion"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The OData-Isolation header specifies the isolation of the current request from external changes. The only supported
|
|
||||||
* value for this header is snapshot.
|
|
||||||
* <br />
|
|
||||||
* If the service doesn’t support OData-Isolation:snapshot and this header was specified on the request, the service
|
|
||||||
* MUST NOT process the request and MUST respond with 412 Precondition Failed.
|
|
||||||
* <br />
|
|
||||||
* Snapshot isolation guarantees that all data returned for a request, including multiple requests within a batch or
|
|
||||||
* results retrieved across multiple pages, will be consistent as of a single point in time. Only data modifications
|
|
||||||
* made within the request (for example, by a data modification request within the same batch) are visible. The effect
|
|
||||||
* is as if the request generates a "snapshot" of the committed data as it existed at the start of the request.
|
|
||||||
* <br />
|
|
||||||
* The OData-Isolation header may be specified on a single or batch request. If it is specified on a batch then the
|
|
||||||
* value is applied to all statements within the batch.
|
|
||||||
* <br />
|
|
||||||
* Next links returned within a snapshot return results within the same snapshot as the initial request; the client is
|
|
||||||
* not required to repeat the header on each individual page request.
|
|
||||||
* <br />
|
|
||||||
* The OData-Isolation header has no effect on links other than the next link. Navigation links, read links, and edit
|
|
||||||
* links return the current version of the data.
|
|
||||||
* <br />
|
|
||||||
* A service returns 410 Gone or 404 Not Found if a consumer tries to follow a next link referring to a snapshot that
|
|
||||||
* is no longer available.
|
|
||||||
* <br />
|
|
||||||
* The syntax of the OData-Isolation header is specified in [OData-ABNF].
|
|
||||||
* <br />
|
|
||||||
* A service MAY specify the support for OData-Isolation:snapshot using an annotation with term
|
|
||||||
* Capabilities.IsolationSupport, see [OData-VocCap].
|
|
||||||
*/
|
|
||||||
odataIsolation("OData-Isolation"),
|
|
||||||
/**
|
|
||||||
* A Prefer header is included in a request to state the client’s preferred, but not required, server behavior (that
|
|
||||||
* is, a hint to the server). The Prefer header MAY be included on any request type (within a standalone or batch
|
|
||||||
* request), and a server MAY honor the header for HTTP POST, PUT, PATCH, and MERGE requests. A Prefer header with a
|
|
||||||
* value of “return-content” MUST NOT be specified on a DELETE request, a batch request as a whole, or a PUT request
|
|
||||||
* to update a named stream.
|
|
||||||
*/
|
|
||||||
prefer("Prefer"),
|
|
||||||
/**
|
|
||||||
* When a Prefer header value is successfully honored by the server, it MAY include a Preference-Applied response
|
|
||||||
* header that states which preference values were honored by the server.
|
|
||||||
*/
|
|
||||||
preferenceApplied("Preference-Applied"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Location header is used to specify the URL of an entity modified through a Data Modification request, or the
|
|
||||||
* request URL to check on the status of an asynchronous operation as described in
|
|
||||||
* <code>202 Accepted</code>.
|
|
||||||
*/
|
|
||||||
location("Location"),
|
|
||||||
/**
|
|
||||||
* A service must include a
|
|
||||||
* <code>Retry-After</code> header in a
|
|
||||||
* <code>202 Accepted</code>.
|
|
||||||
*/
|
|
||||||
retryAfter("Retry-After"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This header is a custom HTTP request header.
|
|
||||||
* <br/>
|
|
||||||
* It is possible to instruct network intermediaries (proxies, firewalls, and so on) inspecting traffic at the
|
|
||||||
* application protocol layer (for example, HTTP) to block requests that contain certain HTTP verbs. In practice, GET
|
|
||||||
* and POST verbs are rarely blocked (traditional web pages rely heavily on these HTTP methods), while, for a variety
|
|
||||||
* of reasons (such as security vulnerabilities in prior protocols), other HTTP methods (PUT, DELETE, and so on) are
|
|
||||||
* at times blocked by intermediaries. Additionally, some existing HTTP libraries do not allow creation of requests
|
|
||||||
* using verbs other than GET or POST. Therefore, an alternative way of specifying request types which use verbs other
|
|
||||||
* than GET and POST is needed to ensure that this document works well in a wide range of environments.
|
|
||||||
* <br/>
|
|
||||||
* To address this need, the X-HTTP-Method header can be added to a POST request that signals that the server MUST
|
|
||||||
* process the request not as a POST, but as if the HTTP verb specified as the value of the header was used as the
|
|
||||||
* method on the HTTP request's request line, as specified in [RFC2616] section 5.1. This technique is often referred
|
|
||||||
* to as "verb tunneling".
|
|
||||||
* <br/>
|
|
||||||
* This header is only valid when on POST requests.
|
|
||||||
*/
|
|
||||||
xHttpMethod("X-HTTP-METHOD"),
|
|
||||||
|
|
||||||
//TODO: Delete
|
|
||||||
dataServiceUrlConventions("DataServiceUrlConventions");
|
|
||||||
|
|
||||||
private final String headerName;
|
|
||||||
|
|
||||||
private HeaderName(final String headerName) {
|
|
||||||
this.headerName = headerName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return headerName;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -28,16 +28,6 @@ import java.util.Collection;
|
||||||
*/
|
*/
|
||||||
public interface ODataHeaders {
|
public interface ODataHeaders {
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the value of the header identified by the given name.
|
|
||||||
* <br/>
|
|
||||||
* Please note that header name is case-insensitive.
|
|
||||||
*
|
|
||||||
* @param name name of the header to be retrieved.
|
|
||||||
* @return header value.
|
|
||||||
*/
|
|
||||||
String getHeader(final HeaderName name);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of the header identified by the given name.
|
* Gets the value of the header identified by the given name.
|
||||||
* <br/>
|
* <br/>
|
||||||
|
@ -66,15 +56,6 @@ public interface ODataHeaders {
|
||||||
*/
|
*/
|
||||||
ODataHeaders setHeader(String name, String value);
|
ODataHeaders setHeader(String name, String value);
|
||||||
|
|
||||||
/**
|
|
||||||
* Add the specified header.
|
|
||||||
*
|
|
||||||
* @param name header key.
|
|
||||||
* @param value header value.
|
|
||||||
* @return the current updated header instance.
|
|
||||||
*/
|
|
||||||
ODataHeaders setHeader(HeaderName name, String value);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the header identified by the given name.
|
* Removes the header identified by the given name.
|
||||||
* <br/>
|
* <br/>
|
||||||
|
@ -83,8 +64,6 @@ public interface ODataHeaders {
|
||||||
* @param name name of the header to be retrieved.
|
* @param name name of the header to be retrieved.
|
||||||
* @return header name (if found).
|
* @return header name (if found).
|
||||||
*/
|
*/
|
||||||
String removeHeader(HeaderName name);
|
|
||||||
|
|
||||||
String removeHeader(String name);
|
String removeHeader(String name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class ODataPreferences {
|
||||||
/**
|
/**
|
||||||
* <code>Prefer</code> header, return content.
|
* <code>Prefer</code> header, return content.
|
||||||
*
|
*
|
||||||
* @see HeaderName#prefer
|
* @see org.apache.olingo.commons.api.http.HttpHeader#PREFER
|
||||||
*/
|
*/
|
||||||
public String returnContent() {
|
public String returnContent() {
|
||||||
return PreferenceNames.returnContent.toString();
|
return PreferenceNames.returnContent.toString();
|
||||||
|
@ -37,14 +37,16 @@ public class ODataPreferences {
|
||||||
/**
|
/**
|
||||||
* <code>Prefer</code> header, return no content.
|
* <code>Prefer</code> header, return no content.
|
||||||
*
|
*
|
||||||
* @see HeaderName#prefer
|
* @see org.apache.olingo.commons.api.http.HttpHeader#PREFER
|
||||||
*/
|
*/
|
||||||
public String returnNoContent() {
|
public String returnNoContent() {
|
||||||
return PreferenceNames.returnNoContent.toString();
|
return PreferenceNames.returnNoContent.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see HeaderName#dataServiceUrlConventions
|
* Gets the value of the non-standard preference that the URL should follow the convention
|
||||||
|
* that keys are formatted as separate segments.
|
||||||
|
* @see org.apache.olingo.commons.api.http.HttpHeader#PREFER
|
||||||
*/
|
*/
|
||||||
public String keyAsSegment() {
|
public String keyAsSegment() {
|
||||||
return PreferenceNames.keyAsSegment.toString();
|
return PreferenceNames.keyAsSegment.toString();
|
||||||
|
@ -64,7 +66,7 @@ public class ODataPreferences {
|
||||||
* <br/><br/>
|
* <br/><br/>
|
||||||
* Supported by OData version 4.0 only.
|
* Supported by OData version 4.0 only.
|
||||||
*
|
*
|
||||||
* @see HeaderName#prefer
|
* @see org.apache.olingo.commons.api.http.HttpHeader#PREFER
|
||||||
* @return preference.
|
* @return preference.
|
||||||
*/
|
*/
|
||||||
public String allowEntityReferences() {
|
public String allowEntityReferences() {
|
||||||
|
@ -127,7 +129,7 @@ public class ODataPreferences {
|
||||||
* <br/><br/>
|
* <br/><br/>
|
||||||
* Supported by OData version 4.0 only.
|
* Supported by OData version 4.0 only.
|
||||||
*
|
*
|
||||||
* @see HeaderName#prefer
|
* @see org.apache.olingo.commons.api.http.HttpHeader#PREFER
|
||||||
* @return preference.
|
* @return preference.
|
||||||
*/
|
*/
|
||||||
public String callback(final String url) {
|
public String callback(final String url) {
|
||||||
|
@ -148,7 +150,7 @@ public class ODataPreferences {
|
||||||
* <br/><br/>
|
* <br/><br/>
|
||||||
* Supported by OData version 4.0 only.
|
* Supported by OData version 4.0 only.
|
||||||
*
|
*
|
||||||
* @see HeaderName#prefer
|
* @see org.apache.olingo.commons.api.http.HttpHeader#PREFER
|
||||||
* @return preference.
|
* @return preference.
|
||||||
*/
|
*/
|
||||||
public String continueOnError() {
|
public String continueOnError() {
|
||||||
|
@ -195,7 +197,7 @@ public class ODataPreferences {
|
||||||
* <br/><br/>
|
* <br/><br/>
|
||||||
* Supported by OData version 4.0 only.
|
* Supported by OData version 4.0 only.
|
||||||
*
|
*
|
||||||
* @see HeaderName#prefer
|
* @see org.apache.olingo.commons.api.http.HttpHeader#PREFER
|
||||||
* @return preference.
|
* @return preference.
|
||||||
*/
|
*/
|
||||||
public String includeAnnotations(final String value) {
|
public String includeAnnotations(final String value) {
|
||||||
|
@ -228,7 +230,7 @@ public class ODataPreferences {
|
||||||
* <br/><br/>
|
* <br/><br/>
|
||||||
* Supported by OData version 4.0 only.
|
* Supported by OData version 4.0 only.
|
||||||
*
|
*
|
||||||
* @see HeaderName#prefer
|
* @see org.apache.olingo.commons.api.http.HttpHeader#PREFER
|
||||||
* @return preference.
|
* @return preference.
|
||||||
*/
|
*/
|
||||||
public String maxPageSize(final int size) {
|
public String maxPageSize(final int size) {
|
||||||
|
@ -253,7 +255,7 @@ public class ODataPreferences {
|
||||||
* <br/><br/>
|
* <br/><br/>
|
||||||
* Supported by OData version 4.0 only.
|
* Supported by OData version 4.0 only.
|
||||||
*
|
*
|
||||||
* @see HeaderName#prefer
|
* @see org.apache.olingo.commons.api.http.HttpHeader#PREFER
|
||||||
* @return preference.
|
* @return preference.
|
||||||
*/
|
*/
|
||||||
public String trackChanges() {
|
public String trackChanges() {
|
||||||
|
@ -288,7 +290,7 @@ public class ODataPreferences {
|
||||||
* <br/><br/>
|
* <br/><br/>
|
||||||
* Supported by OData version 4.0 only.
|
* Supported by OData version 4.0 only.
|
||||||
*
|
*
|
||||||
* @see HeaderName#prefer
|
* @see org.apache.olingo.commons.api.http.HttpHeader#PREFER
|
||||||
* @return preference.
|
* @return preference.
|
||||||
*/
|
*/
|
||||||
public String respondAsync() {
|
public String respondAsync() {
|
||||||
|
@ -308,7 +310,7 @@ public class ODataPreferences {
|
||||||
* <br/><br/>
|
* <br/><br/>
|
||||||
* Supported by OData version 4.0 only.
|
* Supported by OData version 4.0 only.
|
||||||
*
|
*
|
||||||
* @see HeaderName#prefer
|
* @see org.apache.olingo.commons.api.http.HttpHeader#PREFER
|
||||||
* @return preference.
|
* @return preference.
|
||||||
*/
|
*/
|
||||||
public String wait(final int value) {
|
public String wait(final int value) {
|
||||||
|
@ -338,7 +340,7 @@ public class ODataPreferences {
|
||||||
* <br/><br/>
|
* <br/><br/>
|
||||||
* Supported by OData version 4.0 only.
|
* Supported by OData version 4.0 only.
|
||||||
*
|
*
|
||||||
* @see HeaderName#prefer
|
* @see org.apache.olingo.commons.api.http.HttpHeader#PREFER
|
||||||
* @return preference.
|
* @return preference.
|
||||||
*/
|
*/
|
||||||
public String returnMinimal() {
|
public String returnMinimal() {
|
||||||
|
@ -368,7 +370,7 @@ public class ODataPreferences {
|
||||||
* <br/><br/>
|
* <br/><br/>
|
||||||
* Supported by OData version 4.0 only.
|
* Supported by OData version 4.0 only.
|
||||||
*
|
*
|
||||||
* @see HeaderName#prefer
|
* @see org.apache.olingo.commons.api.http.HttpHeader#PREFER
|
||||||
* @return preference.
|
* @return preference.
|
||||||
*/
|
*/
|
||||||
public String returnRepresentation() {
|
public String returnRepresentation() {
|
||||||
|
|
|
@ -22,7 +22,6 @@ import java.io.InputStream;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.apache.olingo.client.api.communication.header.HeaderName;
|
|
||||||
import org.apache.olingo.commons.api.http.HttpMethod;
|
import org.apache.olingo.commons.api.http.HttpMethod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,7 +74,7 @@ public interface ODataRequest {
|
||||||
*
|
*
|
||||||
* @param value header value.
|
* @param value header value.
|
||||||
* @return current object
|
* @return current object
|
||||||
* @see org.apache.olingo.client.api.communication.header.HeaderName#accept
|
* @see org.apache.olingo.commons.api.http.HttpHeader#ACCEPT
|
||||||
*/
|
*/
|
||||||
ODataRequest setAccept(final String value);
|
ODataRequest setAccept(final String value);
|
||||||
|
|
||||||
|
@ -83,7 +82,7 @@ public interface ODataRequest {
|
||||||
* Gets <tt>Accept</tt> OData request header.
|
* Gets <tt>Accept</tt> OData request header.
|
||||||
*
|
*
|
||||||
* @return header value.
|
* @return header value.
|
||||||
* @see org.apache.olingo.client.api.communication.header.HeaderName#accept
|
* @see org.apache.olingo.commons.api.http.HttpHeader#ACCEPT
|
||||||
*/
|
*/
|
||||||
String getAccept();
|
String getAccept();
|
||||||
|
|
||||||
|
@ -92,7 +91,7 @@ public interface ODataRequest {
|
||||||
*
|
*
|
||||||
* @param value header value.
|
* @param value header value.
|
||||||
* @return current object
|
* @return current object
|
||||||
* @see org.apache.olingo.client.api.communication.header.HeaderName#ifMatch
|
* @see org.apache.olingo.commons.api.http.HttpHeader#IF_MATCH
|
||||||
*/
|
*/
|
||||||
ODataRequest setIfMatch(final String value);
|
ODataRequest setIfMatch(final String value);
|
||||||
|
|
||||||
|
@ -100,7 +99,7 @@ public interface ODataRequest {
|
||||||
* Gets <tt>If-Match</tt> OData request header.
|
* Gets <tt>If-Match</tt> OData request header.
|
||||||
*
|
*
|
||||||
* @return header value.
|
* @return header value.
|
||||||
* @see org.apache.olingo.client.api.communication.header.HeaderName#ifMatch
|
* @see org.apache.olingo.commons.api.http.HttpHeader#IF_MATCH
|
||||||
*/
|
*/
|
||||||
String getIfMatch();
|
String getIfMatch();
|
||||||
|
|
||||||
|
@ -109,7 +108,7 @@ public interface ODataRequest {
|
||||||
*
|
*
|
||||||
* @param value header value.
|
* @param value header value.
|
||||||
* @return current object
|
* @return current object
|
||||||
* @see org.apache.olingo.client.api.communication.header.HeaderName#ifNoneMatch
|
* @see org.apache.olingo.commons.api.http.HttpHeader#IF_NONE_MATCH
|
||||||
*/
|
*/
|
||||||
ODataRequest setIfNoneMatch(final String value);
|
ODataRequest setIfNoneMatch(final String value);
|
||||||
|
|
||||||
|
@ -117,7 +116,7 @@ public interface ODataRequest {
|
||||||
* Gets <tt>If-None-Match</tt> OData request header.
|
* Gets <tt>If-None-Match</tt> OData request header.
|
||||||
*
|
*
|
||||||
* @return header value.
|
* @return header value.
|
||||||
* @see org.apache.olingo.client.api.communication.header.HeaderName#ifNoneMatch
|
* @see org.apache.olingo.commons.api.http.HttpHeader#IF_NONE_MATCH
|
||||||
*/
|
*/
|
||||||
String getIfNoneMatch();
|
String getIfNoneMatch();
|
||||||
|
|
||||||
|
@ -126,7 +125,7 @@ public interface ODataRequest {
|
||||||
*
|
*
|
||||||
* @param value header value.
|
* @param value header value.
|
||||||
* @return current object
|
* @return current object
|
||||||
* @see org.apache.olingo.client.api.communication.header.HeaderName#prefer
|
* @see org.apache.olingo.commons.api.http.HttpHeader#PREFER
|
||||||
*/
|
*/
|
||||||
ODataRequest setPrefer(final String value);
|
ODataRequest setPrefer(final String value);
|
||||||
|
|
||||||
|
@ -134,7 +133,7 @@ public interface ODataRequest {
|
||||||
* Gets <tt>Prefer</tt> OData request header.
|
* Gets <tt>Prefer</tt> OData request header.
|
||||||
*
|
*
|
||||||
* @return header value.
|
* @return header value.
|
||||||
* @see org.apache.olingo.client.api.communication.header.HeaderName#prefer
|
* @see org.apache.olingo.commons.api.http.HttpHeader#PREFER
|
||||||
*/
|
*/
|
||||||
String getPrefer();
|
String getPrefer();
|
||||||
|
|
||||||
|
@ -143,7 +142,7 @@ public interface ODataRequest {
|
||||||
*
|
*
|
||||||
* @param value header value.
|
* @param value header value.
|
||||||
* @return current object
|
* @return current object
|
||||||
* @see org.apache.olingo.client.api.communication.header.HeaderName#contentType
|
* @see org.apache.olingo.commons.api.http.HttpHeader#CONTENT_TYPE
|
||||||
*/
|
*/
|
||||||
ODataRequest setContentType(final String value);
|
ODataRequest setContentType(final String value);
|
||||||
|
|
||||||
|
@ -151,7 +150,7 @@ public interface ODataRequest {
|
||||||
* Gets <tt>contentType</tt> OData request header.
|
* Gets <tt>contentType</tt> OData request header.
|
||||||
*
|
*
|
||||||
* @return header value.
|
* @return header value.
|
||||||
* @see org.apache.olingo.client.api.communication.header.HeaderName#contentType
|
* @see org.apache.olingo.commons.api.http.HttpHeader#CONTENT_TYPE
|
||||||
*/
|
*/
|
||||||
String getContentType();
|
String getContentType();
|
||||||
|
|
||||||
|
@ -160,7 +159,7 @@ public interface ODataRequest {
|
||||||
*
|
*
|
||||||
* @param value header value.
|
* @param value header value.
|
||||||
* @return current object
|
* @return current object
|
||||||
* @see org.apache.olingo.client.api.communication.header.HeaderName#xHttpMethod
|
* @see org.apache.olingo.commons.api.http.HttpHeader#X_HTTP_METHOD
|
||||||
*/
|
*/
|
||||||
ODataRequest setXHTTPMethod(final String value);
|
ODataRequest setXHTTPMethod(final String value);
|
||||||
|
|
||||||
|
@ -173,16 +172,6 @@ public interface ODataRequest {
|
||||||
*/
|
*/
|
||||||
ODataRequest addCustomHeader(final String name, final String value);
|
ODataRequest addCustomHeader(final String name, final String value);
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a custom OData request header. The method fails in case of the header name is not supported by the current
|
|
||||||
* working version.
|
|
||||||
*
|
|
||||||
* @param name header name.
|
|
||||||
* @param value header value.
|
|
||||||
* @return current object
|
|
||||||
*/
|
|
||||||
ODataRequest addCustomHeader(final HeaderName name, final String value);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets byte array representation of the full request header.
|
* Gets byte array representation of the full request header.
|
||||||
*
|
*
|
||||||
|
|
|
@ -23,7 +23,6 @@ import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
import org.apache.olingo.client.api.communication.header.HeaderName;
|
|
||||||
import org.apache.olingo.client.api.communication.request.batch.ODataBatchLineIterator;
|
import org.apache.olingo.client.api.communication.request.batch.ODataBatchLineIterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,14 +45,6 @@ public interface ODataResponse {
|
||||||
*/
|
*/
|
||||||
Collection<String> getHeader(final String name);
|
Collection<String> getHeader(final String name);
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets header value of the given header.
|
|
||||||
*
|
|
||||||
* @param name header to be retrieved.
|
|
||||||
* @return response header value.
|
|
||||||
*/
|
|
||||||
Collection<String> getHeader(final HeaderName name);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets 'ETag' header value.
|
* Gets 'ETag' header value.
|
||||||
*
|
*
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.apache.olingo.client.core;
|
||||||
|
|
||||||
import org.apache.olingo.client.api.Configuration;
|
import org.apache.olingo.client.api.Configuration;
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
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.ODataHeaders;
|
||||||
import org.apache.olingo.client.api.communication.header.ODataPreferences;
|
import org.apache.olingo.client.api.communication.header.ODataPreferences;
|
||||||
import org.apache.olingo.client.api.communication.request.AsyncRequestFactory;
|
import org.apache.olingo.client.api.communication.request.AsyncRequestFactory;
|
||||||
|
@ -28,6 +27,7 @@ import org.apache.olingo.client.api.communication.request.batch.BatchRequestFact
|
||||||
import org.apache.olingo.client.api.communication.request.cud.CUDRequestFactory;
|
import org.apache.olingo.client.api.communication.request.cud.CUDRequestFactory;
|
||||||
import org.apache.olingo.client.api.communication.request.invoke.InvokeRequestFactory;
|
import org.apache.olingo.client.api.communication.request.invoke.InvokeRequestFactory;
|
||||||
import org.apache.olingo.client.api.communication.request.retrieve.RetrieveRequestFactory;
|
import org.apache.olingo.client.api.communication.request.retrieve.RetrieveRequestFactory;
|
||||||
|
import org.apache.olingo.client.api.domain.ClientObjectFactory;
|
||||||
import org.apache.olingo.client.api.serialization.ClientODataDeserializer;
|
import org.apache.olingo.client.api.serialization.ClientODataDeserializer;
|
||||||
import org.apache.olingo.client.api.serialization.ODataBinder;
|
import org.apache.olingo.client.api.serialization.ODataBinder;
|
||||||
import org.apache.olingo.client.api.serialization.ODataReader;
|
import org.apache.olingo.client.api.serialization.ODataReader;
|
||||||
|
@ -42,6 +42,7 @@ import org.apache.olingo.client.core.communication.request.batch.BatchRequestFac
|
||||||
import org.apache.olingo.client.core.communication.request.cud.CUDRequestFactoryImpl;
|
import org.apache.olingo.client.core.communication.request.cud.CUDRequestFactoryImpl;
|
||||||
import org.apache.olingo.client.core.communication.request.invoke.InvokeRequestFactoryImpl;
|
import org.apache.olingo.client.core.communication.request.invoke.InvokeRequestFactoryImpl;
|
||||||
import org.apache.olingo.client.core.communication.request.retrieve.RetrieveRequestFactoryImpl;
|
import org.apache.olingo.client.core.communication.request.retrieve.RetrieveRequestFactoryImpl;
|
||||||
|
import org.apache.olingo.client.core.domain.ClientObjectFactoryImpl;
|
||||||
import org.apache.olingo.client.core.serialization.AtomSerializer;
|
import org.apache.olingo.client.core.serialization.AtomSerializer;
|
||||||
import org.apache.olingo.client.core.serialization.ClientODataDeserializerImpl;
|
import org.apache.olingo.client.core.serialization.ClientODataDeserializerImpl;
|
||||||
import org.apache.olingo.client.core.serialization.JsonSerializer;
|
import org.apache.olingo.client.core.serialization.JsonSerializer;
|
||||||
|
@ -50,10 +51,9 @@ import org.apache.olingo.client.core.serialization.ODataReaderImpl;
|
||||||
import org.apache.olingo.client.core.serialization.ODataWriterImpl;
|
import org.apache.olingo.client.core.serialization.ODataWriterImpl;
|
||||||
import org.apache.olingo.client.core.uri.FilterFactoryImpl;
|
import org.apache.olingo.client.core.uri.FilterFactoryImpl;
|
||||||
import org.apache.olingo.client.core.uri.URIBuilderImpl;
|
import org.apache.olingo.client.core.uri.URIBuilderImpl;
|
||||||
import org.apache.olingo.client.api.domain.ClientObjectFactory;
|
|
||||||
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||||
import org.apache.olingo.client.core.domain.ClientObjectFactoryImpl;
|
import org.apache.olingo.commons.api.http.HttpHeader;
|
||||||
|
|
||||||
public class ODataClientImpl implements ODataClient {
|
public class ODataClientImpl implements ODataClient {
|
||||||
|
|
||||||
|
@ -104,8 +104,8 @@ public class ODataClientImpl implements ODataClient {
|
||||||
@Override
|
@Override
|
||||||
public ODataHeaders newVersionHeaders() {
|
public ODataHeaders newVersionHeaders() {
|
||||||
final ODataHeadersImpl odataHeaders = new ODataHeadersImpl();
|
final ODataHeadersImpl odataHeaders = new ODataHeadersImpl();
|
||||||
odataHeaders.setHeader(HeaderName.odataMaxVersion, ODataServiceVersion.V40.toString());
|
odataHeaders.setHeader(HttpHeader.ODATA_MAX_VERSION, ODataServiceVersion.V40.toString());
|
||||||
odataHeaders.setHeader(HeaderName.odataVersion, ODataServiceVersion.V40.toString());
|
odataHeaders.setHeader(HttpHeader.ODATA_VERSION, ODataServiceVersion.V40.toString());
|
||||||
return odataHeaders;
|
return odataHeaders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@ import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
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.ODataHeaders;
|
||||||
|
|
||||||
public class ODataHeadersImpl implements ODataHeaders {
|
public class ODataHeadersImpl implements ODataHeaders {
|
||||||
|
@ -38,27 +37,11 @@ public class ODataHeadersImpl implements ODataHeaders {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ODataHeaders setHeader(final HeaderName name, final String value) {
|
|
||||||
headers.put(name.toString(), value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getHeader(final HeaderName name) {
|
|
||||||
return headers.get(name.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHeader(final String name) {
|
public String getHeader(final String name) {
|
||||||
return headers.get(name);
|
return headers.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String removeHeader(final HeaderName name) {
|
|
||||||
return headers.remove(name.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String removeHeader(final String name) {
|
public String removeHeader(final String name) {
|
||||||
return headers.remove(name);
|
return headers.remove(name);
|
||||||
|
|
|
@ -34,7 +34,6 @@ import org.apache.http.client.HttpClient;
|
||||||
import org.apache.http.client.methods.HttpUriRequest;
|
import org.apache.http.client.methods.HttpUriRequest;
|
||||||
import org.apache.http.impl.client.DecompressingHttpClient;
|
import org.apache.http.impl.client.DecompressingHttpClient;
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
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.ODataHeaders;
|
||||||
import org.apache.olingo.client.api.communication.request.ODataRequest;
|
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.request.ODataStreamer;
|
||||||
|
@ -42,6 +41,7 @@ import org.apache.olingo.client.api.communication.response.ODataResponse;
|
||||||
import org.apache.olingo.client.api.http.HttpClientException;
|
import org.apache.olingo.client.api.http.HttpClientException;
|
||||||
import org.apache.olingo.commons.api.ODataRuntimeException;
|
import org.apache.olingo.commons.api.ODataRuntimeException;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||||
|
import org.apache.olingo.commons.api.http.HttpHeader;
|
||||||
import org.apache.olingo.commons.api.http.HttpMethod;
|
import org.apache.olingo.commons.api.http.HttpMethod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -128,37 +128,37 @@ public abstract class AbstractODataRequest extends AbstractRequest implements OD
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataRequest setAccept(final String value) {
|
public ODataRequest setAccept(final String value) {
|
||||||
odataHeaders.setHeader(HeaderName.accept, value);
|
odataHeaders.setHeader(HttpHeader.ACCEPT, value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataRequest setIfMatch(final String value) {
|
public ODataRequest setIfMatch(final String value) {
|
||||||
odataHeaders.setHeader(HeaderName.ifMatch, value);
|
odataHeaders.setHeader(HttpHeader.IF_MATCH, value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataRequest setIfNoneMatch(final String value) {
|
public ODataRequest setIfNoneMatch(final String value) {
|
||||||
odataHeaders.setHeader(HeaderName.ifNoneMatch, value);
|
odataHeaders.setHeader(HttpHeader.IF_NONE_MATCH, value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataRequest setPrefer(final String value) {
|
public ODataRequest setPrefer(final String value) {
|
||||||
odataHeaders.setHeader(HeaderName.prefer, value);
|
odataHeaders.setHeader(HttpHeader.PREFER, value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataRequest setXHTTPMethod(final String value) {
|
public ODataRequest setXHTTPMethod(final String value) {
|
||||||
odataHeaders.setHeader(HeaderName.xHttpMethod, value);
|
odataHeaders.setHeader(HttpHeader.X_HTTP_METHOD, value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataRequest setContentType(final String value) {
|
public ODataRequest setContentType(final String value) {
|
||||||
odataHeaders.setHeader(HeaderName.contentType, value);
|
odataHeaders.setHeader(HttpHeader.CONTENT_TYPE, value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,41 +168,35 @@ public abstract class AbstractODataRequest extends AbstractRequest implements OD
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ODataRequest addCustomHeader(final HeaderName name, final String value) {
|
|
||||||
odataHeaders.setHeader(name, value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAccept() {
|
public String getAccept() {
|
||||||
final String acceptHead = odataHeaders.getHeader(HeaderName.accept);
|
final String acceptHead = odataHeaders.getHeader(HttpHeader.ACCEPT);
|
||||||
return StringUtils.isBlank(acceptHead)
|
return StringUtils.isBlank(acceptHead) ?
|
||||||
? getDefaultFormat().getContentType().toContentTypeString()
|
getDefaultFormat().getContentType().toContentTypeString() :
|
||||||
: acceptHead;
|
acceptHead;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getIfMatch() {
|
public String getIfMatch() {
|
||||||
return odataHeaders.getHeader(HeaderName.ifMatch);
|
return odataHeaders.getHeader(HttpHeader.IF_MATCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getIfNoneMatch() {
|
public String getIfNoneMatch() {
|
||||||
return odataHeaders.getHeader(HeaderName.ifNoneMatch);
|
return odataHeaders.getHeader(HttpHeader.IF_NONE_MATCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPrefer() {
|
public String getPrefer() {
|
||||||
return odataHeaders.getHeader(HeaderName.prefer);
|
return odataHeaders.getHeader(HttpHeader.PREFER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getContentType() {
|
public String getContentType() {
|
||||||
final String contentTypeHead = odataHeaders.getHeader(HeaderName.contentType);
|
final String contentTypeHead = odataHeaders.getHeader(HttpHeader.CONTENT_TYPE);
|
||||||
return StringUtils.isBlank(contentTypeHead)
|
return StringUtils.isBlank(contentTypeHead) ?
|
||||||
? getDefaultFormat().getContentType().toContentTypeString()
|
getDefaultFormat().getContentType().toContentTypeString() :
|
||||||
: contentTypeHead;
|
contentTypeHead;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -231,10 +225,10 @@ public abstract class AbstractODataRequest extends AbstractRequest implements OD
|
||||||
baos.write(ODataStreamer.CRLF);
|
baos.write(ODataStreamer.CRLF);
|
||||||
|
|
||||||
// Set Content-Type and Accept headers with default values, if not yet set
|
// Set Content-Type and Accept headers with default values, if not yet set
|
||||||
if (StringUtils.isBlank(odataHeaders.getHeader(HeaderName.contentType))) {
|
if (StringUtils.isBlank(odataHeaders.getHeader(HttpHeader.CONTENT_TYPE))) {
|
||||||
setContentType(getContentType());
|
setContentType(getContentType());
|
||||||
}
|
}
|
||||||
if (StringUtils.isBlank(odataHeaders.getHeader(HeaderName.accept))) {
|
if (StringUtils.isBlank(odataHeaders.getHeader(HttpHeader.ACCEPT))) {
|
||||||
setAccept(getAccept());
|
setAccept(getAccept());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,18 +271,16 @@ public abstract class AbstractODataRequest extends AbstractRequest implements OD
|
||||||
checkRequest(odataClient, request);
|
checkRequest(odataClient, request);
|
||||||
|
|
||||||
// Set Content-Type and Accept headers with default values, if not yet set
|
// Set Content-Type and Accept headers with default values, if not yet set
|
||||||
if (StringUtils.isBlank(odataHeaders.getHeader(HeaderName.contentType))) {
|
if (StringUtils.isBlank(odataHeaders.getHeader(HttpHeader.CONTENT_TYPE))) {
|
||||||
setContentType(getContentType());
|
setContentType(getContentType());
|
||||||
}
|
}
|
||||||
if (StringUtils.isBlank(odataHeaders.getHeader(HeaderName.accept))) {
|
if (StringUtils.isBlank(odataHeaders.getHeader(HttpHeader.ACCEPT))) {
|
||||||
setAccept(getAccept());
|
setAccept(getAccept());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add header for KeyAsSegment management
|
// Add header for KeyAsSegment management
|
||||||
if (odataClient.getConfiguration().isKeyAsSegment()) {
|
if (odataClient.getConfiguration().isKeyAsSegment()) {
|
||||||
addCustomHeader(
|
addCustomHeader("DataServiceUrlConventions", odataClient.newPreferences().keyAsSegment());
|
||||||
HeaderName.dataServiceUrlConventions.toString(),
|
|
||||||
odataClient.newPreferences().keyAsSegment());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add all available headers
|
// Add all available headers
|
||||||
|
|
|
@ -23,7 +23,6 @@ import java.util.Collection;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
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.header.ODataPreferences;
|
||||||
import org.apache.olingo.client.api.communication.request.AsyncBatchRequestWrapper;
|
import org.apache.olingo.client.api.communication.request.AsyncBatchRequestWrapper;
|
||||||
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
|
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
|
||||||
|
@ -32,6 +31,7 @@ import org.apache.olingo.client.api.communication.request.batch.ODataBatchReques
|
||||||
import org.apache.olingo.client.api.communication.request.batch.ODataChangeset;
|
import org.apache.olingo.client.api.communication.request.batch.ODataChangeset;
|
||||||
import org.apache.olingo.client.api.communication.response.AsyncResponseWrapper;
|
import org.apache.olingo.client.api.communication.response.AsyncResponseWrapper;
|
||||||
import org.apache.olingo.client.api.communication.response.ODataBatchResponse;
|
import org.apache.olingo.client.api.communication.response.ODataBatchResponse;
|
||||||
|
import org.apache.olingo.commons.api.http.HttpHeader;
|
||||||
|
|
||||||
public class AsyncBatchRequestWrapperImpl extends AsyncRequestWrapperImpl<ODataBatchResponse>
|
public class AsyncBatchRequestWrapperImpl extends AsyncRequestWrapperImpl<ODataBatchResponse>
|
||||||
implements AsyncBatchRequestWrapper {
|
implements AsyncBatchRequestWrapper {
|
||||||
|
@ -91,19 +91,19 @@ public class AsyncBatchRequestWrapperImpl extends AsyncRequestWrapperImpl<ODataB
|
||||||
}
|
}
|
||||||
|
|
||||||
private void retrieveMonitorDetails(final ODataBatchResponse res) {
|
private void retrieveMonitorDetails(final ODataBatchResponse res) {
|
||||||
Collection<String> headers = res.getHeader(HeaderName.location.toString());
|
Collection<String> headers = res.getHeader(HttpHeader.LOCATION);
|
||||||
if (headers == null || headers.isEmpty()) {
|
if (headers == null || headers.isEmpty()) {
|
||||||
throw new AsyncRequestException("Invalid async request response. Monitor URL not found");
|
throw new AsyncRequestException("Invalid async request response. Monitor URL not found");
|
||||||
} else {
|
} else {
|
||||||
this.location = URI.create(headers.iterator().next());
|
this.location = URI.create(headers.iterator().next());
|
||||||
}
|
}
|
||||||
|
|
||||||
headers = res.getHeader(HeaderName.retryAfter.toString());
|
headers = res.getHeader(HttpHeader.RETRY_AFTER);
|
||||||
if (headers != null && !headers.isEmpty()) {
|
if (headers != null && !headers.isEmpty()) {
|
||||||
this.retryAfter = Integer.parseInt(headers.iterator().next());
|
this.retryAfter = Integer.parseInt(headers.iterator().next());
|
||||||
}
|
}
|
||||||
|
|
||||||
headers = res.getHeader(HeaderName.preferenceApplied.toString());
|
headers = res.getHeader(HttpHeader.PREFERENCE_APPLIED);
|
||||||
if (headers != null && !headers.isEmpty()) {
|
if (headers != null && !headers.isEmpty()) {
|
||||||
for (String header : headers) {
|
for (String header : headers) {
|
||||||
if (header.equalsIgnoreCase(new ODataPreferences().respondAsync())) {
|
if (header.equalsIgnoreCase(new ODataPreferences().respondAsync())) {
|
||||||
|
|
|
@ -32,7 +32,6 @@ import org.apache.http.impl.client.DecompressingHttpClient;
|
||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.client.api.communication.ODataClientErrorException;
|
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.header.ODataPreferences;
|
||||||
import org.apache.olingo.client.api.communication.request.AsyncRequestWrapper;
|
import org.apache.olingo.client.api.communication.request.AsyncRequestWrapper;
|
||||||
import org.apache.olingo.client.api.communication.request.ODataRequest;
|
import org.apache.olingo.client.api.communication.request.ODataRequest;
|
||||||
|
@ -41,7 +40,9 @@ import org.apache.olingo.client.api.communication.response.AsyncResponseWrapper;
|
||||||
import org.apache.olingo.client.api.communication.response.ODataDeleteResponse;
|
import org.apache.olingo.client.api.communication.response.ODataDeleteResponse;
|
||||||
import org.apache.olingo.client.api.communication.response.ODataResponse;
|
import org.apache.olingo.client.api.communication.response.ODataResponse;
|
||||||
import org.apache.olingo.client.api.http.HttpClientException;
|
import org.apache.olingo.client.api.http.HttpClientException;
|
||||||
|
import org.apache.olingo.commons.api.http.HttpHeader;
|
||||||
import org.apache.olingo.commons.api.http.HttpMethod;
|
import org.apache.olingo.commons.api.http.HttpMethod;
|
||||||
|
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||||
|
|
||||||
public class AsyncRequestWrapperImpl<R extends ODataResponse> extends AbstractRequest
|
public class AsyncRequestWrapperImpl<R extends ODataResponse> extends AbstractRequest
|
||||||
implements AsyncRequestWrapper<R> {
|
implements AsyncRequestWrapper<R> {
|
||||||
|
@ -75,7 +76,7 @@ public class AsyncRequestWrapperImpl<R extends ODataResponse> extends AbstractRe
|
||||||
this.odataRequest.setAccept(this.odataRequest.getAccept());
|
this.odataRequest.setAccept(this.odataRequest.getAccept());
|
||||||
this.odataRequest.setContentType(this.odataRequest.getContentType());
|
this.odataRequest.setContentType(this.odataRequest.getContentType());
|
||||||
|
|
||||||
extendHeader(HeaderName.prefer.toString(), new ODataPreferences().respondAsync());
|
extendHeader(HttpHeader.PREFER, new ODataPreferences().respondAsync());
|
||||||
|
|
||||||
this.odataClient = odataClient;
|
this.odataClient = odataClient;
|
||||||
final HttpMethod method = odataRequest.getMethod();
|
final HttpMethod method = odataRequest.getMethod();
|
||||||
|
@ -94,14 +95,13 @@ public class AsyncRequestWrapperImpl<R extends ODataResponse> extends AbstractRe
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final AsyncRequestWrapper<R> wait(final int waitInSeconds) {
|
public final AsyncRequestWrapper<R> wait(final int waitInSeconds) {
|
||||||
extendHeader(HeaderName.prefer.toString(), new ODataPreferences().wait(waitInSeconds));
|
extendHeader(HttpHeader.PREFER, new ODataPreferences().wait(waitInSeconds));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final AsyncRequestWrapper<R> callback(URI url) {
|
public final AsyncRequestWrapper<R> callback(URI url) {
|
||||||
extendHeader(HeaderName.prefer.toString(),
|
extendHeader(HttpHeader.PREFER, new ODataPreferences().callback(url.toASCIIString()));
|
||||||
new ODataPreferences().callback(url.toASCIIString()));
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,9 +184,9 @@ public class AsyncRequestWrapperImpl<R extends ODataResponse> extends AbstractRe
|
||||||
for (int i = 0; response == null && i < MAX_RETRY; i++) {
|
for (int i = 0; response == null && i < MAX_RETRY; i++) {
|
||||||
res = checkMonitor(location);
|
res = checkMonitor(location);
|
||||||
|
|
||||||
if (res.getStatusLine().getStatusCode() == 202) {
|
if (res.getStatusLine().getStatusCode() == HttpStatusCode.ACCEPTED.getStatusCode()) {
|
||||||
|
|
||||||
final Header[] headers = res.getHeaders(HeaderName.retryAfter.toString());
|
final Header[] headers = res.getHeaders(HttpHeader.RETRY_AFTER);
|
||||||
if (ArrayUtils.isNotEmpty(headers)) {
|
if (ArrayUtils.isNotEmpty(headers)) {
|
||||||
this.retryAfter = Integer.parseInt(headers[0].getValue());
|
this.retryAfter = Integer.parseInt(headers[0].getValue());
|
||||||
}
|
}
|
||||||
|
@ -211,27 +211,18 @@ public class AsyncRequestWrapperImpl<R extends ODataResponse> extends AbstractRe
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public ODataDeleteResponse delete() {
|
public ODataDeleteResponse delete() {
|
||||||
final ODataDeleteRequest deleteRequest = odataClient.getCUDRequestFactory().getDeleteRequest(location);
|
final ODataDeleteRequest deleteRequest = odataClient.getCUDRequestFactory().getDeleteRequest(location);
|
||||||
return deleteRequest.execute();
|
return deleteRequest.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public AsyncResponseWrapper<ODataDeleteResponse> asyncDelete() {
|
public AsyncResponseWrapper<ODataDeleteResponse> asyncDelete() {
|
||||||
return odataClient.getAsyncRequestFactory().<ODataDeleteResponse>getAsyncRequestWrapper(
|
return odataClient.getAsyncRequestFactory().<ODataDeleteResponse>getAsyncRequestWrapper(
|
||||||
odataClient.getCUDRequestFactory().getDeleteRequest(location)).execute();
|
odataClient.getCUDRequestFactory().getDeleteRequest(location)).execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public AsyncResponseWrapper<R> forceNextMonitorCheck(final URI uri) {
|
public AsyncResponseWrapper<R> forceNextMonitorCheck(final URI uri) {
|
||||||
this.location = uri;
|
this.location = uri;
|
||||||
|
@ -255,7 +246,7 @@ public class AsyncRequestWrapperImpl<R extends ODataResponse> extends AbstractRe
|
||||||
}
|
}
|
||||||
|
|
||||||
private void retrieveMonitorDetails(final HttpResponse res) {
|
private void retrieveMonitorDetails(final HttpResponse res) {
|
||||||
Header[] headers = res.getHeaders(HeaderName.location.toString());
|
Header[] headers = res.getHeaders(HttpHeader.LOCATION);
|
||||||
if (ArrayUtils.isNotEmpty(headers)) {
|
if (ArrayUtils.isNotEmpty(headers)) {
|
||||||
this.location = URI.create(headers[0].getValue());
|
this.location = URI.create(headers[0].getValue());
|
||||||
} else {
|
} else {
|
||||||
|
@ -263,12 +254,12 @@ public class AsyncRequestWrapperImpl<R extends ODataResponse> extends AbstractRe
|
||||||
"Invalid async request response. Monitor URL '" + headers[0].getValue() + "'");
|
"Invalid async request response. Monitor URL '" + headers[0].getValue() + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
headers = res.getHeaders(HeaderName.retryAfter.toString());
|
headers = res.getHeaders(HttpHeader.RETRY_AFTER);
|
||||||
if (ArrayUtils.isNotEmpty(headers)) {
|
if (ArrayUtils.isNotEmpty(headers)) {
|
||||||
this.retryAfter = Integer.parseInt(headers[0].getValue());
|
this.retryAfter = Integer.parseInt(headers[0].getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
headers = res.getHeaders(HeaderName.preferenceApplied.toString());
|
headers = res.getHeaders(HttpHeader.PREFERENCE_APPLIED);
|
||||||
if (ArrayUtils.isNotEmpty(headers)) {
|
if (ArrayUtils.isNotEmpty(headers)) {
|
||||||
for (Header header : headers) {
|
for (Header header : headers) {
|
||||||
if (header.getValue().equalsIgnoreCase(new ODataPreferences().respondAsync())) {
|
if (header.getValue().equalsIgnoreCase(new ODataPreferences().respondAsync())) {
|
||||||
|
|
|
@ -26,7 +26,6 @@ import java.util.concurrent.TimeUnit;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
import org.apache.http.client.HttpClient;
|
import org.apache.http.client.HttpClient;
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
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.header.ODataPreferences;
|
||||||
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
|
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
|
||||||
import org.apache.olingo.client.api.communication.request.batch.BatchManager;
|
import org.apache.olingo.client.api.communication.request.batch.BatchManager;
|
||||||
|
@ -68,7 +67,7 @@ public class ODataBatchRequestImpl
|
||||||
@Override
|
@Override
|
||||||
protected HttpResponse doExecute() {
|
protected HttpResponse doExecute() {
|
||||||
if (odataClient.getConfiguration().isContinueOnError()) {
|
if (odataClient.getConfiguration().isContinueOnError()) {
|
||||||
addCustomHeader(HeaderName.prefer, new ODataPreferences().continueOnError());
|
setPrefer(new ODataPreferences().continueOnError());
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.doExecute();
|
return super.doExecute();
|
||||||
|
|
|
@ -34,11 +34,11 @@ import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.io.LineIterator;
|
import org.apache.commons.io.LineIterator;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.olingo.client.api.ODataBatchConstants;
|
import org.apache.olingo.client.api.ODataBatchConstants;
|
||||||
import org.apache.olingo.client.api.communication.header.HeaderName;
|
|
||||||
import org.apache.olingo.client.api.communication.request.ODataStreamer;
|
import org.apache.olingo.client.api.communication.request.ODataStreamer;
|
||||||
import org.apache.olingo.client.api.communication.request.batch.ODataBatchLineIterator;
|
import org.apache.olingo.client.api.communication.request.batch.ODataBatchLineIterator;
|
||||||
import org.apache.olingo.commons.api.Constants;
|
import org.apache.olingo.commons.api.Constants;
|
||||||
import org.apache.olingo.commons.api.format.ContentType;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
|
import org.apache.olingo.commons.api.http.HttpHeader;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -48,12 +48,11 @@ import org.slf4j.LoggerFactory;
|
||||||
public class ODataBatchUtilities {
|
public class ODataBatchUtilities {
|
||||||
|
|
||||||
public static enum BatchItemType {
|
public static enum BatchItemType {
|
||||||
|
|
||||||
NONE,
|
NONE,
|
||||||
CHANGESET,
|
CHANGESET,
|
||||||
RETRIEVE
|
RETRIEVE
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logger.
|
* Logger.
|
||||||
*/
|
*/
|
||||||
|
@ -300,8 +299,9 @@ public class ODataBatchUtilities {
|
||||||
|
|
||||||
final BatchItemType nextItemType;
|
final BatchItemType nextItemType;
|
||||||
|
|
||||||
final String contentType = headers.containsKey(HeaderName.contentType.toString())
|
final String contentType = headers.containsKey(HttpHeader.CONTENT_TYPE) ?
|
||||||
? headers.get(HeaderName.contentType.toString()).toString() : StringUtils.EMPTY;
|
headers.get(HttpHeader.CONTENT_TYPE).toString() :
|
||||||
|
StringUtils.EMPTY;
|
||||||
|
|
||||||
if (contentType.contains(ContentType.MULTIPART_MIXED.toContentTypeString())) {
|
if (contentType.contains(ContentType.MULTIPART_MIXED.toContentTypeString())) {
|
||||||
nextItemType = BatchItemType.CHANGESET;
|
nextItemType = BatchItemType.CHANGESET;
|
||||||
|
|
|
@ -20,12 +20,12 @@ package org.apache.olingo.client.core.communication.request.batch;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.apache.olingo.client.api.communication.header.HeaderName;
|
|
||||||
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
|
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
|
||||||
import org.apache.olingo.client.api.communication.request.batch.ODataBatchRequest;
|
import org.apache.olingo.client.api.communication.request.batch.ODataBatchRequest;
|
||||||
import org.apache.olingo.client.api.communication.request.batch.ODataChangeset;
|
import org.apache.olingo.client.api.communication.request.batch.ODataChangeset;
|
||||||
import org.apache.olingo.client.core.communication.request.AbstractODataRequest;
|
import org.apache.olingo.client.core.communication.request.AbstractODataRequest;
|
||||||
import org.apache.olingo.commons.api.format.ContentType;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
|
import org.apache.olingo.commons.api.http.HttpHeader;
|
||||||
import org.apache.olingo.commons.api.http.HttpMethod;
|
import org.apache.olingo.commons.api.http.HttpMethod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -99,7 +99,7 @@ public class ODataChangesetImpl extends AbstractODataBatchRequestItem
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasStreamedSomething) {
|
if (!hasStreamedSomething) {
|
||||||
stream((HeaderName.contentType.toString() + ": "
|
stream((HttpHeader.CONTENT_TYPE + ": "
|
||||||
+ ContentType.MULTIPART_MIXED + ";boundary=" + boundary).getBytes());
|
+ ContentType.MULTIPART_MIXED + ";boundary=" + boundary).getBytes());
|
||||||
|
|
||||||
newLine();
|
newLine();
|
||||||
|
|
|
@ -23,7 +23,6 @@ import java.util.Collection;
|
||||||
|
|
||||||
import org.apache.http.client.HttpClient;
|
import org.apache.http.client.HttpClient;
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.client.api.communication.header.HeaderName;
|
|
||||||
import org.apache.olingo.client.api.communication.request.retrieve.EdmMetadataRequest;
|
import org.apache.olingo.client.api.communication.request.retrieve.EdmMetadataRequest;
|
||||||
import org.apache.olingo.client.api.communication.request.retrieve.XMLMetadataRequest;
|
import org.apache.olingo.client.api.communication.request.retrieve.XMLMetadataRequest;
|
||||||
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
||||||
|
@ -112,11 +111,6 @@ class EdmMetadataRequestImpl extends AbstractMetadataRequestImpl<Edm> implements
|
||||||
return xmlMetadataResponse.getHeader(name);
|
return xmlMetadataResponse.getHeader(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<String> getHeader(final HeaderName name) {
|
|
||||||
return xmlMetadataResponse.getHeader(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public XMLMetadata getXMLMetadata() {
|
public XMLMetadata getXMLMetadata() {
|
||||||
if (metadata == null) {
|
if (metadata == null) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -35,7 +35,6 @@ import org.apache.http.HttpResponse;
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.http.HttpStatus;
|
||||||
import org.apache.http.client.HttpClient;
|
import org.apache.http.client.HttpClient;
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.client.api.communication.header.HeaderName;
|
|
||||||
import org.apache.olingo.client.api.communication.request.ODataStreamer;
|
import org.apache.olingo.client.api.communication.request.ODataStreamer;
|
||||||
import org.apache.olingo.client.api.communication.request.batch.ODataBatchLineIterator;
|
import org.apache.olingo.client.api.communication.request.batch.ODataBatchLineIterator;
|
||||||
import org.apache.olingo.client.api.communication.response.ODataResponse;
|
import org.apache.olingo.client.api.communication.response.ODataResponse;
|
||||||
|
@ -45,6 +44,7 @@ import org.apache.olingo.client.core.communication.request.batch.ODataBatchLineI
|
||||||
import org.apache.olingo.client.core.communication.request.batch.ODataBatchUtilities;
|
import org.apache.olingo.client.core.communication.request.batch.ODataBatchUtilities;
|
||||||
import org.apache.olingo.commons.api.Constants;
|
import org.apache.olingo.commons.api.Constants;
|
||||||
import org.apache.olingo.commons.api.ODataRuntimeException;
|
import org.apache.olingo.commons.api.ODataRuntimeException;
|
||||||
|
import org.apache.olingo.commons.api.http.HttpHeader;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -112,76 +112,46 @@ public abstract class AbstractODataResponse implements ODataResponse {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<String> getHeaderNames() {
|
public Collection<String> getHeaderNames() {
|
||||||
return headers.keySet();
|
return headers.keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<String> getHeader(final String name) {
|
public Collection<String> getHeader(final String name) {
|
||||||
return headers.get(name);
|
return headers.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Collection<String> getHeader(final HeaderName name) {
|
|
||||||
return headers.get(name.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getETag() {
|
public String getETag() {
|
||||||
final Collection<String> etag = getHeader(HeaderName.etag);
|
final Collection<String> etag = getHeader(HttpHeader.ETAG);
|
||||||
return etag == null || etag.isEmpty()
|
return etag == null || etag.isEmpty() ? null : etag.iterator().next();
|
||||||
? null
|
|
||||||
: etag.iterator().next();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getContentType() {
|
public String getContentType() {
|
||||||
final Collection<String> contentTypes = getHeader(HeaderName.contentType);
|
final Collection<String> contentTypes = getHeader(HttpHeader.CONTENT_TYPE);
|
||||||
return contentTypes == null || contentTypes.isEmpty()
|
return contentTypes == null || contentTypes.isEmpty() ? null : contentTypes.iterator().next();
|
||||||
? null
|
|
||||||
: contentTypes.iterator().next();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int getStatusCode() {
|
public int getStatusCode() {
|
||||||
return statusCode;
|
return statusCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getStatusMessage() {
|
public String getStatusMessage() {
|
||||||
return statusMessage;
|
return statusMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public final ODataResponse initFromHttpResponse(final HttpResponse res) {
|
public final ODataResponse initFromHttpResponse(final HttpResponse res) {
|
||||||
try {
|
try {
|
||||||
this.payload = res.getEntity() == null ? null : res.getEntity().getContent();
|
this.payload = res.getEntity() == null ? null : res.getEntity().getContent();
|
||||||
} catch (Exception e) {
|
} catch (final IllegalStateException e) {
|
||||||
|
LOG.error("Error retrieving payload", e);
|
||||||
|
throw new ODataRuntimeException(e);
|
||||||
|
} catch (final IOException e) {
|
||||||
LOG.error("Error retrieving payload", e);
|
LOG.error("Error retrieving payload", e);
|
||||||
throw new ODataRuntimeException(e);
|
throw new ODataRuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@ -205,9 +175,6 @@ public abstract class AbstractODataResponse implements ODataResponse {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public ODataResponse initFromBatch(
|
public ODataResponse initFromBatch(
|
||||||
final Map.Entry<Integer, String> responseLine,
|
final Map.Entry<Integer, String> responseLine,
|
||||||
|
@ -229,9 +196,6 @@ public abstract class AbstractODataResponse implements ODataResponse {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public ODataResponse initFromEnclosedPart(final InputStream part) {
|
public ODataResponse initFromEnclosedPart(final InputStream part) {
|
||||||
try {
|
try {
|
||||||
|
@ -275,9 +239,6 @@ public abstract class AbstractODataResponse implements ODataResponse {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc }
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
odataClient.getConfiguration().getHttpClientFactory().close(httpClient);
|
odataClient.getConfiguration().getHttpClientFactory().close(httpClient);
|
||||||
|
@ -287,9 +248,6 @@ public abstract class AbstractODataResponse implements ODataResponse {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream getRawResponse() {
|
public InputStream getRawResponse() {
|
||||||
if (HttpStatus.SC_NO_CONTENT == getStatusCode()) {
|
if (HttpStatus.SC_NO_CONTENT == getStatusCode()) {
|
||||||
|
|
|
@ -26,7 +26,6 @@ import java.util.Map;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.olingo.client.api.communication.header.HeaderName;
|
|
||||||
import org.apache.olingo.client.api.communication.request.batch.ODataBatchLineIterator;
|
import org.apache.olingo.client.api.communication.request.batch.ODataBatchLineIterator;
|
||||||
import org.apache.olingo.client.api.communication.request.batch.ODataBatchResponseItem;
|
import org.apache.olingo.client.api.communication.request.batch.ODataBatchResponseItem;
|
||||||
import org.apache.olingo.client.api.communication.response.ODataBatchResponse;
|
import org.apache.olingo.client.api.communication.response.ODataBatchResponse;
|
||||||
|
@ -34,6 +33,7 @@ import org.apache.olingo.client.core.communication.request.batch.ODataBatchLineI
|
||||||
import org.apache.olingo.client.core.communication.request.batch.ODataBatchUtilities;
|
import org.apache.olingo.client.core.communication.request.batch.ODataBatchUtilities;
|
||||||
import org.apache.olingo.client.core.communication.request.batch.ODataChangesetResponseItem;
|
import org.apache.olingo.client.core.communication.request.batch.ODataChangesetResponseItem;
|
||||||
import org.apache.olingo.commons.api.Constants;
|
import org.apache.olingo.commons.api.Constants;
|
||||||
|
import org.apache.olingo.commons.api.http.HttpHeader;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ public class ODataBatchResponseManager implements Iterator<ODataBatchResponseIte
|
||||||
|
|
||||||
// search for boundary
|
// search for boundary
|
||||||
batchBoundary = ODataBatchUtilities.getBoundaryFromHeader(
|
batchBoundary = ODataBatchUtilities.getBoundaryFromHeader(
|
||||||
res.getHeader(HeaderName.contentType));
|
res.getHeader(HttpHeader.CONTENT_TYPE));
|
||||||
LOG.debug("Retrieved batch response bondary '{}'", batchBoundary);
|
LOG.debug("Retrieved batch response bondary '{}'", batchBoundary);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOG.error("Error parsing batch response", e);
|
LOG.error("Error parsing batch response", e);
|
||||||
|
@ -104,17 +104,11 @@ public class ODataBatchResponseManager implements Iterator<ODataBatchResponseIte
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc }
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return (current == null || continueOnError || !current.isBreaking()) && expectedItemsIterator.hasNext();
|
return (current == null || continueOnError || !current.isBreaking()) && expectedItemsIterator.hasNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc }
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public ODataBatchResponseItem next() {
|
public ODataBatchResponseItem next() {
|
||||||
if (current != null) {
|
if (current != null) {
|
||||||
|
@ -138,7 +132,7 @@ public class ODataBatchResponseManager implements Iterator<ODataBatchResponseIte
|
||||||
|
|
||||||
current.initFromBatch(
|
current.initFromBatch(
|
||||||
batchLineIterator,
|
batchLineIterator,
|
||||||
ODataBatchUtilities.getBoundaryFromHeader(nextItemHeaders.get(HeaderName.contentType.toString())));
|
ODataBatchUtilities.getBoundaryFromHeader(nextItemHeaders.get(HttpHeader.CONTENT_TYPE)));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RETRIEVE:
|
case RETRIEVE:
|
||||||
|
|
Loading…
Reference in New Issue