You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2019/08/23 08:51:12 UTC
[camel] 03/03: Camel-Olingo4: Fixed CS
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 7605794d774cce2423cd1c0f8b3ec788521d77a5
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Fri Aug 23 10:50:33 2019 +0200
Camel-Olingo4: Fixed CS
---
.../camel/component/olingo4/api/Olingo4App.java | 87 +++++++++++-----
.../olingo4/api/Olingo4ResponseHandler.java | 18 ++--
.../olingo4/api/batch/Olingo4BatchRequest.java | 4 +-
.../component/olingo4/api/batch/Operation.java | 11 +-
.../olingo4/api/impl/AbstractFutureCallback.java | 12 +--
.../component/olingo4/api/impl/Olingo4AppImpl.java | 113 ++++++++++-----------
.../camel/component/olingo4/Olingo4AppAPITest.java | 65 ++++++------
.../component/olingo4/Olingo4Configuration.java | 69 +++++++------
.../camel/component/olingo4/Olingo4Consumer.java | 21 ++--
.../camel/component/olingo4/Olingo4Endpoint.java | 6 +-
.../camel/component/olingo4/Olingo4Producer.java | 8 +-
.../olingo4/internal/Olingo4Constants.java | 2 +-
.../olingo4/Olingo4ComponentConsumerTest.java | 109 ++++++++------------
.../olingo4/Olingo4ComponentProducerTest.java | 3 +-
.../camel/component/olingo4/Olingo4RouteTest.java | 4 +-
15 files changed, 281 insertions(+), 251 deletions(-)
diff --git a/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/Olingo4App.java b/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/Olingo4App.java
index 0649a7c..fa6f9b6 100644
--- a/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/Olingo4App.java
+++ b/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/Olingo4App.java
@@ -31,36 +31,43 @@ public interface Olingo4App {
/**
* Sets Service base URI.
+ *
* @param serviceUri
*/
void setServiceUri(String serviceUri);
/**
* Returns Service base URI.
+ *
* @return service base URI.
*/
String getServiceUri();
/**
* Sets custom Http headers to add to every service request.
+ *
* @param httpHeaders custom Http headers.
*/
void setHttpHeaders(Map<String, String> httpHeaders);
/**
* Returns custom Http headers.
+ *
* @return custom Http headers.
*/
Map<String, String> getHttpHeaders();
/**
- * Returns content type for service calls. Defaults to <code>application/json;charset=utf-8</code>.
+ * Returns content type for service calls. Defaults to
+ * <code>application/json;charset=utf-8</code>.
+ *
* @return content type.
*/
String getContentType();
/**
* Set default service call content type.
+ *
* @param contentType content type.
*/
void setContentType(String contentType);
@@ -72,40 +79,54 @@ public interface Olingo4App {
/**
* Reads an OData resource and invokes callback with appropriate result.
- * @param edm Service Edm, read from calling <code>read(null, "$metdata", null, responseHandler)</code>
+ *
+ * @param edm Service Edm, read from calling
+ * <code>read(null, "$metdata", null, responseHandler)</code>
* @param resourcePath OData Resource path
* @param queryParams OData query params
- * http://docs.oasis-open.org/odata/odata/v4.0/odata-v4.0-part1-protocol.html#_Toc453752288
- * @param endpointHttpHeaders HTTP Headers to add/override the component versions
+ * http://docs.oasis-open.org/odata/odata/v4.0/odata-v4.0-part1-protocol.html#_Toc453752288
+ * @param endpointHttpHeaders HTTP Headers to add/override the component
+ * versions
* @param responseHandler callback handler
*/
<T> void read(Edm edm, String resourcePath, Map<String, String> queryParams, Map<String, String> endpointHttpHeaders, Olingo4ResponseHandler<T> responseHandler);
/**
- * Reads an OData resource and invokes callback with the unparsed input stream.
- * @param edm Service Edm, read from calling <code>read(null, "$metdata", null, responseHandler)</code>
+ * Reads an OData resource and invokes callback with the unparsed input
+ * stream.
+ *
+ * @param edm Service Edm, read from calling
+ * <code>read(null, "$metdata", null, responseHandler)</code>
* @param resourcePath OData Resource path
* @param queryParams OData query params
- * http://docs.oasis-open.org/odata/odata/v4.0/odata-v4.0-part1-protocol.html#_Toc453752288
- * @param endpointHttpHeaders HTTP Headers to add/override the component versions
+ * http://docs.oasis-open.org/odata/odata/v4.0/odata-v4.0-part1-protocol.html#_Toc453752288
+ * @param endpointHttpHeaders HTTP Headers to add/override the component
+ * versions
* @param responseHandler callback handler
*/
void uread(Edm edm, String resourcePath, Map<String, String> queryParams, Map<String, String> endpointHttpHeaders, Olingo4ResponseHandler<InputStream> responseHandler);
/**
- * Deletes an OData resource and invokes callback
- * with {@link org.apache.olingo.commons.api.http.HttpStatusCode} on success, or with exception on failure.
+ * Deletes an OData resource and invokes callback with
+ * {@link org.apache.olingo.commons.api.http.HttpStatusCode} on success, or
+ * with exception on failure.
+ *
* @param resourcePath resource path for Entry
- * @param endpointHttpHeaders HTTP Headers to add/override the component versions
- * @param responseHandler {@link org.apache.olingo.commons.api.http.HttpStatusCode} callback handler
+ * @param endpointHttpHeaders HTTP Headers to add/override the component
+ * versions
+ * @param responseHandler
+ * {@link org.apache.olingo.commons.api.http.HttpStatusCode} callback
+ * handler
*/
void delete(String resourcePath, Map<String, String> endpointHttpHeaders, Olingo4ResponseHandler<HttpStatusCode> responseHandler);
/**
* Creates a new OData resource.
+ *
* @param edm service Edm
* @param resourcePath resource path to create
- * @param endpointHttpHeaders HTTP Headers to add/override the component versions
+ * @param endpointHttpHeaders HTTP Headers to add/override the component
+ * versions
* @param data request data
* @param responseHandler callback handler
*/
@@ -113,50 +134,70 @@ public interface Olingo4App {
/**
* Updates an OData resource.
+ *
* @param edm service Edm
* @param resourcePath resource path to update
- * @param endpointHttpHeaders HTTP Headers to add/override the component versions
+ * @param endpointHttpHeaders HTTP Headers to add/override the component
+ * versions
* @param data updated data
- * @param responseHandler {@link org.apache.olingo.client.api.domain.ClientEntity} callback handler
+ * @param responseHandler
+ * {@link org.apache.olingo.client.api.domain.ClientEntity} callback
+ * handler
*/
<T> void update(Edm edm, String resourcePath, Map<String, String> endpointHttpHeaders, Object data, Olingo4ResponseHandler<T> responseHandler);
/**
* Patches/merges an OData resource using HTTP PATCH.
+ *
* @param edm service Edm
* @param resourcePath resource path to update
- * @param endpointHttpHeaders HTTP Headers to add/override the component versions
+ * @param endpointHttpHeaders HTTP Headers to add/override the component
+ * versions
* @param data patch/merge data
- * @param responseHandler {@link org.apache.olingo.client.api.domain.ClientEntity} callback handler
+ * @param responseHandler
+ * {@link org.apache.olingo.client.api.domain.ClientEntity} callback
+ * handler
*/
<T> void patch(Edm edm, String resourcePath, Map<String, String> endpointHttpHeaders, Object data, Olingo4ResponseHandler<T> responseHandler);
/**
* Patches/merges an OData resource using HTTP MERGE.
+ *
* @param edm service Edm
* @param resourcePath resource path to update
- * @param endpointHttpHeaders HTTP Headers to add/override the component versions
+ * @param endpointHttpHeaders HTTP Headers to add/override the component
+ * versions
* @param data patch/merge data
- * @param responseHandler {@link org.apache.olingo.client.api.domain.ClientEntity} callback handler
+ * @param responseHandler
+ * {@link org.apache.olingo.client.api.domain.ClientEntity} callback
+ * handler
*/
<T> void merge(Edm edm, String resourcePath, Map<String, String> endpointHttpHeaders, Object data, Olingo4ResponseHandler<T> responseHandler);
/**
* Executes a batch request.
+ *
* @param edm service Edm
- * @param endpointHttpHeaders HTTP Headers to add/override the component versions
- * @param data ordered {@link org.apache.camel.component.olingo4.api.batch.Olingo4BatchRequest} list
+ * @param endpointHttpHeaders HTTP Headers to add/override the component
+ * versions
+ * @param data ordered
+ * {@link org.apache.camel.component.olingo4.api.batch.Olingo4BatchRequest}
+ * list
* @param responseHandler callback handler
*/
void batch(Edm edm, Map<String, String> endpointHttpHeaders, Object data, Olingo4ResponseHandler<List<Olingo4BatchResponse>> responseHandler);
/**
* Calls a OData action
+ *
* @param edm service Edm
* @param resourcePath resource path to action
- * @param endpointHttpHeaders HTTP Headers to add/override the component versions
+ * @param endpointHttpHeaders HTTP Headers to add/override the component
+ * versions
* @param data action data
- * @param responseHandler {@link org.apache.olingo.client.api.domain.ClientEntity} callback handler
+ * @param responseHandler
+ * {@link org.apache.olingo.client.api.domain.ClientEntity} callback
+ * handler
*/
<T> void action(Edm edm, String resourcePath, Map<String, String> endpointHttpHeaders, Object data, Olingo4ResponseHandler<T> responseHandler);
}
diff --git a/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/Olingo4ResponseHandler.java b/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/Olingo4ResponseHandler.java
index 01d9587..05bc2d0 100644
--- a/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/Olingo4ResponseHandler.java
+++ b/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/Olingo4ResponseHandler.java
@@ -25,22 +25,26 @@ public interface Olingo4ResponseHandler<T> {
/**
* Handle response data on successful completion of Olingo4 request.
- * @param response response data from Olingo4, may be NULL for Olingo4 operations with no response data.
- * @param responseHeaders the response HTTP headers received from the endpoint.
+ *
+ * @param response response data from Olingo4, may be NULL for Olingo4
+ * operations with no response data.
+ * @param responseHeaders the response HTTP headers received from the
+ * endpoint.
*/
void onResponse(T response, Map<String, String> responseHeaders);
/**
* Handle exception raised from Olingo4 request.
- * @param ex exception from Olingo4 request.
- * May be an instance of {@link org.apache.olingo.commons.api.ex.ODataException} or
- * some other exception, such as {@link java.io.IOException}
+ *
+ * @param ex exception from Olingo4 request. May be an instance of
+ * {@link org.apache.olingo.commons.api.ex.ODataException} or
+ * some other exception, such as {@link java.io.IOException}
*/
void onException(Exception ex);
/**
- * Handle Olingo4 request cancellation.
- * May be caused by the underlying HTTP connection being shutdown asynchronously.
+ * Handle Olingo4 request cancellation. May be caused by the underlying HTTP
+ * connection being shutdown asynchronously.
*/
void onCanceled();
}
diff --git a/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/batch/Olingo4BatchRequest.java b/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/batch/Olingo4BatchRequest.java
index 7815691..6b050f4 100644
--- a/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/batch/Olingo4BatchRequest.java
+++ b/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/batch/Olingo4BatchRequest.java
@@ -31,7 +31,7 @@ public abstract class Olingo4BatchRequest {
public String getResourceUri() {
return resourceUri;
}
-
+
public String getResourcePath() {
return resourcePath;
}
@@ -42,4 +42,4 @@ public abstract class Olingo4BatchRequest {
@Override
public abstract String toString();
-}
\ No newline at end of file
+}
diff --git a/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/batch/Operation.java b/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/batch/Operation.java
index 921306c..bb9094d 100644
--- a/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/batch/Operation.java
+++ b/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/batch/Operation.java
@@ -17,15 +17,12 @@
package org.apache.camel.component.olingo4.api.batch;
/**
-* OData operation used by {@link org.apache.camel.component.olingo4.api.batch.Olingo4BatchChangeRequest}.
-*/
+ * OData operation used by
+ * {@link org.apache.camel.component.olingo4.api.batch.Olingo4BatchChangeRequest}.
+ */
public enum Operation {
- CREATE("POST"),
- UPDATE("PUT"),
- PATCH("PATCH"),
- MERGE("MERGE"),
- DELETE("DELETE");
+ CREATE("POST"), UPDATE("PUT"), PATCH("PATCH"), MERGE("MERGE"), DELETE("DELETE");
private final String httpMethod;
diff --git a/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/AbstractFutureCallback.java b/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/AbstractFutureCallback.java
index 4cb62ca..09688ae 100644
--- a/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/AbstractFutureCallback.java
+++ b/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/AbstractFutureCallback.java
@@ -35,14 +35,14 @@ import org.apache.olingo.commons.api.http.HttpStatusCode;
import static org.apache.camel.component.olingo4.api.impl.Olingo4Helper.getContentTypeHeader;
/**
-* Helper implementation of {@link org.apache.http.concurrent.FutureCallback}
+ * Helper implementation of {@link org.apache.http.concurrent.FutureCallback}
* for {@link org.apache.camel.component.olingo4.api.impl.Olingo4AppImpl}
-*/
+ */
public abstract class AbstractFutureCallback<T> implements FutureCallback<HttpResponse> {
public static final Pattern ODATA_MIME_TYPE_PATTERN = Pattern.compile("application/((atom)|(json)|(xml)).*");
public static final int NETWORK_CONNECT_TIMEOUT_ERROR = 599;
-
+
private final Olingo4ResponseHandler<T> responseHandler;
AbstractFutureCallback(Olingo4ResponseHandler<T> responseHandler) {
@@ -56,11 +56,11 @@ public abstract class AbstractFutureCallback<T> implements FutureCallback<HttpRe
if (response.getEntity() != null) {
try {
final ContentType responseContentType = getContentTypeHeader(response);
-
+
if (responseContentType != null && ODATA_MIME_TYPE_PATTERN.matcher(responseContentType.toContentTypeString()).matches()) {
final ODataReader reader = ODataClientFactory.getClient().getReader();
final ODataError error = reader.readError(response.getEntity().getContent(), responseContentType);
-
+
throw new ODataClientErrorException(statusLine, error);
}
} catch (IOException e) {
@@ -86,7 +86,7 @@ public abstract class AbstractFutureCallback<T> implements FutureCallback<HttpRe
} finally {
if (result instanceof Closeable) {
try {
- ((Closeable) result).close();
+ ((Closeable)result).close();
} catch (final IOException ignore) {
}
}
diff --git a/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4AppImpl.java b/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4AppImpl.java
index 87f4ccb..9eb5d49 100644
--- a/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4AppImpl.java
+++ b/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4AppImpl.java
@@ -111,6 +111,7 @@ import org.apache.olingo.server.api.uri.UriResourceKind;
import org.apache.olingo.server.core.uri.parser.Parser;
import static org.apache.camel.component.olingo4.api.impl.Olingo4Helper.getContentTypeHeader;
+
/**
* Application API used by Olingo4 Component.
*/
@@ -269,20 +270,20 @@ public final class Olingo4AppImpl implements Olingo4App {
}
@Override
- public <T> void create(final Edm edm, final String resourcePath, final Map<String, String> endpointHttpHeaders, final Object data, final Olingo4ResponseHandler<T> responseHandler) {
+ public <T> void create(final Edm edm, final String resourcePath, final Map<String, String> endpointHttpHeaders, final Object data,
+ final Olingo4ResponseHandler<T> responseHandler) {
final UriInfo uriInfo = parseUri(edm, resourcePath, null, serviceUri);
writeContent(edm, new HttpPost(createUri(resourcePath, null)), uriInfo, data, endpointHttpHeaders, responseHandler);
}
@Override
- public <T> void update(final Edm edm, final String resourcePath, final Map<String, String> endpointHttpHeaders, final Object data, final Olingo4ResponseHandler<T> responseHandler) {
+ public <T> void update(final Edm edm, final String resourcePath, final Map<String, String> endpointHttpHeaders, final Object data,
+ final Olingo4ResponseHandler<T> responseHandler) {
final UriInfo uriInfo = parseUri(edm, resourcePath, null, serviceUri);
- augmentWithETag(edm, resourcePath, endpointHttpHeaders,
- new HttpPut(createUri(resourcePath, null)),
- request -> writeContent(edm, (HttpPut) request, uriInfo, data, endpointHttpHeaders, responseHandler),
- responseHandler);
+ augmentWithETag(edm, resourcePath, endpointHttpHeaders, new HttpPut(createUri(resourcePath, null)),
+ request -> writeContent(edm, (HttpPut)request, uriInfo, data, endpointHttpHeaders, responseHandler), responseHandler);
}
@Override
@@ -299,30 +300,25 @@ public final class Olingo4AppImpl implements Olingo4App {
});
};
- augmentWithETag(null, resourcePath, endpointHttpHeaders,
- deleteRequest,
- deleteFunction,
- responseHandler);
+ augmentWithETag(null, resourcePath, endpointHttpHeaders, deleteRequest, deleteFunction, responseHandler);
}
@Override
- public <T> void patch(final Edm edm, final String resourcePath, final Map<String, String> endpointHttpHeaders, final Object data, final Olingo4ResponseHandler<T> responseHandler) {
+ public <T> void patch(final Edm edm, final String resourcePath, final Map<String, String> endpointHttpHeaders, final Object data,
+ final Olingo4ResponseHandler<T> responseHandler) {
final UriInfo uriInfo = parseUri(edm, resourcePath, null, serviceUri);
- augmentWithETag(edm, resourcePath, endpointHttpHeaders,
- new HttpPatch(createUri(resourcePath, null)),
- request -> writeContent(edm, (HttpPatch) request, uriInfo, data, endpointHttpHeaders, responseHandler),
- responseHandler);
+ augmentWithETag(edm, resourcePath, endpointHttpHeaders, new HttpPatch(createUri(resourcePath, null)),
+ request -> writeContent(edm, (HttpPatch)request, uriInfo, data, endpointHttpHeaders, responseHandler), responseHandler);
}
@Override
- public <T> void merge(final Edm edm, final String resourcePath, final Map<String, String> endpointHttpHeaders, final Object data, final Olingo4ResponseHandler<T> responseHandler) {
+ public <T> void merge(final Edm edm, final String resourcePath, final Map<String, String> endpointHttpHeaders, final Object data,
+ final Olingo4ResponseHandler<T> responseHandler) {
final UriInfo uriInfo = parseUri(edm, resourcePath, null, serviceUri);
- augmentWithETag(edm, resourcePath, endpointHttpHeaders,
- new HttpMerge(createUri(resourcePath, null)),
- request -> writeContent(edm, (HttpMerge) request, uriInfo, data, endpointHttpHeaders, responseHandler),
- responseHandler);
+ augmentWithETag(edm, resourcePath, endpointHttpHeaders, new HttpMerge(createUri(resourcePath, null)),
+ request -> writeContent(edm, (HttpMerge)request, uriInfo, data, endpointHttpHeaders, responseHandler), responseHandler);
}
@Override
@@ -333,7 +329,8 @@ public final class Olingo4AppImpl implements Olingo4App {
}
@Override
- public <T> void action(final Edm edm, final String resourcePath, final Map<String, String> endpointHttpHeaders, final Object data, final Olingo4ResponseHandler<T> responseHandler) {
+ public <T> void action(final Edm edm, final String resourcePath, final Map<String, String> endpointHttpHeaders, final Object data,
+ final Olingo4ResponseHandler<T> responseHandler) {
final UriInfo uriInfo = parseUri(edm, resourcePath, null, serviceUri);
writeContent(edm, new HttpPost(createUri(resourcePath, null)), uriInfo, data, endpointHttpHeaders, responseHandler);
@@ -367,28 +364,31 @@ public final class Olingo4AppImpl implements Olingo4App {
}
/**
- * On occasion, some resources are protected with Optimistic Concurrency via the use of eTags.
- * This will first conduct a read on the given entity resource, find its eTag then perform the given
- * delegate request function, augmenting the request with the eTag, if appropriate.
- *
- * Since read operations may be asynchronous, it is necessary to chain together the methods via
- * the use of a {@link Consumer} function. Only when the response from the read returns will
- * this delegate function be executed.
+ * On occasion, some resources are protected with Optimistic Concurrency via
+ * the use of eTags. This will first conduct a read on the given entity
+ * resource, find its eTag then perform the given delegate request function,
+ * augmenting the request with the eTag, if appropriate. Since read
+ * operations may be asynchronous, it is necessary to chain together the
+ * methods via the use of a {@link Consumer} function. Only when the
+ * response from the read returns will this delegate function be executed.
*
* @param edm the Edm object to be interrogated
* @param resourcePath the resource path of the entity to be operated on
- * @param endpointHttpHeaders the headers provided from the endpoint which may be required for the read operation
- * @param httpRequest the request to be updated, if appropriate, with the eTag and provided to the delegate request function
- * @param delegateRequestFn the function to be invoked in response to the read operation
- * @param delegateResponseHandler the response handler to respond if any errors occur during the read operation
+ * @param endpointHttpHeaders the headers provided from the endpoint which
+ * may be required for the read operation
+ * @param httpRequest the request to be updated, if appropriate, with the
+ * eTag and provided to the delegate request function
+ * @param delegateRequestFn the function to be invoked in response to the
+ * read operation
+ * @param delegateResponseHandler the response handler to respond if any
+ * errors occur during the read operation
*/
- private <T> void augmentWithETag(final Edm edm, final String resourcePath, final Map<String, String> endpointHttpHeaders,
- final HttpRequestBase httpRequest,
- final Consumer<HttpRequestBase> delegateRequestFn,
- final Olingo4ResponseHandler<T> delegateResponseHandler) {
+ private <T> void augmentWithETag(final Edm edm, final String resourcePath, final Map<String, String> endpointHttpHeaders, final HttpRequestBase httpRequest,
+ final Consumer<HttpRequestBase> delegateRequestFn, final Olingo4ResponseHandler<T> delegateResponseHandler) {
if (edm == null) {
- // Can be the case if calling a delete then need to do a metadata call first
+ // Can be the case if calling a delete then need to do a metadata
+ // call first
final Olingo4ResponseHandler<Edm> edmResponseHandler = new Olingo4ResponseHandler<Edm>() {
@Override
public void onResponse(Edm response, Map<String, String> responseHeaders) {
@@ -411,14 +411,16 @@ public final class Olingo4AppImpl implements Olingo4App {
//
// Reads the metadata to establish an Edm object
- // then the response handler invokes this method again with the new edm object
+ // then the response handler invokes this method again with the new
+ // edm object
//
read(null, Constants.METADATA, null, null, edmResponseHandler);
} else {
//
- // The handler that responds to the read operation and supplies an ETag if necessary
+ // The handler that responds to the read operation and supplies an
+ // ETag if necessary
// and invokes the delegate request function
//
Olingo4ResponseHandler<T> eTagReadHandler = new Olingo4ResponseHandler<T>() {
@@ -426,13 +428,12 @@ public final class Olingo4AppImpl implements Olingo4App {
@Override
public void onResponse(T response, Map<String, String> responseHeaders) {
if (response instanceof ClientEntity) {
- ClientEntity e = (ClientEntity) response;
- Optional
- .ofNullable(e.getETag())
- .ifPresent(v -> httpRequest.addHeader("If-Match", v));
+ ClientEntity e = (ClientEntity)response;
+ Optional.ofNullable(e.getETag()).ifPresent(v -> httpRequest.addHeader("If-Match", v));
}
- // Invoke the delegate request function providing the modified request
+ // Invoke the delegate request function providing the
+ // modified request
delegateRequestFn.accept(httpRequest);
}
@@ -593,8 +594,7 @@ public final class Olingo4AppImpl implements Olingo4App {
switch (lastResourceKind) {
case action:
case entitySet:
- ClientEntity entity = odataReader.readEntity(result.getEntity().getContent(),
- ContentType.parse(result.getEntity().getContentType().getValue()));
+ ClientEntity entity = odataReader.readEntity(result.getEntity().getContent(), ContentType.parse(result.getEntity().getContentType().getValue()));
responseHandler.onResponse((T)entity, headersToMap(result.getAllHeaders()));
break;
default:
@@ -641,7 +641,7 @@ public final class Olingo4AppImpl implements Olingo4App {
} else if (uriInfo.getKind() == UriInfoKind.batch) {
final String boundary = BOUNDARY_PREFIX + UUID.randomUUID();
final String contentHeader = BATCH_CONTENT_TYPE + BOUNDARY_PARAMETER + boundary;
- final List<Olingo4BatchRequest> batchParts = (List<Olingo4BatchRequest>) content;
+ final List<Olingo4BatchRequest> batchParts = (List<Olingo4BatchRequest>)content;
final InputStream requestStream = serializeBatchRequest(edm, batchParts, BOUNDARY_DOUBLE_DASH + boundary);
httpEntity = writeContent(requestStream);
@@ -657,10 +657,10 @@ public final class Olingo4AppImpl implements Olingo4App {
AbstractHttpEntity httpEntity;
if (content instanceof ClientEntity) {
- final InputStream requestStream = odataWriter.writeEntity((ClientEntity) content, getResourceContentType(uriInfo));
+ final InputStream requestStream = odataWriter.writeEntity((ClientEntity)content, getResourceContentType(uriInfo));
httpEntity = writeContent(requestStream);
} else if (content instanceof String) {
- httpEntity = new StringEntity((String) content, org.apache.http.entity.ContentType.APPLICATION_JSON);
+ httpEntity = new StringEntity((String)content, org.apache.http.entity.ContentType.APPLICATION_JSON);
} else {
throw new ODataException("Unsupported content type: " + content);
}
@@ -672,7 +672,7 @@ public final class Olingo4AppImpl implements Olingo4App {
private AbstractHttpEntity writeContent(InputStream inputStream) throws ODataException {
AbstractHttpEntity httpEntity;
-
+
try {
httpEntity = new ByteArrayEntity(IOUtils.toByteArray(inputStream));
} catch (IOException e) {
@@ -706,8 +706,7 @@ public final class Olingo4AppImpl implements Olingo4App {
batchRequestHeaderOutputStream.write(ODataStreamer.CRLF);
final ContentType acceptType = getResourceContentType(uriInfo);
final String acceptCharset = acceptType.getParameter(ContentType.PARAMETER_CHARSET);
- writeHttpHeader(batchRequestHeaderOutputStream, HttpHeaders.ACCEPT,
- contentType.getType().toLowerCase() + "/" + contentType.getSubtype().toLowerCase());
+ writeHttpHeader(batchRequestHeaderOutputStream, HttpHeaders.ACCEPT, contentType.getType().toLowerCase() + "/" + contentType.getSubtype().toLowerCase());
if (null != acceptCharset) {
writeHttpHeader(batchRequestHeaderOutputStream, HttpHeaders.ACCEPT_CHARSET, acceptCharset.toLowerCase());
}
@@ -732,8 +731,7 @@ public final class Olingo4AppImpl implements Olingo4App {
writeHttpHeader(batchRequestHeaderOutputStream, HttpHeader.ODATA_VERSION, ODataServiceVersion.V40.toString());
final ContentType acceptType = getResourceContentType(uriInfo);
final String acceptCharset = acceptType.getParameter(ContentType.PARAMETER_CHARSET);
- writeHttpHeader(batchRequestHeaderOutputStream, HttpHeaders.ACCEPT,
- contentType.getType().toLowerCase() + "/" + contentType.getSubtype().toLowerCase());
+ writeHttpHeader(batchRequestHeaderOutputStream, HttpHeaders.ACCEPT, contentType.getType().toLowerCase() + "/" + contentType.getSubtype().toLowerCase());
if (null != acceptCharset) {
writeHttpHeader(batchRequestHeaderOutputStream, HttpHeaders.ACCEPT_CHARSET, acceptCharset.toLowerCase());
}
@@ -944,7 +942,7 @@ public final class Olingo4AppImpl implements Olingo4App {
}
return result;
}
-
+
private static Map<String, String> headersToMap(final Header[] headers) {
final Map<String, String> responseHeaders = new HashMap<>();
for (Header header : headers) {
@@ -957,8 +955,7 @@ public final class Olingo4AppImpl implements Olingo4App {
// add accept header when its not a form or multipart
if (!ContentType.APPLICATION_FORM_URLENCODED.equals(contentType) && !contentType.toContentTypeString().startsWith(MULTIPART_MIME_TYPE)) {
// otherwise accept what is being sent
- httpUriRequest.addHeader(HttpHeaders.ACCEPT,
- contentType.getType().toLowerCase() + "/" + contentType.getSubtype().toLowerCase());
+ httpUriRequest.addHeader(HttpHeaders.ACCEPT, contentType.getType().toLowerCase() + "/" + contentType.getSubtype().toLowerCase());
final String acceptCharset = contentType.getParameter(ContentType.PARAMETER_CHARSET);
if (null != acceptCharset) {
httpUriRequest.addHeader(HttpHeaders.ACCEPT_CHARSET, acceptCharset.toLowerCase());
@@ -976,7 +973,7 @@ public final class Olingo4AppImpl implements Olingo4App {
httpUriRequest.setHeader(entry.getKey(), entry.getValue());
}
}
-
+
// set user specified endpoint headers
if (ObjectHelper.isNotEmpty(endpointHttpHeaders)) {
for (Map.Entry<String, String> entry : endpointHttpHeaders.entrySet()) {
diff --git a/components/camel-olingo4/camel-olingo4-api/src/test/java/org/apache/camel/component/olingo4/Olingo4AppAPITest.java b/components/camel-olingo4/camel-olingo4-api/src/test/java/org/apache/camel/component/olingo4/Olingo4AppAPITest.java
index d6c7d2e..66f7e2e 100644
--- a/components/camel-olingo4/camel-olingo4-api/src/test/java/org/apache/camel/component/olingo4/Olingo4AppAPITest.java
+++ b/components/camel-olingo4/camel-olingo4-api/src/test/java/org/apache/camel/component/olingo4/Olingo4AppAPITest.java
@@ -94,8 +94,20 @@ public class Olingo4AppAPITest {
private static final String PEOPLE = "People";
private static final String TEST_PEOPLE = "People('russellwhyte')";
private static final String TEST_AIRLINE = "Airlines('FM')";
- private static final String TEST_AIRLINE_TO_UPDATE = "Airlines('AA')"; // Careful using this as it get updated!
- private static final String TEST_AIRLINE_TO_DELETE = "Airlines('MU')"; // Careful using this as it gets deleted!
+ private static final String TEST_AIRLINE_TO_UPDATE = "Airlines('AA')"; // Careful
+ // using
+ // this
+ // as
+ // it
+ // get
+ // updated!
+ private static final String TEST_AIRLINE_TO_DELETE = "Airlines('MU')"; // Careful
+ // using
+ // this
+ // as
+ // it
+ // gets
+ // deleted!
private static final String TRIPS = "Trips";
private static final String TEST_CREATE_RESOURCE_CONTENT_ID = "1";
private static final String TEST_UPDATE_RESOURCE_CONTENT_ID = "2";
@@ -304,12 +316,11 @@ public class Olingo4AppAPITest {
}
/**
- * The Airline resource is implemented with Optimistic Concurrency.
- * This requires an eTag to be first fetched via a read before performing
- * patch, update, delete or merge operations.
- *
- * The test should complete successfully and not throw an error of the form
- * 'The request need to have If-Match or If-None-Match header'
+ * The Airline resource is implemented with Optimistic Concurrency. This
+ * requires an eTag to be first fetched via a read before performing patch,
+ * update, delete or merge operations. The test should complete successfully
+ * and not throw an error of the form 'The request need to have If-Match or
+ * If-None-Match header'
*
* @throws Exception
*/
@@ -346,12 +357,11 @@ public class Olingo4AppAPITest {
}
/**
- * The Airline resource is implemented with Optimistic Concurrency.
- * This requires an eTag to be first fetched via a read before performing
- * patch, update, delete or merge operations.
- *
- * The test should complete successfully and not throw an error of the form
- * 'The request need to have If-Match or If-None-Match header'
+ * The Airline resource is implemented with Optimistic Concurrency. This
+ * requires an eTag to be first fetched via a read before performing patch,
+ * update, delete or merge operations. The test should complete successfully
+ * and not throw an error of the form 'The request need to have If-Match or
+ * If-None-Match header'
*
* @throws Exception
*/
@@ -370,8 +380,7 @@ public class Olingo4AppAPITest {
TestOlingo4ResponseHandler<HttpStatusCode> statusHandler = new TestOlingo4ResponseHandler<>();
ClientEntity clientEntity = objFactory.newEntity(null);
String newAirlineName = "The Patched American Airlines";
- clientEntity.getProperties().add(objFactory.newPrimitiveProperty("Name",
- objFactory.newPrimitiveValueBuilder().buildString(newAirlineName)));
+ clientEntity.getProperties().add(objFactory.newPrimitiveProperty("Name", objFactory.newPrimitiveValueBuilder().buildString(newAirlineName)));
//
// Call patch
@@ -392,12 +401,11 @@ public class Olingo4AppAPITest {
}
/**
- * The Airline resource is implemented with Optimistic Concurrency.
- * This requires an eTag to be first fetched via a read before performing
- * patch, update, delete or merge operations.
- *
- * The test should complete successfully and not throw an error of the form
- * 'The request need to have If-Match or If-None-Match header'
+ * The Airline resource is implemented with Optimistic Concurrency. This
+ * requires an eTag to be first fetched via a read before performing patch,
+ * update, delete or merge operations. The test should complete successfully
+ * and not throw an error of the form 'The request need to have If-Match or
+ * If-None-Match header'
*
* @throws Exception
*/
@@ -416,8 +424,7 @@ public class Olingo4AppAPITest {
TestOlingo4ResponseHandler<HttpStatusCode> statusHandler = new TestOlingo4ResponseHandler<>();
ClientEntity clientEntity = objFactory.newEntity(null);
String newAirlineName = "The Updated American Airlines";
- clientEntity.getProperties().add(objFactory.newPrimitiveProperty("Name",
- objFactory.newPrimitiveValueBuilder().buildString(newAirlineName)));
+ clientEntity.getProperties().add(objFactory.newPrimitiveProperty("Name", objFactory.newPrimitiveValueBuilder().buildString(newAirlineName)));
//
// Call update
@@ -571,8 +578,8 @@ public class Olingo4AppAPITest {
assertEquals(HttpStatusCode.NO_CONTENT, statusCode);
}
-
- // Unfortunately there is no action that returns a client entity. So we fake one
+ // Unfortunately there is no action that returns a client entity. So we fake
+ // one
@Test
public void testBoundActionRequestWithClientEntityResponse() throws Exception {
final ODataClient odataClient = ODataClientFactory.getClient();
@@ -584,10 +591,8 @@ public class Olingo4AppAPITest {
public void process(HttpResponse response, HttpContext context) throws HttpException, IOException {
if (response.getStatusLine().getStatusCode() == HttpStatusCode.NO_CONTENT.getStatusCode()) {
try {
- response.setEntity(
- new InputStreamEntity(
- odataWriter.writeEntity(createEntity(), ContentType.JSON),
- org.apache.http.entity.ContentType.parse(ContentType.JSON.toContentTypeString())));
+ response.setEntity(new InputStreamEntity(odataWriter.writeEntity(createEntity(), ContentType.JSON),
+ org.apache.http.entity.ContentType.parse(ContentType.JSON.toContentTypeString())));
response.setStatusCode(HttpStatusCode.OK.getStatusCode());
} catch (ODataSerializerException e) {
throw new IOException(e);
diff --git a/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Configuration.java b/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Configuration.java
index 8702458..6af68aa 100644
--- a/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Configuration.java
+++ b/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Configuration.java
@@ -41,7 +41,8 @@ public class Olingo4Configuration {
@UriPath
@Metadata(required = true)
private Olingo4ApiName apiName;
- @UriPath @Metadata(required = true)
+ @UriPath
+ @Metadata(required = true)
private String methodName;
@UriParam
private String serviceUri;
@@ -91,7 +92,8 @@ public class Olingo4Configuration {
}
/**
- * Target OData service base URI, e.g. http://services.odata.org/OData/OData.svc
+ * Target OData service base URI, e.g.
+ * http://services.odata.org/OData/OData.svc
*/
public void setServiceUri(String serviceUri) {
this.serviceUri = serviceUri;
@@ -102,7 +104,8 @@ public class Olingo4Configuration {
}
/**
- * Content-Type header value can be used to specify JSON or XML message format, defaults to application/json;charset=utf-8
+ * Content-Type header value can be used to specify JSON or XML message
+ * format, defaults to application/json;charset=utf-8
*/
public void setContentType(String contentType) {
this.contentType = contentType;
@@ -113,7 +116,8 @@ public class Olingo4Configuration {
}
/**
- * Custom HTTP headers to inject into every request, this could include OAuth tokens, etc.
+ * Custom HTTP headers to inject into every request, this could include
+ * OAuth tokens, etc.
*/
public void setHttpHeaders(Map<String, String> httpHeaders) {
this.httpHeaders = httpHeaders;
@@ -124,7 +128,8 @@ public class Olingo4Configuration {
}
/**
- * HTTP connection creation timeout in milliseconds, defaults to 30,000 (30 seconds)
+ * HTTP connection creation timeout in milliseconds, defaults to 30,000 (30
+ * seconds)
*/
public void setConnectTimeout(int connectTimeout) {
this.connectTimeout = connectTimeout;
@@ -168,8 +173,10 @@ public class Olingo4Configuration {
}
/**
- * Custom HTTP async client builder for more complex HTTP client configuration, overrides connectionTimeout, socketTimeout, proxy and sslContext.
- * Note that a socketTimeout MUST be specified in the builder, otherwise OData requests could block indefinitely
+ * Custom HTTP async client builder for more complex HTTP client
+ * configuration, overrides connectionTimeout, socketTimeout, proxy and
+ * sslContext. Note that a socketTimeout MUST be specified in the builder,
+ * otherwise OData requests could block indefinitely
*/
public void setHttpAsyncClientBuilder(HttpAsyncClientBuilder httpAsyncClientBuilder) {
this.httpAsyncClientBuilder = httpAsyncClientBuilder;
@@ -180,8 +187,10 @@ public class Olingo4Configuration {
}
/**
- * Custom HTTP client builder for more complex HTTP client configuration, overrides connectionTimeout, socketTimeout, proxy and sslContext.
- * Note that a socketTimeout MUST be specified in the builder, otherwise OData requests could block indefinitely
+ * Custom HTTP client builder for more complex HTTP client configuration,
+ * overrides connectionTimeout, socketTimeout, proxy and sslContext. Note
+ * that a socketTimeout MUST be specified in the builder, otherwise OData
+ * requests could block indefinitely
*/
public void setHttpClientBuilder(HttpClientBuilder httpClientBuilder) {
this.httpClientBuilder = httpClientBuilder;
@@ -195,7 +204,9 @@ public class Olingo4Configuration {
}
/**
- * Set this to true to filter out results that have already been communicated by this component.
+ * Set this to true to filter out results that have already been
+ * communicated by this component.
+ *
* @param filterAlreadySeen
*/
public void setFilterAlreadySeen(boolean filterAlreadySeen) {
@@ -204,33 +215,27 @@ public class Olingo4Configuration {
@Override
public int hashCode() {
- return new HashCodeBuilder()
- .append(serviceUri)
- .append(contentType)
- .append(httpHeaders)
- .append(connectTimeout)
- .append(socketTimeout)
- .append(proxy)
- .append(sslContextParameters)
- .append(httpAsyncClientBuilder)
- .append(httpClientBuilder)
- .hashCode();
+ return new HashCodeBuilder().append(serviceUri).append(contentType).append(httpHeaders).append(connectTimeout).append(socketTimeout).append(proxy)
+ .append(sslContextParameters).append(httpAsyncClientBuilder).append(httpClientBuilder).hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj instanceof Olingo4Configuration) {
- Olingo4Configuration other = (Olingo4Configuration) obj;
- return serviceUri == null ? other.serviceUri == null : serviceUri.equals(other.serviceUri)
- && contentType == null ? other.contentType == null : contentType.equals(other.contentType)
- && httpHeaders == null ? other.httpHeaders == null : httpHeaders.equals(other.httpHeaders)
- && connectTimeout == other.connectTimeout
- && socketTimeout == other.socketTimeout
- && proxy == null ? other.proxy == null : proxy.equals(other.proxy)
- && sslContextParameters == null ? other.sslContextParameters == null : sslContextParameters.equals(other.sslContextParameters)
- && httpAsyncClientBuilder == null ? other.httpAsyncClientBuilder == null
- : httpAsyncClientBuilder.equals(other.httpAsyncClientBuilder)
- && httpClientBuilder == null ? other.httpClientBuilder == null : httpClientBuilder.equals(other.httpClientBuilder);
+ Olingo4Configuration other = (Olingo4Configuration)obj;
+ return serviceUri == null
+ ? other.serviceUri == null
+ : serviceUri.equals(other.serviceUri) && contentType == null
+ ? other.contentType == null
+ : contentType.equals(other.contentType) && httpHeaders == null
+ ? other.httpHeaders == null
+ : httpHeaders.equals(other.httpHeaders) && connectTimeout == other.connectTimeout && socketTimeout == other.socketTimeout && proxy == null
+ ? other.proxy == null
+ : proxy.equals(other.proxy) && sslContextParameters == null
+ ? other.sslContextParameters == null
+ : sslContextParameters.equals(other.sslContextParameters) && httpAsyncClientBuilder == null
+ ? other.httpAsyncClientBuilder == null : httpAsyncClientBuilder.equals(other.httpAsyncClientBuilder) && httpClientBuilder == null
+ ? other.httpClientBuilder == null : httpClientBuilder.equals(other.httpClientBuilder);
}
return false;
}
diff --git a/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Consumer.java b/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Consumer.java
index 778e0cb..3fcb9b9 100644
--- a/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Consumer.java
+++ b/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Consumer.java
@@ -97,10 +97,10 @@ public class Olingo4Consumer extends AbstractApiConsumer<Olingo4ApiName, Olingo4
}
//
- // Allow consumer idle properties to properly handle an empty polling response
+ // Allow consumer idle properties to properly handle an empty
+ // polling response
//
- if ((result[0] == null)
- || (result[0] instanceof ClientEntitySet && (((ClientEntitySet) result[0]).getEntities().isEmpty()))) {
+ if ((result[0] == null) || (result[0] instanceof ClientEntitySet && (((ClientEntitySet)result[0]).getEntities().isEmpty()))) {
return 0;
} else {
int processed = ApiConsumerHelper.getResultsProcessed(this, result[0], isSplitResult());
@@ -115,7 +115,8 @@ public class Olingo4Consumer extends AbstractApiConsumer<Olingo4ApiName, Olingo4
@Override
public void interceptProperties(Map<String, Object> properties) {
//
- // If we have a filterAlreadySeen property then initialise the filter index
+ // If we have a filterAlreadySeen property then initialise the filter
+ // index
//
Object value = properties.get(Olingo4Endpoint.FILTER_ALREADY_SEEN);
if (value == null) {
@@ -123,7 +124,8 @@ public class Olingo4Consumer extends AbstractApiConsumer<Olingo4ApiName, Olingo4
}
//
- // Initialise the index if not already and if filterAlreadySeen has been set
+ // Initialise the index if not already and if filterAlreadySeen has been
+ // set
//
if (Boolean.parseBoolean(value.toString()) && resultIndex == null) {
resultIndex = new Olingo4Index();
@@ -144,21 +146,20 @@ public class Olingo4Consumer extends AbstractApiConsumer<Olingo4ApiName, Olingo4
List<Object> splitResult = new ArrayList<>();
if (result instanceof ClientEntitySet) {
- ClientEntitySet entitySet = (ClientEntitySet) result;
+ ClientEntitySet entitySet = (ClientEntitySet)result;
for (ClientEntity entity : entitySet.getEntities()) {
//
// If $count has been set to true then this value is left behind
// on the ClientEntitySet. Therefore, append it to each result.
//
if (entitySet.getCount() != null) {
- ClientValue value = new ClientPrimitiveValueImpl.BuilderImpl()
- .buildInt32(entitySet.getCount());
+ ClientValue value = new ClientPrimitiveValueImpl.BuilderImpl().buildInt32(entitySet.getCount());
entity.getProperties().add(new ClientPropertyImpl("ResultCount", value));
}
splitResult.add(entity);
}
- } else if (result instanceof ClientValue && ((ClientValue) result).isCollection()) {
- ClientValue value = (ClientValue) result;
+ } else if (result instanceof ClientValue && ((ClientValue)result).isCollection()) {
+ ClientValue value = (ClientValue)result;
ClientCollectionValue<ClientValue> collection = value.asCollection();
collection.forEach(v -> {
splitResult.add(v);
diff --git a/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Endpoint.java b/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Endpoint.java
index 8c4cc2b..8a3d52c 100644
--- a/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Endpoint.java
+++ b/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Endpoint.java
@@ -166,7 +166,7 @@ public class Olingo4Endpoint extends AbstractApiEndpoint<Olingo4ApiName, Olingo4
@Override
public void interceptProperties(Map<String, Object> properties) {
- Map<String, String> endpointHttpHeaders = (Map<String, String>) properties.get(ENDPOINT_HTTP_HEADERS_PROPERTY);
+ Map<String, String> endpointHttpHeaders = (Map<String, String>)properties.get(ENDPOINT_HTTP_HEADERS_PROPERTY);
// read Edm if not set yet
properties.put(EDM_PROPERTY, apiProxy.getEdm(endpointHttpHeaders));
@@ -206,8 +206,8 @@ public class Olingo4Endpoint extends AbstractApiEndpoint<Olingo4ApiName, Olingo4
final String paramName = entry.getKey();
/**
- * Avoid swallowing consumer scheduler properties, which
- * get processed in configureProperties()
+ * Avoid swallowing consumer scheduler properties, which get
+ * processed in configureProperties()
*/
if (paramName.startsWith("consumer.")) {
continue;
diff --git a/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Producer.java b/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Producer.java
index 5ae3373..bebb619 100644
--- a/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Producer.java
+++ b/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Producer.java
@@ -67,7 +67,7 @@ public class Olingo4Producer extends AbstractApiProducer<Olingo4ApiName, Olingo4
exchange.getOut().setBody(response);
// copy headers
exchange.getOut().setHeaders(exchange.getIn().getHeaders());
-
+
// Add http response headers
exchange.getOut().setHeader(Olingo4Constants.PROPERTY_PREFIX + Olingo4Constants.RESPONSE_HTTP_HEADERS, responseHeaders);
@@ -115,7 +115,8 @@ public class Olingo4Producer extends AbstractApiProducer<Olingo4ApiName, Olingo4
@Override
public void interceptProperties(Map<String, Object> properties) {
//
- // If we have a filterAlreadySeen property then initialise the filter index
+ // If we have a filterAlreadySeen property then initialise the filter
+ // index
//
Object value = properties.get(Olingo4Endpoint.FILTER_ALREADY_SEEN);
if (value == null) {
@@ -123,7 +124,8 @@ public class Olingo4Producer extends AbstractApiProducer<Olingo4ApiName, Olingo4
}
//
- // Initialise the index if not already and if filterAlreadySeen has been set
+ // Initialise the index if not already and if filterAlreadySeen has been
+ // set
//
if (Boolean.parseBoolean(value.toString()) && resultIndex == null) {
resultIndex = new Olingo4Index();
diff --git a/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/internal/Olingo4Constants.java b/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/internal/Olingo4Constants.java
index 240005f..700b897 100644
--- a/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/internal/Olingo4Constants.java
+++ b/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/internal/Olingo4Constants.java
@@ -26,6 +26,6 @@ public interface Olingo4Constants {
// thread profile name for this component
String THREAD_PROFILE_NAME = "CamelOlingo4";
-
+
String RESPONSE_HTTP_HEADERS = "responseHttpHeaders";
}
diff --git a/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4ComponentConsumerTest.java b/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4ComponentConsumerTest.java
index c81b174..bbad81e 100644
--- a/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4ComponentConsumerTest.java
+++ b/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4ComponentConsumerTest.java
@@ -55,9 +55,7 @@ public class Olingo4ComponentConsumerTest extends AbstractOlingo4TestSupport {
RouteBuilder builder = new RouteBuilder() {
public void configure() {
- from("olingo4://read/" + PEOPLE + "?"
- + "$filter=LastName eq 'Whyte'&$expand=Trips")
- .to("mock:consumer-query");
+ from("olingo4://read/" + PEOPLE + "?" + "$filter=LastName eq 'Whyte'&$expand=Trips").to("mock:consumer-query");
};
};
addRouteAndStartContext(builder);
@@ -72,7 +70,7 @@ public class Olingo4ComponentConsumerTest extends AbstractOlingo4TestSupport {
// First polled messages contained all the entities
//
assertTrue(body instanceof ClientEntity);
- ClientEntity e = (ClientEntity) body;
+ ClientEntity e = (ClientEntity)body;
ClientProperty nameProp = e.getProperty("UserName");
assertNotNull(nameProp);
assertEquals("russellwhyte", nameProp.getValue().toString());
@@ -81,16 +79,14 @@ public class Olingo4ComponentConsumerTest extends AbstractOlingo4TestSupport {
}
/**
- * Read entity set of the People object
- * and filter already seen items on subsequent exchanges
- * Use a delay since the mock endpoint does not always get
- * the correct number of exchanges before being satisfied.
- *
- * Note:
- * - consumer.splitResults is set to false since this ensures the first returned message
- * contains all the results. This is preferred for the purposes of this test. The default
- * will mean the first n messages contain the results (where n is the result total) then
- * subsequent messages will be empty
+ * Read entity set of the People object and filter already seen items on
+ * subsequent exchanges Use a delay since the mock endpoint does not always
+ * get the correct number of exchanges before being satisfied. Note: -
+ * consumer.splitResults is set to false since this ensures the first
+ * returned message contains all the results. This is preferred for the
+ * purposes of this test. The default will mean the first n messages contain
+ * the results (where n is the result total) then subsequent messages will
+ * be empty
*/
@Test
public void testConsumerReadFilterAlreadySeen() throws Exception {
@@ -117,7 +113,7 @@ public class Olingo4ComponentConsumerTest extends AbstractOlingo4TestSupport {
// First polled messages contained all the entities
//
assertTrue(body instanceof ClientEntitySet);
- ClientEntitySet set = (ClientEntitySet) body;
+ ClientEntitySet set = (ClientEntitySet)body;
assertEquals(expectedEntities, set.getEntities().size());
} else {
//
@@ -130,16 +126,13 @@ public class Olingo4ComponentConsumerTest extends AbstractOlingo4TestSupport {
}
/**
- * Read entity set of the People object
- * and filter already seen items on subsequent exchanges
- * Use a delay since the mock endpoint does not always get
- * the correct number of exchanges before being satisfied.
- *
- * Note:
- * - consumer.splitResults is set to false since this ensures the first returned message
- * contains all the results.
- * - consumer.sendEmptyMessageWhenIdle is set to false so only 1 message should
- * even be returned.
+ * Read entity set of the People object and filter already seen items on
+ * subsequent exchanges Use a delay since the mock endpoint does not always
+ * get the correct number of exchanges before being satisfied. Note: -
+ * consumer.splitResults is set to false since this ensures the first
+ * returned message contains all the results. -
+ * consumer.sendEmptyMessageWhenIdle is set to false so only 1 message
+ * should even be returned.
*/
@Test
public void testConsumerReadFilterAlreadySeenNoEmptyMsgs() throws Exception {
@@ -175,14 +168,12 @@ public class Olingo4ComponentConsumerTest extends AbstractOlingo4TestSupport {
// Only polled message contains all the entities
//
assertTrue(body instanceof ClientEntitySet);
- ClientEntitySet set = (ClientEntitySet) body;
+ ClientEntitySet set = (ClientEntitySet)body;
assertEquals(expectedEntities, set.getEntities().size());
}
/**
- * WithPredicate in address
- * FilterAlreadySeen: true
- * SplitResults: true
+ * WithPredicate in address FilterAlreadySeen: true SplitResults: true
* consumer.sendEmptyMessageWhenIdle: true
*
* @throws Exception
@@ -195,11 +186,8 @@ public class Olingo4ComponentConsumerTest extends AbstractOlingo4TestSupport {
RouteBuilder builder = new RouteBuilder() {
public void configure() {
- from("olingo4://read/" + AIRPORTS + "('KSFO')"
- + "?filterAlreadySeen=true&"
- + "consumer.delay=2&consumer.sendEmptyMessageWhenIdle=true&"
- + "consumer.splitResult=true")
- .to("mock:consumer-splitresult-kp-airport");
+ from("olingo4://read/" + AIRPORTS + "('KSFO')" + "?filterAlreadySeen=true&" + "consumer.delay=2&consumer.sendEmptyMessageWhenIdle=true&"
+ + "consumer.splitResult=true").to("mock:consumer-splitresult-kp-airport");
};
};
addRouteAndStartContext(builder);
@@ -214,7 +202,7 @@ public class Olingo4ComponentConsumerTest extends AbstractOlingo4TestSupport {
// First polled messages contained all the entities
//
assertTrue(body instanceof ClientEntity);
- ClientEntity ksfoEntity = (ClientEntity) body;
+ ClientEntity ksfoEntity = (ClientEntity)body;
ClientProperty nameProp = ksfoEntity.getProperty("Name");
assertNotNull(nameProp);
assertEquals("San Francisco International Airport", nameProp.getValue().toString());
@@ -229,9 +217,7 @@ public class Olingo4ComponentConsumerTest extends AbstractOlingo4TestSupport {
}
/**
- * WithPredicate in address
- * FilterAlreadySeen: true
- * SplitResults: true
+ * WithPredicate in address FilterAlreadySeen: true SplitResults: true
* consumer.sendEmptyMessageWhenIdle: false
*
* @throws Exception
@@ -250,11 +236,8 @@ public class Olingo4ComponentConsumerTest extends AbstractOlingo4TestSupport {
RouteBuilder builder = new RouteBuilder() {
public void configure() {
- from("olingo4://read/" + AIRPORTS + "('KSFO')"
- + "?filterAlreadySeen=true&"
- + "consumer.delay=2&consumer.sendEmptyMessageWhenIdle=false&"
- + "consumer.splitResult=true")
- .to("mock:consumer-splitresult-kp-airport");
+ from("olingo4://read/" + AIRPORTS + "('KSFO')" + "?filterAlreadySeen=true&" + "consumer.delay=2&consumer.sendEmptyMessageWhenIdle=false&"
+ + "consumer.splitResult=true").to("mock:consumer-splitresult-kp-airport");
};
};
addRouteAndStartContext(builder);
@@ -273,15 +256,15 @@ public class Olingo4ComponentConsumerTest extends AbstractOlingo4TestSupport {
// Only polled message contains the entity
//
assertTrue(body instanceof ClientEntity);
- ClientEntity ksfoEntity = (ClientEntity) body;
+ ClientEntity ksfoEntity = (ClientEntity)body;
ClientProperty nameProp = ksfoEntity.getProperty("Name");
assertNotNull(nameProp);
assertEquals("San Francisco International Airport", nameProp.getValue().toString());
}
/**
- * Read entity set of the People object and split the results
- * into individual messages
+ * Read entity set of the People object and split the results into
+ * individual messages
*/
@Test
public void testConsumerReadSplitResults() throws Exception {
@@ -291,8 +274,7 @@ public class Olingo4ComponentConsumerTest extends AbstractOlingo4TestSupport {
RouteBuilder builder = new RouteBuilder() {
public void configure() {
- from("olingo4://read/" + PEOPLE + "?consumer.splitResult=true")
- .to("mock:consumer-splitresult");
+ from("olingo4://read/" + PEOPLE + "?consumer.splitResult=true").to("mock:consumer-splitresult");
};
};
addRouteAndStartContext(builder);
@@ -309,7 +291,7 @@ public class Olingo4ComponentConsumerTest extends AbstractOlingo4TestSupport {
ClientProperty nameProperty = entity.getProperty("UserName");
assertNotNull(nameProperty);
- switch(i) {
+ switch (i) {
case 0:
assertEquals("russellwhyte", nameProperty.getValue().toString());
break;
@@ -325,8 +307,8 @@ public class Olingo4ComponentConsumerTest extends AbstractOlingo4TestSupport {
}
/**
- * Read value of the People object and split the results
- * into individual messages
+ * Read value of the People object and split the results into individual
+ * messages
*/
@Test
public void testConsumerReadClientValuesSplitResults() throws Exception {
@@ -335,8 +317,7 @@ public class Olingo4ComponentConsumerTest extends AbstractOlingo4TestSupport {
RouteBuilder builder = new RouteBuilder() {
public void configure() {
- from("olingo4://read/" + TEST_PEOPLE + "/FavoriteFeature?consumer.splitResult=true")
- .to("mock:consumer-splitresult-value");
+ from("olingo4://read/" + TEST_PEOPLE + "/FavoriteFeature?consumer.splitResult=true").to("mock:consumer-splitresult-value");
};
};
addRouteAndStartContext(builder);
@@ -347,13 +328,13 @@ public class Olingo4ComponentConsumerTest extends AbstractOlingo4TestSupport {
//
Object body = mockEndpoint.getExchanges().get(0).getIn().getBody();
assertIsInstanceOf(ClientPrimitiveValue.class, body);
- ClientPrimitiveValue value = (ClientPrimitiveValue) body;
+ ClientPrimitiveValue value = (ClientPrimitiveValue)body;
assertEquals("Feature1", value.toString());
}
/**
- * Read value of the People object's AddressInfo collection value
- * & split the results into individual messages for each address
+ * Read value of the People object's AddressInfo collection value & split
+ * the results into individual messages for each address
*/
@Test
public void testConsumerReadClientCollectionValuesSplitResults() throws Exception {
@@ -362,8 +343,7 @@ public class Olingo4ComponentConsumerTest extends AbstractOlingo4TestSupport {
RouteBuilder builder = new RouteBuilder() {
public void configure() {
- from("olingo4://read/" + TEST_PEOPLE + "/AddressInfo?consumer.splitResult=true")
- .to("mock:consumer-splitresult-collection-value");
+ from("olingo4://read/" + TEST_PEOPLE + "/AddressInfo?consumer.splitResult=true").to("mock:consumer-splitresult-collection-value");
};
};
addRouteAndStartContext(builder);
@@ -374,13 +354,13 @@ public class Olingo4ComponentConsumerTest extends AbstractOlingo4TestSupport {
//
Object body = mockEndpoint.getExchanges().get(0).getIn().getBody();
assertIsInstanceOf(ClientComplexValue.class, body);
- ClientComplexValue value = (ClientComplexValue) body;
+ ClientComplexValue value = (ClientComplexValue)body;
assertEquals("Boise", value.get("City").getComplexValue().get("Name").getValue().toString());
}
/**
- * Read value of the People object's AddressInfo collection value
- * & split the results into individual messages for each address
+ * Read value of the People object's AddressInfo collection value & split
+ * the results into individual messages for each address
*/
@Test
public void testConsumerReadClientCollectionValuesNoSplitResults() throws Exception {
@@ -389,8 +369,7 @@ public class Olingo4ComponentConsumerTest extends AbstractOlingo4TestSupport {
RouteBuilder builder = new RouteBuilder() {
public void configure() {
- from("olingo4://read/" + TEST_PEOPLE + "/AddressInfo?consumer.splitResult=false")
- .to("mock:consumer-nosplitresult-colleciton-value");
+ from("olingo4://read/" + TEST_PEOPLE + "/AddressInfo?consumer.splitResult=false").to("mock:consumer-nosplitresult-colleciton-value");
};
};
addRouteAndStartContext(builder);
@@ -401,12 +380,12 @@ public class Olingo4ComponentConsumerTest extends AbstractOlingo4TestSupport {
//
Object body = mockEndpoint.getExchanges().get(0).getIn().getBody();
assertIsInstanceOf(ClientCollectionValue.class, body);
- ClientCollectionValue<?> value = (ClientCollectionValue<?>) body;
+ ClientCollectionValue<?> value = (ClientCollectionValue<?>)body;
assertEquals(1, value.size());
Iterator<?> propIter = value.iterator();
Object propValueObj = propIter.next();
assertIsInstanceOf(ClientComplexValue.class, propValueObj);
- ClientComplexValue propValue = (ClientComplexValue) propValueObj;
+ ClientComplexValue propValue = (ClientComplexValue)propValueObj;
assertEquals("Boise", propValue.get("City").getComplexValue().get("Name").getValue().toString());
}
}
diff --git a/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4ComponentProducerTest.java b/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4ComponentProducerTest.java
index 2537347..07079bb 100644
--- a/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4ComponentProducerTest.java
+++ b/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4ComponentProducerTest.java
@@ -109,7 +109,7 @@ public class Olingo4ComponentProducerTest extends AbstractOlingo4TestSupport {
Iterator<?> propIter = collectionProperty.iterator();
Object propValueObj = propIter.next();
assertIsInstanceOf(ClientComplexValue.class, propValueObj);
- ClientComplexValue propValue = (ClientComplexValue) propValueObj;
+ ClientComplexValue propValue = (ClientComplexValue)propValueObj;
assertEquals("Boise", propValue.get("City").getComplexValue().get("Name").getValue().toString());
final ClientEntity entity = (ClientEntity)requestBodyAndHeaders("direct:readentitybyid", null, headers);
@@ -393,7 +393,6 @@ public class Olingo4ComponentProducerTest extends AbstractOlingo4TestSupport {
}
}
-
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
diff --git a/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4RouteTest.java b/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4RouteTest.java
index 07904e0..bb7f268 100644
--- a/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4RouteTest.java
+++ b/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4RouteTest.java
@@ -29,7 +29,7 @@ public class Olingo4RouteTest extends CamelTestSupport {
protected <T> T requestBody(String endpoint, Object body) throws CamelExecutionException {
return (T)template().requestBody(endpoint, body);
}
-
+
@Test
public void testRead() throws Exception {
// Read entity set of the People object
@@ -37,7 +37,7 @@ public class Olingo4RouteTest extends CamelTestSupport {
assertNotNull(entities);
assertEquals(20, entities.getEntities().size());
}
-
+
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {